summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYolanda Robla <yroblamo@redhat.com>2018-07-27 12:54:25 +0200
committerYolanda Robla <yroblamo@redhat.com>2018-10-23 10:00:03 +0200
commitdfd341585b3a331df240202b2de80834ae1acc9d (patch)
tree42ea104c77a19852a84efa6f93732963bc261470
parentfb94fb825cccecd11c4a2f78beeff3b0b19956f3 (diff)
downloadpython-ironicclient-dfd341585b3a331df240202b2de80834ae1acc9d.tar.gz
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
-rw-r--r--ironicclient/common/http.py2
-rwxr-xr-xironicclient/osc/v1/baremetal_node.py28
-rw-r--r--ironicclient/tests/unit/osc/v1/test_baremetal_node.py64
-rw-r--r--ironicclient/tests/unit/v1/test_node_shell.py3
-rw-r--r--ironicclient/v1/node.py3
-rw-r--r--ironicclient/v1/resource_fields.py4
-rw-r--r--releasenotes/notes/add_automated_clean_field-d2a0c824a4e90bf4.yaml6
7 files changed, 92 insertions, 18 deletions
diff --git a/ironicclient/common/http.py b/ironicclient/common/http.py
index d650753..a981cb1 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 238e635..fb8e3fe 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='<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()
@@ -1106,6 +1112,11 @@ class SetBaremetalNode(command.Command):
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>',
help=_('Set the target RAID configuration (JSON) for the node. '
@@ -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 5c62d80..e49491a 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 9d01553..b3f6412 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 584fecf..7c7ccc1 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 bfea9c8..647b9e9 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 0000000..4e416b2
--- /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.