pyvcloud.vcd.vm module¶
-
class
pyvcloud.vcd.vm.
VM
(client, href=None, resource=None)¶ Bases:
object
A helper class to work with Virtual Machines.
-
deploy
(power_on=True, force_customization=False)¶ Deploys the VM.
Deploying the VM will allocate all resources assigned to the VM. If an already deployed VM is attempted to deploy, an exception is raised.
Returns: A lxml.objectify.StringElement
object describing the asynchronous task that operates on the VM.
-
get_cpus
()¶ Returns the number of CPUs.
Returns: A dictionary with: num_cpus: (int): number of cpus num_cores_per_socket: (int): number of cores per socket
-
get_memory
()¶ Returns the amount of memory in MB.
Returns: (int): Amount of memory in MB
-
get_vc
()¶ Returns the vCenter where this VM is located.
Returns: (str): Name of the vCenter
-
modify_cpu
(virtual_quantity, cores_per_socket=None)¶ Updates the number of CPUs of a VM.
Parameters: - virtual_quantity – (int): The number of virtual CPUs to configure on the VM.
- cores_per_socket – (int): The number of cores per socket.
Returns: A
lxml.objectify.StringElement
object describing the asynchronous task that updates the VM.
-
modify_memory
(virtual_quantity)¶ Updates the memory of a VM.
Parameters: virtual_quantity – (int): The number of MB of memory to configure on the VM. Returns: A lxml.objectify.StringElement
object describing the asynchronous task that updates the VM.
-
power_off
()¶ Powers off the VM.
Returns: A lxml.objectify.StringElement
object describing the asynchronous task that operates on the VM.
-
power_on
()¶ Powers on the VM.
Returns: A lxml.objectify.StringElement
object describing the asynchronous task that operates on the VM.
-
power_reset
()¶ Powers reset the VM.
Returns: A lxml.objectify.StringElement
object describing the asynchronous task that operates on the VM.
-
reboot
()¶ Reboots the VM.
Returns: A lxml.objectify.StringElement
object describing the asynchronous Task rebooting the VM.
-
reload
()¶ Updates the xml representation of the VM from vCD.
-
shutdown
()¶ Shutdown the VM.
Returns: A lxml.objectify.StringElement
object describing the asynchronous Task shutting down the VM.
-
snapshot_create
(memory=None, quiesce=None, name=None)¶ Snapshot the VM.
Parameters: - memory – (bool): True if the snapshot should include the virtual machine’s memory.
- quiesce – (bool): True if the file system of the virtual machine should be quiesced before the snapshot is created. (Requires VMware tools installed)
- name – (bool): Typically used to name or identify the subject of the request. For example, the name of the object being created or modified.
Returns: A
lxml.objectify.StringElement
object describing the asynchronous task that operates on the VM.
-
snapshot_remove_all
()¶ Removes all user created snapshots for a virtual machine.
Returns: A lxml.objectify.StringElement
object describing the asynchronous Task shutting down the VM.
-
snapshot_revert_to_current
()¶ Reverts a virtual machine to the current snapshot, if any.
Returns: A lxml.objectify.StringElement
object describing the asynchronous Task shutting down the VM.
-
undeploy
(action='default')¶ Undeploy the VM.
Returns: A lxml.objectify.StringElement
object describing the asynchronous task that operates on the VM.
-