Merge "Make set/unset command in identity and image pass normally when nothing specified"
This commit is contained in:
commit
1464c8a237
openstackclient
identity/v2_0
image/v2
tests
releasenotes/notes
@ -189,13 +189,6 @@ class SetProject(command.Command):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
if (not parsed_args.name
|
|
||||||
and not parsed_args.description
|
|
||||||
and not parsed_args.enable
|
|
||||||
and not parsed_args.property
|
|
||||||
and not parsed_args.disable):
|
|
||||||
return
|
|
||||||
|
|
||||||
project = utils.find_resource(
|
project = utils.find_resource(
|
||||||
identity_client.tenants,
|
identity_client.tenants,
|
||||||
parsed_args.project,
|
parsed_args.project,
|
||||||
@ -295,7 +288,6 @@ class UnsetProject(command.Command):
|
|||||||
metavar='<key>',
|
metavar='<key>',
|
||||||
action='append',
|
action='append',
|
||||||
default=[],
|
default=[],
|
||||||
required=True,
|
|
||||||
help=_('Unset a project property '
|
help=_('Unset a project property '
|
||||||
'(repeat option to unset multiple properties)'),
|
'(repeat option to unset multiple properties)'),
|
||||||
)
|
)
|
||||||
@ -307,9 +299,6 @@ class UnsetProject(command.Command):
|
|||||||
identity_client.tenants,
|
identity_client.tenants,
|
||||||
parsed_args.project,
|
parsed_args.project,
|
||||||
)
|
)
|
||||||
if not parsed_args.property:
|
|
||||||
self.app.log.error(_("No changes requested\n"))
|
|
||||||
else:
|
|
||||||
kwargs = project._info
|
kwargs = project._info
|
||||||
for key in parsed_args.property:
|
for key in parsed_args.property:
|
||||||
if key in kwargs:
|
if key in kwargs:
|
||||||
|
@ -287,15 +287,6 @@ class SetUser(command.Command):
|
|||||||
if parsed_args.password_prompt:
|
if parsed_args.password_prompt:
|
||||||
parsed_args.password = utils.get_password(self.app.stdin)
|
parsed_args.password = utils.get_password(self.app.stdin)
|
||||||
|
|
||||||
if (not parsed_args.name
|
|
||||||
and not parsed_args.name
|
|
||||||
and not parsed_args.password
|
|
||||||
and not parsed_args.email
|
|
||||||
and not parsed_args.project
|
|
||||||
and not parsed_args.enable
|
|
||||||
and not parsed_args.disable):
|
|
||||||
return
|
|
||||||
|
|
||||||
user = utils.find_resource(
|
user = utils.find_resource(
|
||||||
identity_client.users,
|
identity_client.users,
|
||||||
parsed_args.user,
|
parsed_args.user,
|
||||||
|
@ -817,11 +817,6 @@ class SetImage(command.Command):
|
|||||||
parsed_args.project_domain,
|
parsed_args.project_domain,
|
||||||
).id
|
).id
|
||||||
|
|
||||||
# Checks if anything that requires getting the image
|
|
||||||
if not (kwargs or parsed_args.deactivate or parsed_args.activate):
|
|
||||||
msg = _("No arguments specified")
|
|
||||||
raise exceptions.CommandError(msg)
|
|
||||||
|
|
||||||
image = utils.find_resource(
|
image = utils.find_resource(
|
||||||
image_client.images, parsed_args.image)
|
image_client.images, parsed_args.image)
|
||||||
|
|
||||||
@ -833,10 +828,6 @@ class SetImage(command.Command):
|
|||||||
image_client.images.reactivate(image.id)
|
image_client.images.reactivate(image.id)
|
||||||
activation_status = "activated"
|
activation_status = "activated"
|
||||||
|
|
||||||
# Check if need to do the actual update
|
|
||||||
if not kwargs:
|
|
||||||
return {}, {}
|
|
||||||
|
|
||||||
if parsed_args.tags:
|
if parsed_args.tags:
|
||||||
# Tags should be extended, but duplicates removed
|
# Tags should be extended, but duplicates removed
|
||||||
kwargs['tags'] = list(set(image.tags).union(set(parsed_args.tags)))
|
kwargs['tags'] = list(set(image.tags).union(set(parsed_args.tags)))
|
||||||
@ -909,10 +900,6 @@ class UnsetImage(command.Command):
|
|||||||
parsed_args.image,
|
parsed_args.image,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not (parsed_args.tags or parsed_args.properties):
|
|
||||||
msg = _("No arguments specified")
|
|
||||||
raise exceptions.CommandError(msg)
|
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
tagret = 0
|
tagret = 0
|
||||||
propret = 0
|
propret = 0
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
|
from osc_lib import exceptions
|
||||||
|
|
||||||
from openstackclient.identity.v2_0 import project
|
from openstackclient.identity.v2_0 import project
|
||||||
from openstackclient.tests import fakes
|
from openstackclient.tests import fakes
|
||||||
@ -410,6 +411,26 @@ class TestProjectSet(TestProject):
|
|||||||
|
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_project_set_unexist_project(self):
|
||||||
|
arglist = [
|
||||||
|
"unexist-project",
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('project', "unexist-project"),
|
||||||
|
('name', None),
|
||||||
|
('description', None),
|
||||||
|
('enable', False),
|
||||||
|
('disable', False),
|
||||||
|
('property', None),
|
||||||
|
]
|
||||||
|
self.projects_mock.get.side_effect = exceptions.NotFound(None)
|
||||||
|
self.projects_mock.find.side_effect = exceptions.NotFound(None)
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
self.assertRaises(
|
||||||
|
exceptions.CommandError, self.cmd.take_action, parsed_args)
|
||||||
|
|
||||||
def test_project_set_name(self):
|
def test_project_set_name(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--name', 'qwerty',
|
'--name', 'qwerty',
|
||||||
@ -604,6 +625,19 @@ class TestProjectUnset(TestProject):
|
|||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = project.UnsetProject(self.app, None)
|
self.cmd = project.UnsetProject(self.app, None)
|
||||||
|
|
||||||
|
def test_project_unset_no_options(self):
|
||||||
|
arglist = [
|
||||||
|
identity_fakes.project_name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('project', identity_fakes.project_name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_project_unset_key(self):
|
def test_project_unset_key(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--property', 'fee',
|
'--property', 'fee',
|
||||||
|
@ -17,6 +17,7 @@ import copy
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from keystoneauth1 import exceptions as ks_exc
|
from keystoneauth1 import exceptions as ks_exc
|
||||||
|
from osc_lib import exceptions
|
||||||
|
|
||||||
from openstackclient.identity.v2_0 import user
|
from openstackclient.identity.v2_0 import user
|
||||||
from openstackclient.tests import fakes
|
from openstackclient.tests import fakes
|
||||||
@ -563,6 +564,27 @@ class TestUserSet(TestUser):
|
|||||||
|
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_user_set_unexist_user(self):
|
||||||
|
arglist = [
|
||||||
|
"unexist-user",
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('name', None),
|
||||||
|
('password', None),
|
||||||
|
('email', None),
|
||||||
|
('project', None),
|
||||||
|
('enable', False),
|
||||||
|
('disable', False),
|
||||||
|
('user', "unexist-user"),
|
||||||
|
]
|
||||||
|
self.users_mock.get.side_effect = exceptions.NotFound(None)
|
||||||
|
self.users_mock.find.side_effect = exceptions.NotFound(None)
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
self.assertRaises(
|
||||||
|
exceptions.CommandError, self.cmd.take_action, parsed_args)
|
||||||
|
|
||||||
def test_user_set_name(self):
|
def test_user_set_name(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--name', 'qwerty',
|
'--name', 'qwerty',
|
||||||
|
@ -842,6 +842,19 @@ class TestImageSet(TestImage):
|
|||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = image.SetImage(self.app, None)
|
self.cmd = image.SetImage(self.app, None)
|
||||||
|
|
||||||
|
def test_image_set_no_options(self):
|
||||||
|
arglist = [
|
||||||
|
image_fakes.image_id,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('image', image_fakes.image_id)
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_image_set_options(self):
|
def test_image_set_options(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--name', 'new-name',
|
'--name', 'new-name',
|
||||||
@ -1242,6 +1255,19 @@ class TestImageUnset(TestImage):
|
|||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = image.UnsetImage(self.app, None)
|
self.cmd = image.UnsetImage(self.app, None)
|
||||||
|
|
||||||
|
def test_image_unset_no_options(self):
|
||||||
|
arglist = [
|
||||||
|
image_fakes.image_id,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('image', image_fakes.image_id)
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_image_unset_tag_option(self):
|
def test_image_unset_tag_option(self):
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
upgrade:
|
upgrade:
|
||||||
- All ``set`` and ``unset`` commands in network and volume now return
|
- All ``set`` and ``unset`` commands in network, identity, image, and volume now
|
||||||
normally when nothing specified to modify. This will become the default
|
return normally when nothing specified to modify. This will become the default
|
||||||
behavior of OSC ``set`` and ``unset`` commands.
|
behavior of OSC ``set`` and ``unset`` commands.
|
||||||
[Bug `1588588 <https://bugs.launchpad.net/python-openstackclient/+bug/1588588>`_]
|
[Bug `1588588 <https://bugs.launchpad.net/python-openstackclient/+bug/1588588>`_]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user