Add args to CLI 'node-create' for selecting hardware interfaces

Adds the below args to CLI 'ironic node-create' and OSC:
--boot-interface
--console-interface
--deploy-interface
--inspect-interface
--management-interface
--power-interface
--raid-interface
--vendor-interface

Change-Id: I405d067ad2cd71f272241c10ce3760549de94711
Partial-Bug: #1524745
Depends-On: Ic8398a6093189a65a7c1ab5cf7e682577dde3257
This commit is contained in:
Dao Cong Tien 2017-01-10 19:20:36 +07:00
parent 808a4cbfa4
commit 78a3dcb522
8 changed files with 275 additions and 5 deletions

View File

@ -25,7 +25,7 @@ LOG = logging.getLogger(__name__)
API_VERSION_OPTION = 'os_baremetal_api_version'
API_NAME = 'baremetal'
LAST_KNOWN_API_VERSION = 28
LAST_KNOWN_API_VERSION = 31
API_VERSIONS = {
'1.%d' % i: 'ironicclient.v1.client.Client'
for i in range(1, LAST_KNOWN_API_VERSION + 1)

View File

@ -293,11 +293,59 @@ class CreateBaremetalNode(command.ShowOne):
'--name',
metavar='<name>',
help="Unique name for the node.")
parser.add_argument(
'--boot-interface',
metavar='<boot_interface>',
help='Boot interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
parser.add_argument(
'--console-interface',
metavar='<console_interface>',
help='Console interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
parser.add_argument(
'--deploy-interface',
metavar='<deploy_interface>',
help='Deploy interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
parser.add_argument(
'--inspect-interface',
metavar='<inspect_interface>',
help='Inspect interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
parser.add_argument(
'--management-interface',
metavar='<management_interface>',
help='Management interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
parser.add_argument(
'--network-interface',
metavar='<network_interface>',
help='Network interface used for switching node to '
'cleaning/provisioning networks.')
parser.add_argument(
'--power-interface',
metavar='<power_interface>',
help='Power interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
parser.add_argument(
'--raid-interface',
metavar='<raid_interface>',
help='RAID interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
parser.add_argument(
'--vendor-interface',
metavar='<vendor_interface>',
help='Vendor interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
parser.add_argument(
'--resource-class',
metavar='<resource_class>',
@ -312,7 +360,11 @@ class CreateBaremetalNode(command.ShowOne):
field_list = ['chassis_uuid', 'driver', 'driver_info',
'properties', 'extra', 'uuid', 'name',
'network_interface', 'resource_class']
'boot_interface', 'console_interface',
'deploy_interface', 'inspect_interface',
'management_interface', 'network_interface',
'power_interface', 'raid_interface',
'vendor_interface', 'resource_class']
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')

View File

@ -334,11 +334,51 @@ class TestBaremetalCreate(TestBaremetal):
[('name', 'name')],
{'name': 'name'})
def test_baremetal_create_with_boot_interface(self):
self.check_with_options(['--boot-interface', 'boot'],
[('boot_interface', 'boot')],
{'boot_interface': 'boot'})
def test_baremetal_create_with_console_interface(self):
self.check_with_options(['--console-interface', 'console'],
[('console_interface', 'console')],
{'console_interface': 'console'})
def test_baremetal_create_with_deploy_interface(self):
self.check_with_options(['--deploy-interface', 'deploy'],
[('deploy_interface', 'deploy')],
{'deploy_interface': 'deploy'})
def test_baremetal_create_with_inspect_interface(self):
self.check_with_options(['--inspect-interface', 'inspect'],
[('inspect_interface', 'inspect')],
{'inspect_interface': 'inspect'})
def test_baremetal_create_with_management_interface(self):
self.check_with_options(['--management-interface', 'management'],
[('management_interface', 'management')],
{'management_interface': 'management'})
def test_baremetal_create_with_network_interface(self):
self.check_with_options(['--network-interface', 'neutron'],
[('network_interface', 'neutron')],
{'network_interface': 'neutron'})
def test_baremetal_create_with_power_interface(self):
self.check_with_options(['--power-interface', 'power'],
[('power_interface', 'power')],
{'power_interface': 'power'})
def test_baremetal_create_with_raid_interface(self):
self.check_with_options(['--raid-interface', 'raid'],
[('raid_interface', 'raid')],
{'raid_interface': 'raid'})
def test_baremetal_create_with_vendor_interface(self):
self.check_with_options(['--vendor-interface', 'vendor'],
[('vendor_interface', 'vendor')],
{'vendor_interface': 'vendor'})
def test_baremetal_create_with_resource_class(self):
self.check_with_options(['--resource-class', 'foo'],
[('resource_class', 'foo')],
@ -499,7 +539,11 @@ class TestBaremetalList(TestBaremetal):
'Target RAID configuration',
'Updated At', 'Inspection Finished At',
'Inspection Started At', 'UUID', 'Name',
'Network Interface')
'Boot Interface', 'Console Interface',
'Deploy Interface', 'Inspect Interface',
'Management Interface', 'Network Interface',
'Power Interface', 'RAID Interface',
'Vendor Interface')
self.assertEqual(collist, columns)
datalist = ((
'',
@ -531,6 +575,14 @@ class TestBaremetalList(TestBaremetal):
baremetal_fakes.baremetal_uuid,
baremetal_fakes.baremetal_name,
'',
'',
'',
'',
'',
'',
'',
'',
'',
), )
self.assertEqual(datalist, tuple(data))

View File

@ -47,7 +47,15 @@ class NodeShellTest(utils.BaseTestCase):
'maintenance',
'maintenance_reason',
'name',
'boot_interface',
'console_interface',
'deploy_interface',
'inspect_interface',
'management_interface',
'network_interface',
'power_interface',
'raid_interface',
'vendor_interface',
'power_state',
'properties',
'provision_state',
@ -198,6 +206,56 @@ class NodeShellTest(utils.BaseTestCase):
n_shell.do_node_create(client_mock, args)
client_mock.node.create.assert_called_once_with(name=args.name)
def test_do_node_create_with_boot_interface(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()
args.boot_interface = 'boot'
args.json = False
n_shell.do_node_create(client_mock, args)
client_mock.node.create.assert_called_once_with(
boot_interface='boot')
def test_do_node_create_with_console_interface(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()
args.console_interface = 'console'
args.json = False
n_shell.do_node_create(client_mock, args)
client_mock.node.create.assert_called_once_with(
console_interface='console')
def test_do_node_create_with_deploy_interface(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()
args.deploy_interface = 'deploy'
args.json = False
n_shell.do_node_create(client_mock, args)
client_mock.node.create.assert_called_once_with(
deploy_interface='deploy')
def test_do_node_create_with_inspect_interface(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()
args.inspect_interface = 'inspect'
args.json = False
n_shell.do_node_create(client_mock, args)
client_mock.node.create.assert_called_once_with(
inspect_interface='inspect')
def test_do_node_create_with_management_interface(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()
args.management_interface = 'management'
args.json = False
n_shell.do_node_create(client_mock, args)
client_mock.node.create.assert_called_once_with(
management_interface='management')
def test_do_node_create_with_network_interface(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()
@ -208,6 +266,36 @@ class NodeShellTest(utils.BaseTestCase):
client_mock.node.create.assert_called_once_with(
network_interface='neutron')
def test_do_node_create_with_power_interface(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()
args.power_interface = 'power'
args.json = False
n_shell.do_node_create(client_mock, args)
client_mock.node.create.assert_called_once_with(
power_interface='power')
def test_do_node_create_with_raid_interface(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()
args.raid_interface = 'raid'
args.json = False
n_shell.do_node_create(client_mock, args)
client_mock.node.create.assert_called_once_with(
raid_interface='raid')
def test_do_node_create_with_vendor_interface(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()
args.vendor_interface = 'vendor'
args.json = False
n_shell.do_node_create(client_mock, args)
client_mock.node.create.assert_called_once_with(
vendor_interface='vendor')
def test_do_node_show(self):
client_mock = mock.MagicMock()
args = mock.MagicMock()

View File

@ -46,7 +46,11 @@ class NodeManager(base.CreateManager):
resource_class = Node
_creation_attributes = ['chassis_uuid', 'driver', 'driver_info',
'extra', 'uuid', 'properties', 'name',
'network_interface', 'resource_class']
'boot_interface', 'console_interface',
'deploy_interface', 'inspect_interface',
'management_interface', 'network_interface',
'power_interface', 'raid_interface',
'vendor_interface', 'resource_class']
_resource_name = 'nodes'
def list(self, associated=None, maintenance=None, marker=None, limit=None,

View File

@ -212,11 +212,59 @@ def do_node_list(cc, args):
'-n', '--name',
metavar='<name>',
help="Unique name for the node.")
@cliutils.arg(
'--boot-interface',
metavar='<boot-interface>',
help='Boot interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
@cliutils.arg(
'--console-interface',
metavar='<console-interface>',
help='Console interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
@cliutils.arg(
'--deploy-interface',
metavar='<deploy-interface>',
help='Deploy interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
@cliutils.arg(
'--inspect-interface',
metavar='<inspect-interface>',
help='Inspect interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
@cliutils.arg(
'--management-interface',
metavar='<management-interface>',
help='Management interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
@cliutils.arg(
'--network-interface',
metavar='<network_interface>',
help='Network interface used for switching node to cleaning/provisioning '
'networks.')
@cliutils.arg(
'--power-interface',
metavar='<power-interface>',
help='Power interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
@cliutils.arg(
'--raid-interface',
metavar='<raid-interface>',
help='RAID interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
@cliutils.arg(
'--vendor-interface',
metavar='<vendor-interface>',
help='Vendor interface used by the node\'s driver. This is '
'only applicable when the specified --driver is a '
'hardware type.')
@cliutils.arg(
'--resource-class',
metavar='<resource_class>',
@ -226,7 +274,11 @@ 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',
'network_interface', 'resource_class']
'boot_interface', 'console_interface',
'deploy_interface', 'inspect_interface',
'management_interface', 'network_interface',
'power_interface', 'raid_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')

View File

@ -70,7 +70,15 @@ class Resource(object):
'local_link_connection': 'Local Link Connection',
'pxe_enabled': 'PXE boot enabled',
'portgroup_uuid': 'Portgroup UUID',
'boot_interface': 'Boot Interface',
'console_interface': 'Console Interface',
'deploy_interface': 'Deploy Interface',
'inspect_interface': 'Inspect Interface',
'management_interface': 'Management Interface',
'network_interface': 'Network Interface',
'power_interface': 'Power Interface',
'raid_interface': 'RAID Interface',
'vendor_interface': 'Vendor Interface',
'standalone_ports_supported': 'Standalone Ports Supported',
'id': 'ID',
}
@ -161,7 +169,15 @@ NODE_DETAILED_RESOURCE = Resource(
'inspection_started_at',
'uuid',
'name',
'boot_interface',
'console_interface',
'deploy_interface',
'inspect_interface',
'management_interface',
'network_interface',
'power_interface',
'raid_interface',
'vendor_interface',
],
sort_excluded=[
# The server cannot sort on "chassis_uuid" because it isn't a column in

View File

@ -0,0 +1,6 @@
---
features:
- Add new arguments to the CLI node-create to allow selecting
boot, console, deploy, inspect, management, power, raid, and vendor
hardware interfaces, when hardware types are used. They are available
starting with ironic API microversion 1.31.