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):
self.storages[lv_storage.name()].update(retry)
else:
# 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)
else:
s = Storage(lv_storage)
self.storages[s.name] = s
# add tags
self.handler.tag_db.add_tags((
......@@ -416,7 +423,6 @@ class StorageIndex(object):
class Storage(object):
"""Storage abstraction."""
SHARED_TYPES = ['rbd']
REFRESH_RETRY_INTERVAL = 1
def __init__(self, lv_storage):
......@@ -438,7 +444,7 @@ class Storage(object):
@property
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):
StringIO(self.lv_storage.XMLDesc(0))).get('type')
class SharedStorageVolumeDispenser(object):
def __init__(self, storage):
self.storage = storage
def get(self, name):
return SharedVolume(self.storage, 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)
@property
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 = self.lv_volume.info()[1:]
class SharedVolume(object):
"""Shared volume abstraction."""
def __init__(self, storage, name):
self.storage = storage
self.path, self.capacity, self.allocation = None, None, None
self.name = 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
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment