Merge "Make set/unset commands pass normally when nothing specified in identityv3"
This commit is contained in:
commit
13f1aa9b81
@ -15,8 +15,6 @@
|
||||
|
||||
"""Identity v3 Consumer action implementations"""
|
||||
|
||||
import sys
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
import six
|
||||
@ -102,10 +100,6 @@ class SetConsumer(command.Command):
|
||||
if parsed_args.description:
|
||||
kwargs['description'] = parsed_args.description
|
||||
|
||||
if not len(kwargs):
|
||||
sys.stdout.write(_('Consumer not updated, no arguments present\n'))
|
||||
return
|
||||
|
||||
consumer = identity_client.oauth1.consumers.update(
|
||||
consumer.id, **kwargs)
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
"""Identity v3 Domain action implementations"""
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from keystoneauth1 import exceptions as ks_exc
|
||||
from osc_lib.command import command
|
||||
@ -168,9 +167,6 @@ class SetDomain(command.Command):
|
||||
if parsed_args.disable:
|
||||
kwargs['enabled'] = False
|
||||
|
||||
if not kwargs:
|
||||
sys.stdout.write(_("Domain not updated, no arguments present\n"))
|
||||
return
|
||||
identity_client.domains.update(domain.id, **kwargs)
|
||||
|
||||
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
"""Identity v3 Endpoint action implementations"""
|
||||
|
||||
import sys
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
import six
|
||||
@ -212,12 +210,6 @@ class SetEndpoint(command.Command):
|
||||
endpoint = utils.find_resource(identity_client.endpoints,
|
||||
parsed_args.endpoint)
|
||||
|
||||
if (not parsed_args.interface and not parsed_args.url
|
||||
and not parsed_args.service and not parsed_args.region
|
||||
and not parsed_args.enabled and not parsed_args.disabled):
|
||||
sys.stdout.write(_("Endpoint not updated, no arguments present\n"))
|
||||
return
|
||||
|
||||
service_id = None
|
||||
if parsed_args.service:
|
||||
service = common.find_service(identity_client, parsed_args.service)
|
||||
|
@ -149,10 +149,6 @@ class SetProtocol(command.Command):
|
||||
def take_action(self, parsed_args):
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
if not parsed_args.mapping:
|
||||
LOG.error(_("No changes requested"))
|
||||
return
|
||||
|
||||
protocol = identity_client.federation.protocols.update(
|
||||
parsed_args.identity_provider, parsed_args.federation_protocol,
|
||||
parsed_args.mapping)
|
||||
|
@ -343,9 +343,6 @@ class SetGroup(command.Command):
|
||||
if parsed_args.description:
|
||||
kwargs['description'] = parsed_args.description
|
||||
|
||||
if not len(kwargs):
|
||||
sys.stderr.write("Group not updated, no arguments present\n")
|
||||
return
|
||||
identity_client.groups.update(group.id, **kwargs)
|
||||
|
||||
|
||||
|
@ -169,14 +169,6 @@ class SetIdentityProvider(command.Command):
|
||||
def take_action(self, parsed_args):
|
||||
federation_client = self.app.client_manager.identity.federation
|
||||
|
||||
# Basic argument checking
|
||||
if (not parsed_args.enable and not parsed_args.disable and
|
||||
not parsed_args.remote_id and
|
||||
not parsed_args.remote_id_file and
|
||||
not parsed_args.description):
|
||||
LOG.error(_('No changes requested'))
|
||||
return (None, None)
|
||||
|
||||
# Always set remote_ids if either is passed in
|
||||
if parsed_args.remote_id_file:
|
||||
file_content = utils.read_blob_file_contents(
|
||||
|
@ -162,10 +162,6 @@ class SetMapping(command.Command, _RulesReader):
|
||||
def take_action(self, parsed_args):
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
if not parsed_args.rules:
|
||||
LOG.error(_("No changes requested"))
|
||||
return
|
||||
|
||||
rules = self._read_rules(parsed_args.rules)
|
||||
|
||||
mapping = identity_client.federation.mappings.update(
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
"""Identity v3 Policy action implementations"""
|
||||
|
||||
import sys
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
import six
|
||||
@ -136,9 +134,6 @@ class SetPolicy(command.Command):
|
||||
if parsed_args.type:
|
||||
kwargs['type'] = parsed_args.type
|
||||
|
||||
if not kwargs:
|
||||
sys.stdout.write(_('Policy not updated, no arguments present\n'))
|
||||
return
|
||||
identity_client.policies.update(parsed_args.policy, **kwargs)
|
||||
|
||||
|
||||
|
@ -263,13 +263,6 @@ class SetProject(command.Command):
|
||||
def take_action(self, parsed_args):
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
if (not parsed_args.name
|
||||
and not parsed_args.domain
|
||||
and not parsed_args.description
|
||||
and not parsed_args.enable
|
||||
and not parsed_args.property
|
||||
and not parsed_args.disable):
|
||||
return
|
||||
project = common.find_project(identity_client,
|
||||
parsed_args.project,
|
||||
parsed_args.domain)
|
||||
|
@ -132,8 +132,6 @@ class SetRegion(command.Command):
|
||||
def take_action(self, parsed_args):
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
if not parsed_args.parent_region and not parsed_args.description:
|
||||
return
|
||||
kwargs = {}
|
||||
if parsed_args.description:
|
||||
kwargs['description'] = parsed_args.description
|
||||
|
@ -357,10 +357,6 @@ class SetRole(command.Command):
|
||||
def take_action(self, parsed_args):
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
if not parsed_args.name:
|
||||
sys.stderr.write(_("Incorrect set of arguments provided. "
|
||||
"See openstack --help for more details\n"))
|
||||
return
|
||||
role = utils.find_resource(
|
||||
identity_client.roles,
|
||||
parsed_args.role,
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
"""Identity v3 Service action implementations"""
|
||||
|
||||
import sys
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
import six
|
||||
@ -163,14 +161,6 @@ class SetService(command.Command):
|
||||
def take_action(self, parsed_args):
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
if (not parsed_args.name
|
||||
and not parsed_args.type
|
||||
and not parsed_args.description
|
||||
and not parsed_args.enable
|
||||
and not parsed_args.disable):
|
||||
sys.stderr.write(_("Incorrect set of arguments provided. "
|
||||
"See openstack --help for more details\n"))
|
||||
return
|
||||
service = common.find_service(identity_client,
|
||||
parsed_args.service)
|
||||
kwargs = {}
|
||||
|
@ -13,8 +13,6 @@
|
||||
|
||||
"""Service Provider action implementations"""
|
||||
|
||||
import sys
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
import six
|
||||
@ -164,13 +162,6 @@ class SetServiceProvider(command.Command):
|
||||
elif parsed_args.disable is True:
|
||||
enabled = False
|
||||
|
||||
if not any((enabled is not None, parsed_args.description,
|
||||
parsed_args.service_provider_url,
|
||||
parsed_args.auth_url)):
|
||||
sys.stdout.write(_("Service Provider not updated, no arguments "
|
||||
"present\n"))
|
||||
return (None, None)
|
||||
|
||||
service_provider = federation_client.service_providers.update(
|
||||
parsed_args.service_provider, enabled=enabled,
|
||||
description=parsed_args.description,
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from keystoneauth1 import exceptions as ks_exc
|
||||
from osc_lib.command import command
|
||||
@ -330,18 +329,6 @@ class SetUser(command.Command):
|
||||
if parsed_args.password_prompt:
|
||||
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.description
|
||||
and not parsed_args.enable
|
||||
and not parsed_args.disable):
|
||||
sys.stderr.write(_("Incorrect set of arguments provided. "
|
||||
"See openstack --help for more details\n"))
|
||||
return
|
||||
|
||||
user = utils.find_resource(
|
||||
identity_client.users,
|
||||
parsed_args.user,
|
||||
|
@ -253,7 +253,11 @@ class TestDomainSet(TestDomain):
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertNotCalled(self.domains_mock.update)
|
||||
kwargs = {}
|
||||
self.domains_mock.update.assert_called_with(
|
||||
self.domain.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_domain_set_name(self):
|
||||
|
@ -485,7 +485,17 @@ class TestEndpointSet(TestEndpoint):
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertNotCalled(self.endpoints_mock.update)
|
||||
kwargs = {
|
||||
'enabled': None,
|
||||
'interface': None,
|
||||
'region': None,
|
||||
'service': None,
|
||||
'url': None,
|
||||
}
|
||||
self.endpoints_mock.update.assert_called_with(
|
||||
identity_fakes.endpoint_id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_endpoint_set_interface(self):
|
||||
|
@ -585,8 +585,8 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
|
||||
# expect take_action() to return (None, None) as
|
||||
# neither --enable nor --disable was specified
|
||||
self.assertIsNone(columns)
|
||||
self.assertIsNone(data)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, data)
|
||||
|
||||
|
||||
class TestIdentityProviderShow(TestIdentityProvider):
|
||||
|
@ -253,7 +253,11 @@ class TestRegionSet(TestRegion):
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertNotCalled(self.regions_mock.update)
|
||||
kwargs = {}
|
||||
self.regions_mock.update.assert_called_with(
|
||||
identity_fakes.region_id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_region_set_description(self):
|
||||
|
@ -377,8 +377,15 @@ class TestServiceProviderSet(TestServiceProvider):
|
||||
# expect take_action() to return (None, None) as none of --disabled,
|
||||
# --enabled, --description, --service-provider-url, --auth_url option
|
||||
# was set.
|
||||
self.assertIsNone(columns)
|
||||
self.assertIsNone(data)
|
||||
self.assertEqual(self.columns, columns)
|
||||
datalist = (
|
||||
service_fakes.sp_auth_url,
|
||||
service_fakes.sp_description,
|
||||
True,
|
||||
service_fakes.sp_id,
|
||||
service_fakes.service_provider_url
|
||||
)
|
||||
self.assertEqual(datalist, data)
|
||||
|
||||
|
||||
class TestServiceProviderShow(TestServiceProvider):
|
||||
|
Loading…
Reference in New Issue
Block a user