Commit cf89ed48 authored by Antoine Millet's avatar Antoine Millet

Added a way to handle ceph storages without refreshing them

parent 5f24a255
......@@ -293,6 +293,9 @@ class EventLoop(object):
class StorageIndex(object):
"""Keep an index of all storage volume paths."""
SHARED_TYPES = ['rbd']
def __init__(self, handler, lv_con):
:param handler: Hypervisor handler instance
......@@ -319,7 +322,11 @@ class StorageIndex(object):
# add storage pool
s = Storage(lv_storage)
storage_type = et.ElementTree().parse(StringIO(lv_storage.XMLDesc(0))).get('type')
if storage_type in self.SHARED_TYPES:
s = SharedStorage(lv_storage)
s = Storage(lv_storage)
self.storages[] = s
# add tags
......@@ -416,7 +423,6 @@ class StorageIndex(object):
class Storage(object):
"""Storage abstraction."""
SHARED_TYPES = ['rbd']
def __init__(self, lv_storage):
......@@ -438,7 +444,7 @@ class Storage(object):
def is_shared(self):
return True if self.type in Storage.SHARED_TYPES else False
return False
def update(self, retry=1):
for _ in xrange(retry):
......@@ -473,6 +479,36 @@ class Storage(object):
class SharedStorageVolumeDispenser(object):
def __init__(self, storage): = storage
def get(self, name):
return SharedVolume(, name)
def itervalues(self):
return iter([])
class SharedStorage(Storage):
"""Shared storage abstraction."""
def __init__(self, lv_storage):
:param lv_storage: Libvirt pool storage instance
super(SharedStorage, self).__init__(lv_storage)
self.volumes = SharedStorageVolumeDispenser(self)
def is_shared(self):
return True
def update(self, retry=1):
pass # Do nothing.
class Volume(object):
"""Volume abstraction."""
def __init__(self, storage, lv_volume):
......@@ -490,6 +526,18 @@ class Volume(object):
self.capacity, self.allocation =[1:]
class SharedVolume(object):
"""Shared volume abstraction."""
def __init__(self, storage, name): = storage
self.path, self.capacity, self.allocation = None, None, None = name
self.lv_volume = None
def update(self):
pass # Do nothing.
class BoundVolumeProxy(object):
"""Proxy object to an existing Volume when its bound to a VM."""
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment