From 4bbeb5488ef7fcc2657a26b82bd7742818c2049d Mon Sep 17 00:00:00 2001 From: Georgy Okrokvertskhov Date: Fri, 14 Mar 2014 22:25:52 -0700 Subject: [PATCH] Add Stats List method This patch adds a new StatsManager. This manager allow to get a list of stats for all servers via list method. Change-Id: Ic7bf3aaee11534542df6ca95f675da6585dc2638 Partly-Implements: blueprint api-request-stats --- muranoclient/v1/client.py | 2 ++ muranoclient/v1/statistics.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 muranoclient/v1/statistics.py diff --git a/muranoclient/v1/client.py b/muranoclient/v1/client.py index d57568e5..25231410 100644 --- a/muranoclient/v1/client.py +++ b/muranoclient/v1/client.py @@ -14,6 +14,7 @@ from muranoclient.common import http from muranoclient.v1 import environments, sessions, services, deployments +from muranoclient.v1 import statistics class Client(http.HTTPClient): @@ -32,3 +33,4 @@ class Client(http.HTTPClient): self.sessions = sessions.SessionManager(self) self.services = services.ServiceManager(self) self.deployments = deployments.DeploymentManager(self) + self.statistics = statistics.StatisticsManager(self) diff --git a/muranoclient/v1/statistics.py b/muranoclient/v1/statistics.py new file mode 100644 index 00000000..00708f95 --- /dev/null +++ b/muranoclient/v1/statistics.py @@ -0,0 +1,30 @@ +# Copyright (c) 2013 Mirantis, Inc. +# +# 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 muranoclient.common import base + + +class Statistic(base.Resource): + def __repr__(self): + return "" % self._info + + def data(self, **kwargs): + return self.manager.data(self, **kwargs) + + +class StatisticsManager(base.Manager): + resource_class = Statistic + + def list(self): + return self._list('/stats', 'stats')