Beispiel #1
0
    def index(self, req):
        """Returns a list of share servers."""

        context = req.environ["manila.context"]
        policy.check_policy(context, RESOURCE_NAME, "index")

        search_opts = {}
        search_opts.update(req.GET)

        share_servers = db_api.share_server_get_all(context)
        for s in share_servers:
            s.project_id = s.share_network["project_id"]
            if s.share_network["name"]:
                s.share_network_name = s.share_network["name"]
            else:
                s.share_network_name = s.share_network_id
        if search_opts:
            for k, v in six.iteritems(search_opts):
                share_servers = [
                    s
                    for s in share_servers
                    if (
                        hasattr(s, k)
                        and s[k] == v
                        or k == "share_network"
                        and v in [s.share_network["name"], s.share_network["id"]]
                    )
                ]
        return self._view_builder.build_share_servers(share_servers)
Beispiel #2
0
    def index(self, req):
        """Returns a list of share servers."""

        context = req.environ['manila.context']

        search_opts = {}
        search_opts.update(req.GET)
        share_servers = db_api.share_server_get_all(context)
        for s in share_servers:
            try:
                s.share_network_id = s.share_network_subnet['share_network_id']
                share_network = db_api.share_network_get(
                    context, s.share_network_id)
                s.project_id = share_network['project_id']
                if share_network['name']:
                    s.share_network_name = share_network['name']
                else:
                    s.share_network_name = share_network['id']
            except exception.ShareNetworkNotFound:
                # NOTE(dviroel): The share-network may already be deleted while
                # the share-server is in 'deleting' state. In this scenario,
                # we will return some empty values.
                LOG.debug(
                    "Unable to retrieve share network details for share "
                    "server %(server)s, the network %(network)s was "
                    "not found.", {
                        'server': s.id,
                        'network': s.share_network_id
                    })
                s.project_id = ''
                s.share_network_name = ''
        if search_opts:
            for k, v in search_opts.items():
                share_servers = [
                    s for s in share_servers
                    if (hasattr(s, k) and s[k] == v or k == 'share_network'
                        and v in [s.share_network_name, s.share_network_id])
                ]
        return self._view_builder.build_share_servers(req, share_servers)
Beispiel #3
0
    def index(self, req):
        """Returns a list of share servers."""

        context = req.environ['manila.context']
        policy.check_policy(context, RESOURCE_NAME, 'index')

        search_opts = {}
        search_opts.update(req.GET)

        share_servers = db_api.share_server_get_all(context)
        for s in share_servers:
            s.project_id = s.share_network['project_id']
            if s.share_network['name']:
                s.share_network_name = s.share_network['name']
            else:
                s.share_network_name = s.share_network_id
        if search_opts:
            for k, v in search_opts.iteritems():
                share_servers = [s for s in share_servers if (hasattr(s, k) and
                    s[k] == v or k == 'share_network' and v in
                        [s.share_network['name'], s.share_network['id']])]
        return self._view_builder.build_share_servers(share_servers)
Beispiel #4
0
    def index(self, req):
        """Returns a list of share servers."""

        context = req.environ['manila.context']

        search_opts = {}
        search_opts.update(req.GET)

        share_servers = db_api.share_server_get_all(context)
        for s in share_servers:
            s.project_id = s.share_network['project_id']
            if s.share_network['name']:
                s.share_network_name = s.share_network['name']
            else:
                s.share_network_name = s.share_network_id
        if search_opts:
            for k, v in search_opts.items():
                share_servers = [s for s in share_servers if
                                 (hasattr(s, k) and
                                  s[k] == v or k == 'share_network' and
                                  v in [s.share_network['name'],
                                        s.share_network['id']])]
        return self._view_builder.build_share_servers(share_servers)