Switch Adjutant service type to Admin-Logic
Change-Id: Ic173891bfdd109d8d0fe1038d0ec10184da0e4e6
This commit is contained in:
parent
c0f32f26b3
commit
03c00a10d9
@ -33,7 +33,7 @@ You can use the API with a keystone session:
|
|||||||
If you use a clouds.yaml file os_client_config can also be used:
|
If you use a clouds.yaml file os_client_config can also be used:
|
||||||
|
|
||||||
>>> import os_client_config
|
>>> import os_client_config
|
||||||
>>> sess = os_client_config.make_rest_client('registration')
|
>>> sess = os_client_config.make_rest_client('admin-logic')
|
||||||
>>> adjutant = Client('1', session=sess)
|
>>> adjutant = Client('1', session=sess)
|
||||||
|
|
||||||
A few of the endpoints (users.password_forgot(), token.submit(), signup, token.get()) don't require authentication.
|
A few of the endpoints (users.password_forgot(), token.submit(), signup, token.get()) don't require authentication.
|
||||||
|
@ -132,7 +132,7 @@ def _construct_http_client(endpoint=None, username=None, password=None,
|
|||||||
kwargs['endpoint_override'] = endpoint
|
kwargs['endpoint_override'] = endpoint
|
||||||
|
|
||||||
if 'service_type' not in kwargs:
|
if 'service_type' not in kwargs:
|
||||||
kwargs['service_type'] = 'registration'
|
kwargs['service_type'] = 'admin-logic'
|
||||||
|
|
||||||
if 'interface' not in kwargs and endpoint_type:
|
if 'interface' not in kwargs and endpoint_type:
|
||||||
kwargs['interface'] = endpoint_type
|
kwargs['interface'] = endpoint_type
|
||||||
|
@ -18,10 +18,10 @@ from osc_lib import utils
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_OS_REGISTRATION_VERSION = '1'
|
DEFAULT_OS_ADMIN_LOGIC_VERSION = '1'
|
||||||
DEFAULT_API_VERSION = '1'
|
DEFAULT_API_VERSION = '1'
|
||||||
API_VERSION_OPTION = 'os_registration_version'
|
API_VERSION_OPTION = 'os_admin_logic_version'
|
||||||
API_NAME = "registration"
|
API_NAME = "admin_logic"
|
||||||
API_VERSIONS = {
|
API_VERSIONS = {
|
||||||
"1": "adjutantclient.v1.client.Client",
|
"1": "adjutantclient.v1.client.Client",
|
||||||
}
|
}
|
||||||
@ -47,17 +47,9 @@ def make_client(instance):
|
|||||||
kwargs = {'region_name': instance.region_name}
|
kwargs = {'region_name': instance.region_name}
|
||||||
|
|
||||||
if instance.session:
|
if instance.session:
|
||||||
kwargs.update({'session': instance.session,
|
kwargs.update({'session': instance.session})
|
||||||
'service_type': API_NAME})
|
|
||||||
else:
|
else:
|
||||||
endpoint = instance.get_endpoint_for_service_type(
|
kwargs.update({'auth_url': instance.auth.auth_url,
|
||||||
API_NAME,
|
|
||||||
region_name=instance.region_name,
|
|
||||||
interface=instance.interface,
|
|
||||||
)
|
|
||||||
|
|
||||||
kwargs.update({'endpoint': endpoint,
|
|
||||||
'auth_url': instance.auth.auth_url,
|
|
||||||
'username': instance.auth_ref.username,
|
'username': instance.auth_ref.username,
|
||||||
'token': instance.auth_ref.auth_token})
|
'token': instance.auth_ref.auth_token})
|
||||||
|
|
||||||
@ -69,12 +61,12 @@ def make_client(instance):
|
|||||||
def build_option_parser(parser):
|
def build_option_parser(parser):
|
||||||
"""Hook to add global options."""
|
"""Hook to add global options."""
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--os-registration-version',
|
'--os-admin-logic-version',
|
||||||
metavar='<registration-version>',
|
metavar='<admin-logic-version>',
|
||||||
default=utils.env(
|
default=utils.env(
|
||||||
'OS_REGISTRATION_VERSION',
|
'OS_ADMIN_LOGIC_VERSION',
|
||||||
default=DEFAULT_OS_REGISTRATION_VERSION),
|
default=DEFAULT_OS_ADMIN_LOGIC_VERSION),
|
||||||
help=('Client version, default=' +
|
help=('Client version, default=' +
|
||||||
DEFAULT_OS_REGISTRATION_VERSION +
|
DEFAULT_OS_ADMIN_LOGIC_VERSION +
|
||||||
' (Env: DEFAULT_OS_REGISTRATION_VERSION)'))
|
' (Env: DEFAULT_OS_ADMIN_LOGIC_VERSION)'))
|
||||||
return parser
|
return parser
|
||||||
|
@ -46,7 +46,7 @@ class NotificationList(command.Lister):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if parsed_args.filters:
|
if parsed_args.filters:
|
||||||
@ -74,7 +74,7 @@ class NotificationShow(command.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
return _show_notification(parsed_args.notification_id, client,
|
return _show_notification(parsed_args.notification_id, client,
|
||||||
parsed_args.formatter)
|
parsed_args.formatter)
|
||||||
|
|
||||||
@ -89,6 +89,6 @@ class NotificationAcknowledge(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
resp = client.notifications.acknowledge(note_list=parsed_args.note_ids)
|
resp = client.notifications.acknowledge(note_list=parsed_args.note_ids)
|
||||||
print('Success', ' '.join(resp.notes))
|
print('Success', ' '.join(resp.notes))
|
||||||
|
@ -39,7 +39,7 @@ class QuotaShow(command.Lister):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
|
|
||||||
if not parsed_args.region:
|
if not parsed_args.region:
|
||||||
quota_data = client.quota.get()
|
quota_data = client.quota.get()
|
||||||
@ -76,7 +76,7 @@ class QuotaSizes(command.Lister):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
|
|
||||||
quota_data = client.quota.get()
|
quota_data = client.quota.get()
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class QuotaTasks(command.Lister):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
|
|
||||||
quota_data = client.quota.get()
|
quota_data = client.quota.get()
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ class QuotaUpdate(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
if parsed_args.regions:
|
if parsed_args.regions:
|
||||||
status = client.quota.update(parsed_args.size, parsed_args.regions)
|
status = client.quota.update(parsed_args.size, parsed_args.regions)
|
||||||
else:
|
else:
|
||||||
|
@ -58,7 +58,7 @@ class Signup(command.Command):
|
|||||||
# user wanting to access and submit a sign up (I.E. an admin)
|
# user wanting to access and submit a sign up (I.E. an admin)
|
||||||
self.app.client_manager._auth_required = True
|
self.app.client_manager._auth_required = True
|
||||||
self.app.client_manager.setup_auth()
|
self.app.client_manager.setup_auth()
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
else:
|
else:
|
||||||
client = adjutant_client.Client(1, parsed_args.bypass_url)
|
client = adjutant_client.Client(1, parsed_args.bypass_url)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class Status(command.Command):
|
|||||||
"""Lists adjutant tasks. """
|
"""Lists adjutant tasks. """
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
|
|
||||||
status = client.status.get().json()
|
status = client.status.get().json()
|
||||||
print(json.dumps(status, indent=2))
|
print(json.dumps(status, indent=2))
|
||||||
|
@ -56,7 +56,7 @@ class TaskList(command.Lister):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
|
|
||||||
kwargs = {'filters': parsed_args.filters}
|
kwargs = {'filters': parsed_args.filters}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ class TaskShow(command.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
return _show_task(parsed_args.task_id, client, parsed_args.formatter)
|
return _show_task(parsed_args.task_id, client, parsed_args.formatter)
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class TaskApprove(command.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
client.tasks.approve(parsed_args.task_id)
|
client.tasks.approve(parsed_args.task_id)
|
||||||
return _show_task(parsed_args.task_id, client, parsed_args.formatter)
|
return _show_task(parsed_args.task_id, client, parsed_args.formatter)
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ class TaskCancel(command.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
client.tasks.cancel(task_id=parsed_args.task_id)
|
client.tasks.cancel(task_id=parsed_args.task_id)
|
||||||
return _show_task(parsed_args.task_id, client, parsed_args.formatter)
|
return _show_task(parsed_args.task_id, client, parsed_args.formatter)
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ class TaskUpdate(command.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
client.tasks.update(task_id=parsed_args.task_id,
|
client.tasks.update(task_id=parsed_args.task_id,
|
||||||
data=json.loads(parsed_args.data))
|
data=json.loads(parsed_args.data))
|
||||||
return _show_task(parsed_args.task_id, client, parsed_args.formatter)
|
return _show_task(parsed_args.task_id, client, parsed_args.formatter)
|
||||||
@ -154,6 +154,6 @@ class TaskTokenReissue(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
resp = client.tokens.reissue(task_id=parsed_args.task_id)
|
resp = client.tokens.reissue(task_id=parsed_args.task_id)
|
||||||
print('Success', ' '.join(resp.notes))
|
print('Success', ' '.join(resp.notes))
|
||||||
|
@ -49,7 +49,7 @@ class TokenList(command.Lister):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
return _list_tokens(client, parsed_args.filters)
|
return _list_tokens(client, parsed_args.filters)
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class TokenShow(command.ShowOne):
|
|||||||
if not parsed_args.bypass_url:
|
if not parsed_args.bypass_url:
|
||||||
self.app.client_manager._auth_required = True
|
self.app.client_manager._auth_required = True
|
||||||
self.app.client_manager.setup_auth()
|
self.app.client_manager.setup_auth()
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
else:
|
else:
|
||||||
client = adjutant_client.Client("1", parsed_args.bypass_url)
|
client = adjutant_client.Client("1", parsed_args.bypass_url)
|
||||||
token = client.tokens.get(parsed_args.token)
|
token = client.tokens.get(parsed_args.token)
|
||||||
@ -91,7 +91,7 @@ class TokenSubmit(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
resp = client.tokens.submit(
|
resp = client.tokens.submit(
|
||||||
parsed_args.token, json.loads(parsed_args.data))
|
parsed_args.token, json.loads(parsed_args.data))
|
||||||
print('Success', ' '.join(resp.notes))
|
print('Success', ' '.join(resp.notes))
|
||||||
@ -101,7 +101,7 @@ class TokenClear(command.Lister):
|
|||||||
"""Clear Expired tokens, admin only."""
|
"""Clear Expired tokens, admin only."""
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
resp = client.tokens.clear_expired()
|
resp = client.tokens.clear_expired()
|
||||||
print('Success. ' + ' '.join(resp.json()['notes']))
|
print('Success. ' + ' '.join(resp.json()['notes']))
|
||||||
return _list_tokens(client)
|
return _list_tokens(client)
|
||||||
|
@ -29,7 +29,7 @@ class UserList(command.Lister):
|
|||||||
"""Lists users in the currently scoped project. """
|
"""Lists users in the currently scoped project. """
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
project_users = client.users.list()
|
project_users = client.users.list()
|
||||||
headers = [
|
headers = [
|
||||||
'id', 'name', 'email', 'roles', 'cohort', 'status']
|
'id', 'name', 'email', 'roles', 'cohort', 'status']
|
||||||
@ -53,7 +53,7 @@ class UserShow(command.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
# This ends up for names doing multiple requests, it may
|
# This ends up for names doing multiple requests, it may
|
||||||
# be better to do something slightly different here
|
# be better to do something slightly different here
|
||||||
user_id = utils.find_resource(client.users, parsed_args.user)
|
user_id = utils.find_resource(client.users, parsed_args.user)
|
||||||
@ -85,7 +85,7 @@ class UserInvite(command.Command):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
if not parsed_args.roles:
|
if not parsed_args.roles:
|
||||||
parsed_args.roles = ['Member']
|
parsed_args.roles = ['Member']
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
client.users.invite(
|
client.users.invite(
|
||||||
username=parsed_args.username, email=parsed_args.email,
|
username=parsed_args.username, email=parsed_args.email,
|
||||||
role_list=parsed_args.roles)
|
role_list=parsed_args.roles)
|
||||||
@ -104,7 +104,7 @@ class UserInviteCancel(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
for user in parsed_args.user:
|
for user in parsed_args.user:
|
||||||
try:
|
try:
|
||||||
user_id = client.users.find(name=user).id
|
user_id = client.users.find(name=user).id
|
||||||
@ -128,7 +128,7 @@ class UserRoleAdd(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
|
|
||||||
role = utils.find_resource(client.managed_roles, parsed_args.role)
|
role = utils.find_resource(client.managed_roles, parsed_args.role)
|
||||||
user = utils.find_resource(client.users, parsed_args.user)
|
user = utils.find_resource(client.users, parsed_args.user)
|
||||||
@ -150,7 +150,7 @@ class UserRoleRemove(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
role = utils.find_resource(client.managed_roles, parsed_args.role)
|
role = utils.find_resource(client.managed_roles, parsed_args.role)
|
||||||
user = utils.find_resource(client.users, parsed_args.user)
|
user = utils.find_resource(client.users, parsed_args.user)
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ class UserRoleList(command.Lister):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
|
|
||||||
user = utils.find_resource(client.users, parsed_args.user)
|
user = utils.find_resource(client.users, parsed_args.user)
|
||||||
kwargs = {'user': user.id}
|
kwargs = {'user': user.id}
|
||||||
@ -181,7 +181,7 @@ class UserRoleList(command.Lister):
|
|||||||
class ManageableRolesList(command.Lister):
|
class ManageableRolesList(command.Lister):
|
||||||
""" Lists roles able to be managed by the current user """
|
""" Lists roles able to be managed by the current user """
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
roles = client.managed_roles.list()
|
roles = client.managed_roles.list()
|
||||||
|
|
||||||
headers = ['id', 'name']
|
headers = ['id', 'name']
|
||||||
@ -205,7 +205,7 @@ class PasswordReset(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
|
|
||||||
data = {'email': parsed_args.email}
|
data = {'email': parsed_args.email}
|
||||||
if parsed_args.username:
|
if parsed_args.username:
|
||||||
@ -240,7 +240,7 @@ class PasswordForgot(command.Command):
|
|||||||
if not parsed_args.bypass_url:
|
if not parsed_args.bypass_url:
|
||||||
self.app.client_manager._auth_required = True
|
self.app.client_manager._auth_required = True
|
||||||
self.app.client_manager.setup_auth()
|
self.app.client_manager.setup_auth()
|
||||||
client = self.app.client_manager.registration
|
client = self.app.client_manager.admin_logic
|
||||||
else:
|
else:
|
||||||
client = adjutant_client.Client(1, parsed_args.bypass_url)
|
client = adjutant_client.Client(1, parsed_args.bypass_url)
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ packages =
|
|||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
openstack.cli.extension =
|
openstack.cli.extension =
|
||||||
registration = adjutantclient.osc.plugin
|
admin_logic = adjutantclient.osc.plugin
|
||||||
|
|
||||||
openstack.registration.v1 =
|
openstack.admin_logic.v1 =
|
||||||
admin_task_list = adjutantclient.osc.v1.tasks:TaskList
|
admin_task_list = adjutantclient.osc.v1.tasks:TaskList
|
||||||
admin_task_show = adjutantclient.osc.v1.tasks:TaskShow
|
admin_task_show = adjutantclient.osc.v1.tasks:TaskShow
|
||||||
admin_task_approve = adjutantclient.osc.v1.tasks:TaskApprove
|
admin_task_approve = adjutantclient.osc.v1.tasks:TaskApprove
|
||||||
|
Loading…
Reference in New Issue
Block a user