Improve User experience
This patch adds access to new REST API for config and service metadata retrieval. The following work has been done: * Create new manager for config retrieval * Create new Resource and CRUD manager for service info retrieval * Add managers to client * Add new CLI command and openstack client entries Change-Id: I43f572202b1cd3832a820f46f7c7b44a0d998406 Depends-on: https://review.openstack.org/#/c/406180/
This commit is contained in:
@@ -60,6 +60,8 @@ class Client(object):
|
|||||||
self.reportsummary = report.ReportSummaryManager(self.http_client)
|
self.reportsummary = report.ReportSummaryManager(self.http_client)
|
||||||
self.quotations = core.QuotationManager(self.http_client)
|
self.quotations = core.QuotationManager(self.http_client)
|
||||||
self.storage = storage.StorageManager(self.http_client)
|
self.storage = storage.StorageManager(self.http_client)
|
||||||
|
self.config = core.ConfigInfoManager(self.http_client)
|
||||||
|
self.service_info = core.ServiceInfoManager(self.http_client)
|
||||||
self._expose_submodules()
|
self._expose_submodules()
|
||||||
|
|
||||||
def _expose_submodules(self):
|
def _expose_submodules(self):
|
||||||
|
@@ -64,3 +64,26 @@ class QuotationManager(base.Manager):
|
|||||||
out = self.api.post(self.base_url,
|
out = self.api.post(self.base_url,
|
||||||
json={'resources': resources}).json()
|
json={'resources': resources}).json()
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceInfo(base.Resource):
|
||||||
|
|
||||||
|
key = "service"
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<Service %s>" % self._info
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceInfoManager(base.CrudManager):
|
||||||
|
resource_class = ServiceInfo
|
||||||
|
base_url = "/v1/info"
|
||||||
|
key = "service"
|
||||||
|
collection_key = "services"
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigInfoManager(base.Manager):
|
||||||
|
base_url = "/v1/info/config"
|
||||||
|
|
||||||
|
def get_config(self):
|
||||||
|
out = self.api.get(self.base_url).json()
|
||||||
|
return out
|
||||||
|
@@ -86,3 +86,29 @@ def do_module_set_priority(cc, args):
|
|||||||
modules = [cc.modules.get(module_id=args.name)]
|
modules = [cc.modules.get(module_id=args.name)]
|
||||||
utils.print_list(modules, fields, field_labels,
|
utils.print_list(modules, fields, field_labels,
|
||||||
sortby=0)
|
sortby=0)
|
||||||
|
|
||||||
|
|
||||||
|
def do_info_config_get(cc, args):
|
||||||
|
'''Get cloudkitty configuration.'''
|
||||||
|
utils.print_dict(cc.config.get_config(), dict_property="Section")
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('-n', '--name',
|
||||||
|
help='Service name',
|
||||||
|
required=False)
|
||||||
|
def do_info_service_get(cc, args):
|
||||||
|
'''Get service info.'''
|
||||||
|
if args.name:
|
||||||
|
try:
|
||||||
|
services_info = [cc.service_info.get(service_id=args.name)]
|
||||||
|
except exceptions.NotFound:
|
||||||
|
raise exc.CommandError('Service not found: %s' % args.name)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
services_info = cc.service_info.list()
|
||||||
|
except exceptions.NotFound:
|
||||||
|
raise exc.CommandError('ServiceInfo not found')
|
||||||
|
|
||||||
|
field_labels = ['Service', 'Metadata', 'Unit']
|
||||||
|
fields = ['service_id', 'metadata', 'unit']
|
||||||
|
utils.print_list(services_info, fields, field_labels, sortby=0)
|
||||||
|
@@ -66,3 +66,26 @@ class CliModuleSetPriority(command.Command):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
ckclient = self.app.client_manager.rating
|
ckclient = self.app.client_manager.rating
|
||||||
shell.do_module_set_priority(ckclient, parsed_args)
|
shell.do_module_set_priority(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliInfoGetConfig(command.Command):
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliInfoGetConfig, self).get_parser(prog_name)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_info_config_get(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliInfoGetService(command.Command):
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliInfoGetService, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-n', '--name',
|
||||||
|
help='Service name',
|
||||||
|
required=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_info_service_get(ckclient, parsed_args)
|
||||||
|
@@ -39,6 +39,9 @@ openstack.rating.v1 =
|
|||||||
rating_module-disable = cloudkittyclient.v1.shell_cli:CliModuleDisable
|
rating_module-disable = cloudkittyclient.v1.shell_cli:CliModuleDisable
|
||||||
rating_module-set-priority = cloudkittyclient.v1.shell_cli:CliModuleSetPriority
|
rating_module-set-priority = cloudkittyclient.v1.shell_cli:CliModuleSetPriority
|
||||||
|
|
||||||
|
rating_info-config-get = cloudkittyclient.v1.shell_cli:CliInfoGetConfig
|
||||||
|
rating_info-service-get = cloudkittyclient.v1.shell_cli:CliInfoGetService
|
||||||
|
|
||||||
rating_total-get = cloudkittyclient.v1.report.shell_cli:CliTotalGet
|
rating_total-get = cloudkittyclient.v1.report.shell_cli:CliTotalGet
|
||||||
rating_summary-get = cloudkittyclient.v1.report.shell_cli:CliSummaryGet
|
rating_summary-get = cloudkittyclient.v1.report.shell_cli:CliSummaryGet
|
||||||
rating_report-tenant-list = cloudkittyclient.v1.report.shell_cli:CliReportTenantList
|
rating_report-tenant-list = cloudkittyclient.v1.report.shell_cli:CliReportTenantList
|
||||||
|
Reference in New Issue
Block a user