diff --git a/ironicclient/tests/functional/base.py b/ironicclient/tests/functional/base.py index 11dc1db46..f230755cd 100644 --- a/ironicclient/tests/functional/base.py +++ b/ironicclient/tests/functional/base.py @@ -352,12 +352,14 @@ class FunctionalTestBase(base.ClientTestBase): def create_port(self, node_id, mac_address=None, + flags='', params=''): if mac_address is None: mac_address = data_utils.rand_mac_address() port = self.ironic('port-create', + flags=flags, params='--address {0} --node {1} {2}' .format(mac_address, node_id, params)) if not port: diff --git a/ironicclient/tests/functional/test_port.py b/ironicclient/tests/functional/test_port.py index 002d29ee2..095f731e3 100644 --- a/ironicclient/tests/functional/test_port.py +++ b/ironicclient/tests/functional/test_port.py @@ -115,3 +115,20 @@ class PortSanityTestIronicClient(base.FunctionalTestBase): addresses = {x['Address'] for x in port_list} self.assertTrue({self.port['address'], other_port['address']}.issubset(addresses)) + + def test_port_create_with_portgroup_uuid(self): + """Test steps: + + 1) Create node in setUp(). + 2) Create a port group. + 3) Create a port with specified port group UUID. + 4) Check port properties for portgroup_uuid. + """ + flag = '--ironic-api-version 1.25' + port_group = self.create_portgroup(self.node['uuid']) + port = self.create_port( + self.node['uuid'], + flags=flag, + params='--portgroup {0}'.format(port_group['uuid'])) + + self.assertEqual(port_group['uuid'], port['portgroup_uuid'])