コード例 #1
0
    def list(self, project_name, tenant):
        """This function gives list of comma separated consistency group uris.

        :param project_name: Name of the project path
        :param tenant: Name of the tenant
        :returns: list of consistency group ids separated by comma
        """
        if tenant is None:
            tenant = ""
        projobj = project.Project(self.ipaddr, self.port)
        fullproj = tenant + "/" + project_name
        projuri = projobj.project_query(fullproj)

        (s, h) = common.service_json_request(
            self.ipaddr, self.port, "GET",
            self.URI_CONSISTENCY_GROUPS_SEARCH.format(projuri), None)
        o = common.json_decode(s)
        if not o:
            return []

        congroups = []
        resources = common.get_node_value(o, "resource")
        for resource in resources:
            congroups.append(resource["id"])

        return congroups
コード例 #2
0
ファイル: exportgroup.py プロジェクト: C2python/cinder
    def exportgroup_list(self, project_name, tenant):
        """This function gives list of export group uris separated by comma.

        :param project_name: Name of the project path
        :param tenant: Name of the tenant
        :returns: list of export group ids separated by comma
        """
        if tenant is None:
            tenant = ""
        projobj = project.Project(self.ipaddr, self.port)
        fullproj = tenant + "/" + project_name
        projuri = projobj.project_query(fullproj)

        uri = self.URI_EXPORT_GROUP_SEARCH

        if '?' in uri:
            uri += '&project=' + projuri
        else:
            uri += '?project=' + projuri

        (s, h) = common.service_json_request(self.ipaddr, self.port, "GET",
                                             uri, None)
        o = common.json_decode(s)
        if not o:
            return []

        exportgroups = []
        resources = common.get_node_value(o, "resource")
        for resource in resources:
            exportgroups.append(resource["id"])

        return exportgroups
コード例 #3
0
ファイル: host.py プロジェクト: bravandi/cinder
 def search_by_name(self, host_name):
     """Search host by its name."""
     (s, h) = common.service_json_request(
         self.ipaddr, self.port, "GET",
         self.URI_HOSTS_SEARCH_BY_NAME.format(host_name), None)
     o = common.json_decode(s)
     if not o:
         return []
     return common.get_node_value(o, "resource")
コード例 #4
0
ファイル: host.py プロジェクト: C2python/cinder
    def show_by_uri(self, uri):
        """Makes REST API call to retrieve Host details based on its UUID."""
        (s, h) = common.service_json_request(self.ipaddr, self.port, "GET",
                                             Host.URI_HOST_DETAILS.format(uri),
                                             None)
        o = common.json_decode(s)
        inactive = common.get_node_value(o, 'inactive')

        if inactive:
            return None
        return o
コード例 #5
0
ファイル: volume.py プロジェクト: CoprHD/cinder-driver
    def show_by_uri(self, uri):
        """Makes REST API call and retrieves volume details based on UUID.

        :param uri: UUID of volume
        :returns: Volume details in JSON response payload
        """

        (s, h) = common.service_json_request(self.ipaddr, self.port,
                                             "GET",
                                             Volume.URI_VOLUME.format(uri),
                                             None)
        o = common.json_decode(s)
        inactive = common.get_node_value(o, 'inactive')
        if inactive:
            return None
        return o
コード例 #6
0
ファイル: project.py プロジェクト: CoprHD/cinder-driver
    def project_show_by_uri(self, uri):
        """Makes REST API call and retrieves project derails based on UUID.

        :param uri: UUID of project
        :returns: Project details in JSON response payload
        """

        (s, h) = common.service_json_request(self.ipaddr, self.port,
                                             "GET",
                                             Project.URI_PROJECT.format(uri),
                                             None)
        o = common.json_decode(s)
        inactive = common.get_node_value(o, 'inactive')
        if inactive:
            return None

        return o
コード例 #7
0
ファイル: volume.py プロジェクト: CoprHD/cinder-driver
    def search_volumes(self, project_name):

        proj = project.Project(self.ipaddr, self.port)
        project_uri = proj.project_query(project_name)

        (s, h) = common.service_json_request(self.ipaddr, self.port,
                                             "GET",
                                             Volume.URI_SEARCH_VOLUMES.format(
                                                 project_uri),
                                             None)
        o = common.json_decode(s)
        if not o:
            return []

        volume_uris = []
        resources = common.get_node_value(o, "resource")
        for resource in resources:
            volume_uris.append(resource["id"])
        return volume_uris
コード例 #8
0
ファイル: snapshot.py プロジェクト: C2python/cinder
    def snapshot_query(self, storageres_type,
                       storageres_typename, resuri, snapshot_name):
        if resuri is not None:
            uris = self.snapshot_list_uri(
                storageres_type,
                storageres_typename,
                resuri)
            for uri in uris:
                snapshot = self.snapshot_show_uri(
                    storageres_type,
                    resuri,
                    uri['id'])
                if (False == common.get_node_value(snapshot, 'inactive') and
                        snapshot['name'] == snapshot_name):
                    return snapshot['id']

        raise common.CoprHdError(
            common.CoprHdError.SOS_FAILURE_ERR,
            (_("snapshot with the name: "
               "%s Not Found") % snapshot_name))
コード例 #9
0
ファイル: host.py プロジェクト: C2python/cinder
    def list_initiators(self, host_name):
        """Lists all initiators for the given host.

        :param host_name: The name of the host
        """
        if not common.is_uri(host_name):
            hostUri = self.query_by_name(host_name, None)
        else:
            hostUri = host_name

        (s, h) = common.service_json_request(
            self.ipaddr, self.port, "GET",
            Host.URI_HOST_LIST_INITIATORS.format(hostUri),
            None)
        o = common.json_decode(s)

        if not o or "initiator" not in o:
            return []

        return common.get_node_value(o, 'initiator')