Add support for OpenStack client
Cloudkittyclient now provides a plugin for the Openstack client. setup.cfg was modified to provide entrypoints for the Openstack client. These entrypoints can be found in the different shell_cli.py files. Python-openstackclient was added to the requirements. Implements: blueprint openstackclient-support Change-Id: If0bbd919b1552b82cd77a52ded4f4ec32e6e14d8
This commit is contained in:
35
cloudkittyclient/osc.py
Normal file
35
cloudkittyclient/osc.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Copyright 2014 OpenStack Foundation
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from cloudkittyclient import client as ckclient
|
||||||
|
|
||||||
|
DEFAULT_API_VERSION = '1'
|
||||||
|
API_VERSION_OPTION = 'os_rating_api_version'
|
||||||
|
API_NAME = "rating"
|
||||||
|
API_VERSIONS = {
|
||||||
|
"1": "cloudkittyclient.v1.client.Client",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def make_client(instance):
|
||||||
|
"""Returns a rating service client."""
|
||||||
|
version = instance._api_version[API_NAME]
|
||||||
|
version = int(version)
|
||||||
|
auth_config = instance.get_configuration()['auth']
|
||||||
|
return ckclient.get_client(version, **auth_config)
|
||||||
|
|
||||||
|
|
||||||
|
def build_option_parser(parser):
|
||||||
|
"""Hook to add global options."""
|
||||||
|
return parser
|
109
cloudkittyclient/v1/collector/shell_cli.py
Normal file
109
cloudkittyclient/v1/collector/shell_cli.py
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
# Copyright 2016 Objectif Libre
|
||||||
|
#
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from osc_lib.command import command
|
||||||
|
|
||||||
|
from cloudkittyclient.v1.collector import shell
|
||||||
|
|
||||||
|
|
||||||
|
class CliCollectorMappingList(command.Command):
|
||||||
|
"""List collector mappings."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliCollectorMappingList, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-c', '--collector',
|
||||||
|
help='Collector name to filter on.',
|
||||||
|
required=False,
|
||||||
|
default=None)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_collector_mapping_list(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliCollectorMappingGet(command.Command):
|
||||||
|
"""Show collector mapping detail."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliCollectorMappingGet, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--service',
|
||||||
|
help='Which service to get the mapping for.',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_collector_mapping_get(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliCollectorMappingCreate(command.Command):
|
||||||
|
"""Create collector mappings."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliCollectorMappingCreate, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-c', '--collector',
|
||||||
|
help='Map a service to this collector.',
|
||||||
|
required=True)
|
||||||
|
parser.add_argument('-s', '--service',
|
||||||
|
help='Map a collector to this service.',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_collector_mapping_create(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliCollectorMappingDelete(command.Command):
|
||||||
|
"""Delete collector mappings."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliCollectorMappingDelete, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--service',
|
||||||
|
help='Filter on this service',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_collector_mapping_delete(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class BaseCliCollectorState(command.Command):
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(BaseCliCollectorState, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-n', '--name',
|
||||||
|
help='Name of the collector',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
class CliCollectorStateGet(BaseCliCollectorState):
|
||||||
|
"""Show collector state."""
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_collector_state_get(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliCollectorStateEnable(BaseCliCollectorState):
|
||||||
|
"""Enable collector state."""
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_collector_state_enable(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliCollectorStateDisable(BaseCliCollectorState):
|
||||||
|
"""Disable collector state."""
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_collector_state_disable(ckclient, parsed_args)
|
355
cloudkittyclient/v1/rating/hashmap/shell_cli.py
Normal file
355
cloudkittyclient/v1/rating/hashmap/shell_cli.py
Normal file
@@ -0,0 +1,355 @@
|
|||||||
|
# Copyright 2016 Objectif Libre
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import functools
|
||||||
|
|
||||||
|
from osc_lib.command import command
|
||||||
|
from oslo_utils import strutils
|
||||||
|
|
||||||
|
from cloudkittyclient.v1.rating.hashmap import shell
|
||||||
|
|
||||||
|
|
||||||
|
_bool_strict = functools.partial(strutils.bool_from_string, strict=True)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapServiceCreate(command.Command):
|
||||||
|
"""Create a service."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapServiceCreate, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-n', '--name',
|
||||||
|
help='Service name',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_service_create(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapServiceList(command.Command):
|
||||||
|
"""List services."""
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_service_list(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapServiceDelete(command.Command):
|
||||||
|
"""Delete a service."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapServiceDelete, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--service-id',
|
||||||
|
help='Service id',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_service_delete(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapFieldCreate(command.Command):
|
||||||
|
"""Create a field."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapFieldCreate, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--service-id',
|
||||||
|
help='Service id',
|
||||||
|
required=True)
|
||||||
|
parser.add_argument('-n', '--name',
|
||||||
|
help='Field name',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_field_create(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapFieldList(command.Command):
|
||||||
|
"""List fields."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapFieldList, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--service-id',
|
||||||
|
help='Service id',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_field_list(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapFieldDelete(command.Command):
|
||||||
|
"""Delete a field."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapFieldDelete, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-f', '--field-id',
|
||||||
|
help='Field id',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_field_delete(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapMappingCommon(command.Command):
|
||||||
|
def get_parser(self, prog_name, cost=False):
|
||||||
|
parser = super(CliHashmapMappingCommon, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-c', '--cost',
|
||||||
|
help='Mapping Cost',
|
||||||
|
required=cost)
|
||||||
|
parser.add_argument('-v', '--value',
|
||||||
|
help='Mapping Value',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-t', '--type',
|
||||||
|
help='Mapping type (flat, rate)',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-g', '--group-id',
|
||||||
|
help='Group id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-p', '--project-id',
|
||||||
|
help='Project/Tenant id',
|
||||||
|
required=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapMappingCreate(CliHashmapMappingCommon):
|
||||||
|
"""Create a mapping."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapMappingCreate, self).get_parser(prog_name,
|
||||||
|
cost=True)
|
||||||
|
parser.add_argument('-s', '--service-id',
|
||||||
|
help='Service id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-f', '--field-id',
|
||||||
|
help='Service id',
|
||||||
|
required=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_mapping_create(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapMappingUpdate(CliHashmapMappingCommon):
|
||||||
|
"""Update a mapping."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapMappingUpdate, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-m', '--mapping-id',
|
||||||
|
help='Mapping id',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_mapping_update(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapMappingList(command.Command):
|
||||||
|
"""List mappings."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapMappingList, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--service-id',
|
||||||
|
help='Service id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-f', '--field-id',
|
||||||
|
help='Field id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-g', '--group-id',
|
||||||
|
help='Group id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-p', '--project-id',
|
||||||
|
help='Project id',
|
||||||
|
required=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_mapping_list(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapMappingDelete(command.Command):
|
||||||
|
"""Delete a mapping."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapMappingDelete, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-m', '--mapping-id',
|
||||||
|
help='Mapping id',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_mapping_delete(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapGroupCreate(command.Command):
|
||||||
|
"""Create a group."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapGroupCreate, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-n', '--name',
|
||||||
|
help='Group name.',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_group_create(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapGroupList(command.Command):
|
||||||
|
"""List groups."""
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_group_list(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapGroupDelete(command.Command):
|
||||||
|
"""Delete a group."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapGroupDelete, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-g', '--group-id',
|
||||||
|
help='Group uuid',
|
||||||
|
required=True)
|
||||||
|
parser.add_argument('-r', '--recursive',
|
||||||
|
help="""Delete the group's mappings.""",
|
||||||
|
required=False,
|
||||||
|
default=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_group_delete(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapThresholdCommon(command.Command):
|
||||||
|
def get_parser(self, prog_name, create=False):
|
||||||
|
parser = super(CliHashmapThresholdCommon, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-l', '--level',
|
||||||
|
help='Threshold level',
|
||||||
|
required=create)
|
||||||
|
parser.add_argument('-c', '--cost',
|
||||||
|
help='Threshold cost',
|
||||||
|
required=create)
|
||||||
|
parser.add_argument('-t', '--type',
|
||||||
|
help='Threshold type',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-g', '--group-id',
|
||||||
|
help='Group id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-p', '--project-id',
|
||||||
|
help='Project/tenant id',
|
||||||
|
required=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapThresholdCreate(CliHashmapThresholdCommon):
|
||||||
|
"""Create a threshold."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapThresholdCreate, self).get_parser(prog_name,
|
||||||
|
create=True)
|
||||||
|
parser.add_argument('-s', '--service-id',
|
||||||
|
help='Service id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-f', '--field-id',
|
||||||
|
help='Field id',
|
||||||
|
required=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_threshold_create(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapThresholdUpdate(CliHashmapThresholdCommon):
|
||||||
|
"""Update a threshold."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapThresholdUpdate, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-i', '--threshold-id',
|
||||||
|
help='Threshold id',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_threshold_update(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapThresholdList(command.Command):
|
||||||
|
"""List thresholds."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapThresholdList, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--service-id',
|
||||||
|
help='Service id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-f', '--field-id',
|
||||||
|
help='Field id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-g', '--group-id',
|
||||||
|
help='Group id',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('--no-group',
|
||||||
|
type=_bool_strict, metavar='{True,False}',
|
||||||
|
help='If True, list only orphaned thresholds',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-p', '--project-id',
|
||||||
|
help='Project/tenant id',
|
||||||
|
required=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_threshold_list(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapThresholdDelete(command.Command):
|
||||||
|
"""Delete a threshold."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapThresholdDelete, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-i', '--threshold-id',
|
||||||
|
help='Threshold uuid',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_threshold_delete(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapThresholdGet(command.Command):
|
||||||
|
"""Get a threshold."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapThresholdGet, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-i', '--threshold-id',
|
||||||
|
help='Threshold uuid',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_threshold_get(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliHashmapThresholdGroup(command.Command):
|
||||||
|
"""Get a threshold group."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliHashmapThresholdGroup, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-i', '--threshold-id',
|
||||||
|
help='Threshold uuid',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_hashmap_threshold_group(ckclient, parsed_args)
|
115
cloudkittyclient/v1/rating/pyscripts/shell_cli.py
Normal file
115
cloudkittyclient/v1/rating/pyscripts/shell_cli.py
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
# Copyright 2016 Objectif Libre
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import functools
|
||||||
|
|
||||||
|
from osc_lib.command import command
|
||||||
|
from oslo_utils import strutils
|
||||||
|
|
||||||
|
from cloudkittyclient.v1.rating.pyscripts import shell
|
||||||
|
|
||||||
|
|
||||||
|
_bool_strict = functools.partial(strutils.bool_from_string, strict=True)
|
||||||
|
|
||||||
|
|
||||||
|
class CliPyScriptCreate(command.Command):
|
||||||
|
"""Create a script."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliPyScriptCreate, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-n', '--name',
|
||||||
|
help='Script name',
|
||||||
|
required=True)
|
||||||
|
parser.add_argument('-f', '--file',
|
||||||
|
help='Script file',
|
||||||
|
required=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_pyscripts_script_create(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliPyScriptList(command.Command):
|
||||||
|
"""List scripts."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliPyScriptList, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-d', '--show-data',
|
||||||
|
help='Show data in the listing',
|
||||||
|
required=False,
|
||||||
|
default=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_pyscripts_script_list(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliPyScriptGet(command.Command):
|
||||||
|
"""Get script."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliPyScriptGet, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--script-id',
|
||||||
|
help='Script uuid',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_pyscripts_script_get(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliPyScriptGetData(command.Command):
|
||||||
|
"""Get script data."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliPyScriptGetData, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--script-id',
|
||||||
|
help='Script uuid',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_pyscripts_script_get_data(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliPyScriptDelete(command.Command):
|
||||||
|
"""Get script data."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliPyScriptDelete, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--script-id',
|
||||||
|
help='Script uuid',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_pyscripts_script_delete(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliPyScriptUpdate(command.Command):
|
||||||
|
"""Update a script."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliPyScriptUpdate, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-s', '--script-id',
|
||||||
|
help='Script uuid',
|
||||||
|
required=True)
|
||||||
|
parser.add_argument('-f', '--file',
|
||||||
|
help='Script file',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_pyscripts_script_update(ckclient, parsed_args)
|
48
cloudkittyclient/v1/report/shell_cli.py
Normal file
48
cloudkittyclient/v1/report/shell_cli.py
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Copyright 2016 Objectif Libre
|
||||||
|
#
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from osc_lib.command import command
|
||||||
|
|
||||||
|
from cloudkittyclient.v1.report import shell
|
||||||
|
|
||||||
|
|
||||||
|
class CliTotalGet(command.Command):
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliTotalGet, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-t', '--tenant-id',
|
||||||
|
help='Tenant id',
|
||||||
|
required=False,
|
||||||
|
dest='total_tenant_id')
|
||||||
|
parser.add_argument('-b', '--begin',
|
||||||
|
help='Begin timestamp',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-e', '--end',
|
||||||
|
help='End timestamp',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-s', '--service',
|
||||||
|
help='Service Type',
|
||||||
|
required=False)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_total_get(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliReportTenantList(command.Command):
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_report_tenant_list(ckclient, parsed_args)
|
68
cloudkittyclient/v1/shell_cli.py
Normal file
68
cloudkittyclient/v1/shell_cli.py
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
# Copyright 2016 Objectif Libre
|
||||||
|
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from osc_lib.command import command
|
||||||
|
|
||||||
|
from cloudkittyclient.v1 import shell
|
||||||
|
|
||||||
|
|
||||||
|
class CliModuleList(command.Command):
|
||||||
|
"""List modules."""
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_module_list(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliModuleEnable(command.Command):
|
||||||
|
"""Enable a module."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliModuleEnable, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-n', '--name',
|
||||||
|
help='Module name',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_module_enable(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliModuleDisable(command.Command):
|
||||||
|
"""Disable a module."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliModuleDisable, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-n', '--name',
|
||||||
|
help='Module name',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_module_disable(ckclient, parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class CliModuleSetPriority(command.Command):
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliModuleSetPriority, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-n', '--name',
|
||||||
|
help='Module name',
|
||||||
|
required=True)
|
||||||
|
parser.add_argument('-p', '--priority',
|
||||||
|
help='Module priority',
|
||||||
|
required=True)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_module_set_priority(ckclient, parsed_args)
|
44
cloudkittyclient/v1/storage/shell_cli.py
Normal file
44
cloudkittyclient/v1/storage/shell_cli.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Copyright 2016 Objectif Libre
|
||||||
|
#
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from osc_lib.command import command
|
||||||
|
|
||||||
|
from cloudkittyclient.v1.storage import shell
|
||||||
|
|
||||||
|
|
||||||
|
class CliStorageDataframeList(command.Command):
|
||||||
|
"""List dataframes."""
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CliStorageDataframeList, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('-b', '--begin',
|
||||||
|
help='Starting date/time (YYYY-MM-ddThh:mm:ss)',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-e', '--end',
|
||||||
|
help='Ending date/time (YYYY-MM-ddThh:mm:ss)',
|
||||||
|
required=False)
|
||||||
|
parser.add_argument('-t', '--tenant',
|
||||||
|
help='Tenant ID',
|
||||||
|
required=False,
|
||||||
|
default=None)
|
||||||
|
parser.add_argument('-r', '--resource-type',
|
||||||
|
help='Resource type (compute, image...)',
|
||||||
|
required=False,
|
||||||
|
default=None)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
ckclient = self.app.client_manager.rating
|
||||||
|
shell.do_storage_dataframe_list(ckclient, parsed_args)
|
@@ -5,6 +5,7 @@
|
|||||||
pbr>=1.6 # Apache-2.0
|
pbr>=1.6 # Apache-2.0
|
||||||
Babel>=2.3.4 # BSD
|
Babel>=2.3.4 # BSD
|
||||||
python-keystoneclient!=1.8.0,!=2.1.0,>=1.7.0 # Apache-2.0
|
python-keystoneclient!=1.8.0,!=2.1.0,>=1.7.0 # Apache-2.0
|
||||||
|
python-openstackclient>=3.0.0 # Apache-2.0
|
||||||
stevedore>=1.10.0 # Apache-2.0
|
stevedore>=1.10.0 # Apache-2.0
|
||||||
oslo.i18n>=2.1.0 # Apache-2.0
|
oslo.i18n>=2.1.0 # Apache-2.0
|
||||||
oslo.serialization>=1.10.0 # Apache-2.0
|
oslo.serialization>=1.10.0 # Apache-2.0
|
||||||
|
49
setup.cfg
49
setup.cfg
@@ -30,6 +30,55 @@ cloudkitty.client.modules =
|
|||||||
hashmap = cloudkittyclient.v1.rating.hashmap.extension:Extension
|
hashmap = cloudkittyclient.v1.rating.hashmap.extension:Extension
|
||||||
pyscripts = cloudkittyclient.v1.rating.pyscripts.extension:Extension
|
pyscripts = cloudkittyclient.v1.rating.pyscripts.extension:Extension
|
||||||
|
|
||||||
|
openstack.cli.extension =
|
||||||
|
rating = cloudkittyclient.osc
|
||||||
|
|
||||||
|
openstack.rating.v1 =
|
||||||
|
rating_module-list = cloudkittyclient.v1.shell_cli:CliModuleList
|
||||||
|
rating_module-enable = cloudkittyclient.v1.shell_cli:CliModuleEnable
|
||||||
|
rating_module-disable = cloudkittyclient.v1.shell_cli:CliModuleDisable
|
||||||
|
rating_module-set-priority = cloudkittyclient.v1.shell_cli:CliModuleSetPriority
|
||||||
|
|
||||||
|
rating_total-get = cloudkittyclient.v1.report.shell_cli:CliTotalGet
|
||||||
|
rating_report-tenant-list = cloudkittyclient.v1.report.shell_cli:CliReportTenantList
|
||||||
|
|
||||||
|
rating_collector-mapping-list = cloudkittyclient.v1.collector.shell_cli:CliCollectorMappingList
|
||||||
|
rating_collector-mapping-get = cloudkittyclient.v1.collector.shell_cli:CliCollectorMappingGet
|
||||||
|
rating_collector-mapping-create = cloudkittyclient.v1.collector.shell_cli:CliCollectorMappingCreate
|
||||||
|
rating_collector-mapping-delete = cloudkittyclient.v1.collector.shell_cli:CliCollectorMappingDelete
|
||||||
|
rating_collector-state-get = cloudkittyclient.v1.collector.shell_cli:CliCollectorStateGet
|
||||||
|
rating_collector-state-enable = cloudkittyclient.v1.collector.shell_cli:CliCollectorStateEnable
|
||||||
|
rating_collector-state-disable = cloudkittyclient.v1.collector.shell_cli:CliCollectorStateDisable
|
||||||
|
|
||||||
|
rating_storage-dataframe-list = cloudkittyclient.v1.storage.shell_cli:CliStorageDataframeList
|
||||||
|
|
||||||
|
rating_hashmap-service-create = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapServiceCreate
|
||||||
|
rating_hashmap-service-list = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapServiceList
|
||||||
|
rating_hashmap-service-delete = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapServiceDelete
|
||||||
|
rating_hashmap-field-create = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapFieldCreate
|
||||||
|
rating_hashmap-field-list = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapFieldList
|
||||||
|
rating_hashmap-field-delete = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapFieldDelete
|
||||||
|
rating_hashmap-mapping-create = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapMappingCreate
|
||||||
|
rating_hashmap-mapping-update = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapMappingUpdate
|
||||||
|
rating_hashmap-mapping-list = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapMappingList
|
||||||
|
rating_hashmap-mapping-delete = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapMappingDelete
|
||||||
|
rating_hashmap-group-create = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapGroupCreate
|
||||||
|
rating_hashmap-group-list = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapGroupList
|
||||||
|
rating_hashmap-group-delete = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapGroupDelete
|
||||||
|
rating_hashmap-threshold-create = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapThresholdCreate
|
||||||
|
rating_hashmap-threshold-update = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapThresholdUpdate
|
||||||
|
rating_hashmap-threshold-list = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapThresholdList
|
||||||
|
rating_hashmap-threshold-delete = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapThresholdDelete
|
||||||
|
rating_hashmap-threshold-get = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapThresholdGet
|
||||||
|
rating_hashmap-threshold-group = cloudkittyclient.v1.rating.hashmap.shell_cli:CliHashmapThresholdGroup
|
||||||
|
|
||||||
|
rating_pyscripts-script-create = cloudkittyclient.v1.rating.pyscripts.shell_cli:CliPyScriptCreate
|
||||||
|
rating_pyscripts-script-list = cloudkittyclient.v1.rating.pyscripts.shell_cli:CliPyScriptList
|
||||||
|
rating_pyscripts-script-get = cloudkittyclient.v1.rating.pyscripts.shell_cli:CliPyScriptGet
|
||||||
|
rating_pyscripts-script-get-data = cloudkittyclient.v1.rating.pyscripts.shell_cli:CliPyScriptGetData
|
||||||
|
rating_pyscripts-script-delete = cloudkittyclient.v1.rating.pyscripts.shell_cli:CliPyScriptDelete
|
||||||
|
rating_pyscripts-script-update = cloudkittyclient.v1.rating.pyscripts.shell_cli:CliPyScriptUpdate
|
||||||
|
|
||||||
[build_sphinx]
|
[build_sphinx]
|
||||||
source-dir = doc/source
|
source-dir = doc/source
|
||||||
build-dir = doc/build
|
build-dir = doc/build
|
||||||
|
Reference in New Issue
Block a user