From 5af0762f6d4fbf802a82fafeee105f9476e0dcc8 Mon Sep 17 00:00:00 2001 From: Vladyslav Drok Date: Mon, 19 Dec 2016 19:28:12 +0200 Subject: [PATCH] Add mode and properties to portgroup This change adds mode and properties (available since ironic API microversion 1.26) as possible creation attributes for ironic CLI. OpenStackClient support coming in the next patch. Partial-Bug: #1618754 Change-Id: I4552f06884c7cf7e66c310c5639e8f3149497105 --- .../tests/unit/osc/v1/test_baremetal_portgroup.py | 4 +++- ironicclient/tests/unit/v1/test_portgroup_shell.py | 8 ++++++-- ironicclient/v1/portgroup.py | 2 +- ironicclient/v1/portgroup_shell.py | 14 +++++++++++++- ironicclient/v1/resource_fields.py | 4 ++++ ...portgroup-mode-properties-0a3023cf905adaef.yaml | 5 +++++ 6 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/add-portgroup-mode-properties-0a3023cf905adaef.yaml diff --git a/ironicclient/tests/unit/osc/v1/test_baremetal_portgroup.py b/ironicclient/tests/unit/osc/v1/test_baremetal_portgroup.py index ff291eed4..2a1df88b0 100644 --- a/ironicclient/tests/unit/osc/v1/test_baremetal_portgroup.py +++ b/ironicclient/tests/unit/osc/v1/test_baremetal_portgroup.py @@ -353,7 +353,7 @@ class TestBaremetalPortGroupList(TestBaremetalPortGroup): collist = ('UUID', 'Address', 'Created At', 'Extra', 'Standalone Ports Supported', 'Node UUID', 'Name', - 'Updated At', 'Internal Info') + 'Updated At', 'Internal Info', 'Mode', 'Properties') self.assertEqual(collist, columns) datalist = ((baremetal_fakes.baremetal_portgroup_uuid, @@ -364,6 +364,8 @@ class TestBaremetalPortGroupList(TestBaremetalPortGroup): baremetal_fakes.baremetal_uuid, baremetal_fakes.baremetal_portgroup_name, '', + '', + '', ''),) self.assertEqual(datalist, tuple(data)) diff --git a/ironicclient/tests/unit/v1/test_portgroup_shell.py b/ironicclient/tests/unit/v1/test_portgroup_shell.py index bf3d79c7d..4a7a1a6b0 100644 --- a/ironicclient/tests/unit/v1/test_portgroup_shell.py +++ b/ironicclient/tests/unit/v1/test_portgroup_shell.py @@ -30,7 +30,8 @@ class PortgroupShellTest(utils.BaseTestCase): portgroup = object() pg_shell._print_portgroup_show(portgroup) exp = ['address', 'created_at', 'extra', 'standalone_ports_supported', - 'node_uuid', 'updated_at', 'uuid', 'name', 'internal_info'] + 'node_uuid', 'updated_at', 'uuid', 'name', 'internal_info', + 'mode', 'properties'] act = actual.keys() self.assertEqual(sorted(exp), sorted(act)) @@ -272,10 +273,13 @@ class PortgroupShellTest(utils.BaseTestCase): client_mock = mock.MagicMock() args = mock.MagicMock() args.address = 'aa:bb:cc:dd:ee:ff' + args.mode = '802.3ad' + args.properties = ['xmit_hash_policy=layer3+4', 'miimon=100'] args.json = False pg_shell.do_portgroup_create(client_mock, args) client_mock.portgroup.create.assert_called_once_with( - address='aa:bb:cc:dd:ee:ff') + address='aa:bb:cc:dd:ee:ff', mode='802.3ad', + properties={'xmit_hash_policy': 'layer3+4', 'miimon': 100}) def test_do_portgroup_node_uuid(self): client_mock = mock.MagicMock() diff --git a/ironicclient/v1/portgroup.py b/ironicclient/v1/portgroup.py index 36e91239a..c590ed054 100644 --- a/ironicclient/v1/portgroup.py +++ b/ironicclient/v1/portgroup.py @@ -27,7 +27,7 @@ class PortgroupManager(base.CreateManager): resource_class = Portgroup _resource_name = 'portgroups' _creation_attributes = ['address', 'extra', 'name', 'node_uuid', - 'standalone_ports_supported'] + 'standalone_ports_supported', 'mode', 'properties'] def list(self, node=None, address=None, limit=None, marker=None, sort_key=None, sort_dir=None, detail=False, fields=None): diff --git a/ironicclient/v1/portgroup_shell.py b/ironicclient/v1/portgroup_shell.py index a3904ea78..8e4f25283 100644 --- a/ironicclient/v1/portgroup_shell.py +++ b/ironicclient/v1/portgroup_shell.py @@ -172,13 +172,25 @@ def do_portgroup_list(cc, args): '-u', '--uuid', metavar='', help="UUID of the portgroup.") +@cliutils.arg( + '-m', '--mode', + metavar='', + help="Portgroup mode. For possible values, refer to " + "https://www.kernel.org/doc/Documentation/networking/bonding.txt") +@cliutils.arg( + '-p', '--properties', + metavar="", + action='append', + help="Record key/value properties related to this portgroup's " + "configuration.") def do_portgroup_create(cc, args): """Create a new portgroup.""" field_list = ['address', 'extra', 'node_uuid', 'name', 'uuid', - 'standalone_ports_supported'] + 'standalone_ports_supported', 'mode', 'properties'] 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, 'properties') portgroup = cc.portgroup.create(**fields) data = dict([(f, getattr(portgroup, f, '')) for f in field_list]) diff --git a/ironicclient/v1/resource_fields.py b/ironicclient/v1/resource_fields.py index 0da4914c5..ae77914f0 100644 --- a/ironicclient/v1/resource_fields.py +++ b/ironicclient/v1/resource_fields.py @@ -52,6 +52,7 @@ class Resource(object): 'last_error': 'Last Error', 'maintenance': 'Maintenance', 'maintenance_reason': 'Maintenance Reason', + 'mode': 'Mode', 'name': 'Name', 'node_uuid': 'Node UUID', 'power_state': 'Power State', @@ -230,6 +231,8 @@ PORTGROUP_DETAILED_RESOURCE = Resource( 'name', 'updated_at', 'internal_info', + 'mode', + 'properties', ], sort_excluded=[ 'extra', @@ -238,6 +241,7 @@ PORTGROUP_DETAILED_RESOURCE = Resource( # internal to ironic. See bug #1443003 for more details. 'node_uuid', 'internal_info', + 'properties', ]) PORTGROUP_RESOURCE = Resource( ['uuid', diff --git a/releasenotes/notes/add-portgroup-mode-properties-0a3023cf905adaef.yaml b/releasenotes/notes/add-portgroup-mode-properties-0a3023cf905adaef.yaml new file mode 100644 index 000000000..e1ae9e265 --- /dev/null +++ b/releasenotes/notes/add-portgroup-mode-properties-0a3023cf905adaef.yaml @@ -0,0 +1,5 @@ +--- +features: + - Mode and properties fields were added to the portgroup object, along with + respective arguments for the ironic CLI, they are available starting with + ironic API microversion 1.26.