def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        if parsed_args.local_link_connection_deprecated:
            self.log.warning("Please use --local-link-connection instead of "
                             "-l, as it is deprecated and will be removed in "
                             "future releases.")
            # It is parsed to either None, or to an array
            if parsed_args.local_link_connection:
                parsed_args.local_link_connection.extend(
                    parsed_args.local_link_connection_deprecated)
            else:
                parsed_args.local_link_connection = (
                    parsed_args.local_link_connection_deprecated)

        field_list = ['address', 'extra', 'node_uuid', 'pxe_enabled',
                      'local_link_connection', 'portgroup_uuid']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        fields = utils.args_array_to_dict(fields, 'extra')
        fields = utils.args_array_to_dict(fields, 'local_link_connection')
        port = baremetal_client.port.create(**fields)

        data = dict([(f, getattr(port, f, '')) for f in
                     res_fields.PORT_DETAILED_RESOURCE.fields])

        return self.dict2columns(data)
def do_node_create(cc, args):
    """Register a new node with the Ironic service."""
    field_list = ["chassis_uuid", "driver", "driver_info", "properties", "extra", "uuid", "name"]
    fields = dict((k, v) for (k, v) in vars(args).items() if k in field_list and not (v is None))
    fields = utils.args_array_to_dict(fields, "driver_info")
    fields = utils.args_array_to_dict(fields, "extra")
    fields = utils.args_array_to_dict(fields, "properties")
    node = cc.node.create(**fields)

    data = dict([(f, getattr(node, f, "")) for f in field_list])
    cliutils.print_dict(data, wrap=72)
def do_volume_target_create(cc, args):
    """Create a new volume target."""
    field_list = ['extra', 'volume_type', 'properties',
                  'boot_index', 'node_uuid', 'volume_id', 'uuid']
    fields = dict((k, v) for (k, v) in vars(args).items()
                  if k in field_list and not (v is None))
    fields = utils.args_array_to_dict(fields, 'properties')
    fields = utils.args_array_to_dict(fields, 'extra')
    volume_target = cc.volume_target.create(**fields)

    data = dict([(f, getattr(volume_target, f, '')) for f in field_list])
    cliutils.print_dict(data, wrap=72, json_flag=args.json)
def do_node_create(cc, args):
    """Create a new node."""
    field_list = ['chassis_id', 'driver', 'driver_info', 'properties', 'extra']
    fields = dict((k, v) for (k, v) in vars(args).items()
                  if k in field_list and not (v is None))
    fields = utils.args_array_to_dict(fields, 'driver_info')
    fields = utils.args_array_to_dict(fields, 'extra')
    fields = utils.args_array_to_dict(fields, 'properties')
    node = cc.node.create(**fields)

    field_list.append('uuid')
    data = dict([(f, getattr(node, f, '')) for f in field_list])
    utils.print_dict(data, wrap=72)
def do_node_create(cc, args):
    """Register a new node with the Ironic service."""
    field_list = ['chassis_uuid', 'driver', 'driver_info',
                  'properties', 'extra', 'uuid', 'name']
    fields = dict((k, v) for (k, v) in vars(args).items()
                  if k in field_list and not (v is None))
    fields = utils.args_array_to_dict(fields, 'driver_info')
    fields = utils.args_array_to_dict(fields, 'extra')
    fields = utils.args_array_to_dict(fields, 'properties')
    node = cc.node.create(**fields)

    data = dict([(f, getattr(node, f, '')) for f in field_list])
    cliutils.print_dict(data, wrap=72)
def do_port_create(cc, args):
    """Create a new port."""
    field_list = ['address', 'extra', 'node_uuid', 'uuid',
                  'local_link_connection', 'portgroup_uuid',
                  'pxe_enabled', 'physical_network']
    fields = dict((k, v) for (k, v) in vars(args).items()
                  if k in field_list and not (v is None))
    fields = utils.args_array_to_dict(fields, 'extra')
    fields = utils.args_array_to_dict(fields, 'local_link_connection')
    port = cc.port.create(**fields)

    data = dict([(f, getattr(port, f, '')) for f in field_list])
    cliutils.print_dict(data, wrap=72, json_flag=args.json)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)

        baremetal_client = self.app.client_manager.baremetal

        field_list = ['chassis_uuid', 'driver', 'driver_info',
                      'properties', 'extra', 'uuid', 'name']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and not (v is None))
        fields = utils.args_array_to_dict(fields, 'driver_info')
        fields = utils.args_array_to_dict(fields, 'extra')
        fields = utils.args_array_to_dict(fields, 'properties')
        node = baremetal_client.node.create(**fields)._info

        node.pop('links', None)

        return self.dict2columns(node)
def do_chassis_create(cc, args):
    """Create a new chassis."""
    field_list = ['description', 'extra', 'uuid']
    fields = dict((k, v) for (k, v) in vars(args).items()
                  if k in field_list and not (v is None))
    fields = utils.args_array_to_dict(fields, 'extra')
    chassis = cc.chassis.create(**fields)

    data = dict([(f, getattr(chassis, f, '')) for f in field_list])
    cliutils.print_dict(data, wrap=72)
def do_node_create(cc, args):
    """Register a new node with the Ironic service."""
    field_list = ['chassis_uuid', 'driver', 'driver_info',
                  'properties', 'extra', 'uuid', 'name',
                  'boot_interface', 'console_interface',
                  'deploy_interface', 'inspect_interface',
                  'management_interface', 'network_interface',
                  'power_interface', 'raid_interface',
                  'storage_interface', 'vendor_interface',
                  'resource_class']
    fields = dict((k, v) for (k, v) in vars(args).items()
                  if k in field_list and not (v is None))
    fields = utils.args_array_to_dict(fields, 'driver_info')
    fields = utils.args_array_to_dict(fields, 'extra')
    fields = utils.args_array_to_dict(fields, 'properties')
    node = cc.node.create(**fields)

    data = dict([(f, getattr(node, f, '')) for f in field_list])
    cliutils.print_dict(data, wrap=72, json_flag=args.json)
def do_volume_connector_create(cc, args):
    """Create a new volume connector."""
    field_list = ['extra', 'type', 'connector_id', 'node_uuid', 'uuid']
    fields = dict((k, v) for (k, v) in vars(args).items()
                  if k in field_list and not (v is None))
    fields = utils.args_array_to_dict(fields, 'extra')
    volume_connector = cc.volume_connector.create(**fields)

    data = dict([(f, getattr(volume_connector, f, '')) for f in field_list])
    cliutils.print_dict(data, wrap=72, json_flag=args.json)
def do_port_create(cc, args):
    """Create a new port."""
    field_list = ['address', 'extra', 'node_uuid', 'uuid']
    fields = dict((k, v) for (k, v) in vars(args).items()
                  if k in field_list and not (v is None))
    fields = utils.args_array_to_dict(fields, 'extra')
    port = cc.port.create(**fields)

    data = dict([(f, getattr(port, f, '')) for f in field_list])
    cliutils.print_dict(data, wrap=72)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        if parsed_args.boot_index < 0:
            raise exc.CommandError(
                _('Expected non-negative --boot-index, got %s') %
                parsed_args.boot_index)

        field_list = ['extra', 'volume_type', 'properties',
                      'boot_index', 'node_uuid', 'volume_id', 'uuid']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        fields = utils.args_array_to_dict(fields, 'properties')
        fields = utils.args_array_to_dict(fields, 'extra')
        volume_target = baremetal_client.volume_target.create(**fields)

        data = dict([(f, getattr(volume_target, f, '')) for f in
                     res_fields.VOLUME_TARGET_DETAILED_RESOURCE.fields])
        return self.dict2columns(data)
 def test_args_array_to_dict(self):
     my_args = {
         'matching_metadata': ['metadata.key=metadata_value'],
         'other': 'value'
     }
     cleaned_dict = utils.args_array_to_dict(my_args,
                                             "matching_metadata")
     self.assertEqual(cleaned_dict, {
         'matching_metadata': {'metadata.key': 'metadata_value'},
         'other': 'value'
     })
def do_driver_vendor_passthru(cc, args):
    """Call a vendor-passthru extension for a driver."""
    arguments = utils.args_array_to_dict({'args': args.arguments[0]},
                                          'args')['args']

    # If there were no arguments for the method, arguments will still
    # be an empty list. So make it an empty dict.
    if not arguments:
        arguments = {}

    cc.driver.vendor_passthru(args.driver_name, args.method, args=arguments)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        field_list = ['node_uuid', 'address', 'name', 'uuid', 'extra', 'mode',
                      'properties']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        if parsed_args.support_standalone_ports:
            fields['standalone_ports_supported'] = True
        if parsed_args.unsupport_standalone_ports:
            fields['standalone_ports_supported'] = False

        fields = utils.args_array_to_dict(fields, 'extra')
        fields = utils.args_array_to_dict(fields, 'properties')
        portgroup = baremetal_client.portgroup.create(**fields)

        data = dict([(f, getattr(portgroup, f, '')) for f in
                     res_fields.PORTGROUP_DETAILED_RESOURCE.fields])

        return self.dict2columns(data)
 def test_args_array_to_dict(self):
     my_args = {
         'matching_metadata': ['str=foo', 'int=1', 'bool=true',
                               'list=[1, 2, 3]', 'dict={"foo": "bar"}'],
         'other': 'value'
     }
     cleaned_dict = utils.args_array_to_dict(my_args,
                                             "matching_metadata")
     self.assertEqual({
         'matching_metadata': {'str': 'foo', 'int': 1, 'bool': True,
                               'list': [1, 2, 3], 'dict': {'foo': 'bar'}},
         'other': 'value'
     }, cleaned_dict)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        field_list = ['extra', 'type', 'connector_id', 'node_uuid', 'uuid']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        fields = utils.args_array_to_dict(fields, 'extra')
        volume_connector = baremetal_client.volume_connector.create(**fields)

        data = dict([(f, getattr(volume_connector, f, '')) for f in
                     res_fields.VOLUME_CONNECTOR_DETAILED_RESOURCE.fields])
        return self.dict2columns(data)
def do_driver_vendor_passthru(cc, args):
    """Call a vendor-passthru extension for a driver."""
    fields = {}
    fields['driver_name'] = args.driver_name
    fields['method'] = args.method
    fields['args'] = args.arguments[0]
    fields = utils.args_array_to_dict(fields, 'args')

    # If there were no arguments for the method, fields['args'] will still
    # be an empty list. So make it an empty dict.
    if not fields['args']:
        fields['args'] = {}
    cc.driver.vendor_passthru(**fields)
def do_node_vendor_passthru(cc, args):
    """Call a vendor-passthru extension for a node."""
    arguments = utils.args_array_to_dict({"args": args.arguments[0]}, "args")["args"]

    # If there were no arguments for the method, arguments will still
    # be an empty list. So make it an empty dict.
    if not arguments:
        arguments = {}

    resp = cc.node.vendor_passthru(args.node, args.method, http_method=args.http_method, args=arguments)
    if resp:
        # Print the raw response we don't know how it should be formated
        print(str(resp.to_dict()))
Beispiel #20
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        field_list = ['address', 'extra', 'node_uuid']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        fields = utils.args_array_to_dict(fields, 'extra')
        port = baremetal_client.port.create(**fields)

        data = dict([(f, getattr(port, f, ''))
                     for f in res_fields.PORT_DETAILED_RESOURCE.fields])

        return self.dict2columns(data)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        field_list = ['address', 'extra', 'node_uuid']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        fields = utils.args_array_to_dict(fields, 'extra')
        port = baremetal_client.port.create(**fields)

        data = dict([(f, getattr(port, f, '')) for f in
                     res_fields.PORT_DETAILED_RESOURCE.fields])

        return self.dict2columns(data)
Beispiel #22
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        field_list = [
            'node_uuid', 'address', 'name', 'uuid', 'extra', 'mode',
            'properties'
        ]
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        if parsed_args.support_standalone_ports:
            fields['standalone_ports_supported'] = True
        if parsed_args.unsupport_standalone_ports:
            fields['standalone_ports_supported'] = False

        fields = utils.args_array_to_dict(fields, 'extra')
        fields = utils.args_array_to_dict(fields, 'properties')
        portgroup = baremetal_client.portgroup.create(**fields)

        data = dict([(f, getattr(portgroup, f, ''))
                     for f in res_fields.PORTGROUP_DETAILED_RESOURCE.fields])

        return self.dict2columns(data)
Beispiel #23
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        if parsed_args.boot_index < 0:
            raise exc.CommandError(
                _('Expected non-negative --boot-index, got %s') %
                parsed_args.boot_index)

        field_list = [
            'extra', 'volume_type', 'properties', 'boot_index', 'node_uuid',
            'volume_id', 'uuid'
        ]
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        fields = utils.args_array_to_dict(fields, 'properties')
        fields = utils.args_array_to_dict(fields, 'extra')
        volume_target = baremetal_client.volume_target.create(**fields)

        data = dict([(f, getattr(volume_target, f, ''))
                     for f in res_fields.VOLUME_TARGET_DETAILED_RESOURCE.fields
                     ])
        return self.dict2columns(data)
Beispiel #24
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)

        baremetal_client = self.app.client_manager.baremetal

        field_list = ['description', 'extra', 'uuid']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and not (v is None))
        fields = utils.args_array_to_dict(fields, 'extra')
        chassis = baremetal_client.chassis.create(**fields)._info

        chassis.pop('links', None)
        chassis.pop('nodes', None)

        return self.dict2columns(chassis)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)

        baremetal_client = self.app.client_manager.baremetal

        field_list = ['description', 'extra', 'uuid']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and not (v is None))
        fields = utils.args_array_to_dict(fields, 'extra')
        chassis = baremetal_client.chassis.create(**fields)._info

        chassis.pop('links', None)
        chassis.pop('nodes', None)

        return self.dict2columns(chassis)
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        field_list = ['extra', 'type', 'connector_id', 'node_uuid', 'uuid']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        fields = utils.args_array_to_dict(fields, 'extra')
        volume_connector = baremetal_client.volume_connector.create(**fields)

        data = dict([
            (f, getattr(volume_connector, f, ''))
            for f in res_fields.VOLUME_CONNECTOR_DETAILED_RESOURCE.fields
        ])
        return self.dict2columns(data)
Beispiel #27
0
def do_driver_vendor_passthru(cc, args):
    """Call a vendor-passthru extension for a driver."""
    arguments = utils.args_array_to_dict({'args': args.arguments[0]},
                                         'args')['args']

    # If there were no arguments for the method, arguments will still
    # be an empty list. So make it an empty dict.
    if not arguments:
        arguments = {}

    resp = cc.driver.vendor_passthru(args.driver_name, args.method,
                                     http_method=args.http_method,
                                     args=arguments)
    if resp:
        # Print the raw response we don't know how it should be formated
        print(str(resp.to_dict()))
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        field_list = ['name', 'uuid', 'extra', 'resource_class', 'traits',
                      'candidate_nodes']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)

        fields = utils.args_array_to_dict(fields, 'extra')
        allocation = baremetal_client.allocation.create(**fields)
        if parsed_args.wait_timeout is not None:
            allocation = baremetal_client.allocation.wait(
                allocation.uuid, timeout=parsed_args.wait_timeout)

        data = dict([(f, getattr(allocation, f, '')) for f in
                     res_fields.ALLOCATION_DETAILED_RESOURCE.fields])

        return self.dict2columns(data)
Beispiel #29
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)", parsed_args)
        baremetal_client = self.app.client_manager.baremetal

        steps = utils.handle_json_arg(parsed_args.steps, 'deploy steps')

        field_list = ['name', 'uuid', 'extra']
        fields = dict((k, v) for (k, v) in vars(parsed_args).items()
                      if k in field_list and v is not None)
        fields = utils.args_array_to_dict(fields, 'extra')
        template = baremetal_client.deploy_template.create(steps=steps,
                                                           **fields)

        data = dict([
            (f, getattr(template, f, ''))
            for f in res_fields.DEPLOY_TEMPLATE_DETAILED_RESOURCE.fields
        ])

        return self.dict2columns(data)
 def test_args_array_to_dict(self):
     my_args = {
         'matching_metadata': [
             'str=foo', 'int=1', 'bool=true', 'list=[1, 2, 3]',
             'dict={"foo": "bar"}'
         ],
         'other':
         'value'
     }
     cleaned_dict = utils.args_array_to_dict(my_args, "matching_metadata")
     self.assertEqual(
         {
             'matching_metadata': {
                 'str': 'foo',
                 'int': 1,
                 'bool': True,
                 'list': [1, 2, 3],
                 'dict': {
                     'foo': 'bar'
                 }
             },
             'other': 'value'
         }, cleaned_dict)