summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorreedip <reedip.banerjee@nectechnologies.in>2016-04-08 14:24:30 +0900
committerReedip <reedip.banerjee@nectechnologies.in>2016-04-15 00:28:09 +0000
commit67f8b898eb6d48b11b9f0624ac70f65c4311f8e8 (patch)
treecf2723f8f3e1a755f5f8c405ec501ff78d48803f /openstackclient
parentbe6027e09b806496d20b833a5f9ed6fcf44156b6 (diff)
downloadpython-openstackclient-67f8b898eb6d48b11b9f0624ac70f65c4311f8e8.tar.gz
Add external network options to osc network set
The following patch adds the options "--external" & "--internal" and the suboptions to "external": "--default" & "--no-default", to "osc network set" CLI to provide the user an option to set a network as an external network or remove the setting. Change-Id: I3a7f2cb249bc8101cbb01322d7732e913237d6cd Partial-Bug: #1545537
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/network/v2/network.py38
-rw-r--r--openstackclient/tests/network/v2/test_network.py9
2 files changed, 39 insertions, 8 deletions
diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py
index 20d943ed..afac471a 100644
--- a/openstackclient/network/v2/network.py
+++ b/openstackclient/network/v2/network.py
@@ -76,6 +76,16 @@ def _get_attrs(client_manager, parsed_args):
parsed_args.availability_zone_hints is not None:
attrs['availability_zone_hints'] = parsed_args.availability_zone_hints
+ # update_external_network_options
+ if parsed_args.internal:
+ attrs['router:external'] = False
+ if parsed_args.external:
+ attrs['router:external'] = True
+ if parsed_args.no_default:
+ attrs['is_default'] = False
+ if parsed_args.default:
+ attrs['is_default'] = True
+
return attrs
@@ -197,14 +207,6 @@ class CreateNetwork(common.NetworkAndComputeShowOne):
def take_action_network(self, client, parsed_args):
attrs = _get_attrs(self.app.client_manager, parsed_args)
- if parsed_args.internal:
- attrs['router:external'] = False
- if parsed_args.external:
- attrs['router:external'] = True
- if parsed_args.no_default:
- attrs['is_default'] = False
- if parsed_args.default:
- attrs['is_default'] = True
if parsed_args.provider_network_type:
attrs['provider:network_type'] = parsed_args.provider_network_type
if parsed_args.physical_network:
@@ -379,6 +381,26 @@ class SetNetwork(command.Command):
action='store_true',
help='Do not share the network between projects',
)
+ external_router_grp = parser.add_mutually_exclusive_group()
+ external_router_grp.add_argument(
+ '--external',
+ action='store_true',
+ help='Set this network as an external network. '
+ 'Requires the "external-net" extension to be enabled.')
+ external_router_grp.add_argument(
+ '--internal',
+ action='store_true',
+ help='Set this network as an internal network')
+ default_router_grp = parser.add_mutually_exclusive_group()
+ default_router_grp.add_argument(
+ '--default',
+ action='store_true',
+ help='Specify if this network should be used as '
+ 'the default external network')
+ default_router_grp.add_argument(
+ '--no-default',
+ action='store_true',
+ help='Do not use the network as the default external network.')
return parser
def take_action(self, parsed_args):
diff --git a/openstackclient/tests/network/v2/test_network.py b/openstackclient/tests/network/v2/test_network.py
index 8a75101b..7d0f8717 100644
--- a/openstackclient/tests/network/v2/test_network.py
+++ b/openstackclient/tests/network/v2/test_network.py
@@ -482,12 +482,16 @@ class TestSetNetwork(TestNetwork):
'--enable',
'--name', 'noob',
'--share',
+ '--external',
+ '--default',
]
verifylist = [
('network', self._network.name),
('enable', True),
('name', 'noob'),
('share', True),
+ ('external', True),
+ ('default', True),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -497,6 +501,8 @@ class TestSetNetwork(TestNetwork):
'name': 'noob',
'admin_state_up': True,
'shared': True,
+ 'router:external': True,
+ 'is_default': True,
}
self.network.update_network.assert_called_once_with(
self._network, **attrs)
@@ -507,11 +513,13 @@ class TestSetNetwork(TestNetwork):
self._network.name,
'--disable',
'--no-share',
+ '--internal',
]
verifylist = [
('network', self._network.name),
('disable', True),
('no_share', True),
+ ('internal', True),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -520,6 +528,7 @@ class TestSetNetwork(TestNetwork):
attrs = {
'admin_state_up': False,
'shared': False,
+ 'router:external': False,
}
self.network.update_network.assert_called_once_with(
self._network, **attrs)