Package org.opennebula.client.vm
Class VirtualMachine
- java.lang.Object
-
- org.opennebula.client.PoolElement
-
- org.opennebula.client.vm.VirtualMachine
-
public class VirtualMachine extends PoolElement
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
Constructors Modifier Constructor Description VirtualMachine(int id, Client client)
Creates a new VM representation.protected
VirtualMachine(org.w3c.dom.Node xmlElement, Client client)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected OneResponse
action(java.lang.String action)
Submits an action to be performed on the virtual machine.static OneResponse
allocate(Client client, java.lang.String description)
Allocates a new VM in OpenNebula.static OneResponse
allocate(Client client, java.lang.String description, boolean onHold)
Allocates a new VM in OpenNebula.OneResponse
attachdisk(java.lang.String diskTemplate)
Deprecated.Replaced bydiskAttach(String)
static OneResponse
attachdisk(Client client, int id, java.lang.String diskTemplate)
Deprecated.OneResponse
backup(int ds_id, boolean reset)
Backup VMstatic OneResponse
backup(Client client, int id, int ds_id, boolean reset)
Backup Virtual MachineOneResponse
backupCancel()
Cancel ongoing backup operationstatic OneResponse
backupCancel(Client client, int id)
Cancel ongoing backup operationOneResponse
chgrp(int gid)
Changes the groupOneResponse
chmod(int octet)
Changes the permissionsOneResponse
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 permissionsOneResponse
chmod(java.lang.String octet)
Changes the permissionsstatic OneResponse
chmod(Client client, int id, int octet)
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
chmod(Client client, int id, java.lang.String octet)
Changes the permissionsOneResponse
chown(int uid)
Changes the ownerOneResponse
chown(int uid, int gid)
Changes the owner/groupstatic OneResponse
chown(Client client, int id, int uid, int gid)
Changes the owner/groupOneResponse
deploy(int hostId)
Initiates the instance of the VM on the target host.OneResponse
deploy(int hostId, boolean enforce, int dsId, java.lang.String extra_template)
Initiates the instance of the VM on the target host.OneResponse
detachdisk(int diskId)
Deprecated.static OneResponse
detachdisk(Client client, int id, int diskId)
Deprecated.OneResponse
diskAttach(java.lang.String diskTemplate)
Attaches a disk to a running VMstatic OneResponse
diskAttach(Client client, int id, java.lang.String diskTemplate)
Attaches a disk to a running VMOneResponse
diskDetach(int diskId)
Detaches a disk from a running VMstatic OneResponse
diskDetach(Client client, int id, int diskId)
Detaches a disk from a running VMOneResponse
diskResize(int diskId, long newSize)
Resize VM diskstatic OneResponse
diskResize(Client client, int id, int diskId, long newSize)
Resize VM diskOneResponse
diskSaveas(int diskId, java.lang.String imageName)
Sets the specified vm's disk to be saved as a new image.OneResponse
diskSaveas(int diskId, java.lang.String imageName, int snapId)
Sets the specified vm's disk to be saved in a new image.OneResponse
diskSaveas(int diskId, java.lang.String imageName, java.lang.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, java.lang.String imageName, java.lang.String imageType, int snapId)
Sets the specified vm's disk to be saved as a new image.OneResponse
diskSnapshotCreate(int diskId, java.lang.String name)
Takes a new snapshot of a diskstatic OneResponse
diskSnapshotCreate(Client client, int id, int diskId, java.lang.String name)
Takes a new snapshot of a diskOneResponse
diskSnapshotDelete(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, java.lang.String new_name)
Deletes a disk snapshotOneResponse
diskSnapshotRevert(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 snapshotOneResponse
hold()
Sets the VM to hold state.OneResponse
info()
Loads the xml representation of the virtual machine.static OneResponse
info(Client client, int id)
Retrieves the information of the given VM.static OneResponse
info(Client client, int id, boolean decrypt)
Retrieves the information of the given VM.int
lcmState()
Returns the LCM state of the VirtualMachine (numeric value).java.lang.String
lcmStateStr()
Returns the LCM state of the VirtualMachine (string value).OneResponse
liveMigrate(int hostId)
Deprecated.Replaced bymigrate(int, boolean, boolean, int, int)
OneResponse
lock(int level)
Lock this VMstatic OneResponse
lock(Client client, int id, int level)
Lock this VMOneResponse
migrate(int hostId)
Migrates the virtual machine to the target host (hid).OneResponse
migrate(int hostId, boolean live)
Migrates the virtual machine to the target host (hid).OneResponse
migrate(int hostId, boolean live, boolean enforce, int ds_id)
Migrates the virtual machine to the target host (hid).OneResponse
migrate(int hostId, boolean live, boolean enforce, int ds_id, int migration_type)
Migrates the virtual machine to the target host (hid).OneResponse
monitoring()
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 XMLOneResponse
nicAttach(java.lang.String nicTemplate)
Attaches a NIC to a running VMstatic OneResponse
nicAttach(Client client, int id, java.lang.String nicTemplate)
Attaches a NIC to a running VMOneResponse
nicDetach(int nicId)
Detaches a NIC from a running VMstatic OneResponse
nicDetach(Client client, int id, int nicId)
Detaches a NIC from a running VMOneResponse
nicUpdate(int nicId, java.lang.String nicTemplate, boolean append)
Updates a NIC for a VM.static OneResponse
nicUpdate(Client client, int id, int nicId, java.lang.String nicTemplate, boolean append)
Updates a NIC for a VM.OneResponse
poweroff()
Powers off a running VM.OneResponse
poweroff(boolean hard)
Powers off a running VM.OneResponse
reboot()
Reboots a running VM.OneResponse
reboot(boolean hard)
Reboots a running VM.OneResponse
recover(int operation)
Recovers a stuck VM.static OneResponse
recover(Client client, int id, int operation)
Recovers a stuck VM.OneResponse
release()
Releases a virtual machine from hold state.OneResponse
rename(java.lang.String name)
Renames this VMstatic OneResponse
rename(Client client, int id, java.lang.String name)
Renames this VMOneResponse
resched()
Sets the re-scheduling flag for the VMOneResponse
resize(java.lang.String capacityTemplate, boolean enforce)
Resizes this VM's capacitystatic OneResponse
resize(Client client, int id, java.lang.String capacityTemplate, boolean enforce)
Resizes the VM capacityOneResponse
resume()
Resumes the execution of a saved VM.OneResponse
schedadd(java.lang.String new_sched)
Create new scheduled actionstatic OneResponse
schedadd(Client client, int id, java.lang.String new_sched)
Create new scheduled actionOneResponse
scheddelete(int sched_id)
Delete scheduled actionstatic OneResponse
scheddelete(Client client, int id, int sched_id)
Delete scheduled actionOneResponse
schedupdate(int sched_id, java.lang.String updated_sched)
Update VM scheduled actionstatic OneResponse
schedupdate(Client client, int id, int sched_id, java.lang.String updated_sched)
Update VM scheduled actionOneResponse
sgAttach(int nicid, int sgid)
Attaches a NIC to a running VMstatic OneResponse
sgAttach(Client client, int id, int nicid, int sgid)
Attaches a SG to a VM NICOneResponse
sgDetach(int nicid, int sgid)
Detaches a NIC from a running VMstatic OneResponse
sgDetach(Client client, int id, int nicid, int sgid)
Detaches a SG from a VM NICOneResponse
snapshotCreate(java.lang.String name)
Creates a new VM snapshotstatic OneResponse
snapshotCreate(Client client, int id, java.lang.String name)
Creates a new VM snapshotOneResponse
snapshotDelete(int snapId)
Deletes a VM snapshotstatic OneResponse
snapshotDelete(Client client, int id, int snapId)
Deletes a VM snapshot.OneResponse
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.java.lang.String
stateStr()
Returns the VM state of the VirtualMachine (string value).java.lang.String
status()
Returns the short status string for the VirtualMachine.OneResponse
stop()
Stops the virtual machine.OneResponse
suspend()
Suspends the virtual machine.OneResponse
terminate()
Gracefully shuts down the already deployed VM.OneResponse
terminate(boolean hard)
Shuts down the already deployed VM.OneResponse
undeploy(boolean hard)
Undeploy a running VM, it preserve its resources and disk modifications.OneResponse
unlock()
Unlock this VMstatic OneResponse
unlock(Client client, int id)
Unlock this VMOneResponse
unresched()
Unsets the re-scheduling flag for the VMOneResponse
update(java.lang.String new_template)
Replaces this VM's user template contents.OneResponse
update(java.lang.String new_template, boolean append)
Replaces this VM's user template contents.static OneResponse
update(Client client, int id, java.lang.String new_template, boolean append)
Replaces the user template contents for the given VM.OneResponse
updateconf(java.lang.String new_conf)
Update VM Configurationstatic OneResponse
updateconf(Client client, int id, java.lang.String new_conf)
Update VM Configuration
-
-
-
Constructor Detail
-
VirtualMachine
public VirtualMachine(int id, Client client)
Creates a new VM representation.- Parameters:
id
- The virtual machine Id (vid).client
- XML-RPC Client.
-
VirtualMachine
protected VirtualMachine(org.w3c.dom.Node xmlElement, Client client)
- See Also:
PoolElement
-
-
Method Detail
-
allocate
public static OneResponse allocate(Client client, java.lang.String description)
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
public static OneResponse allocate(Client client, java.lang.String description, boolean onHold)
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
public static OneResponse update(Client client, int id, java.lang.String new_template, boolean append)
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
public static OneResponse resize(Client client, int id, java.lang.String capacityTemplate, boolean enforce)
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
public static OneResponse info(Client client, int id)
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
public static OneResponse info(Client client, int id, boolean decrypt)
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
public static OneResponse chown(Client client, int id, int uid, int gid)
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
public static OneResponse chmod(Client client, int id, java.lang.String octet)
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
public static OneResponse chmod(Client client, int id, int octet)
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
public static OneResponse monitoring(Client client, int id)
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
public static OneResponse diskAttach(Client client, int id, java.lang.String diskTemplate)
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
public static OneResponse diskDetach(Client client, int id, int diskId)
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, java.lang.String imageName, java.lang.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
public static OneResponse nicAttach(Client client, int id, java.lang.String nicTemplate)
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
public static OneResponse nicDetach(Client client, int id, int nicId)
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, java.lang.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
public static OneResponse rename(Client client, int id, java.lang.String name)
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
public static OneResponse snapshotCreate(Client client, int id, java.lang.String name)
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
public static OneResponse snapshotRevert(Client client, int id, int snapId)
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
public static OneResponse snapshotDelete(Client client, int id, int snapId)
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
public static OneResponse diskSnapshotCreate(Client client, int id, int diskId, java.lang.String name)
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
public static OneResponse diskSnapshotRevert(Client client, int id, int diskId, int snapId)
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
public static OneResponse diskSnapshotDelete(Client client, int id, int diskId, int snapId)
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, java.lang.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
public static OneResponse diskResize(Client client, int id, int diskId, long newSize)
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
public static OneResponse updateconf(Client client, int id, java.lang.String new_conf)
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
public static OneResponse schedadd(Client client, int id, java.lang.String new_sched)
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
public static OneResponse scheddelete(Client client, int id, int sched_id)
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
public static OneResponse schedupdate(Client client, int id, int sched_id, java.lang.String updated_sched)
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
public static OneResponse recover(Client client, int id, int operation)
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
public static OneResponse lock(Client client, int id, int level)
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
public static OneResponse unlock(Client client, int id)
Unlock this VM- Parameters:
client
- XML-RPC Client.id
- The VM id.- Returns:
- If an error occurs the error message contains the reason.
-
sgAttach
public static OneResponse sgAttach(Client client, int id, int nicid, int sgid)
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
public static OneResponse sgDetach(Client client, int id, int nicid, int sgid)
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.
-
backup
public static OneResponse backup(Client client, int id, int ds_id, boolean reset)
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
public static OneResponse backupCancel(Client client, int id)
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.
-
info
public OneResponse info()
Loads the xml representation of the virtual machine. The info is also stored internally.- See Also:
info(Client, int)
-
deploy
public OneResponse deploy(int hostId, boolean enforce, int dsId, java.lang.String extra_template)
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
public OneResponse deploy(int hostId)
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
protected OneResponse action(java.lang.String 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
public OneResponse migrate(int hostId, boolean live, boolean enforce, int ds_id)
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
public OneResponse migrate(int hostId, boolean live)
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
public OneResponse migrate(int hostId)
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
public OneResponse chown(int uid, int gid)
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
public OneResponse chown(int uid)
Changes the owner- Parameters:
uid
- The new owner user ID.- Returns:
- If an error occurs the error message contains the reason.
-
chgrp
public OneResponse chgrp(int gid)
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
public OneResponse chmod(java.lang.String octet)
Changes the permissions- Parameters:
octet
- Permissions octed , e.g. 640- Returns:
- If an error occurs the error message contains the reason.
-
chmod
public OneResponse chmod(int octet)
Changes the permissions- Parameters:
octet
- Permissions octed , e.g. 640- Returns:
- If an error occurs the error message contains the reason.
-
monitoring
public OneResponse 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
public OneResponse diskAttach(java.lang.String diskTemplate)
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
public OneResponse diskDetach(int diskId)
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
public OneResponse diskSaveas(int diskId, java.lang.String imageName, java.lang.String imageType, int snapId)
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
public OneResponse diskSaveas(int diskId, java.lang.String imageName)
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
public OneResponse diskSaveas(int diskId, java.lang.String imageName, int snapId)
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
public OneResponse nicAttach(java.lang.String nicTemplate)
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
public OneResponse nicDetach(int nicId)
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
public OneResponse nicUpdate(int nicId, java.lang.String nicTemplate, boolean append)
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
public OneResponse rename(java.lang.String name)
Renames this VM- Parameters:
name
- New name for the VM.- Returns:
- If an error occurs the error message contains the reason.
-
update
public OneResponse update(java.lang.String new_template)
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
public OneResponse update(java.lang.String new_template, boolean append)
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
public OneResponse resize(java.lang.String capacityTemplate, boolean enforce)
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
public OneResponse snapshotCreate(java.lang.String name)
Creates a new VM snapshot- Parameters:
name
- Name for the snapshot.- Returns:
- If an error occurs the error message contains the reason.
-
snapshotRevert
public OneResponse snapshotRevert(int snapId)
Reverts to a snapshot- Parameters:
snapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
snapshotDelete
public OneResponse snapshotDelete(int snapId)
Deletes a VM snapshot- Parameters:
snapId
- Id of the snapshot- Returns:
- If an error occurs the error message contains the reason.
-
diskSnapshotCreate
public OneResponse diskSnapshotCreate(int diskId, java.lang.String name)
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
public OneResponse diskSnapshotRevert(int diskId, int snapId)
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
public OneResponse diskSnapshotDelete(int diskId, int snapId)
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
public OneResponse diskResize(int diskId, long newSize)
Resize VM disk- Parameters:
diskId
- Id of the disknewSize
- for the disk- Returns:
- diskId of resized disk, or error message
-
updateconf
public OneResponse updateconf(java.lang.String new_conf)
Update VM Configuration- Parameters:
new_conf
- New Configuration of the target VM- Returns:
- If an error occurs the error message contains the reason.
-
schedadd
public OneResponse schedadd(java.lang.String new_sched)
Create new scheduled action- Parameters:
new_sched
- New scheduled action- Returns:
- If an error occurs the error message contains the reason.
-
scheddelete
public OneResponse scheddelete(int sched_id)
Delete scheduled action- Parameters:
sched_id
- The sched action id to delete- Returns:
- If an error occurs the error message contains the reason.
-
schedupdate
public OneResponse schedupdate(int sched_id, java.lang.String updated_sched)
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
public OneResponse recover(int operation)
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
public OneResponse lock(int level)
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
public OneResponse unlock()
Unlock this VM- Returns:
- If an error occurs the error message contains the reason.
-
sgAttach
public OneResponse sgAttach(int nicid, int sgid)
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
public OneResponse sgDetach(int nicid, int sgid)
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.
-
backup
public OneResponse backup(int ds_id, boolean reset)
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
public OneResponse backupCancel()
Cancel ongoing backup operation- Returns:
- If an error occurs the error message contains the reason.
-
terminate
public OneResponse terminate()
Gracefully shuts down the already deployed VM.- Returns:
- If an error occurs the error message contains the reason.
-
terminate
public OneResponse terminate(boolean hard)
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
public OneResponse undeploy(boolean hard)
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
public OneResponse poweroff()
Powers off a running VM.- Returns:
- If an error occurs the error message contains the reason.
-
poweroff
public OneResponse poweroff(boolean hard)
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
public OneResponse reboot()
Reboots a running VM.- Returns:
- If an error occurs the error message contains the reason.
-
reboot
public OneResponse reboot(boolean hard)
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
public OneResponse 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
public OneResponse release()
Releases a virtual machine from hold state.- Returns:
- If an error occurs the error message contains the reason.
-
stop
public OneResponse 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
public OneResponse 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
public OneResponse resume()
Resumes the execution of a saved VM.- Returns:
- If an error occurs the error message contains the reason.
-
resched
public OneResponse resched()
Sets the re-scheduling flag for the VM- Returns:
- If an error occurs the error message contains the reason.
-
unresched
public OneResponse 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
public java.lang.String 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
public java.lang.String lcmStateStr()
Returns the LCM state of the VirtualMachine (string value).- Returns:
- The LCM state of the VirtualMachine (string value).
-
status
public java.lang.String status()
Returns the short status string for the VirtualMachine.- Returns:
- The short status string for the VirtualMachine.
-
attachdisk
@Deprecated public static OneResponse attachdisk(Client client, int id, java.lang.String diskTemplate)
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 public static OneResponse detachdisk(Client client, int id, int diskId)
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 public OneResponse attachdisk(java.lang.String diskTemplate)
Deprecated.Replaced bydiskAttach(String)
-
detachdisk
@Deprecated public OneResponse detachdisk(int diskId)
Deprecated.
-
liveMigrate
@Deprecated public OneResponse liveMigrate(int hostId)
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.
-
-