Example #1
0
    def ports(self,
              node_uuid,
              limit=None,
              marker=None,
              sort_key='id',
              sort_dir='asc'):
        """Retrieve a list of ports on this node."""
        limit = utils.validate_limit(limit)
        sort_dir = utils.validate_sort_dir(sort_dir)

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

        ports = pecan.request.dbapi.get_ports_by_node(node_uuid,
                                                      limit,
                                                      marker_obj,
                                                      sort_key=sort_key,
                                                      sort_dir=sort_dir)
        collection = port.PortCollection()
        collection.type = 'port'
        collection.items = [port.Port.convert_with_links(n) for n in ports]
        resource_url = '/'.join(['nodes', node_uuid, 'ports'])
        collection.links = collection.make_links(limit,
                                                 resource_url,
                                                 sort_key=sort_key,
                                                 sort_dir=sort_dir)
        return collection
Example #2
0
    def nodes(self,
              chassis_uuid,
              limit=None,
              marker=None,
              sort_key='id',
              sort_dir='asc'):
        """Retrieve a list of nodes contained in the chassis."""
        limit = utils.validate_limit(limit)
        sort_dir = utils.validate_sort_dir(sort_dir)

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

        nodes = pecan.request.dbapi.get_nodes_by_chassis(chassis_uuid,
                                                         limit,
                                                         marker_obj,
                                                         sort_key=sort_key,
                                                         sort_dir=sort_dir)
        collection = node.NodeCollection()
        collection.type = 'node'
        collection.items = [node.Node.convert_with_links(n) for n in nodes]
        resource_url = '/'.join(['chassis', chassis_uuid, 'nodes'])
        collection.links = collection.make_links(limit,
                                                 resource_url,
                                                 sort_key=sort_key,
                                                 sort_dir=sort_dir)
        return collection
Example #3
0
    def ports(self, node_uuid, limit=None, marker=None,
              sort_key='id', sort_dir='asc'):
        """Retrieve a list of ports on this node."""
        limit = utils.validate_limit(limit)
        sort_dir = utils.validate_sort_dir(sort_dir)

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

        ports = pecan.request.dbapi.get_ports_by_node(node_uuid, limit,
                                                      marker_obj,
                                                      sort_key=sort_key,
                                                      sort_dir=sort_dir)
        collection = port.PortCollection()
        collection.type = 'port'
        collection.items = [port.Port.convert_with_links(n) for n in ports]
        resource_url = '/'.join(['nodes', node_uuid, 'ports'])
        collection.links = collection.make_links(limit, resource_url,
                                                 sort_key=sort_key,
                                                 sort_dir=sort_dir)
        return collection
Example #4
0
    def nodes(self, chassis_uuid, limit=None, marker=None,
              sort_key='id', sort_dir='asc'):
        """Retrieve a list of nodes contained in the chassis."""
        limit = utils.validate_limit(limit)
        sort_dir = utils.validate_sort_dir(sort_dir)

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

        nodes = pecan.request.dbapi.get_nodes_by_chassis(chassis_uuid, limit,
                                                         marker_obj,
                                                         sort_key=sort_key,
                                                         sort_dir=sort_dir)
        collection = node.NodeCollection()
        collection.type = 'node'
        collection.items = [node.Node.convert_with_links(n) for n in nodes]
        resource_url = '/'.join(['chassis', chassis_uuid, 'nodes'])
        collection.links = collection.make_links(limit, resource_url,
                                                 sort_key=sort_key,
                                                 sort_dir=sort_dir)
        return collection
Example #5
0
 def convert_with_links(cls, nodes, limit, **kwargs):
     collection = NodeCollection()
     collection.type = 'node'
     collection.items = [Node.convert_with_links(n) for n in nodes]
     collection.links = collection.make_links(limit, 'nodes', **kwargs)
     return collection
Example #6
0
 def convert_with_links(cls, chassis, limit, **kwargs):
     collection = ChassisCollection()
     collection.type = 'chassis'
     collection.items = [Chassis.convert_with_links(ch) for ch in chassis]
     collection.links = collection.make_links(limit, 'chassis', **kwargs)
     return collection
Example #7
0
 def convert_with_links(cls, ports, limit, **kwargs):
     collection = PortCollection()
     collection.type = 'port'
     collection.items = [Port.convert_with_links(p) for p in ports]
     collection.links = collection.make_links(limit, 'ports', **kwargs)
     return collection
Example #8
0
 def convert_with_links(cls, nodes, limit, **kwargs):
     collection = NodeCollection()
     collection.type = 'node'
     collection.items = [Node.convert_with_links(n) for n in nodes]
     collection.links = collection.make_links(limit, 'nodes', **kwargs)
     return collection
Example #9
0
 def convert_with_links(cls, ports, limit, **kwargs):
     collection = PortCollection()
     collection.type = 'port'
     collection.items = [Port.convert_with_links(p) for p in ports]
     collection.links = collection.make_links(limit, 'ports', **kwargs)
     return collection
Example #10
0
 def convert_with_links(cls, chassis, limit, **kwargs):
     collection = ChassisCollection()
     collection.type = 'chassis'
     collection.items = [Chassis.convert_with_links(ch) for ch in chassis]
     collection.links = collection.make_links(limit, 'chassis', **kwargs)
     return collection