Setting VM memory reservation with knife vsphere vm clone


#1

Greetings all,
We are using knife vsphere to automate the birthing of over a hundred VMs,
and it’s working well. One issue we can’t figure out though is how to set
the VM memory reservation during execution of the "knife vsphere vm clone"
command.

I see there is the --cspec CUST_SPEC option, but I cannot find anything
that explains what the format / syntax should be. Can anyone please point
me to where I can find that?

Thanks in advance,
Terry


#2

You use --cram option. --cram 3 means 3GB RAM.

But yes before being able to specify RAM via cram (or CPU via ccpu for
that matter), you do need to specify --cspec. To do that, in Vcenter,
just create a customization specification (it’s really basic info like
timezone, dns, etc):
http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.vsphere.vm_admin.doc/GUID-58E346FF-83AE-42B8-BE58-253641D257BC.html

Then you can use --cspec NAME where NAME is the name of the customization
specification you created.

On Thu, Aug 7, 2014 at 7:47 PM, Terry P. texpilot@gmail.com wrote:

Greetings all,
We are using knife vsphere to automate the birthing of over a hundred VMs,
and it’s working well. One issue we can’t figure out though is how to set
the VM memory reservation during execution of the "knife vsphere vm clone"
command.

I see there is the --cspec CUST_SPEC option, but I cannot find anything
that explains what the format / syntax should be. Can anyone please point
me to where I can find that?

Thanks in advance,
Terry


#3

Hi Terry,

By memory reservation, do you mean the amount of virtual RAM allotted to a
VM OR memory reservation as used in resource management and allocation,
i.e reservation, shares etc.? The former can be specified using the
’–cram’ option as mentioned by Johnny. The latter cannot be specified
using knife-vsphere. Setting memory reservation would be done via a
ResourceAllocationInfo managed data object as a part of the
VirtualMachineConfigSpec and I don’t think knife-vsphere caters to this as
of now.

Regards,
Aditya

On Fri, Aug 8, 2014 at 8:46 AM, Johnny Tan johnnydtan@gmail.com wrote:

You use --cram option. --cram 3 means 3GB RAM.

But yes before being able to specify RAM via cram (or CPU via ccpu for
that matter), you do need to specify --cspec. To do that, in Vcenter,
just create a customization specification (it’s really basic info like
timezone, dns, etc):

http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.vsphere.vm_admin.doc/GUID-58E346FF-83AE-42B8-BE58-253641D257BC.html

Then you can use --cspec NAME where NAME is the name of the
customization specification you created.

On Thu, Aug 7, 2014 at 7:47 PM, Terry P. texpilot@gmail.com wrote:

Greetings all,
We are using knife vsphere to automate the birthing of over a hundred
VMs, and it’s working well. One issue we can’t figure out though is how to
set the VM memory reservation during execution of the “knife vsphere vm
clone” command.

I see there is the --cspec CUST_SPEC option, but I cannot find anything
that explains what the format / syntax should be. Can anyone please point
me to where I can find that?

Thanks in advance,
Terry


#4

Thank you Aditya, I was indeed referring to the memery reservation setting,
not the memory allocation which --cram is used for.

I’ll look into ResourceAllocationInfo to see what I can find out about it.
Even if I cannot set it using knife vsphere, do you know of any other way I
can adjust that setting programmatically from a Linux host?

Thanks in advance,
Terry
On Aug 8, 2014 1:57 AM, “Aditya Karanjkar” <
aditya.karanjkar@relevancelab.com> wrote:

Hi Terry,

By memory reservation, do you mean the amount of virtual RAM allotted to a
VM OR memory reservation as used in resource management and allocation,
i.e reservation, shares etc.? The former can be specified using the
’–cram’ option as mentioned by Johnny. The latter cannot be specified
using knife-vsphere. Setting memory reservation would be done via a
ResourceAllocationInfo managed data object as a part of the
VirtualMachineConfigSpec and I don’t think knife-vsphere caters to this as
of now.

Regards,
Aditya

On Fri, Aug 8, 2014 at 8:46 AM, Johnny Tan johnnydtan@gmail.com wrote:

You use --cram option. --cram 3 means 3GB RAM.

But yes before being able to specify RAM via cram (or CPU via ccpu
for that matter), you do need to specify --cspec. To do that, in Vcenter,
just create a customization specification (it’s really basic info like
timezone, dns, etc):

http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.vsphere.vm_admin.doc/GUID-58E346FF-83AE-42B8-BE58-253641D257BC.html

Then you can use --cspec NAME where NAME is the name of the
customization specification you created.

On Thu, Aug 7, 2014 at 7:47 PM, Terry P. texpilot@gmail.com wrote:

Greetings all,
We are using knife vsphere to automate the birthing of over a hundred
VMs, and it’s working well. One issue we can’t figure out though is how to
set the VM memory reservation during execution of the “knife vsphere vm
clone” command.

I see there is the --cspec CUST_SPEC option, but I cannot find anything
that explains what the format / syntax should be. Can anyone please point
me to where I can find that?

Thanks in advance,
Terry


#5

Hi Johnny,
Actually I set ram, CPUs, etc without creating a custom spec in vcenter, it
works just fine without it. I was referring to memory reservation, not
allocation.

But I’ll take a look at the docs you pointed to and see if THAT allows me
to set the reservation!

Thanks,
Terry
On Aug 7, 2014 10:16 PM, “Johnny Tan” johnnydtan@gmail.com wrote:

You use --cram option. --cram 3 means 3GB RAM.

But yes before being able to specify RAM via cram (or CPU via ccpu for
that matter), you do need to specify --cspec. To do that, in Vcenter,
just create a customization specification (it’s really basic info like
timezone, dns, etc):

http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.vsphere.vm_admin.doc/GUID-58E346FF-83AE-42B8-BE58-253641D257BC.html

Then you can use --cspec NAME where NAME is the name of the
customization specification you created.

On Thu, Aug 7, 2014 at 7:47 PM, Terry P. texpilot@gmail.com wrote:

Greetings all,
We are using knife vsphere to automate the birthing of over a hundred
VMs, and it’s working well. One issue we can’t figure out though is how to
set the VM memory reservation during execution of the “knife vsphere vm
clone” command.

I see there is the --cspec CUST_SPEC option, but I cannot find anything
that explains what the format / syntax should be. Can anyone please point
me to where I can find that?

Thanks in advance,
Terry


#6

Hi Terry,

Try the code given below to set the memory reservation. You will need the
RbVmomi gem for this. It searches for a VM called ‘test_vm’ in a folder
called ‘vm_folder’ and sets the memory reservation to 1024 MB.

#change_memory_reservation.rb
require 'rbvmomi’
vim = RbVmomi::VIM.connect host: ‘10.10.10.1’, user: ‘me’, password:
‘complex_password’, insecure: true
vm = vim.serviceInstance.find_datacenter.find_vm(“vm_folder/test_vm”) or
abort(“VM not found”)
vm_config_spec = RbVmomi::VIM.VirtualMachineConfigSpec
vm_config_spec.memoryAllocation = RbVmomi::VIM.ResourceAllocationInfo
reservation: 1024
task = vm.ReconfigVM_Task spec: vm_config_spec
task.wait_for_completion

Regards,
Aditya

On Fri, Aug 8, 2014 at 6:10 PM, Terry P. texpilot@gmail.com wrote:

Hi Johnny,
Actually I set ram, CPUs, etc without creating a custom spec in vcenter,
it works just fine without it. I was referring to memory reservation, not
allocation.

But I’ll take a look at the docs you pointed to and see if THAT allows me
to set the reservation!

Thanks,
Terry
On Aug 7, 2014 10:16 PM, “Johnny Tan” johnnydtan@gmail.com wrote:

You use --cram option. --cram 3 means 3GB RAM.

But yes before being able to specify RAM via cram (or CPU via ccpu
for that matter), you do need to specify --cspec. To do that, in Vcenter,
just create a customization specification (it’s really basic info like
timezone, dns, etc):

http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.vsphere.vm_admin.doc/GUID-58E346FF-83AE-42B8-BE58-253641D257BC.html

Then you can use --cspec NAME where NAME is the name of the
customization specification you created.

On Thu, Aug 7, 2014 at 7:47 PM, Terry P. texpilot@gmail.com wrote:

Greetings all,
We are using knife vsphere to automate the birthing of over a hundred
VMs, and it’s working well. One issue we can’t figure out though is how to
set the VM memory reservation during execution of the “knife vsphere vm
clone” command.

I see there is the --cspec CUST_SPEC option, but I cannot find anything
that explains what the format / syntax should be. Can anyone please point
me to where I can find that?

Thanks in advance,
Terry


#7

Forgot to mention. I referred to the vSphere API docs for this. You can
find them here:
http://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.VirtualMachine.html

-Aditya

On Mon, Aug 11, 2014 at 12:23 PM, Aditya Karanjkar <
aditya.karanjkar@relevancelab.com> wrote:

Hi Terry,

Try the code given below to set the memory reservation. You will need the
RbVmomi gem for this. It searches for a VM called ‘test_vm’ in a folder
called ‘vm_folder’ and sets the memory reservation to 1024 MB.

#change_memory_reservation.rb
require 'rbvmomi’
vim = RbVmomi::VIM.connect host: ‘10.10.10.1’, user: ‘me’, password:
‘complex_password’, insecure: true
vm = vim.serviceInstance.find_datacenter.find_vm(“vm_folder/test_vm”) or
abort(“VM not found”)
vm_config_spec = RbVmomi::VIM.VirtualMachineConfigSpec
vm_config_spec.memoryAllocation = RbVmomi::VIM.ResourceAllocationInfo
reservation: 1024
task = vm.ReconfigVM_Task spec: vm_config_spec
task.wait_for_completion

Regards,
Aditya

On Fri, Aug 8, 2014 at 6:10 PM, Terry P. texpilot@gmail.com wrote:

Hi Johnny,
Actually I set ram, CPUs, etc without creating a custom spec in vcenter,
it works just fine without it. I was referring to memory reservation, not
allocation.

But I’ll take a look at the docs you pointed to and see if THAT allows me
to set the reservation!

Thanks,
Terry
On Aug 7, 2014 10:16 PM, “Johnny Tan” johnnydtan@gmail.com wrote:

You use --cram option. --cram 3 means 3GB RAM.

But yes before being able to specify RAM via cram (or CPU via ccpu
for that matter), you do need to specify --cspec. To do that, in Vcenter,
just create a customization specification (it’s really basic info like
timezone, dns, etc):

http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.vsphere.vm_admin.doc/GUID-58E346FF-83AE-42B8-BE58-253641D257BC.html

Then you can use --cspec NAME where NAME is the name of the
customization specification you created.

On Thu, Aug 7, 2014 at 7:47 PM, Terry P. texpilot@gmail.com wrote:

Greetings all,
We are using knife vsphere to automate the birthing of over a hundred
VMs, and it’s working well. One issue we can’t figure out though is how to
set the VM memory reservation during execution of the “knife vsphere vm
clone” command.

I see there is the --cspec CUST_SPEC option, but I cannot find anything
that explains what the format / syntax should be. Can anyone please point
me to where I can find that?

Thanks in advance,
Terry