Merge "Adds separate class for Hypervisor Stats"
This commit is contained in:
commit
a9223d314e
@ -168,3 +168,11 @@ class HypervisorsTest(utils.FixturedTestCase):
|
||||
self.assert_called('GET', '/os-hypervisors/statistics')
|
||||
|
||||
self.compare_to_expected(expected, result)
|
||||
|
||||
def test_hypervisor_statistics_data_model(self):
|
||||
result = self.cs.hypervisor_stats.statistics()
|
||||
self.assert_called('GET', '/os-hypervisors/statistics')
|
||||
|
||||
# Test for Bug #1370415, the line below used to raise AttributeError
|
||||
self.assertEqual("<HypervisorStats: 2 Hypervisors>",
|
||||
result.__repr__())
|
||||
|
@ -151,6 +151,7 @@ class Client(object):
|
||||
self.aggregates = aggregates.AggregateManager(self)
|
||||
self.hosts = hosts.HostManager(self)
|
||||
self.hypervisors = hypervisors.HypervisorManager(self)
|
||||
self.hypervisor_stats = hypervisors.HypervisorStatsManager(self)
|
||||
self.services = services.ServiceManager(self)
|
||||
self.fixed_ips = fixed_ips.FixedIPsManager(self)
|
||||
self.floating_ips_bulk = floating_ips_bulk.FloatingIPBulkManager(self)
|
||||
|
@ -66,6 +66,25 @@ class HypervisorManager(base.ManagerWithFind):
|
||||
return self._get("/os-hypervisors/%s/uptime" % base.getid(hypervisor),
|
||||
"hypervisor")
|
||||
|
||||
def statistics(self):
|
||||
"""
|
||||
Get hypervisor statistics over all compute nodes.
|
||||
|
||||
Kept for backwards compatibility, new code should call
|
||||
hypervisor_stats.statistics() instead of hypervisors.statistics()
|
||||
"""
|
||||
return self.api.hypervisor_stats.statistics()
|
||||
|
||||
|
||||
class HypervisorStats(base.Resource):
|
||||
def __repr__(self):
|
||||
return ("<HypervisorStats: %d Hypervisor%s>" %
|
||||
(self.count, "s" if self.count != 1 else ""))
|
||||
|
||||
|
||||
class HypervisorStatsManager(base.Manager):
|
||||
resource_class = HypervisorStats
|
||||
|
||||
def statistics(self):
|
||||
"""
|
||||
Get hypervisor statistics over all compute nodes.
|
||||
|
@ -3631,7 +3631,7 @@ def do_hypervisor_uptime(cs, args):
|
||||
|
||||
def do_hypervisor_stats(cs, args):
|
||||
"""Get hypervisor statistics over all compute nodes."""
|
||||
stats = cs.hypervisors.statistics()
|
||||
stats = cs.hypervisor_stats.statistics()
|
||||
utils.print_dict(stats._info.copy())
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user