コード例 #1
0
    def test_validate_limit(self):
        limit = utils.validate_limit(10)
        self.assertEqual(10, 10)

        # max limit
        limit = utils.validate_limit(999999999)
        self.assertEqual(CONF.api.max_limit, limit)

        # negative
        self.assertRaises(wsme.exc.ClientSideError, utils.validate_limit, -1)

        # zero
        self.assertRaises(wsme.exc.ClientSideError, utils.validate_limit, 0)
コード例 #2
0
ファイル: test_utils.py プロジェクト: HackToday/magnum
    def test_validate_limit(self):
        limit = utils.validate_limit(10)
        self.assertEqual(10, 10)

        # max limit
        limit = utils.validate_limit(999999999)
        self.assertEqual(CONF.api.max_limit, limit)

        # negative
        self.assertRaises(wsme.exc.ClientSideError, utils.validate_limit, -1)

        # zero
        self.assertRaises(wsme.exc.ClientSideError, utils.validate_limit, 0)
コード例 #3
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)
コード例 #4
0
ファイル: baymodel.py プロジェクト: drzaeus77/magnum
    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)
コード例 #5
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)
コード例 #6
0
ファイル: container.py プロジェクト: Tennyson53/magnum
    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)
コード例 #7
0
ファイル: x509keypair.py プロジェクト: Tennyson53/SUR
    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)
コード例 #8
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)
コード例 #9
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)
コード例 #10
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)
コード例 #11
0
ファイル: container.py プロジェクト: drzaeus77/magnum
    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)
コード例 #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
ファイル: container.py プロジェクト: digambar15/magnum-1
    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
ファイル: x509keypair.py プロジェクト: eros-lige/magnum
    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)