Merge "Follow Boolean Option rule"
This commit is contained in:
commit
b4c3adbd30
openstackclient
@ -52,10 +52,14 @@ def _get_attrs(client_manager, parsed_args):
|
||||
attrs = {}
|
||||
if parsed_args.name is not None:
|
||||
attrs['name'] = str(parsed_args.name)
|
||||
if parsed_args.admin_state is not None:
|
||||
attrs['admin_state_up'] = parsed_args.admin_state
|
||||
if parsed_args.shared is not None:
|
||||
attrs['shared'] = parsed_args.shared
|
||||
if parsed_args.enable:
|
||||
attrs['admin_state_up'] = True
|
||||
if parsed_args.disable:
|
||||
attrs['admin_state_up'] = False
|
||||
if parsed_args.share:
|
||||
attrs['shared'] = True
|
||||
if parsed_args.no_share:
|
||||
attrs['shared'] = False
|
||||
|
||||
# "network set" command doesn't support setting project.
|
||||
if 'project' in parsed_args and parsed_args.project is not None:
|
||||
@ -79,8 +83,10 @@ def _get_attrs_compute(client_manager, parsed_args):
|
||||
attrs = {}
|
||||
if parsed_args.name is not None:
|
||||
attrs['label'] = str(parsed_args.name)
|
||||
if parsed_args.shared is not None:
|
||||
attrs['share_address'] = parsed_args.shared
|
||||
if parsed_args.share:
|
||||
attrs['share_address'] = True
|
||||
if parsed_args.no_share:
|
||||
attrs['share_address'] = False
|
||||
if parsed_args.subnet is not None:
|
||||
attrs['cidr'] = parsed_args.subnet
|
||||
|
||||
@ -99,15 +105,13 @@ class CreateNetwork(common.NetworkAndComputeShowOne):
|
||||
share_group = parser.add_mutually_exclusive_group()
|
||||
share_group.add_argument(
|
||||
'--share',
|
||||
dest='shared',
|
||||
action='store_true',
|
||||
default=None,
|
||||
help='Share the network between projects',
|
||||
)
|
||||
share_group.add_argument(
|
||||
'--no-share',
|
||||
dest='shared',
|
||||
action='store_false',
|
||||
action='store_true',
|
||||
help='Do not share the network between projects',
|
||||
)
|
||||
return parser
|
||||
@ -116,15 +120,13 @@ class CreateNetwork(common.NetworkAndComputeShowOne):
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
admin_group.add_argument(
|
||||
'--enable',
|
||||
dest='admin_state',
|
||||
action='store_true',
|
||||
default=True,
|
||||
help='Enable network (default)',
|
||||
)
|
||||
admin_group.add_argument(
|
||||
'--disable',
|
||||
dest='admin_state',
|
||||
action='store_false',
|
||||
action='store_true',
|
||||
help='Disable network',
|
||||
)
|
||||
parser.add_argument(
|
||||
@ -301,29 +303,25 @@ class SetNetwork(command.Command):
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
admin_group.add_argument(
|
||||
'--enable',
|
||||
dest='admin_state',
|
||||
action='store_true',
|
||||
default=None,
|
||||
help='Enable network',
|
||||
)
|
||||
admin_group.add_argument(
|
||||
'--disable',
|
||||
dest='admin_state',
|
||||
action='store_false',
|
||||
action='store_true',
|
||||
help='Disable network',
|
||||
)
|
||||
share_group = parser.add_mutually_exclusive_group()
|
||||
share_group.add_argument(
|
||||
'--share',
|
||||
dest='shared',
|
||||
action='store_true',
|
||||
default=None,
|
||||
help='Share the network between projects',
|
||||
)
|
||||
share_group.add_argument(
|
||||
'--no-share',
|
||||
dest='shared',
|
||||
action='store_false',
|
||||
action='store_true',
|
||||
help='Do not share the network between projects',
|
||||
)
|
||||
return parser
|
||||
|
@ -86,8 +86,10 @@ def _get_attrs(client_manager, parsed_args):
|
||||
attrs['device_id'] = parsed_args.device
|
||||
if parsed_args.device_owner is not None:
|
||||
attrs['device_owner'] = parsed_args.device_owner
|
||||
if parsed_args.admin_state is not None:
|
||||
attrs['admin_state_up'] = parsed_args.admin_state
|
||||
if parsed_args.enable:
|
||||
attrs['admin_state_up'] = True
|
||||
if parsed_args.disable:
|
||||
attrs['admin_state_up'] = False
|
||||
if parsed_args.binding_profile is not None:
|
||||
attrs['binding:profile'] = parsed_args.binding_profile
|
||||
if parsed_args.vnic_type is not None:
|
||||
@ -217,15 +219,13 @@ class CreatePort(command.ShowOne):
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
admin_group.add_argument(
|
||||
'--enable',
|
||||
dest='admin_state',
|
||||
action='store_true',
|
||||
default=True,
|
||||
help='Enable port (default)',
|
||||
)
|
||||
admin_group.add_argument(
|
||||
'--disable',
|
||||
dest='admin_state',
|
||||
action='store_false',
|
||||
action='store_true',
|
||||
help='Disable port',
|
||||
)
|
||||
parser.add_argument(
|
||||
@ -333,15 +333,13 @@ class SetPort(command.Command):
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
admin_group.add_argument(
|
||||
'--enable',
|
||||
dest='admin_state',
|
||||
action='store_true',
|
||||
default=None,
|
||||
help='Enable port',
|
||||
)
|
||||
admin_group.add_argument(
|
||||
'--disable',
|
||||
dest='admin_state',
|
||||
action='store_false',
|
||||
action='store_true',
|
||||
help='Disable port',
|
||||
)
|
||||
parser.add_argument(
|
||||
|
@ -53,10 +53,15 @@ def _get_attrs(client_manager, parsed_args):
|
||||
attrs = {}
|
||||
if parsed_args.name is not None:
|
||||
attrs['name'] = str(parsed_args.name)
|
||||
if parsed_args.admin_state_up is not None:
|
||||
attrs['admin_state_up'] = parsed_args.admin_state_up
|
||||
if parsed_args.distributed is not None:
|
||||
attrs['distributed'] = parsed_args.distributed
|
||||
if parsed_args.enable:
|
||||
attrs['admin_state_up'] = True
|
||||
if parsed_args.disable:
|
||||
attrs['admin_state_up'] = False
|
||||
# centralized is available only for SetRouter and not for CreateRouter
|
||||
if 'centralized' in parsed_args and parsed_args.centralized:
|
||||
attrs['distributed'] = False
|
||||
if parsed_args.distributed:
|
||||
attrs['distributed'] = True
|
||||
if ('availability_zone_hints' in parsed_args
|
||||
and parsed_args.availability_zone_hints is not None):
|
||||
attrs['availability_zone_hints'] = parsed_args.availability_zone_hints
|
||||
@ -95,15 +100,13 @@ class CreateRouter(command.ShowOne):
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
admin_group.add_argument(
|
||||
'--enable',
|
||||
dest='admin_state_up',
|
||||
action='store_true',
|
||||
default=True,
|
||||
help="Enable router (default)",
|
||||
)
|
||||
admin_group.add_argument(
|
||||
'--disable',
|
||||
dest='admin_state_up',
|
||||
action='store_false',
|
||||
action='store_true',
|
||||
help="Disable router",
|
||||
)
|
||||
parser.add_argument(
|
||||
@ -235,29 +238,24 @@ class SetRouter(command.Command):
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
admin_group.add_argument(
|
||||
'--enable',
|
||||
dest='admin_state_up',
|
||||
action='store_true',
|
||||
default=None,
|
||||
help='Enable router',
|
||||
)
|
||||
admin_group.add_argument(
|
||||
'--disable',
|
||||
dest='admin_state_up',
|
||||
action='store_false',
|
||||
action='store_true',
|
||||
help='Disable router',
|
||||
)
|
||||
distribute_group = parser.add_mutually_exclusive_group()
|
||||
distribute_group.add_argument(
|
||||
'--distributed',
|
||||
dest='distributed',
|
||||
action='store_true',
|
||||
default=None,
|
||||
help="Set router to distributed mode (disabled router only)",
|
||||
)
|
||||
distribute_group.add_argument(
|
||||
'--centralized',
|
||||
dest='distributed',
|
||||
action='store_false',
|
||||
action='store_true',
|
||||
help="Set router to centralized mode (disabled router only)",
|
||||
)
|
||||
routes_group = parser.add_mutually_exclusive_group()
|
||||
@ -275,7 +273,6 @@ class SetRouter(command.Command):
|
||||
)
|
||||
routes_group.add_argument(
|
||||
'--clear-routes',
|
||||
dest='clear_routes',
|
||||
action='store_true',
|
||||
help="Clear routes associated with the router",
|
||||
)
|
||||
|
@ -116,8 +116,8 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
||||
]
|
||||
verifylist = [
|
||||
('name', self._network.name),
|
||||
('admin_state', True),
|
||||
('shared', None),
|
||||
('enable', True),
|
||||
('share', None),
|
||||
('project', None),
|
||||
]
|
||||
|
||||
@ -141,8 +141,8 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
||||
self._network.name,
|
||||
]
|
||||
verifylist = [
|
||||
('admin_state', False),
|
||||
('shared', True),
|
||||
('disable', True),
|
||||
('share', True),
|
||||
('project', identity_fakes_v3.project_name),
|
||||
('project_domain', identity_fakes_v3.domain_name),
|
||||
('availability_zone_hints', ["nova"]),
|
||||
@ -169,8 +169,8 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
||||
self._network.name,
|
||||
]
|
||||
verifylist = [
|
||||
('admin_state', True),
|
||||
('shared', False),
|
||||
('enable', True),
|
||||
('no_share', True),
|
||||
('name', self._network.name),
|
||||
]
|
||||
|
||||
@ -249,8 +249,8 @@ class TestCreateNetworkIdentityV2(TestNetwork):
|
||||
self._network.name,
|
||||
]
|
||||
verifylist = [
|
||||
('admin_state', True),
|
||||
('shared', None),
|
||||
('enable', True),
|
||||
('share', None),
|
||||
('name', self._network.name),
|
||||
('project', identity_fakes_v2.project_name),
|
||||
]
|
||||
@ -273,8 +273,8 @@ class TestCreateNetworkIdentityV2(TestNetwork):
|
||||
self._network.name,
|
||||
]
|
||||
verifylist = [
|
||||
('admin_state', True),
|
||||
('shared', None),
|
||||
('enable', True),
|
||||
('share', None),
|
||||
('project', identity_fakes_v3.project_name),
|
||||
('project_domain', identity_fakes_v3.domain_name),
|
||||
('name', self._network.name),
|
||||
@ -455,9 +455,9 @@ class TestSetNetwork(TestNetwork):
|
||||
]
|
||||
verifylist = [
|
||||
('network', self._network.name),
|
||||
('admin_state', True),
|
||||
('enable', True),
|
||||
('name', 'noob'),
|
||||
('shared', True),
|
||||
('share', True),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -480,8 +480,8 @@ class TestSetNetwork(TestNetwork):
|
||||
]
|
||||
verifylist = [
|
||||
('network', self._network.name),
|
||||
('admin_state', False),
|
||||
('shared', False),
|
||||
('disable', True),
|
||||
('no_share', True),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
@ -103,7 +103,7 @@ class TestCreatePort(TestPort):
|
||||
]
|
||||
verifylist = [
|
||||
('network', self._port.network_id,),
|
||||
('admin_state', True),
|
||||
('enable', True),
|
||||
('name', 'test-port'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -143,7 +143,7 @@ class TestCreatePort(TestPort):
|
||||
),
|
||||
('device', 'deviceid'),
|
||||
('device_owner', 'fakeowner'),
|
||||
('admin_state', False),
|
||||
('disable', True),
|
||||
('vnic_type', 'macvtap'),
|
||||
('binding_profile', {'foo': 'bar', 'foo2': 'bar2'}),
|
||||
('network', self._port.network_id),
|
||||
@ -301,7 +301,7 @@ class TestSetPort(TestPort):
|
||||
self._port.name,
|
||||
]
|
||||
verifylist = [
|
||||
('admin_state', False),
|
||||
('disable', True),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -322,7 +322,7 @@ class TestSetPort(TestPort):
|
||||
self._port.name,
|
||||
]
|
||||
verifylist = [
|
||||
('admin_state', True),
|
||||
('enable', True),
|
||||
('vnic_type', 'macvtap'),
|
||||
('binding_profile', {'foo': 'bar'}),
|
||||
('host', 'binding-host-id-xxxx'),
|
||||
|
@ -73,7 +73,7 @@ class TestCreateRouter(TestRouter):
|
||||
]
|
||||
verifylist = [
|
||||
('name', self.new_router.name),
|
||||
('admin_state_up', True),
|
||||
('enable', True),
|
||||
('distributed', False),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -83,7 +83,6 @@ class TestCreateRouter(TestRouter):
|
||||
self.network.create_router.assert_called_once_with(**{
|
||||
'admin_state_up': True,
|
||||
'name': self.new_router.name,
|
||||
'distributed': False,
|
||||
})
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, data)
|
||||
@ -97,7 +96,7 @@ class TestCreateRouter(TestRouter):
|
||||
verifylist = [
|
||||
('name', self.new_router.name),
|
||||
('availability_zone_hints', ['fake-az', 'fake-az2']),
|
||||
('admin_state_up', True),
|
||||
('enable', True),
|
||||
('distributed', False),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -106,7 +105,6 @@ class TestCreateRouter(TestRouter):
|
||||
self.network.create_router.assert_called_once_with(**{
|
||||
'admin_state_up': True,
|
||||
'name': self.new_router.name,
|
||||
'distributed': False,
|
||||
'availability_zone_hints': ['fake-az', 'fake-az2'],
|
||||
})
|
||||
|
||||
@ -252,7 +250,7 @@ class TestSetRouter(TestRouter):
|
||||
]
|
||||
verifylist = [
|
||||
('router', self._router.name),
|
||||
('admin_state_up', True),
|
||||
('enable', True),
|
||||
('distributed', True),
|
||||
('name', 'noob'),
|
||||
]
|
||||
@ -277,8 +275,8 @@ class TestSetRouter(TestRouter):
|
||||
]
|
||||
verifylist = [
|
||||
('router', self._router.name),
|
||||
('admin_state_up', False),
|
||||
('distributed', False),
|
||||
('disable', True),
|
||||
('centralized', True),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
Loading…
x
Reference in New Issue
Block a user