summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-12-24 12:00:03 +0000
committerGerrit Code Review <review@openstack.org>2018-12-24 12:00:03 +0000
commit7b72fb816f7727fae0c6fe6d32aaa53ff82d4c69 (patch)
tree9515135632917183e2167ad8cdb11d511cf3b832 /openstackclient
parent4eab8364413ab26f40446a348d7be06fe61c7f45 (diff)
parentc82f4237e59dd61f180b2bfbd3383c6540cd6cef (diff)
downloadpython-openstackclient-7b72fb816f7727fae0c6fe6d32aaa53ff82d4c69.tar.gz
Merge "Support enable/disable uplink status propagation"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/network/v2/port.py18
-rw-r--r--openstackclient/tests/unit/network/v2/fakes.py3
-rw-r--r--openstackclient/tests/unit/network/v2/test_port.py39
3 files changed, 60 insertions, 0 deletions
diff --git a/openstackclient/network/v2/port.py b/openstackclient/network/v2/port.py
index 0d276d9d..1001e6cf 100644
--- a/openstackclient/network/v2/port.py
+++ b/openstackclient/network/v2/port.py
@@ -163,6 +163,13 @@ def _get_attrs(client_manager, parsed_args):
attrs['qos_policy_id'] = client_manager.network.find_qos_policy(
parsed_args.qos_policy, ignore_missing=False).id
+ if ('enable_uplink_status_propagation' in parsed_args and
+ parsed_args.enable_uplink_status_propagation):
+ attrs['propagate_uplink_status'] = True
+ if ('disable_uplink_status_propagation' in parsed_args and
+ parsed_args.disable_uplink_status_propagation):
+ attrs['propagate_uplink_status'] = False
+
return attrs
@@ -349,6 +356,17 @@ class CreatePort(command.ShowOne):
action='store_true',
help=_("Disable port")
)
+ uplink_status_group = parser.add_mutually_exclusive_group()
+ uplink_status_group.add_argument(
+ '--enable-uplink-status-propagation',
+ action='store_true',
+ help=_("Enable uplink status propagate")
+ )
+ uplink_status_group.add_argument(
+ '--disable-uplink-status-propagation',
+ action='store_true',
+ help=_("Disable uplink status propagate (default)")
+ )
parser.add_argument(
'--project',
metavar='<project>',
diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py
index aec7402f..28e92d11 100644
--- a/openstackclient/tests/unit/network/v2/fakes.py
+++ b/openstackclient/tests/unit/network/v2/fakes.py
@@ -581,6 +581,7 @@ class FakePort(object):
'tenant_id': 'project-id-' + uuid.uuid4().hex,
'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
'tags': [],
+ 'uplink_status_propagation': False,
}
# Overwrite default attributes.
@@ -600,6 +601,8 @@ class FakePort(object):
port.project_id = port_attrs['tenant_id']
port.security_group_ids = port_attrs['security_group_ids']
port.qos_policy_id = port_attrs['qos_policy_id']
+ port.uplink_status_propagation = port_attrs[
+ 'uplink_status_propagation']
return port
diff --git a/openstackclient/tests/unit/network/v2/test_port.py b/openstackclient/tests/unit/network/v2/test_port.py
index 78d7fd6c..8ac3e54f 100644
--- a/openstackclient/tests/unit/network/v2/test_port.py
+++ b/openstackclient/tests/unit/network/v2/test_port.py
@@ -64,6 +64,7 @@ class TestPort(network_fakes.TestNetworkV2):
'security_group_ids',
'status',
'tags',
+ 'uplink_status_propagation',
)
data = (
@@ -93,6 +94,7 @@ class TestPort(network_fakes.TestNetworkV2):
utils.format_list(fake_port.security_group_ids),
fake_port.status,
utils.format_list(fake_port.tags),
+ fake_port.uplink_status_propagation,
)
return columns, data
@@ -571,6 +573,43 @@ class TestCreatePort(TestPort):
def test_create_with_no_tag(self):
self._test_create_with_tag(add_tags=False)
+ def _test_create_with_uplink_status_propagation(self, enable=True):
+ arglist = [
+ '--network', self._port.network_id,
+ 'test-port',
+ ]
+ if enable:
+ arglist += ['--enable-uplink-status-propagation']
+ else:
+ arglist += ['--disable-uplink-status-propagation']
+ verifylist = [
+ ('network', self._port.network_id,),
+ ('name', 'test-port'),
+ ]
+ if enable:
+ verifylist.append(('enable_uplink_status_propagation', True))
+ else:
+ verifylist.append(('disable_uplink_status_propagation', True))
+ 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,
+ 'propagate_uplink_status': enable,
+ 'name': 'test-port',
+ })
+
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(self.data, data)
+
+ def test_create_with_uplink_status_propagation_enabled(self):
+ self._test_create_with_uplink_status_propagation(enable=True)
+
+ def test_create_with_uplink_status_propagation_disabled(self):
+ self._test_create_with_uplink_status_propagation(enable=False)
+
class TestDeletePort(TestPort):