Exemplo n.º 1
0
 def setUp(self):
     self.connection = Connection('127.0.0.1')
     self.connection._access_token = "123456789"
     self.policies = policies.Policies(self.connection)
     self.clusters = clusters.OmnistackClusters(self.connection)
     self.hosts = hosts.Hosts(self.connection)
     self.cluster_groups = cluster_groups.ClusterGroups(self.connection)
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def create(self, datastore_name, cluster, policy, size=0, timeout=-1):
        """Creates a new datastore.

        Args:
            datastore_name: The name of the new datastore created from this action.
            cluster: Destination OmnistackCluster object/name.
            policy: Object/name of the policy to assocaited with the new datastore.
            size: The size in bytes of the new datastore.
            timeout: Time out for the request in seconds.

        Returns:
            object: Datastore object.
        """
        method_url = "{}".format(URL)

        if not isinstance(cluster, omnistack_clusters.OmnistackCluster):
            # if passed name of the cluster
            clusters_obj = omnistack_clusters.OmnistackClusters(
                self._connection)
            cluster = clusters_obj.get_by_name(cluster)

        if not isinstance(policy, policies.Policy):
            # if passed name of the policy
            policies_obj = policies.Policies(self._connection)
            policy = policies_obj.get_by_name(policy)

        data = {
            "name": datastore_name,
            "omnistack_cluster_id": cluster.data['id'],
            "policy_id": policy.data['id'],
            "size": size
        }

        out = self._client.do_post(method_url, data, timeout, None)
        return self.get_by_id(out[0]["object_id"])
Exemplo n.º 4
0
    def set_policy(self, policy, timeout=-1):
        """Sets the backup policy for a datastore.

        Args:
            policy: Policy object/name
            timeout: Time out for the request in seconds.

        Returns:
            object: Datastore object.

        """
        resource_uri = "{}/{}/set_policy".format(URL, self.data["id"])
        if not isinstance(policy, policies.Policy):
            # if passed name of the policy
            policy = policies.Policies(self._connection).get_by_name(policy)

        data = {"policy_id": policy.data['id']}
        self._client.do_post(resource_uri, data, timeout, None)
        self.__refresh()

        return self
    def set_policy(self, policy, timeout=-1):
        """Sets the backup policy for virtual machine.

        Args:
            policy: Policy object/name
            timeout: Time out for the request in seconds.

        Returns:
            self: Returns the same object.
        """
        method_url = "{}/{}/set_policy".format(URL, self.data["id"])

        if not isinstance(policy, policies.Policy):
            # if passed name of the policy
            policy = policies.Policies(self._connection).get_by_name(policy)

        data = {"policy_id": policy.data["id"]}

        self._client.do_post(method_url, data, timeout, None)
        self.__refresh()

        return self
    def policy_impact_report(self, policy, vms, timeout=-1):
        """Generate a backup impact reported based on proposed application of a policy to one or more virtual machines.

        Args:
            policy: Policy object/name
            vms: List of vm objects
            timeout: Time out for the request in seconds.

        Returns:
            dict: Returns the dictionary for impact report of policy applied on virtual machines.
        """
        method_url = "{}/policy_impact_report/apply_policy".format(URL)
        custom_headers = {
            'Content-type': 'application/vnd.simplivity.v1.14+json'
        }

        vm_ids = [vm.data["id"] for vm in vms]
        if not isinstance(policy, policies.Policy):
            # if passed name of the policy
            policy = policies.Policies(self._connection).get_by_name(policy)

        data = {"virtual_machine_id": vm_ids, "policy_id": policy.data["id"]}

        return self._client.do_post(method_url, data, timeout, custom_headers)
Exemplo n.º 7
0
 def setUp(self):
     self.connection = Connection('127.0.0.1')
     self.connection._access_token = "123456789"
     self.policies = policies.Policies(self.connection)