Now empty tags are not added to Networks
Added a check if the tag values is empty or not before adding that tag to the network. Change-Id: I92659da97fe829a7715d0bef5570a4d9c5db95da Closes-Bug: #1603292
This commit is contained in:
parent
2e60acdff2
commit
235c4e60aa
|
@ -50,6 +50,9 @@ class AddTag(neutronv20.NeutronCommand):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
client = self.get_client()
|
||||
if not parsed_args.tag:
|
||||
raise exceptions.CommandError(
|
||||
_('Cannot add an empty value as tag'))
|
||||
resource_type, resource_id = _convert_resource_args(client,
|
||||
parsed_args)
|
||||
client.add_tag(resource_type, resource_id, parsed_args.tag)
|
||||
|
|
|
@ -81,6 +81,14 @@ class CLITestV20Tag(test_cli20.CLITestV20Base):
|
|||
'--tag', 'red']
|
||||
self._test_tag_operation(cmd, path, 'PUT', args, "tag-add")
|
||||
|
||||
def test_add_tag_empty_tag(self):
|
||||
cmd = tag.AddTag(test_cli20.MyApp(sys.stdout), None)
|
||||
path = self._make_tag_path('network', 'myid', '')
|
||||
args = ['--resource-type', 'network', '--resource', 'myid',
|
||||
'--tag', '']
|
||||
self.assertRaises(exceptions.CommandError, self._test_tag_operation,
|
||||
cmd, path, 'PUT', args, "tag-add")
|
||||
|
||||
def test_replace_tag(self):
|
||||
cmd = tag.ReplaceTag(test_cli20.MyApp(sys.stdout), None)
|
||||
path = self._make_tags_path('network', 'myid')
|
||||
|
|
Loading…
Reference in New Issue