Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0696510d29 | ||
|
|
4ee7dcb3ee | ||
|
|
5efcd30fdd | ||
|
|
52955c5749 | ||
|
|
2ccbed9139 |
@@ -31,6 +31,7 @@ from cloudkittyclient import client as ckclient
|
||||
from cloudkittyclient.common import utils
|
||||
from cloudkittyclient import exc
|
||||
from cloudkittyclient.openstack.common import cliutils
|
||||
from cloudkittyclient.v1.collector import shell as collector_shell
|
||||
from cloudkittyclient.v1.report import shell as report_shell
|
||||
from cloudkittyclient.v1.storage import shell as storage_shell
|
||||
|
||||
@@ -119,6 +120,7 @@ class CloudkittyShell(object):
|
||||
subparsers = parser.add_subparsers(metavar='<subcommand>')
|
||||
submodule = utils.import_versioned_module(version, 'shell')
|
||||
self._find_actions(subparsers, submodule)
|
||||
self._find_actions(subparsers, collector_shell)
|
||||
self._find_actions(subparsers, report_shell)
|
||||
self._find_actions(subparsers, storage_shell)
|
||||
extensions = extension.ExtensionManager(
|
||||
|
||||
@@ -17,6 +17,7 @@ from stevedore import extension
|
||||
|
||||
from cloudkittyclient import client as ckclient
|
||||
from cloudkittyclient.openstack.common.apiclient import client
|
||||
from cloudkittyclient.v1 import collector
|
||||
from cloudkittyclient.v1 import core
|
||||
from cloudkittyclient.v1 import report
|
||||
from cloudkittyclient.v1 import storage
|
||||
@@ -55,6 +56,7 @@ class Client(object):
|
||||
|
||||
self.http_client = client.BaseClient(self.client)
|
||||
self.modules = core.CloudkittyModuleManager(self.http_client)
|
||||
self.collector = collector.CollectorManager(self.http_client)
|
||||
self.reports = report.ReportManager(self.http_client)
|
||||
self.quotations = core.QuotationManager(self.http_client)
|
||||
self.storage = storage.StorageManager(self.http_client)
|
||||
|
||||
@@ -12,19 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from cloudkittyclient.common import base
|
||||
from cloudkittyclient.v1.collector import mapping
|
||||
from cloudkittyclient.v1.collector import state
|
||||
|
||||
|
||||
class Collector(base.Resource):
|
||||
|
||||
key = 'collector'
|
||||
|
||||
def __repr__(self):
|
||||
return "<Collector %s>" % self._info
|
||||
|
||||
|
||||
class CollectorManager(base.Manager):
|
||||
resource_class = Collector
|
||||
base_url = "/v1/rating"
|
||||
key = "collector"
|
||||
collection_key = "collectors"
|
||||
class CollectorManager(object):
|
||||
def __init__(self, http_client):
|
||||
self.mappings = mapping.MappingManager(http_client)
|
||||
self.states = state.StateManager(http_client)
|
||||
|
||||
30
cloudkittyclient/v1/collector/mapping.py
Normal file
30
cloudkittyclient/v1/collector/mapping.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright 2015 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 cloudkittyclient.common import base
|
||||
|
||||
|
||||
class Mapping(base.Resource):
|
||||
|
||||
key = 'mapping'
|
||||
|
||||
def __repr__(self):
|
||||
return "<Mapping %s>" % self._info
|
||||
|
||||
|
||||
class MappingManager(base.CrudManager):
|
||||
resource_class = Mapping
|
||||
base_url = "/v1/collector"
|
||||
key = "mapping"
|
||||
collection_key = "mappings"
|
||||
80
cloudkittyclient/v1/collector/shell.py
Normal file
80
cloudkittyclient/v1/collector/shell.py
Normal file
@@ -0,0 +1,80 @@
|
||||
# Copyright 2015 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 cloudkittyclient.common import utils
|
||||
|
||||
|
||||
@utils.arg('--collector',
|
||||
help='Collector name to filter on.',
|
||||
required=False,
|
||||
default=None)
|
||||
def do_collector_mapping_list(cc, args):
|
||||
data = cc.collector.mappings.list(collector=args.collector)
|
||||
fields = ['service', 'collector']
|
||||
fields_labels = ['Service', 'Collector']
|
||||
utils.print_list(data, fields, fields_labels, sortby=0)
|
||||
|
||||
|
||||
@utils.arg('--service',
|
||||
help='Which service to get the mapping for.',
|
||||
required=True)
|
||||
def do_collector_mapping_get(cc, args):
|
||||
data = cc.collector.mappings.get(mapping_id=args.service)
|
||||
utils.print_dict(data.to_dict())
|
||||
|
||||
|
||||
@utils.arg('--collector',
|
||||
help='Map a service to this collector.',
|
||||
required=True)
|
||||
@utils.arg('--service',
|
||||
help='Map a collector to this service.',
|
||||
required=True)
|
||||
def do_collector_mapping_create(cc, args):
|
||||
out = cc.collector.mappings.create(service=args.service,
|
||||
collector=args.collector)
|
||||
utils.print_dict(out.to_dict())
|
||||
|
||||
|
||||
@utils.arg('--service',
|
||||
help='Filter on this service.',
|
||||
required=True)
|
||||
def do_collector_mapping_delete(cc, args):
|
||||
# TODO(sheeprine): Use a less hacky way to do this
|
||||
cc.collector.mappings.delete(mapping_id=args.service)
|
||||
|
||||
|
||||
@utils.arg('--name',
|
||||
help='Name of the collector.',
|
||||
required=True)
|
||||
def do_collector_state_get(cc, args):
|
||||
data = cc.collector.states.get(state_id=args.name)
|
||||
utils.print_dict(data.to_dict())
|
||||
|
||||
|
||||
@utils.arg('--name',
|
||||
help='Name of the collector.',
|
||||
required=True)
|
||||
def do_collector_state_enable(cc, args):
|
||||
new_state = cc.collector.states.update(name=args.name, enabled=True)
|
||||
utils.print_dict(new_state.to_dict())
|
||||
|
||||
|
||||
@utils.arg('--name',
|
||||
help='Name of the collector.',
|
||||
required=True)
|
||||
def do_collector_state_disable(cc, args):
|
||||
new_state = cc.collector.states.update(name=args.name, enabled=False)
|
||||
utils.print_dict(new_state.to_dict())
|
||||
30
cloudkittyclient/v1/collector/state.py
Normal file
30
cloudkittyclient/v1/collector/state.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright 2015 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 cloudkittyclient.common import base
|
||||
|
||||
|
||||
class State(base.Resource):
|
||||
|
||||
key = 'state'
|
||||
|
||||
def __repr__(self):
|
||||
return "<State %s>" % self._info
|
||||
|
||||
|
||||
class StateManager(base.CrudManager):
|
||||
resource_class = State
|
||||
base_url = "/v1/collector"
|
||||
key = "state"
|
||||
collection_key = "states"
|
||||
@@ -131,7 +131,7 @@ def do_hashmap_field_delete(cc, args={}):
|
||||
help='Group id',
|
||||
required=False)
|
||||
def do_hashmap_mapping_create(cc, args={}):
|
||||
"""Create a ampping."""
|
||||
"""Create a mapping."""
|
||||
arg_to_field_mapping = {
|
||||
'cost': 'cost',
|
||||
'value': 'value',
|
||||
@@ -291,7 +291,7 @@ def do_hashmap_group_delete(cc, args={}):
|
||||
help='Group id',
|
||||
required=False)
|
||||
def do_hashmap_threshold_create(cc, args={}):
|
||||
"""Create a ampping."""
|
||||
"""Create a mapping."""
|
||||
arg_to_field_mapping = {
|
||||
'level': 'level',
|
||||
'cost': 'cost',
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
pbr>=0.6,!=0.7,<1.0
|
||||
pbr!=0.7,<1.0,>=0.6
|
||||
Babel>=1.3
|
||||
python-keystoneclient
|
||||
stevedore
|
||||
oslo.i18n
|
||||
oslo.serialization
|
||||
oslo.utils
|
||||
python-keystoneclient<1.4.0,>=1.2.0
|
||||
stevedore<1.4.0,>=1.3.0 # Apache-2.0
|
||||
oslo.i18n<1.6.0,>=1.5.0 # Apache-2.0
|
||||
oslo.serialization<1.5.0,>=1.4.0 # Apache-2.0
|
||||
oslo.utils<1.5.0,>=1.4.0 # Apache-2.0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[metadata]
|
||||
name = python-cloudkittyclient
|
||||
summary = Cloudkittyclient is the api client for the cloudkitty rating project.
|
||||
version = 0.4.1
|
||||
summary = API client of cloudkitty, Rating as a Service project.
|
||||
description-file =
|
||||
README.rst
|
||||
author = OpenStack
|
||||
|
||||
9
setup.py
Executable file → Normal file
9
setup.py
Executable file → Normal file
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,6 +16,14 @@
|
||||
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
|
||||
import setuptools
|
||||
|
||||
# In python < 2.7.4, a lazy loading of package `pbr` will break
|
||||
# setuptools if some other modules registered functions in `atexit`.
|
||||
# solution from: http://bugs.python.org/issue15881#msg170215
|
||||
try:
|
||||
import multiprocessing # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['pbr'],
|
||||
pbr=True)
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
hacking>=0.9.2,<0.10
|
||||
hacking<0.10,>=0.9.2
|
||||
|
||||
coverage>=3.6
|
||||
discover
|
||||
python-subunit
|
||||
sphinx>=1.1.2
|
||||
oslosphinx
|
||||
oslotest>=1.1.0.0a1
|
||||
python-subunit>=0.0.18
|
||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||
oslosphinx<2.6.0,>=2.5.0 # Apache-2.0
|
||||
oslotest<1.6.0,>=1.5.1 # Apache-2.0
|
||||
testrepository>=0.0.18
|
||||
testscenarios>=0.4
|
||||
testtools>=0.9.34
|
||||
testtools!=1.2.0,>=0.9.36
|
||||
|
||||
Reference in New Issue
Block a user