trivial: Use plural for appended parameters
Multiple compute commands take a '--property' parameter or variant thereof. These should be stored in a 'properties' (plural) dest for sanity's sake. Correct this. Change-Id: If393836925fa736404527d9abd212b8ac9931027 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
f200799848
commit
bbf7de83ff
@ -101,6 +101,7 @@ class CreateAggregate(command.ShowOne):
|
||||
"--property",
|
||||
metavar="<key=value>",
|
||||
action=parseractions.KeyValueAction,
|
||||
dest="properties",
|
||||
help=_("Property to add to this aggregate "
|
||||
"(repeat option to set multiple properties)")
|
||||
)
|
||||
@ -116,10 +117,10 @@ class CreateAggregate(command.ShowOne):
|
||||
|
||||
aggregate = compute_client.create_aggregate(**attrs)
|
||||
|
||||
if parsed_args.property:
|
||||
if parsed_args.properties:
|
||||
aggregate = compute_client.set_aggregate_metadata(
|
||||
aggregate.id,
|
||||
parsed_args.property,
|
||||
parsed_args.properties,
|
||||
)
|
||||
|
||||
display_columns, columns = _get_aggregate_columns(aggregate)
|
||||
@ -269,12 +270,12 @@ class SetAggregate(command.Command):
|
||||
"--property",
|
||||
metavar="<key=value>",
|
||||
action=parseractions.KeyValueAction,
|
||||
dest="properties",
|
||||
help=_("Property to set on <aggregate> "
|
||||
"(repeat option to set multiple properties)")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no-property",
|
||||
dest="no_property",
|
||||
action="store_true",
|
||||
help=_("Remove all properties from <aggregate> "
|
||||
"(specify both --property and --no-property to "
|
||||
@ -296,21 +297,20 @@ class SetAggregate(command.Command):
|
||||
if kwargs:
|
||||
compute_client.update_aggregate(aggregate.id, **kwargs)
|
||||
|
||||
set_property = {}
|
||||
properties = {}
|
||||
if parsed_args.no_property:
|
||||
# NOTE(RuiChen): "availability_zone" can not be unset from
|
||||
# properties. It is already excluded from show and create output.
|
||||
set_property.update({key: None
|
||||
for key in aggregate.metadata.keys()
|
||||
if key != 'availability_zone'})
|
||||
if parsed_args.property:
|
||||
set_property.update(parsed_args.property)
|
||||
properties.update({
|
||||
key: None for key in aggregate.metadata.keys()
|
||||
if key != 'availability_zone'
|
||||
})
|
||||
|
||||
if set_property:
|
||||
compute_client.set_aggregate_metadata(
|
||||
aggregate.id,
|
||||
set_property
|
||||
)
|
||||
if parsed_args.properties:
|
||||
properties.update(parsed_args.properties)
|
||||
|
||||
if properties:
|
||||
compute_client.set_aggregate_metadata(aggregate.id, properties)
|
||||
|
||||
|
||||
class ShowAggregate(command.ShowOne):
|
||||
@ -354,7 +354,9 @@ class UnsetAggregate(command.Command):
|
||||
parser.add_argument(
|
||||
"--property",
|
||||
metavar="<key>",
|
||||
action='append',
|
||||
action="append",
|
||||
default=[],
|
||||
dest="properties",
|
||||
help=_("Property to remove from aggregate "
|
||||
"(repeat option to remove multiple properties)")
|
||||
)
|
||||
@ -365,12 +367,10 @@ class UnsetAggregate(command.Command):
|
||||
aggregate = compute_client.find_aggregate(
|
||||
parsed_args.aggregate, ignore_missing=False)
|
||||
|
||||
unset_property = {}
|
||||
if parsed_args.property:
|
||||
unset_property.update({key: None for key in parsed_args.property})
|
||||
if unset_property:
|
||||
compute_client.set_aggregate_metadata(
|
||||
aggregate, unset_property)
|
||||
properties = {key: None for key in parsed_args.properties}
|
||||
|
||||
if properties:
|
||||
compute_client.set_aggregate_metadata(aggregate.id, properties)
|
||||
|
||||
|
||||
class CacheImageForAggregate(command.Command):
|
||||
|
@ -128,6 +128,7 @@ class CreateFlavor(command.ShowOne):
|
||||
"--property",
|
||||
metavar="<key=value>",
|
||||
action=parseractions.KeyValueAction,
|
||||
dest="properties",
|
||||
help=_("Property to add for this flavor "
|
||||
"(repeat option to set multiple properties)")
|
||||
)
|
||||
@ -191,12 +192,12 @@ class CreateFlavor(command.ShowOne):
|
||||
msg = _("Failed to add project %(project)s access to "
|
||||
"flavor: %(e)s")
|
||||
LOG.error(msg, {'project': parsed_args.project, 'e': e})
|
||||
if parsed_args.property:
|
||||
if parsed_args.properties:
|
||||
try:
|
||||
flavor = compute_client.create_flavor_extra_specs(
|
||||
flavor, parsed_args.property)
|
||||
flavor, parsed_args.properties)
|
||||
except Exception as e:
|
||||
LOG.error(_("Failed to set flavor property: %s"), e)
|
||||
LOG.error(_("Failed to set flavor properties: %s"), e)
|
||||
|
||||
display_columns, columns = _get_flavor_columns(flavor)
|
||||
data = utils.get_dict_properties(flavor, columns,
|
||||
@ -398,6 +399,7 @@ class SetFlavor(command.Command):
|
||||
"--property",
|
||||
metavar="<key=value>",
|
||||
action=parseractions.KeyValueAction,
|
||||
dest="properties",
|
||||
help=_("Property to add or modify for this flavor "
|
||||
"(repeat option to set multiple properties)")
|
||||
)
|
||||
@ -447,15 +449,15 @@ class SetFlavor(command.Command):
|
||||
compute_client.delete_flavor_extra_specs_property(
|
||||
flavor.id, key)
|
||||
except Exception as e:
|
||||
LOG.error(_("Failed to clear flavor property: %s"), e)
|
||||
LOG.error(_("Failed to clear flavor properties: %s"), e)
|
||||
result += 1
|
||||
|
||||
if parsed_args.property:
|
||||
if parsed_args.properties:
|
||||
try:
|
||||
compute_client.create_flavor_extra_specs(
|
||||
flavor.id, parsed_args.property)
|
||||
flavor.id, parsed_args.properties)
|
||||
except Exception as e:
|
||||
LOG.error(_("Failed to set flavor property: %s"), e)
|
||||
LOG.error(_("Failed to set flavor properties: %s"), e)
|
||||
result += 1
|
||||
|
||||
if parsed_args.project:
|
||||
@ -537,6 +539,7 @@ class UnsetFlavor(command.Command):
|
||||
"--property",
|
||||
metavar="<key>",
|
||||
action='append',
|
||||
dest="properties",
|
||||
help=_("Property to remove from flavor "
|
||||
"(repeat option to unset multiple properties)")
|
||||
)
|
||||
@ -563,8 +566,8 @@ class UnsetFlavor(command.Command):
|
||||
raise exceptions.CommandError(_(e.message))
|
||||
|
||||
result = 0
|
||||
if parsed_args.property:
|
||||
for key in parsed_args.property:
|
||||
if parsed_args.properties:
|
||||
for key in parsed_args.properties:
|
||||
try:
|
||||
compute_client.delete_flavor_extra_specs_property(
|
||||
flavor.id, key)
|
||||
|
@ -614,6 +614,7 @@ class CreateServer(command.ShowOne):
|
||||
'--image-property',
|
||||
metavar='<key=value>',
|
||||
action=parseractions.KeyValueAction,
|
||||
dest='image_properties',
|
||||
help=_("Image property to be matched"),
|
||||
)
|
||||
disk_group.add_argument(
|
||||
@ -659,6 +660,7 @@ class CreateServer(command.ShowOne):
|
||||
'--property',
|
||||
metavar='<key=value>',
|
||||
action=parseractions.KeyValueAction,
|
||||
dest='properties',
|
||||
help=_(
|
||||
'Set a property on this server '
|
||||
'(repeat option to set multiple values)'
|
||||
@ -886,8 +888,8 @@ class CreateServer(command.ShowOne):
|
||||
image = image_client.find_image(
|
||||
parsed_args.image, ignore_missing=False)
|
||||
|
||||
if not image and parsed_args.image_property:
|
||||
def emit_duplicated_warning(img, image_property):
|
||||
if not image and parsed_args.image_properties:
|
||||
def emit_duplicated_warning(img):
|
||||
img_uuid_list = [str(image.id) for image in img]
|
||||
LOG.warning(
|
||||
'Multiple matching images: %(img_uuid_list)s\n'
|
||||
@ -930,9 +932,9 @@ class CreateServer(command.ShowOne):
|
||||
|
||||
return images_matched
|
||||
|
||||
images = _match_image(image_client, parsed_args.image_property)
|
||||
images = _match_image(image_client, parsed_args.image_properties)
|
||||
if len(images) > 1:
|
||||
emit_duplicated_warning(images, parsed_args.image_property)
|
||||
emit_duplicated_warning(images, parsed_args.image_properties)
|
||||
if images:
|
||||
image = images[0]
|
||||
else:
|
||||
@ -1195,7 +1197,7 @@ class CreateServer(command.ShowOne):
|
||||
config_drive = parsed_args.config_drive
|
||||
|
||||
boot_kwargs = dict(
|
||||
meta=parsed_args.property,
|
||||
meta=parsed_args.properties,
|
||||
files=files,
|
||||
reservation_id=None,
|
||||
min_count=parsed_args.min,
|
||||
@ -2473,6 +2475,7 @@ class RebuildServer(command.ShowOne):
|
||||
'--property',
|
||||
metavar='<key=value>',
|
||||
action=parseractions.KeyValueAction,
|
||||
dest='properties',
|
||||
help=_(
|
||||
'Set a new property on the rebuilt server '
|
||||
'(repeat option to set multiple values)'
|
||||
@ -2614,8 +2617,8 @@ class RebuildServer(command.ShowOne):
|
||||
if parsed_args.preserve_ephemeral is not None:
|
||||
kwargs['preserve_ephemeral'] = parsed_args.preserve_ephemeral
|
||||
|
||||
if parsed_args.property:
|
||||
kwargs['meta'] = parsed_args.property
|
||||
if parsed_args.properties:
|
||||
kwargs['meta'] = parsed_args.properties
|
||||
|
||||
if parsed_args.description:
|
||||
if compute_client.api_version < api_versions.APIVersion('2.19'):
|
||||
@ -3278,9 +3281,10 @@ class SetServer(command.Command):
|
||||
help=_('Set new root password (interactive only)'),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--property",
|
||||
metavar="<key=value>",
|
||||
'--property',
|
||||
metavar='<key=value>',
|
||||
action=parseractions.KeyValueAction,
|
||||
dest='properties',
|
||||
help=_('Property to add/change for this server '
|
||||
'(repeat option to set multiple properties)'),
|
||||
)
|
||||
@ -3321,11 +3325,8 @@ class SetServer(command.Command):
|
||||
if parsed_args.name:
|
||||
server.update(name=parsed_args.name)
|
||||
|
||||
if parsed_args.property:
|
||||
compute_client.servers.set_meta(
|
||||
server,
|
||||
parsed_args.property,
|
||||
)
|
||||
if parsed_args.properties:
|
||||
compute_client.servers.set_meta(server, parsed_args.properties)
|
||||
|
||||
if parsed_args.state:
|
||||
server.reset_state(state=parsed_args.state)
|
||||
@ -3740,6 +3741,7 @@ class UnsetServer(command.Command):
|
||||
metavar='<key>',
|
||||
action='append',
|
||||
default=[],
|
||||
dest='properties',
|
||||
help=_('Property key to remove from server '
|
||||
'(repeat option to remove multiple values)'),
|
||||
)
|
||||
@ -3771,11 +3773,8 @@ class UnsetServer(command.Command):
|
||||
parsed_args.server,
|
||||
)
|
||||
|
||||
if parsed_args.property:
|
||||
compute_client.servers.delete_meta(
|
||||
server,
|
||||
parsed_args.property,
|
||||
)
|
||||
if parsed_args.properties:
|
||||
compute_client.servers.delete_meta(server, parsed_args.properties)
|
||||
|
||||
if parsed_args.description:
|
||||
if compute_client.api_version < api_versions.APIVersion("2.19"):
|
||||
|
@ -138,7 +138,7 @@ class TestAggregateCreate(TestAggregate):
|
||||
'ag1',
|
||||
]
|
||||
verifylist = [
|
||||
('property', {'key1': 'value1', 'key2': 'value2'}),
|
||||
('properties', {'key1': 'value1', 'key2': 'value2'}),
|
||||
('name', 'ag1'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -146,7 +146,7 @@ class TestAggregateCreate(TestAggregate):
|
||||
self.sdk_client.create_aggregate.assert_called_once_with(
|
||||
name=parsed_args.name)
|
||||
self.sdk_client.set_aggregate_metadata.assert_called_once_with(
|
||||
self.fake_ag.id, parsed_args.property)
|
||||
self.fake_ag.id, parsed_args.properties)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertItemsEqual(self.data, data)
|
||||
|
||||
@ -378,7 +378,7 @@ class TestAggregateSet(TestAggregate):
|
||||
'ag1',
|
||||
]
|
||||
verifylist = [
|
||||
('property', {'key1': 'value1', 'key2': 'value2'}),
|
||||
('properties', {'key1': 'value1', 'key2': 'value2'}),
|
||||
('aggregate', 'ag1'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -388,7 +388,7 @@ class TestAggregateSet(TestAggregate):
|
||||
parsed_args.aggregate, ignore_missing=False)
|
||||
self.assertNotCalled(self.sdk_client.update_aggregate)
|
||||
self.sdk_client.set_aggregate_metadata.assert_called_once_with(
|
||||
self.fake_ag.id, parsed_args.property)
|
||||
self.fake_ag.id, parsed_args.properties)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_aggregate_set_with_no_property_and_property(self):
|
||||
@ -399,7 +399,7 @@ class TestAggregateSet(TestAggregate):
|
||||
]
|
||||
verifylist = [
|
||||
('no_property', True),
|
||||
('property', {'key2': 'value2'}),
|
||||
('properties', {'key2': 'value2'}),
|
||||
('aggregate', 'ag1'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -509,14 +509,14 @@ class TestAggregateUnset(TestAggregate):
|
||||
'ag1',
|
||||
]
|
||||
verifylist = [
|
||||
('property', ['unset_key']),
|
||||
('properties', ['unset_key']),
|
||||
('aggregate', 'ag1'),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.sdk_client.set_aggregate_metadata.assert_called_once_with(
|
||||
self.fake_ag, {'unset_key': None})
|
||||
self.fake_ag.id, {'unset_key': None})
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_aggregate_unset_multiple_properties(self):
|
||||
@ -526,14 +526,14 @@ class TestAggregateUnset(TestAggregate):
|
||||
'ag1',
|
||||
]
|
||||
verifylist = [
|
||||
('property', ['unset_key1', 'unset_key2']),
|
||||
('properties', ['unset_key1', 'unset_key2']),
|
||||
('aggregate', 'ag1'),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.sdk_client.set_aggregate_metadata.assert_called_once_with(
|
||||
self.fake_ag, {'unset_key1': None, 'unset_key2': None})
|
||||
self.fake_ag.id, {'unset_key1': None, 'unset_key2': None})
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_aggregate_unset_no_option(self):
|
||||
@ -541,7 +541,7 @@ class TestAggregateUnset(TestAggregate):
|
||||
'ag1',
|
||||
]
|
||||
verifylist = [
|
||||
('property', None),
|
||||
('properties', []),
|
||||
('aggregate', 'ag1'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
@ -160,7 +160,7 @@ class TestFlavorCreate(TestFlavor):
|
||||
('rxtx_factor', self.flavor.rxtx_factor),
|
||||
('public', True),
|
||||
('description', self.flavor.description),
|
||||
('property', {'property': 'value'}),
|
||||
('properties', {'property': 'value'}),
|
||||
('name', self.flavor.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -232,7 +232,7 @@ class TestFlavorCreate(TestFlavor):
|
||||
('public', False),
|
||||
('description', 'description'),
|
||||
('project', self.project.id),
|
||||
('property', {'key1': 'value1', 'key2': 'value2'}),
|
||||
('properties', {'key1': 'value1', 'key2': 'value2'}),
|
||||
('name', self.flavor.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -688,7 +688,7 @@ class TestFlavorSet(TestFlavor):
|
||||
'baremetal'
|
||||
]
|
||||
verifylist = [
|
||||
('property', {'FOO': '"B A R"'}),
|
||||
('properties', {'FOO': '"B A R"'}),
|
||||
('flavor', 'baremetal')
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -1017,7 +1017,7 @@ class TestFlavorUnset(TestFlavor):
|
||||
'baremetal'
|
||||
]
|
||||
verifylist = [
|
||||
('property', ['property']),
|
||||
('properties', ['property']),
|
||||
('flavor', 'baremetal'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -1039,7 +1039,7 @@ class TestFlavorUnset(TestFlavor):
|
||||
'baremetal'
|
||||
]
|
||||
verifylist = [
|
||||
('property', ['property1', 'property2']),
|
||||
('properties', ['property1', 'property2']),
|
||||
('flavor', 'baremetal'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
@ -1159,7 +1159,7 @@ class TestServerCreate(TestServer):
|
||||
('image', 'image1'),
|
||||
('flavor', 'flavor1'),
|
||||
('key_name', 'keyname'),
|
||||
('property', {'Beta': 'b'}),
|
||||
('properties', {'Beta': 'b'}),
|
||||
('security_group', ['securitygroup']),
|
||||
('hint', {'a': ['b', 'c']}),
|
||||
('config_drive', True),
|
||||
@ -2227,7 +2227,7 @@ class TestServerCreate(TestServer):
|
||||
self.new_server.name,
|
||||
]
|
||||
verifylist = [
|
||||
('image_property', {'hypervisor_type': 'qemu'}),
|
||||
('image_properties', {'hypervisor_type': 'qemu'}),
|
||||
('flavor', 'flavor1'),
|
||||
('nic', ['none']),
|
||||
('config_drive', False),
|
||||
@ -2282,7 +2282,7 @@ class TestServerCreate(TestServer):
|
||||
self.new_server.name,
|
||||
]
|
||||
verifylist = [
|
||||
('image_property', {'hypervisor_type': 'qemu',
|
||||
('image_properties', {'hypervisor_type': 'qemu',
|
||||
'hw_disk_bus': 'ide'}),
|
||||
('flavor', 'flavor1'),
|
||||
('nic', ['none']),
|
||||
@ -2338,7 +2338,7 @@ class TestServerCreate(TestServer):
|
||||
self.new_server.name,
|
||||
]
|
||||
verifylist = [
|
||||
('image_property', {'hypervisor_type': 'qemu',
|
||||
('image_properties', {'hypervisor_type': 'qemu',
|
||||
'hw_disk_bus': 'virtio'}),
|
||||
('flavor', 'flavor1'),
|
||||
('nic', ['none']),
|
||||
@ -2370,7 +2370,7 @@ class TestServerCreate(TestServer):
|
||||
]
|
||||
|
||||
verifylist = [
|
||||
('image_property',
|
||||
('image_properties',
|
||||
{'owner_specified.openstack.object': 'image/cirros'}),
|
||||
('flavor', 'flavor1'),
|
||||
('nic', ['none']),
|
||||
@ -4973,10 +4973,10 @@ class TestServerRebuild(TestServer):
|
||||
'--property', 'key1=value1',
|
||||
'--property', 'key2=value2'
|
||||
]
|
||||
expected_property = {'key1': 'value1', 'key2': 'value2'}
|
||||
expected_properties = {'key1': 'value1', 'key2': 'value2'}
|
||||
verifylist = [
|
||||
('server', self.server.id),
|
||||
('property', expected_property)
|
||||
('properties', expected_properties)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -4986,7 +4986,7 @@ class TestServerRebuild(TestServer):
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.get_image_mock.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, meta=expected_property)
|
||||
self.image, None, meta=expected_properties)
|
||||
|
||||
def test_rebuild_with_keypair_name(self):
|
||||
self.app.client_manager.compute.api_version = \
|
||||
@ -6145,13 +6145,13 @@ class TestServerSet(TestServer):
|
||||
'foo_vm',
|
||||
]
|
||||
verifylist = [
|
||||
('property', {'key1': 'value1', 'key2': 'value2'}),
|
||||
('properties', {'key1': 'value1', 'key2': 'value2'}),
|
||||
('server', 'foo_vm'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.servers_mock.set_meta.assert_called_once_with(
|
||||
self.fake_servers[0], parsed_args.property)
|
||||
self.fake_servers[0], parsed_args.properties)
|
||||
self.assertIsNone(result)
|
||||
|
||||
@mock.patch.object(getpass, 'getpass',
|
||||
@ -6579,7 +6579,7 @@ class TestServerUnset(TestServer):
|
||||
'foo_vm',
|
||||
]
|
||||
verifylist = [
|
||||
('property', ['key1', 'key2']),
|
||||
('properties', ['key1', 'key2']),
|
||||
('server', 'foo_vm'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
Loading…
x
Reference in New Issue
Block a user