Class VirtualMachine


  • public class VirtualMachine
    extends PoolElement
    This class represents an OpenNebula VM. It also offers static XML-RPC call wrappers.
    • 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 contents
        append - 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 resized
        enforce - 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 from
        decrypt - 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 change
        owner_m - 1 to allow, 0 deny, -1 do not change
        owner_a - 1 to allow, 0 deny, -1 do not change
        group_u - 1 to allow, 0 deny, -1 do not change
        group_m - 1 to allow, 0 deny, -1 do not change
        group_a - 1 to allow, 0 deny, -1 do not change
        other_u - 1 to allow, 0 deny, -1 do not change
        other_m - 1 to allow, 0 deny, -1 do not change
        other_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 type
        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 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 detach
        nicTemplate - Template containing the updated NIC definition
        append - 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 disk
        name - 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 disk
        snapId - 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 disk
        snapId - 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 disk
        snapId - Id of the snapshot
        new_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 disk
        newSize - 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 id
        updated_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 Group
        sgid - 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 detached
        sgid - 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 backup
        reset - 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 false
        dsId - 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.
      • 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 false
        ds_id - The System Datastore where to migrate the VM. To use the current one, set it to -1
        migration_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 false
        ds_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 change
        owner_m - 1 to allow, 0 deny, -1 do not change
        owner_a - 1 to allow, 0 deny, -1 do not change
        group_u - 1 to allow, 0 deny, -1 do not change
        group_m - 1 to allow, 0 deny, -1 do not change
        group_a - 1 to allow, 0 deny, -1 do not change
        other_u - 1 to allow, 0 deny, -1 do not change
        other_m - 1 to allow, 0 deny, -1 do not change
        other_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 type
        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.
      • 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 detach
        nicTemplate - Template containing the updated NIC definition
        append - 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 contents
        append - 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 resized
        enforce - 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 disk
        name - 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 disk
        snapId - 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 disk
        snapId - 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 disk
        newSize - 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 id
        updated_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 Group
        sgid - 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 detached
        sgid - 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 backup
        reset - 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 class PoolElement
        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)
        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)
        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.
      • detachdisk

        @Deprecated
        public OneResponse detachdisk​(int diskId)
        Deprecated.
      • liveMigrate

        @Deprecated
        public OneResponse liveMigrate​(int hostId)
        Performs a live migration of the virtual machine to the target host (hid).
        It does the same as migrate(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.