diff --git a/ironicclient/common/http.py b/ironicclient/common/http.py index d65075358..a981cb133 100644 --- a/ironicclient/common/http.py +++ b/ironicclient/common/http.py @@ -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__) diff --git a/ironicclient/osc/v1/baremetal_node.py b/ironicclient/osc/v1/baremetal_node.py index 238e63517..fb8e3fe3c 100755 --- a/ironicclient/osc/v1/baremetal_node.py +++ b/ironicclient/osc/v1/baremetal_node.py @@ -432,6 +432,11 @@ class CreateBaremetalNode(command.ShowOne): '--conductor-group', metavar='', 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='', 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='', @@ -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', diff --git a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py index 5c62d80c6..e49491a8e 100644 --- a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py +++ b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py @@ -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', diff --git a/ironicclient/tests/unit/v1/test_node_shell.py b/ironicclient/tests/unit/v1/test_node_shell.py index 9d0155361..b3f6412a2 100644 --- a/ironicclient/tests/unit/v1/test_node_shell.py +++ b/ironicclient/tests/unit/v1/test_node_shell.py @@ -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', diff --git a/ironicclient/v1/node.py b/ironicclient/v1/node.py index 584fecf31..7c7ccc17f 100644 --- a/ironicclient/v1/node.py +++ b/ironicclient/v1/node.py @@ -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, diff --git a/ironicclient/v1/resource_fields.py b/ironicclient/v1/resource_fields.py index bfea9c875..647b9e9c7 100644 --- a/ironicclient/v1/resource_fields.py +++ b/ironicclient/v1/resource_fields.py @@ -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', diff --git a/releasenotes/notes/add_automated_clean_field-d2a0c824a4e90bf4.yaml b/releasenotes/notes/add_automated_clean_field-d2a0c824a4e90bf4.yaml new file mode 100644 index 000000000..4e416b268 --- /dev/null +++ b/releasenotes/notes/add_automated_clean_field-d2a0c824a4e90bf4.yaml @@ -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.