Пример #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
    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
    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
Пример #4
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
Пример #5
0
 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")
Пример #6
0
    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
Пример #7
0
    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
Пример #8
0
    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
    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
Пример #10
0
    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
Пример #11
0
    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
Пример #12
0
    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
Пример #13
0
    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
Пример #14
0
    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
Пример #15
0
    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')
Пример #16
0
    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')
Пример #17
0
    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))