diff options
| author | Hongbin Lu <hongbin.lu@huawei.com> | 2018-01-30 19:11:40 +0000 |
|---|---|---|
| committer | Sean McGinnis <sean.mcginnis@gmail.com> | 2020-03-09 21:01:53 -0500 |
| commit | 962efd949feb461283a9bb4a668fbd310f80ba40 (patch) | |
| tree | fc015ecc493ab889e54814a27ae867a1def6bd50 /openstackclient/network/v2 | |
| parent | ee0170824fada41fae0da2d03106d3978fc1c697 (diff) | |
| download | python-openstackclient-962efd949feb461283a9bb4a668fbd310f80ba40.tar.gz | |
Disallow setting default on internal network
The ``--default`` option should be only used for external network.
Default internal network is not currently supported so we disallow
it for now.
Change-Id: Ia9d39b40e1e041d7bda0f6a27d058e382b572e1a
Closes-Bug: #1745658
Diffstat (limited to 'openstackclient/network/v2')
| -rw-r--r-- | openstackclient/network/v2/network.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py index 00cb782b..3f579b6d 100644 --- a/openstackclient/network/v2/network.py +++ b/openstackclient/network/v2/network.py @@ -16,6 +16,7 @@ from cliff import columns as cliff_columns from osc_lib.cli import format_columns from osc_lib.command import command +from osc_lib import exceptions from osc_lib import utils from osc_lib.utils import tags as _tag @@ -125,6 +126,9 @@ def _get_attrs_network(client_manager, parsed_args): attrs['is_default'] = False if parsed_args.default: attrs['is_default'] = True + if attrs.get('is_default') and not attrs.get('router:external'): + msg = _("Cannot set default for internal network") + raise exceptions.CommandError(msg) # Update Provider network options if parsed_args.provider_network_type: attrs['provider:network_type'] = parsed_args.provider_network_type @@ -702,7 +706,8 @@ class SetNetwork(command.Command): default_router_grp.add_argument( '--default', action='store_true', - help=_("Set the network as the default external network") + help=_("Set the network as the default external network " + "(cannot be used with internal network).") ) default_router_grp.add_argument( '--no-default', |
