3 Replies Latest reply on May 2, 2012 2:47 PM by lamw

    Change number of virtual sockets / cores for VM

    Martin Gavanda Enthusiast

      Hi,

       

      Have you any idea how to change number of virtual cores for a VM? It is not a problem to assign more virtual sockets to the VM via standard CLI tools, but I need to assign for instance 2 quad core vrtual processors to the VM

       

      Any hint?

       

      Thanks & Regards

       

      Martin Gavanda

        • 1. Re: Change number of virtual sockets / cores for VM
          lamw Guru
          VMware EmployeesCommunity Warriors

          Yes. Just like with any VM reconfiguration operation, you need to use ReconfigVM_Task() http://vijava.sourceforge.net/vSphereAPIDoc/ver5/ReferenceGuide/vim.VirtualMachine.html#reconfigure and you can change the # of cores per socket and sockets by looking at numCPUs and coresPerSocket properties in the VM spec http://vijava.sourceforge.net/vSphereAPIDoc/ver5/ReferenceGuide/vim.vm.ConfigSpec.html

           

          You can use this script as a reference - http://vghetto.svn.sourceforge.net/viewvc/vghetto/scripts/updateVMReservations.pl?view=log

          • 2. Re: Change number of virtual sockets / cores for VM
            mrhank Lurker

            Hi William,

             

            I've been trying to use updateVMReservations.pl script, however I'm getting this error:

             

            ./updateVMReservations.pl --server myServer --username myUser --password myPass -vmlist myVM --cpu_rsv somenumber
            Error: Couldn't open the myVM! at ./updateVMReservations.pl line 134.

             

            I'm able to use other VM configuration scripts such as addVMAnnotation, but VMreservation script is not working. What might be the problem?

             

            Another question is, sharesmanager.pl script provided with the vCLI library works for me but it takes around 8 seconds to complete. Is there any way to make these kind of reconfigurations to VMs faster? When I use vSphere client to change the cpu reservatation, it takes 1-2 seconds to reconfigure the VMs. Why using scripts is much slower than using vSphere client? Is it the remote connection overhead?

             

            I'd appreciate if you can give me some pointers about these issues. Thanks a lot.

            • 3. Re: Change number of virtual sockets / cores for VM
              lamw Guru
              VMware EmployeesCommunity Warriors

              It looks like the file you're passing in can not be open, is it in the same directory as the script? If not, you should pass in the full path.

               

              Regarding the sharesmanager.pl, if you have a large vSphere Inventory, it may take sometime to filter out the specific VM before it actually makes the changes.You could further optimize by only extracting only properties that are needed, which you will need to go through the script to see what is being accesesd.

               

              An example of this is:

               

              // this will give you the entire VirtualMachine managed object

              my $vm_views = Vim::find_entity_views(view_type => 'VirtualMachine', filter => {"config.name" => $vmname});

               

              //where as this will only filter out the name and the resourceConfig->cpuAllocatioin->shares properties of the VM managed object

              my $vm_views = Vim::find_entity_views(view_type => 'VirtualMachine', filter => {"config.name" => $vmname}, properties => ['name','resourceConfig.cpuAllocation.shares']);