コード例 #1
0
    def list(self,
             marker=None,
             limit=None,
             sort_key=None,
             sort_dir=None,
             detail=False,
             bay_ident=None):
        """Retrieve a list of containers.

        :param marker: Optional, the UUID of a containers, eg the last
                       containers from a previous result set. Return
                       the next result set.
        :param limit: The maximum number of results to return per
                      request, if:

            1) limit > 0, the maximum number of containers to return.
            2) limit == 0, return the entire list of containers.
            3) limit param is NOT specified (None), the number of items
               returned respect the maximum imposed by the Magnum API
               (see Magnum's api.max_limit option).

        :param sort_key: Optional, field used for sorting.

        :param sort_dir: Optional, direction of sorting, either 'asc' (the
                         default) or 'desc'.

        :param detail: Optional, boolean whether to return detailed information
                       about containers.

        :returns: A list of containers.

        """
        if limit is not None:
            limit = int(limit)

        filters = utils.common_filters(marker, limit, sort_key, sort_dir)

        path = ''
        if detail:
            path += 'detail'
        if filters:
            path += '?' + '&'.join(filters)

        if limit is None:
            # TODO(yuanying): if endpoint returns "map",
            # change None to response_key
            return self._list(self._path(path, bay_ident=bay_ident),
                              "containers")
        else:
            # TODO(yuanying): if endpoint returns "map",
            # change None to response_key
            return self._list_pagination(self._path(path, bay_ident=bay_ident),
                                         "containers",
                                         limit=limit)
コード例 #2
0
    def list(self,
             bay_ident,
             limit=None,
             marker=None,
             sort_key=None,
             sort_dir=None,
             detail=False):
        """Retrieve a list of ReplicationControllers.

        :param bay_ident: UUID or Name of the Bay.
        :param marker: Optional, the UUID or Name of a rc, e.g. the last
                       rc from a previous result set. Return
                       the next result set.
        :param limit: The maximum number of results to return per
                      request, if:

            1) limit > 0, the maximum number of rcs to return.
            2) limit == 0, return the entire list of rcs.
            3) limit param is NOT specified (None), the number of items
               returned respect the maximum imposed by the Magnum API
               (see Magnum's api.max_limit option).

        :param sort_key: Optional, field used for sorting.

        :param sort_dir: Optional, direction of sorting, either 'asc' (the
                         default) or 'desc'.

        :param detail: Optional, boolean whether to return detailed
                       information about ReplicationControllers.

        :returns: A list of ReplicationControllers.

        """
        if limit is not None:
            limit = int(limit)

        filters = utils.common_filters(marker, limit, sort_key, sort_dir)
        filters.append('bay_ident=%s' % bay_ident)

        path = ''
        if detail:
            path += 'detail'
        if filters:
            path += '?' + '&'.join(filters)

        if limit is None:
            return self._list(self._path(bay_ident=bay_ident), "rcs")
        else:
            return self._list_pagination(self._path(bay_ident=bay_ident),
                                         "rcs",
                                         limit=limit)
コード例 #3
0
    def list(self, marker=None, limit=None, sort_key=None,
             sort_dir=None, detail=False, bay_ident=None):
        """Retrieve a list of containers.

        :param marker: Optional, the UUID of a containers, eg the last
                       containers from a previous result set. Return
                       the next result set.
        :param limit: The maximum number of results to return per
                      request, if:

            1) limit > 0, the maximum number of containers to return.
            2) limit == 0, return the entire list of containers.
            3) limit param is NOT specified (None), the number of items
               returned respect the maximum imposed by the Magnum API
               (see Magnum's api.max_limit option).

        :param sort_key: Optional, field used for sorting.

        :param sort_dir: Optional, direction of sorting, either 'asc' (the
                         default) or 'desc'.

        :param detail: Optional, boolean whether to return detailed information
                       about containers.

        :returns: A list of containers.

        """
        if limit is not None:
            limit = int(limit)

        filters = utils.common_filters(marker, limit, sort_key, sort_dir)

        path = ''
        if detail:
            path += 'detail'
        if filters:
            path += '?' + '&'.join(filters)

        if limit is None:
            # TODO(yuanying): if endpoint returns "map",
            # change None to response_key
            return self._list(self._path(path, bay_ident=bay_ident),
                              "containers")
        else:
            # TODO(yuanying): if endpoint returns "map",
            # change None to response_key
            return self._list_pagination(self._path(path,
                                                    bay_ident=bay_ident),
                                         "containers",
                                         limit=limit)
コード例 #4
0
    def list(self,
             limit=None,
             marker=None,
             sort_key=None,
             sort_dir=None,
             detail=False):
        """Retrieve a list of bays.

        :param marker: Optional, the UUID of a bay, eg the last
                       bay from a previous result set. Return
                       the next result set.
        :param limit: The maximum number of results to return per
                      request, if:

            1) limit > 0, the maximum number of bays to return.
            2) limit == 0, return the entire list of bays.
            3) limit param is NOT specified (None), the number of items
               returned respect the maximum imposed by the Magnum API
               (see Magnum's api.max_limit option).

        :param sort_key: Optional, field used for sorting.

        :param sort_dir: Optional, direction of sorting, either 'asc' (the
                         default) or 'desc'.

        :param detail: Optional, boolean whether to return detailed information
                       about bays.

        :returns: A list of bays.

        """
        if limit is not None:
            limit = int(limit)

        filters = utils.common_filters(marker, limit, sort_key, sort_dir)

        path = ''
        if detail:
            path += 'detail'
        if filters:
            path += '?' + '&'.join(filters)

        if limit is None:
            return self._list(self._path(path), self.__class__.template_name)
        else:
            return self._list_pagination(self._path(path),
                                         self.__class__.template_name,
                                         limit=limit)
コード例 #5
0
    def list(self, bay_ident, marker=None, limit=None, sort_key=None,
             sort_dir=None, detail=False):
        """Retrieve a list of services.

        :param bay_ident: UUID or Name of the Bay.
        :param marker: Optional, the UUID or Name of a service, e.g. the
                       last service from a previous result set. Return
                       the next result set.
        :param limit: The maximum number of results to return per
                      request, if:

            1) limit > 0, the maximum number of services to return.
            2) limit == 0, return the entire list of services.
            3) limit param is NOT specified (None), the number of items
               returned respect the maximum imposed by the Magnum API
               (see Magnum's api.max_limit option).

        :param sort_key: Optional, field used for sorting.

        :param sort_dir: Optional, direction of sorting, either 'asc' (the
                         default) or 'desc'.

        :param detail: Optional, boolean whether to return detailed information
                       about services.

        :returns: A list of services.

        """
        if limit is not None:
            limit = int(limit)

        filters = utils.common_filters(marker, limit, sort_key, sort_dir)
        filters.append('bay_ident=%s' % bay_ident)

        path = ''
        if detail:
            path += 'detail'
        if filters:
            path += '?' + '&'.join(filters)

        if limit is None:
            return self._list(self._path(path), "services")
        else:
            return self._list_pagination(self._path(path), "services",
                                         limit=limit)
コード例 #6
0
    def list(self, limit=None, marker=None, sort_key=None,
             sort_dir=None, all_tenants=False):

        if limit is not None:
            limit = int(limit)

        filters = utils.common_filters(marker, limit, sort_key, sort_dir)

        if all_tenants:
            filters.append('all_tenants=True')

        path = self._path()
        if filters:
            path += '?' + '&'.join(filters)

        if limit is None:
            return self._list(path, self.api_name)
        else:
            return self._list_pagination(path, self.api_name,
                                         limit=limit)
コード例 #7
0
    def list(self, cluster_id, limit=None, marker=None, sort_key=None,
             sort_dir=None, role=None, detail=False):
        if limit is not None:
            limit = int(limit)

        filters = utils.common_filters(marker, limit, sort_key, sort_dir)
        path = ''
        if role:
            filters.append('role=%s' % role)
        if detail:
            path += 'detail'
        if filters:
            path += '?' + '&'.join(filters)

        if limit is None:
            return self._list(self._path(cluster_id, id=path),
                              self.__class__.api_name)
        else:
            return self._list_pagination(self._path(cluster_id, id=path),
                                         self.__class__.api_name,
                                         limit=limit)
コード例 #8
0
    def list(self, cluster_id, limit=None, marker=None, sort_key=None,
             sort_dir=None, role=None, detail=False):
        if limit is not None:
            limit = int(limit)

        filters = utils.common_filters(marker, limit, sort_key, sort_dir)
        path = ''
        if role:
            filters.append('role=%s' % role)
        if detail:
            path += 'detail'
        if filters:
            path += '?' + '&'.join(filters)

        if limit is None:
            return self._list(self._path(cluster_id, id=path),
                              self.__class__.api_name)
        else:
            return self._list_pagination(self._path(cluster_id, id=path),
                                         self.__class__.api_name,
                                         limit=limit)
コード例 #9
0
    def list(self,
             limit=None,
             marker=None,
             sort_key=None,
             sort_dir=None,
             all_tenants=False):

        if limit is not None:
            limit = int(limit)

        filters = utils.common_filters(marker, limit, sort_key, sort_dir)

        if all_tenants:
            filters.append('all_tenants=True')

        path = self._path()
        if filters:
            path += '?' + '&'.join(filters)

        if limit is None:
            return self._list(path, self.api_name)
        else:
            return self._list_pagination(path, self.api_name, limit=limit)
コード例 #10
0
 def test_other(self):
     for key in ('marker', 'sort_key', 'sort_dir'):
         result = utils.common_filters(**{key: 'test'})
         self.assertEqual(['%s=test' % key], result)
コード例 #11
0
 def test_limit(self):
     result = utils.common_filters(limit=42)
     self.assertEqual(['limit=42'], result)
コード例 #12
0
 def test_limit_0(self):
     result = utils.common_filters(limit=0)
     self.assertEqual([], result)
コード例 #13
0
 def test_limit_negative_number(self):
     result = utils.common_filters(limit=-2)
     self.assertEqual(['limit=-2'], result)
コード例 #14
0
 def test_other(self):
     for key in ('marker', 'sort_key', 'sort_dir'):
         result = utils.common_filters(**{key: 'test'})
         self.assertEqual(['%s=test' % key], result)
コード例 #15
0
 def test_limit_0(self):
     result = utils.common_filters(limit=0)
     self.assertEqual([], result)
コード例 #16
0
 def test_limit(self):
     result = utils.common_filters(limit=42)
     self.assertEqual(['limit=42'], result)
コード例 #17
0
 def test_limit_negative_number(self):
     result = utils.common_filters(limit=-2)
     self.assertEqual(['limit=-2'], result)