Merge "Revert "Disallow setting default on internal network""
This commit is contained in:
commit
af1ffc456f
@ -16,7 +16,6 @@
|
|||||||
from cliff import columns as cliff_columns
|
from cliff import columns as cliff_columns
|
||||||
from osc_lib.cli import format_columns
|
from osc_lib.cli import format_columns
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
from osc_lib.utils import tags as _tag
|
from osc_lib.utils import tags as _tag
|
||||||
|
|
||||||
@ -126,9 +125,6 @@ def _get_attrs_network(client_manager, parsed_args):
|
|||||||
attrs['is_default'] = False
|
attrs['is_default'] = False
|
||||||
if parsed_args.default:
|
if parsed_args.default:
|
||||||
attrs['is_default'] = True
|
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
|
# Update Provider network options
|
||||||
if parsed_args.provider_network_type:
|
if parsed_args.provider_network_type:
|
||||||
attrs['provider:network_type'] = parsed_args.provider_network_type
|
attrs['provider:network_type'] = parsed_args.provider_network_type
|
||||||
@ -706,8 +702,7 @@ class SetNetwork(command.Command):
|
|||||||
default_router_grp.add_argument(
|
default_router_grp.add_argument(
|
||||||
'--default',
|
'--default',
|
||||||
action='store_true',
|
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(
|
default_router_grp.add_argument(
|
||||||
'--no-default',
|
'--no-default',
|
||||||
|
@ -278,24 +278,6 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
|||||||
def test_create_with_no_tag(self):
|
def test_create_with_no_tag(self):
|
||||||
self._test_create_with_tag(add_tags=False)
|
self._test_create_with_tag(add_tags=False)
|
||||||
|
|
||||||
def test_create_default_internal(self):
|
|
||||||
arglist = [
|
|
||||||
self._network.name,
|
|
||||||
"--default",
|
|
||||||
]
|
|
||||||
verifylist = [
|
|
||||||
('name', self._network.name),
|
|
||||||
('enable', True),
|
|
||||||
('share', None),
|
|
||||||
('project', None),
|
|
||||||
('external', False),
|
|
||||||
('default', True),
|
|
||||||
]
|
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
||||||
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
|
|
||||||
parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class TestCreateNetworkIdentityV2(TestNetwork):
|
class TestCreateNetworkIdentityV2(TestNetwork):
|
||||||
|
|
||||||
@ -1043,21 +1025,6 @@ class TestSetNetwork(TestNetwork):
|
|||||||
def test_set_with_no_tag(self):
|
def test_set_with_no_tag(self):
|
||||||
self._test_set_tags(with_tags=False)
|
self._test_set_tags(with_tags=False)
|
||||||
|
|
||||||
def test_set_default_internal(self):
|
|
||||||
arglist = [
|
|
||||||
self._network.name,
|
|
||||||
'--internal',
|
|
||||||
'--default',
|
|
||||||
]
|
|
||||||
verifylist = [
|
|
||||||
('internal', True),
|
|
||||||
('default', True),
|
|
||||||
]
|
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
||||||
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
|
|
||||||
parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class TestShowNetwork(TestNetwork):
|
class TestShowNetwork(TestNetwork):
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
fixes:
|
|
||||||
- |
|
|
||||||
For ``network create`` the
|
|
||||||
`--default`` option should be only used for external networks.
|
|
||||||
After this release, we enforce this scenario. If a users attempts
|
|
||||||
to create an internal default network or update a network to be
|
|
||||||
internal default, the command will be denied.
|
|
||||||
[Bug `1745658 <https://bugs.launchpad.net/bugs/1745658>`_]
|
|
Loading…
x
Reference in New Issue
Block a user