Package org.opennebula.client.vm
Class VirtualMachine
java.lang.Object
org.opennebula.client.PoolElement
org.opennebula.client.vm.VirtualMachine
This class represents an OpenNebula VM.
It also offers static XML-RPC call wrappers.
-
Field Summary
Fields inherited from class org.opennebula.client.PoolElement
client, id, xml, xpath
-
Constructor Summary
ConstructorsModifierConstructorDescriptionVirtualMachine
(int id, Client client) Creates a new VM representation.protected
VirtualMachine
(Node xmlElement, Client client) -
Method Summary
Modifier and TypeMethodDescriptionprotected OneResponse
Submits an action to be performed on the virtual machine.static OneResponse
Allocates a new VM in OpenNebula.static OneResponse
Allocates a new VM in OpenNebula.attachdisk
(String diskTemplate) Deprecated.static OneResponse
attachdisk
(Client client, int id, String diskTemplate) Deprecated.backup
(int ds_id, boolean reset) Backup VMstatic OneResponse
Backup Virtual MachineCancel ongoing backup operationstatic OneResponse
backupCancel
(Client client, int id) Cancel ongoing backup operationchgrp
(int gid) Changes the groupchmod
(int octet) Changes the permissionschmod
(int owner_u, int owner_m, int owner_a, int group_u, int group_m, int group_a, int other_u, int other_m, int other_a) Changes the VM permissionsChanges the permissionsstatic OneResponse
Changes the permissionsstatic OneResponse
chmod
(Client client, int id, int owner_u, int owner_m, int owner_a, int group_u, int group_m, int group_a, int other_u, int other_m, int other_a) Changes the VM permissionsstatic OneResponse
Changes the permissionschown
(int uid) Changes the ownerchown
(int uid, int gid) Changes the owner/groupstatic OneResponse
Changes the owner/groupdeploy
(int hostId) Initiates the instance of the VM on the target host.Initiates the instance of the VM on the target host.detachdisk
(int diskId) Deprecated.static OneResponse
detachdisk
(Client client, int id, int diskId) Deprecated.diskAttach
(String diskTemplate) Attaches a disk to a running VMstatic OneResponse
diskAttach
(Client client, int id, String diskTemplate) Attaches a disk to a running VMdiskDetach
(int diskId) Detaches a disk from a running VMstatic OneResponse
diskDetach
(Client client, int id, int diskId) Detaches a disk from a running VMdiskResize
(int diskId, long newSize) Resize VM diskstatic OneResponse
diskResize
(Client client, int id, int diskId, long newSize) Resize VM diskdiskSaveas
(int diskId, String imageName) Sets the specified vm's disk to be saved as a new image.diskSaveas
(int diskId, String imageName, int snapId) Sets the specified vm's disk to be saved in a new image.diskSaveas
(int diskId, String imageName, String imageType, int snapId) Sets the specified vm's disk to be saved as a new image.static OneResponse
diskSaveas
(Client client, int id, int diskId, String imageName, String imageType, int snapId) Sets the specified vm's disk to be saved as a new image.diskSnapshotCreate
(int diskId, String name) Takes a new snapshot of a diskstatic OneResponse
diskSnapshotCreate
(Client client, int id, int diskId, String name) Takes a new snapshot of a diskdiskSnapshotDelete
(int diskId, int snapId) Deletes a disk snapshotstatic OneResponse
diskSnapshotDelete
(Client client, int id, int diskId, int snapId) Deletes a disk snapshotstatic OneResponse
diskSnapshotRename
(Client client, int id, int diskId, int snapId, String new_name) Deletes a disk snapshotdiskSnapshotRevert
(int diskId, int snapId) Reverts disk state to a previously taken snapshotstatic OneResponse
diskSnapshotRevert
(Client client, int id, int diskId, int snapId) Reverts disk state to a previously taken snapshothold()
Sets the VM to hold state.info()
Loads the xml representation of the virtual machine.static OneResponse
Retrieves the information of the given VM.static OneResponse
Retrieves the information of the given VM.int
lcmState()
Returns the LCM state of the VirtualMachine (numeric value).Returns the LCM state of the VirtualMachine (string value).liveMigrate
(int hostId) Deprecated.Replaced bymigrate(int, boolean, boolean, int, int)
lock
(int level) Lock this VMstatic OneResponse
Lock this VMmigrate
(int hostId) Migrates the virtual machine to the target host (hid).migrate
(int hostId, boolean live) Migrates the virtual machine to the target host (hid).migrate
(int hostId, boolean live, boolean enforce, int ds_id) Migrates the virtual machine to the target host (hid).migrate
(int hostId, boolean live, boolean enforce, int ds_id, int migration_type) Migrates the virtual machine to the target host (hid).Retrieves the monitoring information of the given VM, in XMLstatic OneResponse
monitoring
(Client client, int id) Retrieves the monitoring information of the given VM, in XMLAttaches a NIC to a running VMstatic OneResponse
Attaches a NIC to a running VMnicDetach
(int nicId) Detaches a NIC from a running VMstatic OneResponse
Detaches a NIC from a running VMUpdates a NIC for a VM.static OneResponse
Updates a NIC for a VM.Attaches a PCI to a VMstatic OneResponse
Attaches a PCI to a VMpciDetach
(int pciid) Detaches a PCI from a VMstatic OneResponse
Detaches a PCI from a VMpoweroff()
Powers off a running VM.poweroff
(boolean hard) Powers off a running VM.reboot()
Reboots a running VM.reboot
(boolean hard) Reboots a running VM.recover
(int operation) Recovers a stuck VM.static OneResponse
Recovers a stuck VM.release()
Releases a virtual machine from hold state.Renames this VMstatic OneResponse
Renames this VMresched()
Sets the re-scheduling flag for the VMResizes this VM's capacitystatic OneResponse
Resizes the VM capacityrestore
(int imageId, int incrementId, int diskId) Restore Virtual Machine disks from backup Imagestatic OneResponse
Restore Virtual Machine disks from backup Imageresume()
Resumes the execution of a saved VM.Create new scheduled actionstatic OneResponse
Create new scheduled actionscheddelete
(int sched_id) Delete scheduled actionstatic OneResponse
scheddelete
(Client client, int id, int sched_id) Delete scheduled actionschedupdate
(int sched_id, String updated_sched) Update VM scheduled actionstatic OneResponse
schedupdate
(Client client, int id, int sched_id, String updated_sched) Update VM scheduled actionsgAttach
(int nicid, int sgid) Attaches a NIC to a running VMstatic OneResponse
Attaches a SG to a VM NICsgDetach
(int nicid, int sgid) Detaches a NIC from a running VMstatic OneResponse
Detaches a SG from a VM NICsnapshotCreate
(String name) Creates a new VM snapshotstatic OneResponse
snapshotCreate
(Client client, int id, String name) Creates a new VM snapshotsnapshotDelete
(int snapId) Deletes a VM snapshotstatic OneResponse
snapshotDelete
(Client client, int id, int snapId) Deletes a VM snapshot.snapshotRevert
(int snapId) Reverts to a snapshotstatic OneResponse
snapshotRevert
(Client client, int id, int snapId) Reverts to a snapshotint
state()
Performs an xpath evaluation for the "state" expression.stateStr()
Returns the VM state of the VirtualMachine (string value).status()
Returns the short status string for the VirtualMachine.stop()
Stops the virtual machine.suspend()
Suspends the virtual machine.Gracefully shuts down the already deployed VM.terminate
(boolean hard) Shuts down the already deployed VM.undeploy
(boolean hard) Undeploy a running VM, it preserve its resources and disk modifications.unlock()
Unlock this VMstatic OneResponse
Unlock this VMUnsets the re-scheduling flag for the VMReplaces this VM's user template contents.Replaces this VM's user template contents.static OneResponse
Replaces the user template contents for the given VM.updateconf
(String new_conf) Update VM Configurationstatic OneResponse
updateconf
(Client client, int id, String new_conf) Update VM Configuration
-
Constructor Details
-
VirtualMachine
Creates a new VM representation.- Parameters:
id
- The virtual machine Id (vid).client
- XML-RPC Client.
-
VirtualMachine
- See Also:
-
-
Method Details
-
allocate
Allocates a new VM in OpenNebula.- Parameters:
client
- XML-RPC Client.description
- A string containing the template of the vm.- Returns:
- If successful the message contains the associated id generated for this VM.
-
allocate
Allocates a new VM in OpenNebula.- Parameters:
client
- XML-RPC Client.description
- A string containing the template of the vm.onHold
- False to create this VM in pending state, true on hold- Returns:
- If successful the message contains the associated id generated for this VM.
-
update
Replaces the user template contents for the given VM.- Parameters:
client
- XML-RPC Client.id
- The id of the target vm.new_template
- New template contentsappend
- True to append new attributes instead of replace the whole template- Returns:
- If an error occurs the error message contains the reason.
-
resize
Resizes the VM capacity- Parameters:
client
- XML-RPC Client.id
- The id of the target vm.capacityTemplate
- Template containing the new capacity elements CPU, VCPU, MEMORY. If one of them is not present, or its value is 0, it will not be resizedenforce
- If it is set to true, the host capacity will be checked. This will only affect oneadmin requests, regular users resize requests will always be enforced- Returns:
- If an error occurs the error message contains the reason.
-
info
Retrieves the information of the given VM.- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.- Returns:
- If successful the message contains the string with the information returned by OpenNebula.
-
info
Retrieves the information of the given VM.- Parameters:
client
- XML-RPC Client.id
- The VM id for the VM to retrieve the information fromdecrypt
- If true decrypt sensitive attributes- Returns:
- If successful the message contains the string with the information returned by OpenNebula.
-
chown
Changes the owner/group- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.uid
- The new owner user ID. Set it to -1 to leave the current one.gid
- The new group ID. Set it to -1 to leave the current one.- Returns:
- If an error occurs the error message contains the reason.
-
chmod
public static OneResponse chmod(Client client, int id, int owner_u, int owner_m, int owner_a, int group_u, int group_m, int group_a, int other_u, int other_m, int other_a) Changes the VM permissions- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.owner_u
- 1 to allow, 0 deny, -1 do not changeowner_m
- 1 to allow, 0 deny, -1 do not changeowner_a
- 1 to allow, 0 deny, -1 do not changegroup_u
- 1 to allow, 0 deny, -1 do not changegroup_m
- 1 to allow, 0 deny, -1 do not changegroup_a
- 1 to allow, 0 deny, -1 do not changeother_u
- 1 to allow, 0 deny, -1 do not changeother_m
- 1 to allow, 0 deny, -1 do not changeother_a
- 1 to allow, 0 deny, -1 do not change- Returns:
- If an error occurs the error message contains the reason.
-
chmod
Changes the permissions- Parameters:
client
- XML-RPC Client.id
- The id of the target object.octet
- Permissions octed , e.g. 640- Returns:
- If an error occurs the error message contains the reason.
-
chmod
Changes the permissions- Parameters:
client
- XML-RPC Client.id
- The id of the target object.octet
- Permissions octed , e.g. 640- Returns:
- If an error occurs the error message contains the reason.
-
monitoring
Retrieves the monitoring information of the given VM, in XML- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.- Returns:
- If successful the message contains the string with the monitoring information returned by OpenNebula.
-
diskAttach
Attaches a disk to a running VM- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.diskTemplate
- Template containing the new DISK definition- Returns:
- If an error occurs the error message contains the reason.
-
diskDetach
Detaches a disk from a running VM- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.diskId
- The DISK_ID of the disk to detach- Returns:
- If an error occurs the error message contains the reason.
-
diskSaveas
public static OneResponse diskSaveas(Client client, int id, int diskId, String imageName, String imageType, int snapId) Sets the specified vm's disk to be saved as a new image.- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.diskId
- ID of the disk to be saved.imageName
- Name of the new Image that will be created.imageType
- Type of the new image. Set to empty string to use the default typesnapId
- ID of the snapshot to save, -1 to use the current disk image state- Returns:
- If an error occurs the error message contains the reason.
-
nicAttach
Attaches a NIC to a running VM- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.nicTemplate
- Template containing the new NIC definition- Returns:
- If an error occurs the error message contains the reason.
-
nicDetach
Detaches a NIC from a running VM- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.nicId
- The NIC_ID of the NIC to detach- Returns:
- If an error occurs the error message contains the reason.
-
nicUpdate
public static OneResponse nicUpdate(Client client, int id, int nicId, String nicTemplate, boolean append) Updates a NIC for a VM. In case the VM is running, trigger NIC update on the host.- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.nicId
- The NIC_ID of the NIC to detachnicTemplate
- Template containing the updated NIC definitionappend
- True to append new attributes instead of replace the whole template- Returns:
- If an error occurs the error message contains the reason.
-
rename
Renames this VM- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.name
- New name for the VM.- Returns:
- If an error occurs the error message contains the reason.
-
snapshotCreate
Creates a new VM snapshot- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.name
- Name for the snapshot.- Returns:
- If an error occurs the error message contains the reason.
-
snapshotRevert
Reverts to a snapshot- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.snapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
snapshotDelete
Deletes a VM snapshot.- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.snapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
diskSnapshotCreate
Takes a new snapshot of a disk- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.diskId
- Id of the diskname
- description for the snapshot- Returns:
- New snapshot Id, or the error message
-
diskSnapshotRevert
Reverts disk state to a previously taken snapshot- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.diskId
- Id of the disksnapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
diskSnapshotDelete
Deletes a disk snapshot- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.diskId
- Id of the disksnapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
diskSnapshotRename
public static OneResponse diskSnapshotRename(Client client, int id, int diskId, int snapId, String new_name) Deletes a disk snapshot- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.diskId
- Id of the disksnapId
- Id of the snapshotnew_name
- New name of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
diskResize
Resize VM disk- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.diskId
- Id of the disknewSize
- for the disk- Returns:
- diskId of resized disk, or error message
-
updateconf
Update VM Configuration- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.new_conf
- New Configuration of the target VM- Returns:
- If an error occurs the error message contains the reason.
-
schedadd
Create new scheduled action- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.new_sched
- New scheduled action- Returns:
- If an error occurs the error message contains the reason.
-
scheddelete
Delete scheduled action- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.sched_id
- The sched action id to delete- Returns:
- If an error occurs the error message contains the reason.
-
schedupdate
Update VM scheduled action- Parameters:
client
- XML-RPC Client.id
- The VM id of the target VM.sched_id
- The sched action idupdated_sched
- Updated template of the sched action- Returns:
- If an error occurs the error message contains the reason.
-
recover
Recovers a stuck VM.- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.operation
- to recover the VM: (0) failure, (1) success or (2) retry- Returns:
- If an error occurs the error message contains the reason.
-
lock
Lock this VM- Parameters:
client
- XML-RPC Client.id
- The VM id.level
- Lock level (use (1), manage (2), admin (3), all (4))- Returns:
- If an error occurs the error message contains the reason.
-
unlock
Unlock this VM- Parameters:
client
- XML-RPC Client.id
- The VM id.- Returns:
- If an error occurs the error message contains the reason.
-
sgAttach
Attaches a SG to a VM NIC- Parameters:
client
- XML-RPC Client.id
- The Virtual Machine id (vid) of the target instance.nicid
- The NIC id, where to attach the Security Groupsgid
- The Security Group id to attach- Returns:
- If an error occurs the error message contains the reason.
-
sgDetach
Detaches a SG from a VM NIC- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.nicid
- The NIC id from which the Security Group should be detachedsgid
- The Security Group id to detach- Returns:
- If an error occurs the error message contains the reason.
-
pciAttach
Attaches a PCI to a VM- Parameters:
client
- XML-RPC Client.id
- The Virtual Machine id (vid) of the target instance.pciTemplate
- The PCI Template to attach- Returns:
- If an error occurs the error message contains the reason.
-
pciDetach
Detaches a PCI from a VM- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.pciid
- The PCI id to detach- Returns:
- If an error occurs the error message contains the reason.
-
backup
Backup Virtual Machine- Parameters:
client
- XML-RPC Client.id
- The Virtual Machine ID (vid) of the target instance.ds_id
- Id of the datastore to save the backupreset
- Reset incremental backup, do full backup- Returns:
- If an error occurs the error message contains the reason.
-
backupCancel
Cancel ongoing backup operation- Parameters:
client
- XML-RPC Client.id
- The Virtual Machine ID (vid) of the target instance.- Returns:
- If an error occurs the error message contains the reason.
-
restore
Restore Virtual Machine disks from backup Image- Parameters:
client
- XML-RPC Client.id
- The Virtual Machine ID (vid) of the target instance.imageId
- Id of the backup ImageincrementId
- ID of the backup increment. Use -1 for latest or with full backupdiskId
- ID of the disk to restore. Use -1 to restore all disks- Returns:
- If an error occurs the error message contains the reason.
-
info
Loads the xml representation of the virtual machine. The info is also stored internally.- See Also:
-
deploy
Initiates the instance of the VM on the target host.- Parameters:
hostId
- The host id (hid) of the target host where the VM will be instantiated.enforce
- If it is set to true, the host capacity will be checked, and the deployment will fail if the host is overcommited. Defaults to falsedsId
- The System Datastore where to deploy the VM. To use the default, set it to -1- Returns:
- If an error occurs the error message contains the reason.
-
deploy
Initiates the instance of the VM on the target host.- Parameters:
hostId
- The host id (hid) of the target host where the VM will be instantiated.- Returns:
- If an error occurs the error message contains the reason.
-
action
Submits an action to be performed on the virtual machine.
It is recommended to use the helper methods instead:- Parameters:
action
- The action name to be performed, can be:
"terminate-hard", "terminate", "undeploy-hard", "undeploy", "poweroff-hard", "poweroff", "reboot-hard", "reboot", "hold", "release", "stop", "suspend", "resume", "resched", "unresched"- Returns:
- If an error occurs the error message contains the reason.
-
migrate
public OneResponse migrate(int hostId, boolean live, boolean enforce, int ds_id, int migration_type) Migrates the virtual machine to the target host (hid).- Parameters:
hostId
- The target host id (hid) where we want to migrate the vm.live
- If true we are indicating that we want livemigration, otherwise false.enforce
- If it is set to true, the host capacity will be checked, and the deployment will fail if the host is overcommited. Defaults to falseds_id
- The System Datastore where to migrate the VM. To use the current one, set it to -1migration_type
- the migration type to use (0 save, 1 poweroff, 2 poweroff hard)- Returns:
- If an error occurs the error message contains the reason.
-
migrate
Migrates the virtual machine to the target host (hid).- Parameters:
hostId
- The target host id (hid) where we want to migrate the vm.live
- If true we are indicating that we want livemigration, otherwise false.enforce
- If it is set to true, the host capacity will be checked, and the deployment will fail if the host is overcommited. Defaults to falseds_id
- The System Datastore where to migrate the VM. To use the current one, set it to -1- Returns:
- If an error occurs the error message contains the reason.
-
migrate
Migrates the virtual machine to the target host (hid).- Parameters:
hostId
- The target host id (hid) where we want to migrate the vm.live
- If true the migration is done without downtime.- Returns:
- If an error occurs the error message contains the reason.
-
migrate
Migrates the virtual machine to the target host (hid).- Parameters:
hostId
- The target host id (hid) where we want to migrate the vm.- Returns:
- If an error occurs the error message contains the reason.
-
chown
Changes the owner/group- Parameters:
uid
- The new owner user ID. Set it to -1 to leave the current one.gid
- The new group ID. Set it to -1 to leave the current one.- Returns:
- If an error occurs the error message contains the reason.
-
chown
Changes the owner- Parameters:
uid
- The new owner user ID.- Returns:
- If an error occurs the error message contains the reason.
-
chgrp
Changes the group- Parameters:
gid
- The new group ID.- Returns:
- If an error occurs the error message contains the reason.
-
chmod
public OneResponse chmod(int owner_u, int owner_m, int owner_a, int group_u, int group_m, int group_a, int other_u, int other_m, int other_a) Changes the VM permissions- Parameters:
owner_u
- 1 to allow, 0 deny, -1 do not changeowner_m
- 1 to allow, 0 deny, -1 do not changeowner_a
- 1 to allow, 0 deny, -1 do not changegroup_u
- 1 to allow, 0 deny, -1 do not changegroup_m
- 1 to allow, 0 deny, -1 do not changegroup_a
- 1 to allow, 0 deny, -1 do not changeother_u
- 1 to allow, 0 deny, -1 do not changeother_m
- 1 to allow, 0 deny, -1 do not changeother_a
- 1 to allow, 0 deny, -1 do not change- Returns:
- If an error occurs the error message contains the reason.
-
chmod
Changes the permissions- Parameters:
octet
- Permissions octed , e.g. 640- Returns:
- If an error occurs the error message contains the reason.
-
chmod
Changes the permissions- Parameters:
octet
- Permissions octed , e.g. 640- Returns:
- If an error occurs the error message contains the reason.
-
monitoring
Retrieves the monitoring information of the given VM, in XML- Returns:
- If successful the message contains the string with the monitoring information returned by OpenNebula.
-
diskAttach
Attaches a disk to a running VM- Parameters:
diskTemplate
- Template containing the new DISK definition- Returns:
- If an error occurs the error message contains the reason.
-
diskDetach
Detaches a disk from a running VM- Parameters:
diskId
- The DISK_ID of the disk to detach- Returns:
- If an error occurs the error message contains the reason.
-
diskSaveas
Sets the specified vm's disk to be saved as a new image.- Parameters:
diskId
- ID of the disk to be saved.imageName
- Name of the new Image that will be created.imageType
- Type of the new image. Set to empty string to use the default typesnapId
- ID of the snapshot to save, -1 to use the current disk image state- Returns:
- If an error occurs the error message contains the reason.
-
diskSaveas
Sets the specified vm's disk to be saved as a new image.- Parameters:
diskId
- ID of the disk to be saved.imageName
- Name of the new Image that will be created.- Returns:
- If an error occurs the error message contains the reason.
-
diskSaveas
Sets the specified vm's disk to be saved in a new image.- Parameters:
diskId
- ID of the disk to be saved.imageName
- Name of the new Image that will be created.snapId
- ID of the snapshot to save, -1 to use the current disk image state- Returns:
- If an error occurs the error message contains the reason.
-
nicAttach
Attaches a NIC to a running VM- Parameters:
nicTemplate
- Template containing the new NIC definition- Returns:
- If an error occurs the error message contains the reason.
-
nicDetach
Detaches a NIC from a running VM- Parameters:
nicId
- The NIC_ID of the NIC to detach- Returns:
- If an error occurs the error message contains the reason.
-
nicUpdate
Updates a NIC for a VM. In case the VM is running, trigger NIC update on the host.- Parameters:
nicId
- The NIC_ID of the NIC to detachnicTemplate
- Template containing the updated NIC definitionappend
- True to append new attributes instead of replace the whole template- Returns:
- If an error occurs the error message contains the reason.
-
rename
Renames this VM- Parameters:
name
- New name for the VM.- Returns:
- If an error occurs the error message contains the reason.
-
update
Replaces this VM's user template contents.- Parameters:
new_template
- New template contents- Returns:
- If an error occurs the error message contains the reason.
-
update
Replaces this VM's user template contents.- Parameters:
new_template
- New template contentsappend
- True to append new attributes instead of replace the whole template- Returns:
- If an error occurs the error message contains the reason.
-
resize
Resizes this VM's capacity- Parameters:
capacityTemplate
- Template containing the new capacity elements CPU, VCPU, MEMORY. If one of them is not present, or its value is 0, it will not be resizedenforce
- If it is set to true, the host capacity will be checked. This will only affect oneadmin requests, regular users resize requests will always be enforced- Returns:
- If an error occurs the error message contains the reason.
-
snapshotCreate
Creates a new VM snapshot- Parameters:
name
- Name for the snapshot.- Returns:
- If an error occurs the error message contains the reason.
-
snapshotRevert
Reverts to a snapshot- Parameters:
snapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
snapshotDelete
Deletes a VM snapshot- Parameters:
snapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
diskSnapshotCreate
Takes a new snapshot of a disk- Parameters:
diskId
- Id of the diskname
- description for the snapshot- Returns:
- New snapshot Id, or the error message
-
diskSnapshotRevert
Reverts disk state to a previously taken snapshot- Parameters:
diskId
- Id of the disksnapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
diskSnapshotDelete
Deletes a disk snapshot- Parameters:
diskId
- Id of the disksnapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
diskResize
Resize VM disk- Parameters:
diskId
- Id of the disknewSize
- for the disk- Returns:
- diskId of resized disk, or error message
-
updateconf
Update VM Configuration- Parameters:
new_conf
- New Configuration of the target VM- Returns:
- If an error occurs the error message contains the reason.
-
schedadd
Create new scheduled action- Parameters:
new_sched
- New scheduled action- Returns:
- If an error occurs the error message contains the reason.
-
scheddelete
Delete scheduled action- Parameters:
sched_id
- The sched action id to delete- Returns:
- If an error occurs the error message contains the reason.
-
schedupdate
Update VM scheduled action- Parameters:
sched_id
- The sched action idupdated_sched
- Updated template of the sched action- Returns:
- If an error occurs the error message contains the reason.
-
recover
Recovers a stuck VM.- Parameters:
operation
- to recover the VM:- 0 failure
- 1 success
- 2 retry
- 3 delete
- 4 delete-recreate
- Returns:
- If an error occurs the error message contains the reason.
-
lock
Lock this VM- Parameters:
level
- Lock level (use (1), manage (2), admin (3), all (4))- Returns:
- If an error occurs the error message contains the reason.
-
unlock
Unlock this VM- Returns:
- If an error occurs the error message contains the reason.
-
sgAttach
Attaches a NIC to a running VM- Parameters:
nicid
- The NIC id, where to attach the Security Groupsgid
- The Security Group id to attach- Returns:
- If an error occurs the error message contains the reason.
-
sgDetach
Detaches a NIC from a running VM- Parameters:
nicid
- The NIC id from which the Security Group should be detachedsgid
- The Security Group /id to detach- Returns:
- If an error occurs the error message contains the reason.
-
pciAttach
Attaches a PCI to a VM- Parameters:
pciTemplate
- The PCI template to attach- Returns:
- If an error occurs the error message contains the reason.
-
pciDetach
Detaches a PCI from a VM- Parameters:
pciid
- The PCI id to detach- Returns:
- If an error occurs the error message contains the reason.
-
backup
Backup VM- Parameters:
ds_id
- Id of the datastore to save the backupreset
- Reset incremental backup, do full backup- Returns:
- If an error occurs the error message contains the reason.
-
backupCancel
Cancel ongoing backup operation- Returns:
- If an error occurs the error message contains the reason.
-
restore
Restore Virtual Machine disks from backup Image- Parameters:
imageId
- Id of the backup ImageincrementId
- ID of the backup increment. Use -1 for latest or with full backupdiskId
- ID of the disk to restore. Use -1 to restore all disks- Returns:
- If an error occurs the error message contains the reason.
-
terminate
Gracefully shuts down the already deployed VM.- Returns:
- If an error occurs the error message contains the reason.
-
terminate
Shuts down the already deployed VM.- Parameters:
hard
- True to perform a hard (no acpi) shutdown, false for a graceful shutdown- Returns:
- If an error occurs the error message contains the reason.
-
undeploy
Undeploy a running VM, it preserve its resources and disk modifications.- Parameters:
hard
- True to perform a hard (no acpi) shutdown, false for a graceful shutdown- Returns:
- If an error occurs the error message contains the reason.
-
poweroff
Powers off a running VM.- Returns:
- If an error occurs the error message contains the reason.
-
poweroff
Powers off a running VM.- Parameters:
hard
- True to perform a hard (no acpi) shutdown, false for a graceful shutdown- Returns:
- If an error occurs the error message contains the reason.
-
reboot
Reboots a running VM.- Returns:
- If an error occurs the error message contains the reason.
-
reboot
Reboots a running VM.- Parameters:
hard
- True to perform a hard (no acpi) reboot, false for a graceful reboot- Returns:
- If an error occurs the error message contains the reason.
-
hold
Sets the VM to hold state. The VM will not be scheduled until it is released.- Returns:
- If an error occurs the error message contains the reason.
-
release
Releases a virtual machine from hold state.- Returns:
- If an error occurs the error message contains the reason.
-
stop
Stops the virtual machine. The virtual machine state is transferred back to OpenNebula for a possible reschedule.- Returns:
- If an error occurs the error message contains the reason.
-
suspend
Suspends the virtual machine. The virtual machine state is left in the cluster node for resuming.- Returns:
- If an error occurs the error message contains the reason.
-
resume
Resumes the execution of a saved VM.- Returns:
- If an error occurs the error message contains the reason.
-
resched
Sets the re-scheduling flag for the VM- Returns:
- If an error occurs the error message contains the reason.
-
unresched
Unsets the re-scheduling flag for the VM- Returns:
- If an error occurs the error message contains the reason.
-
state
public int state()Description copied from class:PoolElement
Performs an xpath evaluation for the "state" expression.- Overrides:
state
in classPoolElement
- Returns:
- The value of the STATE element.
-
stateStr
Returns the VM state of the VirtualMachine (string value).- Returns:
- The VM state of the VirtualMachine (string value).
-
lcmState
public int lcmState()Returns the LCM state of the VirtualMachine (numeric value).- Returns:
- The LCM state of the VirtualMachine (numeric value).
-
lcmStateStr
Returns the LCM state of the VirtualMachine (string value).- Returns:
- The LCM state of the VirtualMachine (string value).
-
status
Returns the short status string for the VirtualMachine.- Returns:
- The short status string for the VirtualMachine.
-
attachdisk
Deprecated.Attaches a disk to a running VM- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.diskTemplate
- Template containing the new DISK definition- Returns:
- If an error occurs the error message contains the reason.
-
detachdisk
Deprecated.Detaches a disk from a running VM- Parameters:
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.diskId
- The DISK_ID of the disk to detach- Returns:
- If an error occurs the error message contains the reason.
-
attachdisk
Deprecated.Replaced bydiskAttach(String)
-
detachdisk
Deprecated. -
liveMigrate
Deprecated.Replaced bymigrate(int, boolean, boolean, int, int)
Performs a live migration of the virtual machine to the target host (hid).
It does the same asmigrate(int, boolean)
with live set to true.- Parameters:
hostId
- The target host id (hid) where we want to migrate the vm.- Returns:
- If an error occurs the error message contains the reason.
-
diskAttach(String)