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
This commit is contained in:
parent
be6027e09b
commit
67f8b898eb
@ -171,6 +171,7 @@ Set network properties
|
||||
[--name <name>]
|
||||
[--enable | --disable]
|
||||
[--share | --no-share]
|
||||
[--external [--default | --no-default] | --internal]
|
||||
<network>
|
||||
|
||||
.. option:: --name <name>
|
||||
@ -193,6 +194,24 @@ Set network properties
|
||||
|
||||
Do not share the network between projects
|
||||
|
||||
.. option:: --external
|
||||
|
||||
Set this network as an external network.
|
||||
Requires the "external-net" extension to be enabled.
|
||||
|
||||
.. option:: --internal
|
||||
|
||||
Set this network as an internal network
|
||||
|
||||
.. option:: --default
|
||||
|
||||
Specify if this network should be used as
|
||||
the default external network
|
||||
|
||||
.. option:: --no-default
|
||||
|
||||
Do not use the network as the default external network.
|
||||
|
||||
.. _network_set-network:
|
||||
.. describe:: <network>
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -2,6 +2,7 @@
|
||||
features:
|
||||
- |
|
||||
Add external network options ``--external|--internal`` and ``--external``
|
||||
suboptions ``--default|--no-default`` to the ``network create`` command.
|
||||
These options are available for Networkv2 only.
|
||||
[Bug `1545537 <https://bugs.launchpad.net/bugs/1545537>`_]
|
||||
suboptions ``--default|--no-default`` to the ``network create`` and
|
||||
``network set`` commands.
|
||||
These options are available for Network version 2 only.
|
||||
[Bug `1545537 <https://bugs.launchpad.net/bugs/1545537>`_]
|
Loading…
Reference in New Issue
Block a user