Loading cloudcontrol/node/hypervisor/domains/__init__.py +12 −4 Original line number Diff line number Diff line Loading @@ -23,12 +23,13 @@ from StringIO import StringIO from xml.etree import cElementTree as et from collections import namedtuple from itertools import izip, count from functools import partial import pyev import libvirt from cloudcontrol.common.client.tags import Tag, tag_inspector, TagDB from cloudcontrol.node.hypervisor.lib import DOMAIN_STATES as STATE from cloudcontrol.node.hypervisor.lib import DOMAIN_STATES as STATE, BoundVolumeProxy from cloudcontrol.node.hypervisor.domains import vm_tags from cloudcontrol.node.utils import SocketBuffer from cloudcontrol.node.exc import ConsoleAlreadyOpened, ConsoleError Loading Loading @@ -75,8 +76,10 @@ class VirtualMachine(object): Tag('disk%s_path' % i, v.path, 10), Tag('disk%s_pool' % i, v.storage.name, 10), # FIXME: change Tag('disk%s_vol' % i, v.name, 10), Tag('disk%s_cache' % i, lambda: self.cache_behaviour.get(v.path), 10), Tag('disk%s_shared' % i, lambda: {True: 'yes', False: 'no'}[v.storage.is_shared]) Tag('disk%s_cache' % i, partial(lambda x: self.cache_behaviour.get(x.path), v), 10), Tag('disk%s_shared' % i, partial(lambda x: {True: 'yes', False: 'no'}[x.storage.is_shared], v)), Tag('disk%s_dev' % i, v.device, 10), Tag('disk%s_bus' % i, v.bus, 10) ): self.tag_db.add_tag(t) Loading Loading @@ -278,13 +281,18 @@ class VirtualMachine(object): path = volume.path # Get target device & bus target = d.find('target') device = target.get('dev') bus = target.get('bus') # update cache behaviour driver = d.find('driver') if driver is None: driver = {} self.cache_behaviour[path] = driver.get('cache', 'default') yield volume yield BoundVolumeProxy(volume, device, bus) @property def nics(self): Loading cloudcontrol/node/hypervisor/lib.py +12 −0 Original line number Diff line number Diff line Loading @@ -472,3 +472,15 @@ class Volume(object): def update(self): self.capacity, self.allocation = self.lv_volume.info()[1:] class BoundVolumeProxy(object): """Proxy object to an existing Volume when its bound to a VM.""" def __init__(self, volume, device, bus): self.volume = volume self.device = device self.bus = bus def __getattr__(self, name): return self.volume.__getattribute__(name) Loading
cloudcontrol/node/hypervisor/domains/__init__.py +12 −4 Original line number Diff line number Diff line Loading @@ -23,12 +23,13 @@ from StringIO import StringIO from xml.etree import cElementTree as et from collections import namedtuple from itertools import izip, count from functools import partial import pyev import libvirt from cloudcontrol.common.client.tags import Tag, tag_inspector, TagDB from cloudcontrol.node.hypervisor.lib import DOMAIN_STATES as STATE from cloudcontrol.node.hypervisor.lib import DOMAIN_STATES as STATE, BoundVolumeProxy from cloudcontrol.node.hypervisor.domains import vm_tags from cloudcontrol.node.utils import SocketBuffer from cloudcontrol.node.exc import ConsoleAlreadyOpened, ConsoleError Loading Loading @@ -75,8 +76,10 @@ class VirtualMachine(object): Tag('disk%s_path' % i, v.path, 10), Tag('disk%s_pool' % i, v.storage.name, 10), # FIXME: change Tag('disk%s_vol' % i, v.name, 10), Tag('disk%s_cache' % i, lambda: self.cache_behaviour.get(v.path), 10), Tag('disk%s_shared' % i, lambda: {True: 'yes', False: 'no'}[v.storage.is_shared]) Tag('disk%s_cache' % i, partial(lambda x: self.cache_behaviour.get(x.path), v), 10), Tag('disk%s_shared' % i, partial(lambda x: {True: 'yes', False: 'no'}[x.storage.is_shared], v)), Tag('disk%s_dev' % i, v.device, 10), Tag('disk%s_bus' % i, v.bus, 10) ): self.tag_db.add_tag(t) Loading Loading @@ -278,13 +281,18 @@ class VirtualMachine(object): path = volume.path # Get target device & bus target = d.find('target') device = target.get('dev') bus = target.get('bus') # update cache behaviour driver = d.find('driver') if driver is None: driver = {} self.cache_behaviour[path] = driver.get('cache', 'default') yield volume yield BoundVolumeProxy(volume, device, bus) @property def nics(self): Loading
cloudcontrol/node/hypervisor/lib.py +12 −0 Original line number Diff line number Diff line Loading @@ -472,3 +472,15 @@ class Volume(object): def update(self): self.capacity, self.allocation = self.lv_volume.info()[1:] class BoundVolumeProxy(object): """Proxy object to an existing Volume when its bound to a VM.""" def __init__(self, volume, device, bus): self.volume = volume self.device = device self.bus = bus def __getattr__(self, name): return self.volume.__getattribute__(name)