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

Add storage state tag for hypervisor.

parent 2e2d6e5c
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ from ccnode.host import Handler as HostHandler ...@@ -9,7 +9,7 @@ from ccnode.host import Handler as HostHandler
from ccnode.tags import Tag, tag_inspector, get_tags from ccnode.tags import Tag, tag_inspector, get_tags
from ccnode.hypervisor import tags from ccnode.hypervisor import tags
from ccnode.hypervisor import lib as _libvirt 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 from ccnode.hypervisor.domains import VirtualMachine
...@@ -40,6 +40,7 @@ class Handler(HostHandler): ...@@ -40,6 +40,7 @@ class Handler(HostHandler):
# register hypervisor storage tags # register hypervisor storage tags
for name, storage in self.hypervisor.storage.storages.iteritems(): for name, storage in self.hypervisor.storage.storages.iteritems():
for t in ( for t in (
Tag('sto%s_state' % name, lambda: storage.state, 5),
Tag('sto%s_size' % name, lambda: storage.capacity, 5), Tag('sto%s_size' % name, lambda: storage.capacity, 5),
Tag('sto%s_free' % name, lambda: storage.available, 5), Tag('sto%s_free' % name, lambda: storage.available, 5),
Tag('sto%s_used' % name, Tag('sto%s_used' % name,
...@@ -224,7 +225,8 @@ class Storage(object): ...@@ -224,7 +225,8 @@ class Storage(object):
self.uuid = lv_storage.UUID() self.uuid = lv_storage.UUID()
self.name = lv_storage.name() 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( self.volumes = map(
partial(Volume, storage=self), partial(Volume, storage=self),
......
...@@ -30,6 +30,16 @@ DOMAIN_STATES = ( ...@@ -30,6 +30,16 @@ DOMAIN_STATES = (
) )
STORAGE_STATES = (
'inactive',
'building',
'running',
'degraded',
'inaccessible',
'???', # 5
)
#: libvirt envents #: libvirt envents
EVENTS = ( EVENTS = (
'Added', 'Added',
......
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