コード例 #1
0
def do_node_list(cc, args):
    """List the nodes which are registered with the Ironic service."""
    params = {}
    if args.associated is not None:
        params['associated'] = utils.bool_argument_value("--associated",
                                                         args.associated)
    if args.maintenance is not None:
        params['maintenance'] = utils.bool_argument_value("--maintenance",
                                                          args.maintenance)
    if args.provision_state is not None:
        params['provision_state'] = args.provision_state

    if args.detail:
        fields = res_fields.NODE_DETAILED_RESOURCE.fields
        field_labels = res_fields.NODE_DETAILED_RESOURCE.labels
    elif args.fields:
        utils.check_for_invalid_fields(
            args.fields[0], res_fields.NODE_DETAILED_RESOURCE.fields)
        resource = res_fields.Resource(args.fields[0])
        fields = resource.fields
        field_labels = resource.labels
    else:
        fields = res_fields.NODE_RESOURCE.fields
        field_labels = res_fields.NODE_RESOURCE.labels

    sort_fields = res_fields.NODE_DETAILED_RESOURCE.sort_fields
    sort_field_labels = res_fields.NODE_DETAILED_RESOURCE.sort_labels

    params.update(utils.common_params_for_list(args,
                                               sort_fields,
                                               sort_field_labels))
    nodes = cc.node.list(**params)
    cliutils.print_list(nodes, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #2
0
def do_chassis_list(cc, args):
    """List the chassis."""
    if args.detail:
        fields = res_fields.CHASSIS_DETAILED_RESOURCE.fields
        field_labels = res_fields.CHASSIS_DETAILED_RESOURCE.labels
        sort_fields = res_fields.CHASSIS_DETAILED_RESOURCE.sort_fields
        sort_field_labels = res_fields.CHASSIS_DETAILED_RESOURCE.sort_labels
    elif args.fields:
        utils.check_for_invalid_fields(
            args.fields[0], res_fields.CHASSIS_DETAILED_RESOURCE.fields)
        resource = res_fields.Resource(args.fields[0])
        fields = resource.fields
        field_labels = resource.labels
        sort_fields = res_fields.CHASSIS_DETAILED_RESOURCE.sort_fields
        sort_field_labels = res_fields.CHASSIS_DETAILED_RESOURCE.sort_labels
    else:
        fields = res_fields.CHASSIS_RESOURCE.fields
        field_labels = res_fields.CHASSIS_RESOURCE.labels
        sort_fields = fields
        sort_field_labels = field_labels

    params = utils.common_params_for_list(args, sort_fields,
                                          sort_field_labels)

    chassis = cc.chassis.list(**params)
    cliutils.print_list(chassis, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #3
0
def do_port_list(cc, args):
    """List the ports."""
    params = {}

    if args.address is not None:
        params['address'] = args.address

    if args.detail:
        fields = res_fields.PORT_DETAILED_RESOURCE.fields
        field_labels = res_fields.PORT_DETAILED_RESOURCE.labels
        sort_fields = res_fields.PORT_DETAILED_RESOURCE.sort_fields
        sort_field_labels = res_fields.PORT_DETAILED_RESOURCE.sort_labels
    else:
        fields = res_fields.PORT_RESOURCE.fields
        field_labels = res_fields.PORT_RESOURCE.labels
        sort_fields = fields
        sort_field_labels = field_labels

    params.update(utils.common_params_for_list(args,
                                               sort_fields,
                                               sort_field_labels))

    port = cc.port.list(**params)
    cliutils.print_list(port, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #4
0
def do_volume_target_list(cc, args):
    """List the volume targets."""
    params = {}

    if args.node is not None:
        params['node'] = args.node

    if args.detail:
        fields = res_fields.VOLUME_TARGET_DETAILED_RESOURCE.fields
        field_labels = res_fields.VOLUME_TARGET_DETAILED_RESOURCE.labels
    elif args.fields:
        utils.check_for_invalid_fields(
            args.fields[0],
            res_fields.VOLUME_TARGET_DETAILED_RESOURCE.fields)
        resource = res_fields.Resource(args.fields[0])
        fields = resource.fields
        field_labels = resource.labels
    else:
        fields = res_fields.VOLUME_TARGET_RESOURCE.fields
        field_labels = res_fields.VOLUME_TARGET_RESOURCE.labels

    sort_fields = res_fields.VOLUME_TARGET_DETAILED_RESOURCE.sort_fields
    sort_field_labels = (
        res_fields.VOLUME_TARGET_DETAILED_RESOURCE.sort_labels)

    params.update(utils.common_params_for_list(args,
                                               sort_fields,
                                               sort_field_labels))

    volume_target = cc.volume_target.list(**params)
    cliutils.print_list(volume_target, fields, field_labels=field_labels,
                        sortby_index=None, json_flag=args.json)
コード例 #5
0
def do_node_list(cc, args):
    """List the nodes which are registered with the Ironic service."""
    params = {}
    if args.associated is not None:
        params['associated'] = args.associated
    if args.maintenance is not None:
        params['maintenance'] = args.maintenance
    params['detail'] = args.detail

    # The server cannot sort on "chassis_uuid" because it isn't a
    # column in the "nodes" database table. "chassis_id" is stored,
    # but it is internal to ironic. See bug #1443003 for more details.
    if args.detail:
        fields = res_fields.NODE_FIELDS
        field_labels = res_fields.NODE_FIELD_LABELS
        sort_fields = copy.deepcopy(fields)
        sort_field_labels = copy.deepcopy(field_labels)
        sort_fields.remove('chassis_uuid')
        sort_field_labels.remove('Chassis UUID')
    else:
        fields = res_fields.NODE_LIST_FIELDS
        field_labels = res_fields.NODE_LIST_FIELD_LABELS
        sort_fields = fields
        sort_field_labels = field_labels

    params.update(utils.common_params_for_list(args,
                                               sort_fields,
                                               sort_field_labels))
    nodes = cc.node.list(**params)
    cliutils.print_list(nodes, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #6
0
def do_node_port_list(cc, args):
    """List the ports associated with a node."""
    if args.detail:
        fields = res_fields.PORT_DETAILED_RESOURCE.fields
        field_labels = res_fields.PORT_DETAILED_RESOURCE.labels
    elif args.fields:
        utils.check_for_invalid_fields(
            args.fields[0], res_fields.PORT_DETAILED_RESOURCE.fields)
        resource = res_fields.Resource(args.fields[0])
        fields = resource.fields
        field_labels = resource.labels
    else:
        fields = res_fields.PORT_RESOURCE.fields
        field_labels = res_fields.PORT_RESOURCE.labels

    sort_fields = res_fields.PORT_DETAILED_RESOURCE.sort_fields
    sort_field_labels = res_fields.PORT_DETAILED_RESOURCE.sort_labels

    params = utils.common_params_for_list(args, sort_fields,
                                          sort_field_labels)

    ports = cc.node.list_ports(args.node, **params)
    cliutils.print_list(ports, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #7
0
 def test_sort_key_allows_label(self):
     self.args.sort_key = 'Label'
     self.expected_params.update({'sort_key': 'field'})
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args,
                                                   ['field', 'field2'],
                                                   ['Label', 'Label2']))
コード例 #8
0
def do_port_list(cc, args):
    """List the ports."""
    params = {}

    if args.address is not None:
        params['address'] = args.address

    if args.detail:
        fields = res_fields.PORT_DETAILED_RESOURCE.fields
        field_labels = res_fields.PORT_DETAILED_RESOURCE.labels
    elif args.fields:
        utils.check_for_invalid_fields(
            args.fields[0], res_fields.PORT_DETAILED_RESOURCE.fields)
        resource = res_fields.Resource(args.fields[0])
        fields = resource.fields
        field_labels = resource.labels
    else:
        fields = res_fields.PORT_RESOURCE.fields
        field_labels = res_fields.PORT_RESOURCE.labels

    sort_fields = res_fields.PORT_DETAILED_RESOURCE.sort_fields
    sort_field_labels = res_fields.PORT_DETAILED_RESOURCE.sort_labels

    params.update(utils.common_params_for_list(args,
                                               sort_fields,
                                               sort_field_labels))

    port = cc.port.list(**params)
    cliutils.print_list(port, fields,
                        field_labels=field_labels,
                        sortby_index=None,
                        json_flag=args.json)
コード例 #9
0
 def test_sort_key_and_sort_dir(self):
     self.args.sort_key = 'field'
     self.args.sort_dir = 'desc'
     self.expected_params.update({'sort_key': 'field', 'sort_dir': 'desc'})
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args,
                                                   ['field'],
                                                   []))
コード例 #10
0
ファイル: node_shell.py プロジェクト: balagopalraj/clearlinux
def do_node_port_list(cc, args):
    """List the ports associated with a node."""
    if args.detail:
        fields = res_fields.PORT_FIELDS
        field_labels = res_fields.PORT_FIELD_LABELS
    else:
        fields = res_fields.PORT_LIST_FIELDS
        field_labels = res_fields.PORT_LIST_FIELD_LABELS

    params = utils.common_params_for_list(args, fields, field_labels)

    ports = cc.node.list_ports(args.node, **params)
    cliutils.print_list(
        ports, fields, field_labels=field_labels, sortby_index=None)
コード例 #11
0
def do_chassis_node_list(cc, args):
    """List the nodes contained in a chassis."""
    if args.detail:
        fields = res_fields.NODE_FIELDS
        field_labels = res_fields.NODE_FIELD_LABELS
    else:
        fields = res_fields.NODE_LIST_FIELDS
        field_labels = res_fields.NODE_LIST_FIELD_LABELS

    params = utils.common_params_for_list(args, fields, field_labels)

    nodes = cc.chassis.list_nodes(args.chassis, **params)
    cliutils.print_list(nodes, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #12
0
def do_chassis_node_list(cc, args):
    """List the nodes contained in a chassis."""
    if args.detail:
        fields = res_fields.NODE_DETAILED_RESOURCE.fields
        field_labels = res_fields.NODE_DETAILED_RESOURCE.labels
    else:
        fields = res_fields.NODE_RESOURCE.fields
        field_labels = res_fields.NODE_RESOURCE.labels

    params = utils.common_params_for_list(args, fields, field_labels)

    nodes = cc.chassis.list_nodes(args.chassis, **params)
    cliutils.print_list(nodes, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #13
0
def do_port_list(cc, args):
    """List ports."""
    if args.detail:
        fields = res_fields.PORT_FIELDS
        field_labels = res_fields.PORT_FIELD_LABELS
    else:
        fields = res_fields.PORT_LIST_FIELDS
        field_labels = res_fields.PORT_LIST_FIELD_LABELS

    params = utils.common_params_for_list(args, fields, field_labels)

    port = cc.port.list(**params)
    cliutils.print_list(port, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #14
0
def do_chassis_list(cc, args):
    """List the chassis."""
    if args.detail:
        fields = res_fields.CHASSIS_FIELDS
        field_labels = res_fields.CHASSIS_FIELD_LABELS
    else:
        fields = res_fields.CHASSIS_LIST_FIELDS
        field_labels = res_fields.CHASSIS_LIST_FIELD_LABELS

    params = utils.common_params_for_list(args, fields, field_labels)

    chassis = cc.chassis.list(**params)
    cliutils.print_list(chassis, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #15
0
def do_node_port_list(cc, args):
    """List the ports associated with a node."""
    if args.detail:
        fields = res_fields.PORTS_DETAILED_RESOURCE.fields
        field_labels = res_fields.PORTS_DETAILED_RESOURCE.labels
    else:
        fields = res_fields.PORT_RESOURCE.fields
        field_labels = res_fields.PORT_RESOURCE.labels

    params = utils.common_params_for_list(args, fields, field_labels)

    ports = cc.node.list_ports(args.node, **params)
    cliutils.print_list(ports, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #16
0
ファイル: node_shell.py プロジェクト: balagopalraj/clearlinux
def do_node_list(cc, args):
    """List the nodes which are registered with the Ironic service."""
    params = {}
    if args.associated is not None:
        params['associated'] = args.associated
    if args.maintenance is not None:
        params['maintenance'] = args.maintenance
    params['detail'] = args.detail

    if args.detail:
        fields = res_fields.NODE_FIELDS
        field_labels = res_fields.NODE_FIELD_LABELS
    else:
        fields = res_fields.NODE_LIST_FIELDS
        field_labels = res_fields.NODE_LIST_FIELD_LABELS

    params.update(utils.common_params_for_list(args, fields, field_labels))
    nodes = cc.node.list(**params)
    cliutils.print_list(
        nodes, fields, field_labels=field_labels, sortby_index=None)
コード例 #17
0
ファイル: port_shell.py プロジェクト: balagopalraj/clearlinux
def do_port_list(cc, args):
    """List the ports."""
    params = {}

    if args.address is not None:
        params['address'] = args.address
    if args.detail:
        fields = res_fields.PORT_FIELDS
        field_labels = res_fields.PORT_FIELD_LABELS
    else:
        fields = res_fields.PORT_LIST_FIELDS
        field_labels = res_fields.PORT_LIST_FIELD_LABELS

    params.update(utils.common_params_for_list(args,
                                               fields,
                                               field_labels))

    port = cc.port.list(**params)
    cliutils.print_list(port, fields,
                        field_labels=field_labels,
                        sortby_index=None)
コード例 #18
0
 def test_fields(self):
     self.args.fields = [['a', 'b', 'c']]
     self.expected_params.update({'fields': ['a', 'b', 'c']})
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args, [], []))
コード例 #19
0
 def test_nothing_set(self):
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args, [], []))
コード例 #20
0
 def test_fields(self):
     self.args.fields = [['a', 'b', 'c']]
     self.expected_params.update({'fields': ['a', 'b', 'c']})
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args, [], []))
コード例 #21
0
 def test_marker_and_limit(self):
     self.args.marker = 'foo'
     self.args.limit = 42
     self.expected_params.update({'marker': 'foo', 'limit': 42})
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args, [], []))
コード例 #22
0
 def test_detail(self):
     self.args.detail = True
     self.expected_params['detail'] = True
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args, [], []))
コード例 #23
0
 def test_nothing_set(self):
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args, [], []))
コード例 #24
0
 def test_marker_and_limit(self):
     self.args.marker = 'foo'
     self.args.limit = 42
     self.expected_params.update({'marker': 'foo', 'limit': 42})
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args, [], []))
コード例 #25
0
 def test_detail(self):
     self.args.detail = True
     self.expected_params['detail'] = True
     self.assertEqual(self.expected_params,
                      utils.common_params_for_list(self.args, [], []))