예제 #1
0
파일: service.py 프로젝트: wenchma/magnum
    def _get_services_collection(self,
                                 marker,
                                 limit,
                                 sort_key,
                                 sort_dir,
                                 expand=False,
                                 resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Service.get_by_uuid(pecan.request.context,
                                                     marker)

        services = pecan.request.rpcapi.service_list(pecan.request.context,
                                                     limit,
                                                     marker_obj,
                                                     sort_key=sort_key,
                                                     sort_dir=sort_dir)

        return ServiceCollection.convert_with_links(services,
                                                    limit,
                                                    url=resource_url,
                                                    expand=expand,
                                                    sort_key=sort_key,
                                                    sort_dir=sort_dir)
예제 #2
0
파일: pod.py 프로젝트: drzaeus77/magnum
    def _get_pods_collection(self,
                             marker,
                             limit,
                             sort_key,
                             sort_dir,
                             bay_ident,
                             expand=False,
                             resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Pod.get_by_uuid(pecan.request.context, marker)

        pods = pecan.request.rpcapi.pod_list(pecan.request.context,
                                             limit,
                                             marker_obj,
                                             sort_key=sort_key,
                                             sort_dir=sort_dir)

        return PodCollection.convert_with_links(pods,
                                                limit,
                                                url=resource_url,
                                                expand=expand,
                                                sort_key=sort_key,
                                                sort_dir=sort_dir)
예제 #3
0
    def _get_baymodels_collection(self,
                                  marker,
                                  limit,
                                  sort_key,
                                  sort_dir,
                                  expand=False,
                                  resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.BayModel.get_by_uuid(pecan.request.context,
                                                      marker)

        baymodels = objects.BayModel.list(pecan.request.context,
                                          limit,
                                          marker_obj,
                                          sort_key=sort_key,
                                          sort_dir=sort_dir)

        return BayModelCollection.convert_with_links(baymodels,
                                                     limit,
                                                     url=resource_url,
                                                     expand=expand,
                                                     sort_key=sort_key,
                                                     sort_dir=sort_dir)
예제 #4
0
    def _get_x509keypairs_collection(self,
                                     marker,
                                     limit,
                                     sort_key,
                                     sort_dir,
                                     expand=False,
                                     resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.X509KeyPair.get_by_uuid(
                pecan.request.context, marker)

        x509keypairs = pecan.request.rpcapi.x509keypair_list(
            pecan.request.context,
            limit,
            marker_obj,
            sort_key=sort_key,
            sort_dir=sort_dir)

        return X509KeyPairCollection.convert_with_links(x509keypairs,
                                                        limit,
                                                        url=resource_url,
                                                        expand=expand,
                                                        sort_key=sort_key,
                                                        sort_dir=sort_dir)
예제 #5
0
    def _get_containers_collection(self, marker, limit,
                                   sort_key, sort_dir, expand=False,
                                   resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Container.get_by_uuid(pecan.request.context,
                                                       marker)

        containers = objects.Container.list(pecan.request.context, limit,
                                            marker_obj, sort_key=sort_key,
                                            sort_dir=sort_dir)
        for i, c in enumerate(containers):
            try:
                containers[i] = pecan.request.rpcapi.container_show(c.uuid)
            except Exception as e:
                LOG.exception(_LE("Error while list container %(uuid)s: "
                                  "%(e)s."),
                              {'uuid': c.uuid, 'e': e})
                containers[i].status = fields.ContainerStatus.UNKNOWN

        return ContainerCollection.convert_with_links(containers, limit,
                                                      url=resource_url,
                                                      expand=expand,
                                                      sort_key=sort_key,
                                                      sort_dir=sort_dir)
예제 #6
0
    def _get_rcs_collection(self,
                            marker,
                            limit,
                            sort_key,
                            sort_dir,
                            expand=False,
                            resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.ReplicationController.get_by_uuid(
                pecan.request.context, marker)

        rcs = pecan.request.rpcapi.rc_list(pecan.request.context,
                                           limit,
                                           marker_obj,
                                           sort_key=sort_key,
                                           sort_dir=sort_dir)

        return ReplicationControllerCollection.convert_with_links(
            rcs,
            limit,
            url=resource_url,
            expand=expand,
            sort_key=sort_key,
            sort_dir=sort_dir)
예제 #7
0
    def test_validate_sort_dir(self):
        sort_dir = utils.validate_sort_dir('asc')
        self.assertEqual('asc', sort_dir)

        # invalid sort_dir parameter
        self.assertRaises(wsme.exc.ClientSideError, utils.validate_sort_dir,
                          'fake-sort')
예제 #8
0
    def _get_containers_collection(self,
                                   marker,
                                   limit,
                                   sort_key,
                                   sort_dir,
                                   expand=False,
                                   resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Container.get_by_uuid(pecan.request.context,
                                                       marker)

        containers = objects.Container.list(pecan.request.context,
                                            limit,
                                            marker_obj,
                                            sort_key=sort_key,
                                            sort_dir=sort_dir)
        containers = [
            pecan.request.rpcapi.container_show(c.uuid) for c in containers
        ]

        return ContainerCollection.convert_with_links(containers,
                                                      limit,
                                                      url=resource_url,
                                                      expand=expand,
                                                      sort_key=sort_key,
                                                      sort_dir=sort_dir)
예제 #9
0
    def _get_rcs_collection(self, marker, limit,
                            sort_key, sort_dir,
                            bay_ident, expand=False,
                            resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.ReplicationController.get_by_uuid(
                pecan.request.context,
                marker)

        rcs = pecan.request.rpcapi.rc_list(
            pecan.request.context, limit,
            marker_obj, sort_key=sort_key,
            sort_dir=sort_dir)

        return ReplicationControllerCollection.convert_with_links(
            rcs, limit,
            url=resource_url,
            expand=expand,
            sort_key=sort_key,
            sort_dir=sort_dir)
예제 #10
0
    def _get_containers_collection(self, marker, limit,
                                   sort_key, sort_dir, expand=False,
                                   resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Container.get_by_uuid(pecan.request.context,
                                                       marker)

        containers = objects.Container.list(pecan.request.context, limit,
                                            marker_obj, sort_key=sort_key,
                                            sort_dir=sort_dir)
        for i, c in enumerate(containers):
            try:
                containers[i] = pecan.request.rpcapi.container_show(c.uuid)
            except Exception as e:
                LOG.exception(_LE("Error while list container %(uuid)s: "
                                  "%(e)s."),
                              {'uuid': c.uuid, 'e': e})
                containers[i].status = fields.ContainerStatus.UNKNOWN

        return ContainerCollection.convert_with_links(containers, limit,
                                                      url=resource_url,
                                                      expand=expand,
                                                      sort_key=sort_key,
                                                      sort_dir=sort_dir)
예제 #11
0
    def test_validate_sort_dir(self):
        sort_dir = utils.validate_sort_dir('asc')
        self.assertEqual('asc', sort_dir)

        # invalid sort_dir parameter
        self.assertRaises(wsme.exc.ClientSideError,
                          utils.validate_sort_dir,
                          'fake-sort')
예제 #12
0
파일: service.py 프로젝트: HackToday/magnum
    def _get_services_collection(self, marker, limit, sort_key, sort_dir, expand=False, resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Service.get_by_uuid(pecan.request.context, marker)

        services = pecan.request.rpcapi.service_list(
            pecan.request.context, limit, marker_obj, sort_key=sort_key, sort_dir=sort_dir
        )

        return ServiceCollection.convert_with_links(
            services, limit, url=resource_url, expand=expand, sort_key=sort_key, sort_dir=sort_dir
        )
예제 #13
0
    def _get_containers_collection(self, marker, limit,
                              sort_key, sort_dir, expand=False,
                              resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Container.get_by_uuid(pecan.request.context,
                                                  marker)

        containers = objects.Container.list(pecan.request.context, limit,
                                marker_obj, sort_key=sort_key,
                                sort_dir=sort_dir)

        return ContainerCollection.convert_with_links(containers, limit,
                                                url=resource_url,
                                                expand=expand,
                                                sort_key=sort_key,
                                                sort_dir=sort_dir)
예제 #14
0
    def _get_x509keypairs_collection(self, marker, limit,
                                     sort_key, sort_dir, expand=False,
                                     resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.X509KeyPair.get_by_uuid(pecan.request.context,
                                                         marker)

        x509keypairs = pecan.request.rpcapi.x509keypair_list(
            pecan.request.context, limit,
            marker_obj, sort_key=sort_key,
            sort_dir=sort_dir)

        return X509KeyPairCollection.convert_with_links(x509keypairs, limit,
                                                        url=resource_url,
                                                        expand=expand,
                                                        sort_key=sort_key,
                                                        sort_dir=sort_dir)