Merge "Fix can not set is_default in network"

This commit is contained in:
Jenkins 2017-02-24 04:13:38 +00:00 committed by Gerrit Code Review
commit 1450e8ff4f
3 changed files with 25 additions and 57 deletions

View File

@ -111,10 +111,10 @@ def _get_attrs(client_manager, parsed_args):
attrs['router:external'] = False attrs['router:external'] = False
if parsed_args.external: if parsed_args.external:
attrs['router:external'] = True attrs['router:external'] = True
if parsed_args.no_default: if parsed_args.no_default:
attrs['is_default'] = False attrs['is_default'] = False
if parsed_args.default: if parsed_args.default:
attrs['is_default'] = True attrs['is_default'] = True
# 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

View File

@ -126,6 +126,7 @@ class NetworkTests(base.TestCase):
cmd_output = json.loads(self.openstack( cmd_output = json.loads(self.openstack(
'network create -f json ' + 'network create -f json ' +
'--description aaaa ' + '--description aaaa ' +
'--no-default ' +
name1 name1
)) ))
self.addCleanup(self.openstack, 'network delete ' + name1) self.addCleanup(self.openstack, 'network delete ' + name1)
@ -147,17 +148,11 @@ class NetworkTests(base.TestCase):
'Internal', 'Internal',
cmd_output["router:external"], cmd_output["router:external"],
) )
# NOTE(dtroyer): is_default is not present in the create output
# so make sure it stays that way. self.assertEqual(
# NOTE(stevemar): is_default *is* present in SDK 0.9.11 and newer, False,
# but the value seems to always be None, regardless cmd_output["is_default"],
# of the --default or --no-default value. )
# self.assertEqual('x', cmd_output)
if ('is_default' in cmd_output):
self.assertEqual(
None,
cmd_output["is_default"],
)
self.assertEqual( self.assertEqual(
True, True,
cmd_output["port_security_enabled"], cmd_output["port_security_enabled"],
@ -185,11 +180,10 @@ class NetworkTests(base.TestCase):
True, True,
cmd_output["shared"], cmd_output["shared"],
) )
if ('is_default' in cmd_output): self.assertEqual(
self.assertEqual( None,
None, cmd_output["is_default"],
cmd_output["is_default"], )
)
self.assertEqual( self.assertEqual(
True, True,
cmd_output["port_security_enabled"], cmd_output["port_security_enabled"],
@ -275,16 +269,11 @@ class NetworkTests(base.TestCase):
'Internal', 'Internal',
cmd_output["router:external"], cmd_output["router:external"],
) )
# NOTE(dtroyer): is_default is not present in the create output
# so make sure it stays that way. self.assertEqual(
# NOTE(stevemar): is_default *is* present in SDK 0.9.11 and newer, False,
# but the value seems to always be None, regardless cmd_output["is_default"],
# of the --default or --no-default value. )
if ('is_default' in cmd_output):
self.assertEqual(
None,
cmd_output["is_default"],
)
self.assertEqual( self.assertEqual(
True, True,
cmd_output["port_security_enabled"], cmd_output["port_security_enabled"],
@ -321,7 +310,6 @@ class NetworkTests(base.TestCase):
'External', 'External',
cmd_output["router:external"], cmd_output["router:external"],
) )
# why not 'None' like above??
self.assertEqual( self.assertEqual(
False, False,
cmd_output["is_default"], cmd_output["is_default"],
@ -330,29 +318,3 @@ class NetworkTests(base.TestCase):
False, False,
cmd_output["port_security_enabled"], cmd_output["port_security_enabled"],
) )
# NOTE(dtroyer): There is ambiguity around is_default in that
# it is not in the API docs and apparently can
# not be set when the network is --external,
# although the option handling code only looks at
# the value of is_default when external is True.
raw_output = self.openstack(
'network set ' +
'--default ' +
name
)
self.assertOutput('', raw_output)
cmd_output = json.loads(self.openstack(
'network show -f json ' + name
))
self.assertEqual(
'cccc',
cmd_output["description"],
)
# NOTE(dtroyer): This should be 'True'
self.assertEqual(
False,
cmd_output["port_security_enabled"],
)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Allow ``--default`` and ``--no-default`` options in ``network create`` command to
be recognized when ``--external`` is not present.
[Bug `1665231 <https://bugs.launchpad.net/python-openstackclient/+bug/1665231>`_]