Refactor cliff.Command.run()
* All commands now perform their action in take_action(). Those producing output are derived from DisplayCommandBase. Change-Id: Ic93ba9a2ad449d84242b6aa8624b41379c4fb79a
This commit is contained in:
parent
9be5803993
commit
697a5ac6cb
openstackclient
@ -22,10 +22,10 @@ Server action implementations
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from cliff import command
|
||||||
from cliff import lister
|
from cliff import lister
|
||||||
from cliff import show
|
from cliff import show
|
||||||
|
|
||||||
from openstackclient.common import command
|
|
||||||
from openstackclient.common import utils
|
from openstackclient.common import utils
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ def _format_servers_list_networks(server):
|
|||||||
return '; '.join(output)
|
return '; '.join(output)
|
||||||
|
|
||||||
|
|
||||||
class ListServer(command.OpenStackCommand, lister.Lister):
|
class ListServer(lister.Lister):
|
||||||
"""List server command"""
|
"""List server command"""
|
||||||
|
|
||||||
api = 'compute'
|
api = 'compute'
|
||||||
@ -98,8 +98,8 @@ class ListServer(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
nova_client = self.app.client_manager.compute
|
nova_client = self.app.client_manager.compute
|
||||||
search_opts = {
|
search_opts = {
|
||||||
'all_tenants': parsed_args.all_tenants,
|
'all_tenants': parsed_args.all_tenants,
|
||||||
@ -125,7 +125,7 @@ class ListServer(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ShowServer(command.OpenStackCommand, show.ShowOne):
|
class ShowServer(show.ShowOne):
|
||||||
"""Show server command"""
|
"""Show server command"""
|
||||||
|
|
||||||
api = 'compute'
|
api = 'compute'
|
||||||
@ -139,8 +139,8 @@ class ShowServer(command.OpenStackCommand, show.ShowOne):
|
|||||||
help='Name or ID of server to display')
|
help='Name or ID of server to display')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
nova_client = self.app.client_manager.compute
|
nova_client = self.app.client_manager.compute
|
||||||
server = utils.find_resource(nova_client.servers, parsed_args.server)
|
server = utils.find_resource(nova_client.servers, parsed_args.server)
|
||||||
|
|
||||||
|
@ -21,16 +21,16 @@ Endpoint action implementations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from cliff import command
|
||||||
from cliff import lister
|
from cliff import lister
|
||||||
from cliff import show
|
from cliff import show
|
||||||
|
|
||||||
from keystoneclient import exceptions as identity_exc
|
from keystoneclient import exceptions as identity_exc
|
||||||
from openstackclient.common import command
|
|
||||||
from openstackclient.common import exceptions
|
from openstackclient.common import exceptions
|
||||||
from openstackclient.common import utils
|
from openstackclient.common import utils
|
||||||
|
|
||||||
|
|
||||||
class CreateEndpoint(command.OpenStackCommand, show.ShowOne):
|
class CreateEndpoint(show.ShowOne):
|
||||||
"""Create endpoint command"""
|
"""Create endpoint command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -60,8 +60,8 @@ class CreateEndpoint(command.OpenStackCommand, show.ShowOne):
|
|||||||
help='New endpoint internal URL')
|
help='New endpoint internal URL')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
service = utils.find_resource(
|
service = utils.find_resource(
|
||||||
identity_client.services, parsed_args.service)
|
identity_client.services, parsed_args.service)
|
||||||
@ -80,7 +80,7 @@ class CreateEndpoint(command.OpenStackCommand, show.ShowOne):
|
|||||||
return zip(*sorted(info.iteritems()))
|
return zip(*sorted(info.iteritems()))
|
||||||
|
|
||||||
|
|
||||||
class DeleteEndpoint(command.OpenStackCommand):
|
class DeleteEndpoint(command.Command):
|
||||||
"""Delete endpoint command"""
|
"""Delete endpoint command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -94,14 +94,14 @@ class DeleteEndpoint(command.OpenStackCommand):
|
|||||||
help='ID of endpoint to delete')
|
help='ID of endpoint to delete')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def run(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('run(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
identity_client.endpoints.delete(parsed_args.endpoint)
|
identity_client.endpoints.delete(parsed_args.endpoint)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class ListEndpoint(command.OpenStackCommand, lister.Lister):
|
class ListEndpoint(lister.Lister):
|
||||||
"""List endpoint command"""
|
"""List endpoint command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -116,8 +116,8 @@ class ListEndpoint(command.OpenStackCommand, lister.Lister):
|
|||||||
help='Additional fields are listed in output')
|
help='Additional fields are listed in output')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
if parsed_args.long:
|
if parsed_args.long:
|
||||||
columns = ('ID', 'Region', 'Service Name', 'Service Type',
|
columns = ('ID', 'Region', 'Service Name', 'Service Type',
|
||||||
@ -139,7 +139,7 @@ class ListEndpoint(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ShowEndpoint(command.OpenStackCommand, show.ShowOne):
|
class ShowEndpoint(show.ShowOne):
|
||||||
"""Show endpoint command"""
|
"""Show endpoint command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -172,8 +172,8 @@ class ShowEndpoint(command.OpenStackCommand, show.ShowOne):
|
|||||||
help='Show all endpoints for this service')
|
help='Show all endpoints for this service')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
if not parsed_args.all:
|
if not parsed_args.all:
|
||||||
|
@ -21,14 +21,14 @@ Role action implementations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from cliff import command
|
||||||
from cliff import lister
|
from cliff import lister
|
||||||
from cliff import show
|
from cliff import show
|
||||||
|
|
||||||
from openstackclient.common import command
|
|
||||||
from openstackclient.common import utils
|
from openstackclient.common import utils
|
||||||
|
|
||||||
|
|
||||||
class AddRole(command.OpenStackCommand, show.ShowOne):
|
class AddRole(show.ShowOne):
|
||||||
"""Add role to tenant:user"""
|
"""Add role to tenant:user"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -55,8 +55,8 @@ class AddRole(command.OpenStackCommand, show.ShowOne):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
role = utils.find_resource(
|
role = utils.find_resource(
|
||||||
identity_client.roles, parsed_args.role)
|
identity_client.roles, parsed_args.role)
|
||||||
@ -75,7 +75,7 @@ class AddRole(command.OpenStackCommand, show.ShowOne):
|
|||||||
return zip(*sorted(info.iteritems()))
|
return zip(*sorted(info.iteritems()))
|
||||||
|
|
||||||
|
|
||||||
class CreateRole(command.OpenStackCommand, show.ShowOne):
|
class CreateRole(show.ShowOne):
|
||||||
"""Create new role"""
|
"""Create new role"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -90,8 +90,8 @@ class CreateRole(command.OpenStackCommand, show.ShowOne):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
role = identity_client.roles.create(
|
role = identity_client.roles.create(
|
||||||
parsed_args.role_name,
|
parsed_args.role_name,
|
||||||
@ -102,7 +102,7 @@ class CreateRole(command.OpenStackCommand, show.ShowOne):
|
|||||||
return zip(*sorted(info.iteritems()))
|
return zip(*sorted(info.iteritems()))
|
||||||
|
|
||||||
|
|
||||||
class DeleteRole(command.OpenStackCommand):
|
class DeleteRole(command.Command):
|
||||||
"""Delete existing role"""
|
"""Delete existing role"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -117,8 +117,8 @@ class DeleteRole(command.OpenStackCommand):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def run(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('run(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
role = utils.find_resource(
|
role = utils.find_resource(
|
||||||
identity_client.roles, parsed_args.role)
|
identity_client.roles, parsed_args.role)
|
||||||
@ -126,14 +126,14 @@ class DeleteRole(command.OpenStackCommand):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class ListRole(command.OpenStackCommand, lister.Lister):
|
class ListRole(lister.Lister):
|
||||||
"""List roles"""
|
"""List roles"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
log = logging.getLogger(__name__ + '.ListRole')
|
log = logging.getLogger(__name__ + '.ListRole')
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
columns = ('ID', 'Name')
|
columns = ('ID', 'Name')
|
||||||
data = self.app.client_manager.identity.roles.list()
|
data = self.app.client_manager.identity.roles.list()
|
||||||
return (columns,
|
return (columns,
|
||||||
@ -144,7 +144,7 @@ class ListRole(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ListUserRole(command.OpenStackCommand, lister.Lister):
|
class ListUserRole(lister.Lister):
|
||||||
"""List user-role assignments"""
|
"""List user-role assignments"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -165,8 +165,8 @@ class ListUserRole(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
columns = ('ID', 'Name', 'Tenant ID', 'User ID')
|
columns = ('ID', 'Name', 'Tenant ID', 'User ID')
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ class ListUserRole(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RemoveRole(command.OpenStackCommand):
|
class RemoveRole(command.Command):
|
||||||
"""Remove role from tenant:user"""
|
"""Remove role from tenant:user"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -225,8 +225,8 @@ class RemoveRole(command.OpenStackCommand):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
role = utils.find_resource(
|
role = utils.find_resource(
|
||||||
identity_client.roles, parsed_args.role)
|
identity_client.roles, parsed_args.role)
|
||||||
@ -241,7 +241,7 @@ class RemoveRole(command.OpenStackCommand):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ShowRole(command.OpenStackCommand, show.ShowOne):
|
class ShowRole(show.ShowOne):
|
||||||
"""Show single role"""
|
"""Show single role"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -256,8 +256,8 @@ class ShowRole(command.OpenStackCommand, show.ShowOne):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
role = utils.find_resource(
|
role = utils.find_resource(
|
||||||
identity_client.roles, parsed_args.role)
|
identity_client.roles, parsed_args.role)
|
||||||
|
@ -21,16 +21,16 @@ Service action implementations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from cliff import command
|
||||||
from cliff import lister
|
from cliff import lister
|
||||||
from cliff import show
|
from cliff import show
|
||||||
|
|
||||||
from keystoneclient import exceptions as identity_exc
|
from keystoneclient import exceptions as identity_exc
|
||||||
from openstackclient.common import command
|
|
||||||
from openstackclient.common import exceptions
|
from openstackclient.common import exceptions
|
||||||
from openstackclient.common import utils
|
from openstackclient.common import utils
|
||||||
|
|
||||||
|
|
||||||
class CreateService(command.OpenStackCommand, show.ShowOne):
|
class CreateService(show.ShowOne):
|
||||||
"""Create service command"""
|
"""Create service command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -55,8 +55,8 @@ class CreateService(command.OpenStackCommand, show.ShowOne):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
service = identity_client.services.create(
|
service = identity_client.services.create(
|
||||||
parsed_args.name,
|
parsed_args.name,
|
||||||
@ -69,7 +69,7 @@ class CreateService(command.OpenStackCommand, show.ShowOne):
|
|||||||
return zip(*sorted(info.iteritems()))
|
return zip(*sorted(info.iteritems()))
|
||||||
|
|
||||||
|
|
||||||
class DeleteService(command.OpenStackCommand):
|
class DeleteService(command.Command):
|
||||||
"""Delete service command"""
|
"""Delete service command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -84,14 +84,14 @@ class DeleteService(command.OpenStackCommand):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def run(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('run(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
identity_client.services.delete(parsed_args.service)
|
identity_client.services.delete(parsed_args.service)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class ListService(command.OpenStackCommand, lister.Lister):
|
class ListService(lister.Lister):
|
||||||
"""List service command"""
|
"""List service command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -106,8 +106,8 @@ class ListService(command.OpenStackCommand, lister.Lister):
|
|||||||
help='Additional fields are listed in output')
|
help='Additional fields are listed in output')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
if parsed_args.long:
|
if parsed_args.long:
|
||||||
columns = ('ID', 'Name', 'Type', 'Description')
|
columns = ('ID', 'Name', 'Type', 'Description')
|
||||||
else:
|
else:
|
||||||
@ -121,7 +121,7 @@ class ListService(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ShowService(command.OpenStackCommand, show.ShowOne):
|
class ShowService(show.ShowOne):
|
||||||
"""Show service command"""
|
"""Show service command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -135,8 +135,8 @@ class ShowService(command.OpenStackCommand, show.ShowOne):
|
|||||||
help='Type, name or ID of service to display')
|
help='Type, name or ID of service to display')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
try:
|
try:
|
||||||
# search for the usual ID or name
|
# search for the usual ID or name
|
||||||
|
@ -21,14 +21,14 @@ Tenant action implementations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from cliff import command
|
||||||
from cliff import lister
|
from cliff import lister
|
||||||
from cliff import show
|
from cliff import show
|
||||||
|
|
||||||
from openstackclient.common import command
|
|
||||||
from openstackclient.common import utils
|
from openstackclient.common import utils
|
||||||
|
|
||||||
|
|
||||||
class CreateTenant(command.OpenStackCommand, show.ShowOne):
|
class CreateTenant(show.ShowOne):
|
||||||
"""Create tenant command"""
|
"""Create tenant command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -62,8 +62,8 @@ class CreateTenant(command.OpenStackCommand, show.ShowOne):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
tenant = identity_client.tenants.create(
|
tenant = identity_client.tenants.create(
|
||||||
parsed_args.tenant_name,
|
parsed_args.tenant_name,
|
||||||
@ -76,7 +76,7 @@ class CreateTenant(command.OpenStackCommand, show.ShowOne):
|
|||||||
return zip(*sorted(info.iteritems()))
|
return zip(*sorted(info.iteritems()))
|
||||||
|
|
||||||
|
|
||||||
class DeleteTenant(command.OpenStackCommand):
|
class DeleteTenant(command.Command):
|
||||||
"""Delete tenant command"""
|
"""Delete tenant command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -91,8 +91,8 @@ class DeleteTenant(command.OpenStackCommand):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def run(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('run(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
tenant = utils.find_resource(
|
tenant = utils.find_resource(
|
||||||
identity_client.tenants, parsed_args.tenant)
|
identity_client.tenants, parsed_args.tenant)
|
||||||
@ -100,7 +100,7 @@ class DeleteTenant(command.OpenStackCommand):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class ListTenant(command.OpenStackCommand, lister.Lister):
|
class ListTenant(lister.Lister):
|
||||||
"""List tenant command"""
|
"""List tenant command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -116,8 +116,8 @@ class ListTenant(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
if parsed_args.long:
|
if parsed_args.long:
|
||||||
columns = ('ID', 'Name', 'Description', 'Enabled')
|
columns = ('ID', 'Name', 'Description', 'Enabled')
|
||||||
else:
|
else:
|
||||||
@ -131,7 +131,7 @@ class ListTenant(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SetTenant(command.OpenStackCommand):
|
class SetTenant(command.Command):
|
||||||
"""Set tenant command"""
|
"""Set tenant command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -170,8 +170,8 @@ class SetTenant(command.OpenStackCommand):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def run(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('run(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
tenant = utils.find_resource(
|
tenant = utils.find_resource(
|
||||||
identity_client.tenants, parsed_args.tenant)
|
identity_client.tenants, parsed_args.tenant)
|
||||||
@ -190,7 +190,7 @@ class SetTenant(command.OpenStackCommand):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class ShowTenant(command.OpenStackCommand, show.ShowOne):
|
class ShowTenant(show.ShowOne):
|
||||||
"""Show tenant command"""
|
"""Show tenant command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -205,8 +205,8 @@ class ShowTenant(command.OpenStackCommand, show.ShowOne):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
tenant = utils.find_resource(
|
tenant = utils.find_resource(
|
||||||
identity_client.tenants, parsed_args.tenant)
|
identity_client.tenants, parsed_args.tenant)
|
||||||
|
@ -21,14 +21,14 @@ User action implementations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from cliff import command
|
||||||
from cliff import lister
|
from cliff import lister
|
||||||
from cliff import show
|
from cliff import show
|
||||||
|
|
||||||
from openstackclient.common import command
|
|
||||||
from openstackclient.common import utils
|
from openstackclient.common import utils
|
||||||
|
|
||||||
|
|
||||||
class CreateUser(command.OpenStackCommand, show.ShowOne):
|
class CreateUser(show.ShowOne):
|
||||||
"""Create user command"""
|
"""Create user command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -72,8 +72,8 @@ class CreateUser(command.OpenStackCommand, show.ShowOne):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
if parsed_args.tenant:
|
if parsed_args.tenant:
|
||||||
tenant_id = utils.find_resource(
|
tenant_id = utils.find_resource(
|
||||||
@ -93,7 +93,7 @@ class CreateUser(command.OpenStackCommand, show.ShowOne):
|
|||||||
return zip(*sorted(info.iteritems()))
|
return zip(*sorted(info.iteritems()))
|
||||||
|
|
||||||
|
|
||||||
class DeleteUser(command.OpenStackCommand):
|
class DeleteUser(command.Command):
|
||||||
"""Delete user command"""
|
"""Delete user command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -108,8 +108,8 @@ class DeleteUser(command.OpenStackCommand):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def run(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('run(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
user = utils.find_resource(
|
user = utils.find_resource(
|
||||||
identity_client.users, parsed_args.user)
|
identity_client.users, parsed_args.user)
|
||||||
@ -117,7 +117,7 @@ class DeleteUser(command.OpenStackCommand):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class ListUser(command.OpenStackCommand, lister.Lister):
|
class ListUser(lister.Lister):
|
||||||
"""List user command"""
|
"""List user command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -138,8 +138,8 @@ class ListUser(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
if parsed_args.long:
|
if parsed_args.long:
|
||||||
columns = ('ID', 'Name', 'TenantId', 'Email', 'Enabled')
|
columns = ('ID', 'Name', 'TenantId', 'Email', 'Enabled')
|
||||||
else:
|
else:
|
||||||
@ -153,7 +153,7 @@ class ListUser(command.OpenStackCommand, lister.Lister):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SetUser(command.OpenStackCommand):
|
class SetUser(command.Command):
|
||||||
"""Set user command"""
|
"""Set user command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -202,8 +202,8 @@ class SetUser(command.OpenStackCommand):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def run(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('run(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
user = utils.find_resource(
|
user = utils.find_resource(
|
||||||
identity_client.users, parsed_args.user)
|
identity_client.users, parsed_args.user)
|
||||||
@ -226,7 +226,7 @@ class SetUser(command.OpenStackCommand):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class ShowUser(command.OpenStackCommand, show.ShowOne):
|
class ShowUser(show.ShowOne):
|
||||||
"""Show user command"""
|
"""Show user command"""
|
||||||
|
|
||||||
api = 'identity'
|
api = 'identity'
|
||||||
@ -241,8 +241,8 @@ class ShowUser(command.OpenStackCommand, show.ShowOne):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
user = utils.find_resource(
|
user = utils.find_resource(
|
||||||
identity_client.users, parsed_args.user)
|
identity_client.users, parsed_args.user)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user