Skip to content
Snippets Groups Projects
Commit 2e2d6e5c authored by Anael Beutot's avatar Anael Beutot
Browse files

Storage tag on hypervisor.

parent e87831a4
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ from itertools import chain, imap
import libvirt
from ccnode.host import Handler as HostHandler
from ccnode.tags import tag_inspector, get_tags
from ccnode.tags import Tag, tag_inspector, get_tags
from ccnode.hypervisor import tags
from ccnode.hypervisor import lib as _libvirt
from ccnode.hypervisor.lib import EVENTS, EventLoop
......@@ -37,6 +37,16 @@ class Handler(HostHandler):
self.hypervisor = weakref.proxy(hypervisor)
# register hypervisor storage tags
for name, storage in self.hypervisor.storage.storages.iteritems():
for t in (
Tag('sto%s_size' % name, lambda: storage.capacity, 5),
Tag('sto%s_free' % name, lambda: storage.available, 5),
Tag('sto%s_used' % name,
lambda: storage.capacity - storage.available, 5),
):
self.tags[t.name] = t
# register domains
proxy = kwargs.pop('proxy')
for dom in hypervisor.domains.itervalues():
......@@ -214,6 +224,8 @@ class Storage(object):
self.uuid = lv_storage.UUID()
self.name = lv_storage.name()
self.capacity, self.allocation, self.available = lv_storage.info()[1:]
self.volumes = map(
partial(Volume, storage=self),
(lv_storage.storageVolLookupByName(n) for n in
......
......@@ -55,12 +55,11 @@ def rjobs():
# storage pools
def sto():
def sto(handl):
"""Storage pool names."""
return u' '.join(handl.hypervisor.storage.storages.iterkeys())
# dynamic sto
# Vm related tags
def nvm(handl):
"""Number of VMS in the current hypervisor."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment