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
This commit is contained in:
Vladyslav Drok 2016-12-19 19:28:12 +02:00
parent 1f586f1977
commit 5af0762f6d
6 changed files with 32 additions and 5 deletions

View File

@ -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))

View File

@ -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()

View File

@ -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):

View File

@ -172,13 +172,25 @@ def do_portgroup_list(cc, args):
'-u', '--uuid',
metavar='<uuid>',
help="UUID of the portgroup.")
@cliutils.arg(
'-m', '--mode',
metavar='<mode>',
help="Portgroup mode. For possible values, refer to "
"https://www.kernel.org/doc/Documentation/networking/bonding.txt")
@cliutils.arg(
'-p', '--properties',
metavar="<key=value>",
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])

View File

@ -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',

View File

@ -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.