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

VM tags new tag API.

parent b39958ea
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ class VirtualMachine(object):
self.uuid = dom.UUIDString()
self.name = dom.name()
#: state of VM: started, stoped, paused
self.state = STATE[dom.info()[0]]
self._state = STATE[dom.info()[0]]
#: tags for this VM
self.tags = dict((t.name, t) for t in tag_inspector(vm_tags, self))
# define dynamic tags
......@@ -55,6 +55,15 @@ class VirtualMachine(object):
logger.debug('Virtual Machine tags: %s', self.tags)
@property
def state(self):
return self._state
@state.setter
def state(self, value):
self._state = value
self.tags['status'].value = value
@property
def lv_dom(self):
"""Libvirt domain instance."""
......
from xml.etree import cElementTree as et
from StringIO import StringIO
from ccnode.tags import ttl, refresh
def uuid(dom):
"""Unique identifier of the domain."""
return dom.uuid
@ttl(5)
def status(dom):
return dom.state
status.ttl = 5
def hv(dom):
......@@ -40,9 +42,10 @@ def cpu(dom):
return dom.lv_dom.info()[3]
@ttl(10)
@refresh(5)
def cpuuse():
pass
cpuuse.ttl = 10
def mem(dom):
......@@ -65,13 +68,15 @@ def vncport(dom):
logger.exception('VNCPort')
@ttl(10)
@refresh(10)
def disk(dom):
"""Get backend disks."""
return u' '.join(map(str, xrange(len(dom.disks)))) or None
disk.ttl = 10
@ttl(10)
@refresh(10)
def nic(dom):
"""VM network interfaces."""
return u' '.join(map(str, xrange(len(dom.nics)))) or None
disk.nic = 10
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