|
OpenNebula Cloud API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennebula.client.PoolElement
org.opennebula.client.vm.VirtualMachine
public class 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 | |
---|---|
|
VirtualMachine(int id,
Client client)
Creates a new VM representation. |
protected |
VirtualMachine(org.w3c.dom.Node xmlElement,
Client client)
|
Method Summary | |
---|---|
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. |
static OneResponse |
attachdisk(Client client,
int id,
java.lang.String diskTemplate)
Deprecated. Replaced by diskAttach(org.opennebula.client.Client, int, java.lang.String) |
OneResponse |
attachdisk(java.lang.String diskTemplate)
Deprecated. Replaced by diskAttach(String) |
OneResponse |
boot()
Forces a re-deployment of a VM in UNKNOWN or BOOT states. |
OneResponse |
cancel()
Deprecated. Replaced by hard shutdown shutdown(boolean) |
OneResponse |
chgrp(int gid)
Changes the group |
static OneResponse |
chmod(Client client,
int id,
int octet)
Changes the permissions |
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 |
static OneResponse |
chmod(Client client,
int id,
java.lang.String octet)
Changes the permissions |
OneResponse |
chmod(int octet)
Changes the permissions |
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 |
OneResponse |
chmod(java.lang.String octet)
Changes the permissions |
static OneResponse |
chown(Client client,
int id,
int uid,
int gid)
Changes the owner/group |
OneResponse |
chown(int uid)
Changes the owner |
OneResponse |
chown(int uid,
int gid)
Changes the owner/group |
OneResponse |
delete()
Deletes the VM from the pool and database. |
OneResponse |
delete(boolean recreate)
Deletes the VM from the pool and database. |
OneResponse |
deploy(int hostId)
Initiates the instance of the VM on the target host. |
OneResponse |
deploy(int hostId,
boolean enforce)
Initiates the instance of the VM on the target host. |
static OneResponse |
detachdisk(Client client,
int id,
int diskId)
Deprecated. Replaced by diskDetach(org.opennebula.client.Client, int, int) |
OneResponse |
detachdisk(int diskId)
Deprecated. |
static OneResponse |
diskAttach(Client client,
int id,
java.lang.String diskTemplate)
Attaches a disk to a running VM |
OneResponse |
diskAttach(java.lang.String diskTemplate)
Attaches a disk to a running VM |
static OneResponse |
diskDetach(Client client,
int id,
int diskId)
Detaches a disk from a running VM |
OneResponse |
diskDetach(int diskId)
Detaches a disk from a running VM |
static OneResponse |
diskSnapshot(Client client,
int id,
int diskId,
java.lang.String imageName,
java.lang.String imageType,
boolean hot)
Sets the specified vm's disk to be saved in a new image. |
OneResponse |
diskSnapshot(int diskId,
java.lang.String imageName)
Sets the specified vm's disk to be saved in a new image when the VirtualMachine shuts down. |
OneResponse |
diskSnapshot(int diskId,
java.lang.String imageName,
boolean hot)
Sets the specified vm's disk to be saved in a new image. |
OneResponse |
diskSnapshot(int diskId,
java.lang.String imageName,
java.lang.String imageType,
boolean hot)
Sets the specified vm's disk to be saved in a new image. |
OneResponse |
finalizeVM()
Deprecated. Replaced by delete() |
OneResponse |
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. |
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 by migrate(int, boolean, boolean) |
OneResponse |
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)
Migrates the virtual machine to the target host (hid). |
OneResponse |
monitoring()
Retrieves the monitoring information of the given VM, in XML |
static OneResponse |
monitoring(Client client,
int id)
Retrieves the monitoring information of the given VM, in XML |
static OneResponse |
nicAttach(Client client,
int id,
java.lang.String nicTemplate)
Attaches a NIC to a running VM |
OneResponse |
nicAttach(java.lang.String nicTemplate)
Attaches a NIC to a running VM |
static OneResponse |
nicDetach(Client client,
int id,
int nicId)
Detaches a NIC from a running VM |
OneResponse |
nicDetach(int nicId)
Detaches a NIC from a running 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(boolean success)
Recovers a stuck VM. |
static OneResponse |
recover(Client client,
int id,
boolean success)
Recovers a stuck VM. |
OneResponse |
release()
Releases a virtual machine from hold state. |
static OneResponse |
rename(Client client,
int id,
java.lang.String name)
Renames this VM |
OneResponse |
rename(java.lang.String name)
Renames this VM |
OneResponse |
resched()
Sets the re-scheduling flag for the VM |
OneResponse |
reset()
Deprecated. Replaced by hard reboot reboot(boolean) |
static OneResponse |
resize(Client client,
int id,
java.lang.String capacityTemplate,
boolean enforce)
Resizes the VM capacity |
OneResponse |
resize(java.lang.String capacityTemplate,
boolean enforce)
Resizes this VM's capacity |
OneResponse |
restart()
Deprecated. Replaced by boot() |
OneResponse |
resubmit()
Deprecated. Replaced by delete and recreate delete(boolean) |
OneResponse |
resume()
Resumes the execution of a saved VM. |
OneResponse |
savedisk(int diskId,
java.lang.String imageName)
Deprecated. Replaced by diskSnapshot(int,String) |
OneResponse |
savedisk(int diskId,
java.lang.String imageName,
java.lang.String imageType)
Deprecated. Replaced by diskSnapshot(int,String,String,boolean) |
OneResponse |
shutdown()
Gracefully shuts down the already deployed VM. |
OneResponse |
shutdown(boolean hard)
Shuts down the already deployed VM. |
static OneResponse |
snapshotCreate(Client client,
int id,
java.lang.String name)
Creates a new VM snapshot |
OneResponse |
snapshotCreate(java.lang.String name)
Creates a new VM snapshot |
static OneResponse |
snapshotDelete(Client client,
int id,
int snapId)
Deletes a VM snapshot. |
OneResponse |
snapshotDelete(int snapId)
Deletes a VM snapshot |
static OneResponse |
snapshotRevert(Client client,
int id,
int snapId)
Reverts to a snapshot |
OneResponse |
snapshotRevert(int snapId)
Reverts to a snapshot |
int |
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 |
undeploy(boolean hard)
Undeploy a running VM, it preserve its resources and disk modifications. |
OneResponse |
unresched()
Unsets the re-scheduling flag for the VM |
static OneResponse |
update(Client client,
int id,
java.lang.String new_template)
Replaces the user template contents for the given VM. |
OneResponse |
update(java.lang.String new_template)
Replaces this VM's user template contents. |
Methods inherited from class org.opennebula.client.PoolElement |
---|
chmod, chmod, chmod, getId, getName, gid, id, processInfo, uid, xpath |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VirtualMachine(int id, Client client)
id
- The virtual machine Id (vid).client
- XML-RPC Client.protected VirtualMachine(org.w3c.dom.Node xmlElement, Client client)
PoolElement
Method Detail |
---|
public static OneResponse allocate(Client client, java.lang.String description)
client
- XML-RPC Client.description
- A string containing the template of the vm.
public static OneResponse allocate(Client client, java.lang.String description, boolean onHold)
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
public static OneResponse update(Client client, int id, java.lang.String new_template)
client
- XML-RPC Client.id
- The id of the target vm.new_template
- New template contents
public static OneResponse resize(Client client, int id, java.lang.String capacityTemplate, boolean enforce)
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
public static OneResponse info(Client client, int id)
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.
public static OneResponse chown(Client client, int id, int uid, int gid)
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.
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)
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
public static OneResponse chmod(Client client, int id, java.lang.String octet)
client
- XML-RPC Client.id
- The id of the target object.octet
- Permissions octed , e.g. 640
public static OneResponse chmod(Client client, int id, int octet)
client
- XML-RPC Client.id
- The id of the target object.octet
- Permissions octed , e.g. 640
public static OneResponse monitoring(Client client, int id)
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.
public static OneResponse diskAttach(Client client, int id, java.lang.String diskTemplate)
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.diskTemplate
- Template containing the new DISK definition
public static OneResponse diskDetach(Client client, int id, int diskId)
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.diskId
- The DISK_ID of the disk to detach
public static OneResponse diskSnapshot(Client client, int id, int diskId, java.lang.String imageName, java.lang.String imageType, boolean hot)
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 typehot
- True to save the disk immediately, false will perform
the operation when the VM shuts down
public static OneResponse nicAttach(Client client, int id, java.lang.String nicTemplate)
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.nicTemplate
- Template containing the new NIC definition
public static OneResponse nicDetach(Client client, int id, int nicId)
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.nicId
- The NIC_ID of the NIC to detach
public static OneResponse rename(Client client, int id, java.lang.String name)
client
- XML-RPC Client.id
- The VM id of the target VM.name
- New name for the VM.
public static OneResponse snapshotCreate(Client client, int id, java.lang.String name)
client
- XML-RPC Client.id
- The VM id of the target VM.name
- Name for the snapshot.
public static OneResponse snapshotRevert(Client client, int id, int snapId)
client
- XML-RPC Client.id
- The VM id of the target VM.snapId
- Id of the snapshot
public static OneResponse snapshotDelete(Client client, int id, int snapId)
client
- XML-RPC Client.id
- The VM id of the target VM.snapId
- Id of the snapshot
public static OneResponse recover(Client client, int id, boolean success)
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.success
- recover by succeeding the missing transaction if true.
public OneResponse info()
info(Client, int)
public OneResponse deploy(int hostId, boolean enforce)
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 false
public OneResponse deploy(int hostId)
hostId
- The host id (hid) of the target host where
the VM will be instantiated.
protected OneResponse action(java.lang.String action)
shutdown(boolean)
reboot(boolean)
hold()
release()
stop()
suspend()
resume()
delete(boolean)
boot()
poweroff()
resched()
unresched()
undeploy(boolean)
action
- The action name to be performed, can be:public OneResponse migrate(int hostId, boolean live, boolean enforce)
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 false
public OneResponse migrate(int hostId, boolean live)
hostId
- The target host id (hid) where we want to migrate
the vm.live
- If true the migration is done without downtime.
public OneResponse migrate(int hostId)
hostId
- The target host id (hid) where we want to migrate
the vm.
public OneResponse chown(int uid, int gid)
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.
public OneResponse chown(int uid)
uid
- The new owner user ID.
public OneResponse chgrp(int gid)
gid
- The new group ID.
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)
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
public OneResponse chmod(java.lang.String octet)
octet
- Permissions octed , e.g. 640
public OneResponse chmod(int octet)
octet
- Permissions octed , e.g. 640
public OneResponse monitoring()
public OneResponse diskAttach(java.lang.String diskTemplate)
diskTemplate
- Template containing the new DISK definition
public OneResponse diskDetach(int diskId)
diskId
- The DISK_ID of the disk to detach
public OneResponse diskSnapshot(int diskId, java.lang.String imageName, java.lang.String imageType, boolean hot)
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 typehot
- True to save the disk immediately, false will perform
the operation when the VM shuts down
public OneResponse diskSnapshot(int diskId, java.lang.String imageName)
diskId
- ID of the disk to be saved.imageName
- Name of the new Image that will be created.
public OneResponse diskSnapshot(int diskId, java.lang.String imageName, boolean hot)
diskId
- ID of the disk to be saved.imageName
- Name of the new Image that will be created.hot
- True to save the disk immediately, false will perform
the operation when the VM shuts down
public OneResponse nicAttach(java.lang.String nicTemplate)
nicTemplate
- Template containing the new NIC definition
public OneResponse nicDetach(int nicId)
nicId
- The NIC_ID of the NIC to detach
public OneResponse rename(java.lang.String name)
name
- New name for the VM.
public OneResponse update(java.lang.String new_template)
new_template
- New template contents
public OneResponse resize(java.lang.String capacityTemplate, boolean enforce)
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
public OneResponse snapshotCreate(java.lang.String name)
name
- Name for the snapshot.
public OneResponse snapshotRevert(int snapId)
snapId
- Id of the snapshot
public OneResponse snapshotDelete(int snapId)
snapId
- Id of the snapshot
public OneResponse recover(boolean success)
success
- recover by succeeding the missing transaction if true.
public OneResponse shutdown()
public OneResponse shutdown(boolean hard)
hard
- True to perform a hard (no acpi) shutdown, false for a
graceful shutdown
public OneResponse undeploy(boolean hard)
hard
- True to perform a hard (no acpi) shutdown, false for a
graceful shutdown
public OneResponse poweroff()
public OneResponse poweroff(boolean hard)
hard
- True to perform a hard (no acpi) shutdown, false for a
graceful shutdown
public OneResponse reboot()
public OneResponse reboot(boolean hard)
hard
- True to perform a hard (no acpi) reboot, false for a
graceful reboot
public OneResponse hold()
public OneResponse release()
public OneResponse stop()
public OneResponse suspend()
public OneResponse resume()
public OneResponse delete()
public OneResponse delete(boolean recreate)
recreate
- True to recreate the VM in the pending state.
public OneResponse boot()
public OneResponse resched()
public OneResponse unresched()
public int state()
PoolElement
state
in class PoolElement
public java.lang.String stateStr()
public int lcmState()
public java.lang.String lcmStateStr()
public java.lang.String status()
@Deprecated public static OneResponse attachdisk(Client client, int id, java.lang.String diskTemplate)
diskAttach(org.opennebula.client.Client, int, java.lang.String)
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.diskTemplate
- Template containing the new DISK definition
@Deprecated public static OneResponse detachdisk(Client client, int id, int diskId)
diskDetach(org.opennebula.client.Client, int, int)
client
- XML-RPC Client.id
- The virtual machine id (vid) of the target instance.diskId
- The DISK_ID of the disk to detach
@Deprecated public OneResponse savedisk(int diskId, java.lang.String imageName)
diskSnapshot(int,String)
public OneResponse savedisk(int diskId, java.lang.String imageName, java.lang.String imageType)
diskSnapshot(int,String,String,boolean)
@Deprecated public OneResponse attachdisk(java.lang.String diskTemplate)
diskAttach(String)
@Deprecated public OneResponse detachdisk(int diskId)
@Deprecated public OneResponse cancel()
shutdown(boolean)
@Deprecated public OneResponse reset()
reboot(boolean)
@Deprecated public OneResponse finalizeVM()
delete()
@Deprecated public OneResponse resubmit()
delete(boolean)
@Deprecated public OneResponse restart()
boot()
@Deprecated public OneResponse liveMigrate(int hostId)
migrate(int, boolean, boolean)
migrate(int, boolean)
with live set to true.
hostId
- The target host id (hid) where we want to migrate
the vm.
|
OpenNebula Cloud API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |