Add support for the storage API
Change-Id: Icefefc27b6f77268b473d8ddf79963a92354c666
This commit is contained in:
@@ -32,6 +32,7 @@ from cloudkittyclient.common import utils
|
||||
from cloudkittyclient import exc
|
||||
from cloudkittyclient.openstack.common import cliutils
|
||||
from cloudkittyclient.v1.report import shell as report_shell
|
||||
from cloudkittyclient.v1.storage import shell as storage_shell
|
||||
|
||||
SUBMODULES_NAMESPACE = 'cloudkitty.client.modules'
|
||||
|
||||
@@ -119,6 +120,7 @@ class CloudkittyShell(object):
|
||||
submodule = utils.import_versioned_module(version, 'shell')
|
||||
self._find_actions(subparsers, submodule)
|
||||
self._find_actions(subparsers, report_shell)
|
||||
self._find_actions(subparsers, storage_shell)
|
||||
extensions = extension.ExtensionManager(
|
||||
SUBMODULES_NAMESPACE,
|
||||
)
|
||||
|
||||
@@ -19,6 +19,7 @@ from cloudkittyclient import client as ckclient
|
||||
from cloudkittyclient.openstack.common.apiclient import client
|
||||
from cloudkittyclient.v1 import core
|
||||
from cloudkittyclient.v1 import report
|
||||
from cloudkittyclient.v1 import storage
|
||||
|
||||
SUBMODULES_NAMESPACE = 'cloudkitty.client.modules'
|
||||
|
||||
@@ -56,6 +57,7 @@ class Client(object):
|
||||
self.modules = core.CloudkittyModuleManager(self.http_client)
|
||||
self.reports = report.ReportManager(self.http_client)
|
||||
self.quotations = core.QuotationManager(self.http_client)
|
||||
self.storage = storage.StorageManager(self.http_client)
|
||||
self._expose_submodules()
|
||||
|
||||
def _expose_submodules(self):
|
||||
|
||||
20
cloudkittyclient/v1/storage/__init__.py
Normal file
20
cloudkittyclient/v1/storage/__init__.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# 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.v1.storage import dataframe
|
||||
|
||||
|
||||
class StorageManager(object):
|
||||
def __init__(self, http_client):
|
||||
self.dataframes = dataframe.DataFrameManager(http_client)
|
||||
29
cloudkittyclient/v1/storage/dataframe.py
Normal file
29
cloudkittyclient/v1/storage/dataframe.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# 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 DataFrameResource(base.Resource):
|
||||
key = 'dataframe'
|
||||
|
||||
def __repr__(self):
|
||||
return "<DataFrameResource %s>" % self._info
|
||||
|
||||
|
||||
class DataFrameManager(base.CrudManager):
|
||||
resource_class = DataFrameResource
|
||||
base_url = '/v1/storage'
|
||||
key = 'dataframe'
|
||||
collection_key = 'dataframes'
|
||||
40
cloudkittyclient/v1/storage/shell.py
Normal file
40
cloudkittyclient/v1/storage/shell.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# 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('--begin',
|
||||
help='Starting date/time (YYYY-MM-ddThh:mm:ss)',
|
||||
required=True)
|
||||
@utils.arg('--end',
|
||||
help='Ending date/time (YYYY-MM-ddThh:mm:ss)',
|
||||
required=True)
|
||||
@utils.arg('--tenant',
|
||||
help='Tenant ID',
|
||||
required=False,
|
||||
default=None)
|
||||
@utils.arg('--resource-type',
|
||||
help='Resource type (compute, image, ...)',
|
||||
required=False,
|
||||
default=None)
|
||||
def do_storage_dataframe_list(cc, args):
|
||||
data = cc.storage.dataframes.list(begin=args.begin, end=args.end,
|
||||
tenant_id=args.tenant,
|
||||
resource_type=args.resource_type)
|
||||
fields = ['begin', 'end', 'tenant_id', 'resources']
|
||||
fields_labels = ['Begin', 'End', 'Tenant ID', 'Resources']
|
||||
utils.print_list(data, fields, fields_labels, sortby=0)
|
||||
Reference in New Issue
Block a user