Add management of automated_clean field
Modify api to manage the new automated_clean field. Also bump last known version to 47 Change-Id: I790c762083c2c1b6cbdde4b21434c56bb99236dd Story: #2002161 Task: #23252
This commit is contained in:
parent
fb94fb825c
commit
dfd341585b
@ -43,7 +43,7 @@ from ironicclient import exc
|
||||
# http://specs.openstack.org/openstack/ironic-specs/specs/kilo/api-microversions.html # noqa
|
||||
# for full details.
|
||||
DEFAULT_VER = '1.9'
|
||||
LAST_KNOWN_API_VERSION = 46
|
||||
LAST_KNOWN_API_VERSION = 47
|
||||
LATEST_VERSION = '1.{}'.format(LAST_KNOWN_API_VERSION)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -432,6 +432,11 @@ class CreateBaremetalNode(command.ShowOne):
|
||||
'--conductor-group',
|
||||
metavar='<conductor_group>',
|
||||
help=_('Conductor group the node will belong to'))
|
||||
parser.add_argument(
|
||||
'--automated-clean',
|
||||
action='store_true',
|
||||
default=None,
|
||||
help=_('Enable automated cleaning for the node'))
|
||||
|
||||
return parser
|
||||
|
||||
@ -440,8 +445,9 @@ class CreateBaremetalNode(command.ShowOne):
|
||||
|
||||
baremetal_client = self.app.client_manager.baremetal
|
||||
|
||||
field_list = ['chassis_uuid', 'driver', 'driver_info',
|
||||
'properties', 'extra', 'uuid', 'name', 'conductor_group',
|
||||
field_list = ['automated_clean', 'chassis_uuid', 'driver',
|
||||
'driver_info', 'properties', 'extra', 'uuid', 'name',
|
||||
'conductor_group',
|
||||
'resource_class'] + ['%s_interface' % iface
|
||||
for iface in SUPPORTED_INTERFACES]
|
||||
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
|
||||
@ -1105,6 +1111,11 @@ class SetBaremetalNode(command.Command):
|
||||
metavar='<conductor_group>',
|
||||
help=_('Set the conductor group for the node'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--automated-clean',
|
||||
action='store_true',
|
||||
help=_('Enable automated cleaning for the node'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--target-raid-config',
|
||||
metavar='<target_raid_config>',
|
||||
@ -1161,8 +1172,9 @@ class SetBaremetalNode(command.Command):
|
||||
raid_config)
|
||||
|
||||
properties = []
|
||||
for field in ['instance_uuid', 'name', 'chassis_uuid', 'driver',
|
||||
'resource_class', 'conductor_group']:
|
||||
for field in ['automated_clean', 'instance_uuid', 'name',
|
||||
'chassis_uuid', 'driver', 'resource_class',
|
||||
'conductor_group']:
|
||||
value = getattr(parsed_args, field)
|
||||
if value:
|
||||
properties.extend(utils.args_array_to_patch(
|
||||
@ -1418,6 +1430,12 @@ class UnsetBaremetalNode(command.Command):
|
||||
help=_('Unset conductor group for this baremetal node (the '
|
||||
'default group will be used)'),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--automated-clean",
|
||||
action="store_true",
|
||||
help=_('Unset automated clean option on this baremetal node '
|
||||
'(the value from configuration will be used)'),
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
@ -1434,7 +1452,7 @@ class UnsetBaremetalNode(command.Command):
|
||||
|
||||
properties = []
|
||||
for field in ['instance_uuid', 'name', 'chassis_uuid',
|
||||
'resource_class', 'conductor_group',
|
||||
'resource_class', 'conductor_group', 'automated_clean',
|
||||
'bios_interface', 'boot_interface', 'console_interface',
|
||||
'deploy_interface', 'inspect_interface',
|
||||
'management_interface', 'network_interface',
|
||||
|
@ -287,7 +287,7 @@ class TestBaremetalCreate(TestBaremetal):
|
||||
baremetal_fakes.baremetal_uuid,
|
||||
)
|
||||
self.actual_kwargs = {
|
||||
'driver': 'fake_driver',
|
||||
'driver': 'fake_driver'
|
||||
}
|
||||
|
||||
def check_with_options(self, addl_arglist, addl_verifylist, addl_kwargs):
|
||||
@ -455,6 +455,11 @@ class TestBaremetalCreate(TestBaremetal):
|
||||
[('conductor_group', 'conductor_group')],
|
||||
{'conductor_group': 'conductor_group'})
|
||||
|
||||
def test_baremetal_create_with_automated_clean(self):
|
||||
self.check_with_options(['--automated-clean'],
|
||||
[('automated_clean', True)],
|
||||
{'automated_clean': True})
|
||||
|
||||
|
||||
class TestBaremetalDelete(TestBaremetal):
|
||||
def setUp(self):
|
||||
@ -598,14 +603,15 @@ class TestBaremetalList(TestBaremetal):
|
||||
**kwargs
|
||||
)
|
||||
|
||||
collist = ('Chassis UUID', 'Created At', 'Clean Step',
|
||||
'Conductor Group', 'Console Enabled', 'Deploy Step',
|
||||
'Driver', 'Driver Info', 'Driver Internal Info', 'Extra',
|
||||
'Instance Info', 'Instance UUID', 'Last Error',
|
||||
'Maintenance', 'Maintenance Reason', 'Fault',
|
||||
'Power State', 'Properties', 'Provisioning State',
|
||||
'Provision Updated At', 'Current RAID configuration',
|
||||
'Reservation', 'Resource Class', 'Target Power State',
|
||||
collist = ('Automated clean', 'Chassis UUID', 'Created At',
|
||||
'Clean Step', 'Conductor Group', 'Console Enabled',
|
||||
'Deploy Step', 'Driver', 'Driver Info',
|
||||
'Driver Internal Info', 'Extra', 'Instance Info',
|
||||
'Instance UUID', 'Last Error', 'Maintenance',
|
||||
'Maintenance Reason', 'Fault', 'Power State', 'Properties',
|
||||
'Provisioning State', 'Provision Updated At',
|
||||
'Current RAID configuration', 'Reservation',
|
||||
'Resource Class', 'Target Power State',
|
||||
'Target Provision State', 'Target RAID configuration',
|
||||
'Traits', 'Updated At', 'Inspection Finished At',
|
||||
'Inspection Started At', 'UUID', 'Name',
|
||||
@ -628,6 +634,7 @@ class TestBaremetalList(TestBaremetal):
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
baremetal_fakes.baremetal_instance_uuid,
|
||||
'',
|
||||
baremetal_fakes.baremetal_maintenance,
|
||||
@ -2281,6 +2288,26 @@ class TestBaremetalSet(TestBaremetal):
|
||||
reset_interfaces=None,
|
||||
)
|
||||
|
||||
def test_baremetal_set_automated_clean(self):
|
||||
arglist = [
|
||||
'node_uuid',
|
||||
'--automated-clean'
|
||||
]
|
||||
verifylist = [
|
||||
('node', 'node_uuid'),
|
||||
('automated_clean', True)
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.baremetal_mock.node.update.assert_called_once_with(
|
||||
'node_uuid',
|
||||
[{'path': '/automated_clean', 'value': 'True', 'op': 'add'}],
|
||||
reset_interfaces=None,
|
||||
)
|
||||
|
||||
def test_baremetal_set_extra(self):
|
||||
arglist = [
|
||||
'node_uuid',
|
||||
@ -2733,6 +2760,25 @@ class TestBaremetalUnset(TestBaremetal):
|
||||
[{'path': '/conductor_group', 'op': 'remove'}]
|
||||
)
|
||||
|
||||
def test_baremetal_unset_automated_clean(self):
|
||||
arglist = [
|
||||
'node_uuid',
|
||||
'--automated-clean',
|
||||
]
|
||||
verifylist = [
|
||||
('node', 'node_uuid'),
|
||||
('automated_clean', True)
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.baremetal_mock.node.update.assert_called_once_with(
|
||||
'node_uuid',
|
||||
[{'path': '/automated_clean', 'op': 'remove'}]
|
||||
)
|
||||
|
||||
def test_baremetal_unset_extra(self):
|
||||
arglist = [
|
||||
'node_uuid',
|
||||
|
@ -33,7 +33,8 @@ class NodeShellTest(utils.BaseTestCase):
|
||||
with mock.patch.object(cliutils, 'print_dict', fake_print_dict):
|
||||
node = object()
|
||||
n_shell._print_node_show(node)
|
||||
exp = ['chassis_uuid',
|
||||
exp = ['automated_clean',
|
||||
'chassis_uuid',
|
||||
'clean_step',
|
||||
'created_at',
|
||||
'conductor_group',
|
||||
|
@ -53,7 +53,8 @@ class NodeManager(base.CreateManager):
|
||||
'network_interface', 'power_interface',
|
||||
'raid_interface', 'rescue_interface',
|
||||
'storage_interface', 'vendor_interface',
|
||||
'resource_class', 'conductor_group']
|
||||
'resource_class', 'conductor_group',
|
||||
'automated_clean']
|
||||
_resource_name = 'nodes'
|
||||
|
||||
def list(self, associated=None, maintenance=None, marker=None, limit=None,
|
||||
|
@ -33,6 +33,7 @@ class Resource(object):
|
||||
FIELDS = {
|
||||
'address': 'Address',
|
||||
'async': 'Async',
|
||||
'automated_clean': 'Automated clean',
|
||||
'attach': 'Response is attachment',
|
||||
'bios_name': 'BIOS setting name',
|
||||
'bios_value': 'BIOS setting value',
|
||||
@ -199,7 +200,8 @@ CHASSIS_RESOURCE = Resource(
|
||||
|
||||
# Nodes
|
||||
NODE_DETAILED_RESOURCE = Resource(
|
||||
['chassis_uuid',
|
||||
['automated_clean',
|
||||
'chassis_uuid',
|
||||
'created_at',
|
||||
'clean_step',
|
||||
'conductor_group',
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds the ability to set the ``automated_clean`` field (available starting
|
||||
with API version 1.47) on the baremetal node, to enable the automated
|
||||
cleaning feature at the node level.
|
Loading…
Reference in New Issue
Block a user