summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorHongbin Lu <hongbin.lu@huawei.com>2017-09-18 01:41:32 +0000
committerDean Troyer <dtroyer@gmail.com>2017-09-29 18:49:22 +0000
commitde23ab8d75fe89c164b3b084c53f01c25b9040ca (patch)
tree08d3b1412a66d1be07b002178cf2bc09de84de22 /openstackclient/tests
parenta452c9d82566db6c09419ce2e5c855d51e2631e1 (diff)
downloadpython-openstackclient-de23ab8d75fe89c164b3b084c53f01c25b9040ca.tar.gz
Support creating unaddress neutron port
Introduce an option '--no-fixed-ip' on port create command. If this option is specified and '--fixed-ip' is unspecified, OSC will send a request to neutron with 'fixed_ips' as an empty list, which will create an unaddress neutron port. Note: The use cases of unaddress port was outlined in: https://specs.openstack.org/openstack/neutron-specs/specs/liberty/unaddressed-port.html (dtroyer: add Depends-On for Zuul v3 test) Depends-On: I39e8e49243ab0bda631600715c971c55a34e2fd9 Change-Id: Ibe38598acbbcd0d353c952fc2a6fa67780762151 Closes-Bug: #1717829
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/unit/network/v2/test_port.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/network/v2/test_port.py b/openstackclient/tests/unit/network/v2/test_port.py
index 45e1045d..3f751818 100644
--- a/openstackclient/tests/unit/network/v2/test_port.py
+++ b/openstackclient/tests/unit/network/v2/test_port.py
@@ -356,6 +356,32 @@ class TestCreatePort(TestPort):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
+ def test_create_with_no_fixed_ips(self):
+ arglist = [
+ '--network', self._port.network_id,
+ '--no-fixed-ip',
+ 'test-port',
+ ]
+ verifylist = [
+ ('network', self._port.network_id),
+ ('enable', True),
+ ('no_fixed_ip', True),
+ ('name', 'test-port'),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ columns, data = (self.cmd.take_action(parsed_args))
+
+ self.network.create_port.assert_called_once_with(**{
+ 'admin_state_up': True,
+ 'network_id': self._port.network_id,
+ 'fixed_ips': [],
+ 'name': 'test-port',
+ })
+
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(self.data, data)
+
def test_create_port_with_allowed_address_pair_ipaddr(self):
pairs = [{'ip_address': '192.168.1.123'},
{'ip_address': '192.168.1.45'}]