Commit 9b68a4e7 authored by Anael Beutot's avatar Anael Beutot
Browse files

Add storage state tag for hypervisor.

parent 2e2d6e5c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ from ccnode.host import Handler as HostHandler
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
from ccnode.hypervisor.lib import EVENTS, STORAGE_STATES, EventLoop
from ccnode.hypervisor.domains import VirtualMachine


@@ -40,6 +40,7 @@ class Handler(HostHandler):
        # register hypervisor storage tags
        for name, storage in self.hypervisor.storage.storages.iteritems():
            for t in (
                Tag('sto%s_state' % name, lambda: storage.state, 5),
                Tag('sto%s_size' % name, lambda: storage.capacity, 5),
                Tag('sto%s_free' % name, lambda: storage.available, 5),
                Tag('sto%s_used' % name,
@@ -224,7 +225,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.state, self.capacity, self.allocation, self.available = lv_storage.info()
        self.state = STORAGE_STATES[self.state]

        self.volumes = map(
            partial(Volume, storage=self),
+10 −0
Original line number Diff line number Diff line
@@ -30,6 +30,16 @@ DOMAIN_STATES = (
)


STORAGE_STATES = (
    'inactive',
    'building',
    'running',
    'degraded',
    'inaccessible',
    '???',  # 5
)


#: libvirt envents
EVENTS = (
    'Added',