Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(LVHDSR): add a way to modify config of LVMs #689

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions drivers/LVHDSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,24 @@ def load(self, sr_uuid):
self.path = os.path.join(lvhdutil.VG_LOCATION, self.vgname)
self.mdpath = os.path.join(self.path, self.MDVOLUME_NAME)
self.provision = self.PROVISIONING_DEFAULT

self.other_conf = None
has_sr_ref = self.srcmd.params.get("sr_ref")
if has_sr_ref:
self.other_conf = self.session.xenapi.SR.get_other_config(self.sr_ref)

self.lvm_conf = None
if self.other_conf:
self.lvm_conf = self.other_conf.get('lvm-conf')

try:
self.lvmCache = lvmcache.LVMCache(self.vgname)
self.lvmCache = lvmcache.LVMCache(self.vgname, self.lvm_conf)
except:
raise xs_errors.XenError('SRUnavailable', \
opterr='Failed to initialise the LVMCache')
self.lvActivator = LVActivator(self.uuid, self.lvmCache)
self.journaler = Journaler(self.lvmCache)
if not self.srcmd.params.get("sr_ref"):
if not has_sr_ref:
return # must be a probe call
# Test for thick vs thin provisioning conf parameter
if 'allocation' in self.dconf:
Expand All @@ -177,7 +187,6 @@ def load(self, sr_uuid):
raise xs_errors.XenError('InvalidArg', \
opterr='Allocation parameter must be one of %s' % self.PROVISIONING_TYPES)

self.other_conf = self.session.xenapi.SR.get_other_config(self.sr_ref)
if self.other_conf.get(self.TEST_MODE_KEY):
self.testMode = self.other_conf[self.TEST_MODE_KEY]
self._prepareTestMode()
Expand Down
7 changes: 6 additions & 1 deletion drivers/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,12 @@ def __init__(self, uuid, xapi, createLock, force):
SR.__init__(self, uuid, xapi, createLock, force)
self.vgName = "%s%s" % (lvhdutil.VG_PREFIX, self.uuid)
self.path = os.path.join(lvhdutil.VG_LOCATION, self.vgName)
self.lvmCache = lvmcache.LVMCache(self.vgName)

sr_ref = self.xapi.session.xenapi.SR.get_by_uuid(self.uuid)
other_conf = self.xapi.session.xenapi.SR.get_other_config(sr_ref)
lvm_conf = other_conf.get('lvm-conf') if other_conf else None
self.lvmCache = lvmcache.LVMCache(self.vgName, lvm_conf)

self.lvActivator = LVActivator(self.uuid, self.lvmCache)
self.journaler = journaler.Journaler(self.lvmCache)

Expand Down
5 changes: 3 additions & 2 deletions drivers/lvmcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ class LVMCache:
"""Per-VG object to store LV information. Can be queried for cached LVM
information and refreshed"""

def __init__(self, vgName):
def __init__(self, vgName, config=None):
"""Create a cache for VG vgName, but don't scan the VG yet"""
self.vgName = vgName
self.vgPath = "/dev/%s" % self.vgName
self.config = config
self.lvs = dict()
self.tags = dict()
self.initialized = False
Expand Down Expand Up @@ -115,7 +116,7 @@ def create(self, lvName, size, tag=None):
@lazyInit
def remove(self, lvName):
path = self._getPath(lvName)
lvutil.remove(path)
lvutil.remove(path, self.config)
for tag in self.lvs[lvName].tags:
self._removeTag(lvName, tag)
del self.lvs[lvName]
Expand Down
Loading