Merge "Add support for /v1/status"
This commit is contained in:
commit
698d66fcfc
|
@ -31,11 +31,13 @@ from gnocchiclient.v1 import archive_policy_rule_cli as ap_rule_cli
|
|||
from gnocchiclient.v1 import capabilities_cli
|
||||
from gnocchiclient.v1 import metric_cli
|
||||
from gnocchiclient.v1 import resource_cli
|
||||
from gnocchiclient.v1 import status_cli
|
||||
from gnocchiclient.version import __version__
|
||||
|
||||
|
||||
class GnocchiCommandManager(commandmanager.CommandManager):
|
||||
SHELL_COMMANDS = {
|
||||
"status": status_cli.CliStatusShow,
|
||||
"resource list": resource_cli.CliResourceList,
|
||||
"resource show": resource_cli.CliResourceShow,
|
||||
"resource history": resource_cli.CliResourceHistory,
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# 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 gnocchiclient.tests.functional import base
|
||||
|
||||
|
||||
class MetricClientTest(base.ClientTestBase):
|
||||
def test_status_scenario(self):
|
||||
result = self.gnocchi("status")
|
||||
status = self.details_multiple(result)[0]
|
||||
self.assertEqual(2, len(status))
|
|
@ -18,6 +18,7 @@ from gnocchiclient.v1 import archive_policy_rule
|
|||
from gnocchiclient.v1 import capabilities
|
||||
from gnocchiclient.v1 import metric
|
||||
from gnocchiclient.v1 import resource
|
||||
from gnocchiclient.v1 import status
|
||||
|
||||
|
||||
class Client(object):
|
||||
|
@ -38,3 +39,4 @@ class Client(object):
|
|||
archive_policy_rule.ArchivePolicyRuleManager(self))
|
||||
self.metric = metric.MetricManager(self)
|
||||
self.capabilities = capabilities.CapabilitiesManager(self)
|
||||
self.status = status.StatusManager(self)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#
|
||||
# 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 gnocchiclient.v1 import base
|
||||
|
||||
|
||||
class StatusManager(base.Manager):
|
||||
url = "v1/status"
|
||||
|
||||
def get(self):
|
||||
"""Get Gnocchi status."""
|
||||
return self._get(self.url).json()
|
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
# 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 cliff import show
|
||||
|
||||
|
||||
class CliStatusShow(show.ShowOne):
|
||||
def take_action(self, parsed_args):
|
||||
status = self.app.client.status.get()
|
||||
|
||||
nb_metric = len(status['storage']['measures_to_process'])
|
||||
nb_measures = (
|
||||
sum(status['storage']['measures_to_process'].values())
|
||||
)
|
||||
|
||||
return self.dict2columns({
|
||||
"storage/total number of measures to process": nb_measures,
|
||||
"storage/number of metric having measures to process": nb_metric,
|
||||
})
|
Loading…
Reference in New Issue