コード例 #1
0
 def setUp(self):
     self.connection = Connection('127.0.0.1')
     self.connection._access_token = "123456789"
     self.machines = machines.VirtualMachines(self.connection)
     self.policies = policies.Policies(self.connection)
     self.datastores = datastores.Datastores(self.connection)
     self.clusters = omnistack_clusters.OmnistackClusters(self.connection)
コード例 #2
0
    def move(self, new_vm_name, datastore, timeout=-1):
        """Moves a virtual machine to another datastore.

        Args:
            new_vm_name: Name of the new vm
            datastore: Object/name of the destination datastore
            timeout: Time out for the request in seconds.

        Returns:
            VirtualMachine object: Object of the moved VM
        """
        method_url = "{}/{}/move".format(URL, self.data["id"])

        if not isinstance(datastore, datastores.Datastore):
            # if passed name of the datastore
            datastores_obj = datastores.Datastores(self._connection)
            datastore = datastores_obj.get_by_name(datastore)

        data = {
            "virtual_machine_name": new_vm_name,
            "destination_datastore_id": datastore.data["id"]
        }

        affected_object = self._client.do_post(method_url, data, timeout,
                                               None)[0]
        vm_obj = self._vms.get_by_id(affected_object["object_id"])
        self.data = vm_obj.data

        return self
コード例 #3
0
    def restore(self,
                restore_original,
                virtual_machine_name=None,
                datastore=None,
                timeout=-1):
        """Creates a new virtual machine or replaces the original virtual machine from the specified backup

        Args:
           restore_original: If True, Resets the original virtual machine to the same state it was in when the backup was created
                             If False, Creates a new virtual machine from the backup with the provided name, optionally to a different datastore
           virtual_machine_name: The name of the new virtual machine created from this action.
           datastore: Destination datastore object/name.
           timeout: Time out for the request in seconds.

        Returns:
              Virtual machine object

        """
        resource_uri = "{}/{}/restore".format(URL, self.data["id"])
        data = {}
        if not restore_original:
            data["virtual_machine_name"] = virtual_machine_name
            if datastore:
                if not isinstance(datastore, datastores.Datastore):
                    # if passed by datastore name
                    datastore_obj = datastores.Datastores(self._connection)
                    datastore = datastore_obj.get_by_name(datastore)
                data["datastore_id"] = datastore.data["id"]

        flags = {"restore_original": restore_original}
        affected_object = self._client.do_post(resource_uri, data, timeout,
                                               None, flags)[0]
        virtual_machines_obj = virtual_machines.VirtualMachines(
            self._connection)
        return virtual_machines_obj.get_by_id(affected_object["object_id"])
コード例 #4
0
 def setUp(self):
     self.connection = Connection('127.0.0.1')
     self.connection._access_token = "123456789"
     self.backups = backups.Backups(self.connection)
     self.datastores = datastores.Datastores(self.connection)
     self.virtual_machines = virtual_machines.VirtualMachines(self.connection)
     self.clusters = omnistack_clusters.OmnistackClusters(self.connection)
     self.cluster_groups = cluster_groups.ClusterGroups(self.connection)
コード例 #5
0
 def setUp(self):
     self.connection = Connection('127.0.0.1')
     self.connection._access_token = "123456789"
     self.datastores = datastores.Datastores(self.connection)