Skip to content

Commit bc8ee2e

Browse files
committed
feat(LVHDSR): add a way to modify config of LVMs (#56)
With this change the driver supports a "lvm-conf" param on "other-config". For now The configuration is only used by "remove" calls from LVMCache. Example to issue discards after a lvremove command: > xe sr-param-set uuid=<SR_UUID> other-config:lvm-conf=issue_discards=1 And to remove the param: > xe sr-param-remove uuid=<SR_UUID> param-name=other-config param-key=lvm-conf Signed-off-by: Ronan Abhamon <[email protected]>
1 parent 05e5ce0 commit bc8ee2e

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

drivers/LVHDSR.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,24 @@ def load(self, sr_uuid):
161161
self.path = os.path.join(lvhdutil.VG_LOCATION, self.vgname)
162162
self.mdpath = os.path.join(self.path, self.MDVOLUME_NAME)
163163
self.provision = self.PROVISIONING_DEFAULT
164+
165+
self.other_conf = None
166+
has_sr_ref = self.srcmd.params.get("sr_ref")
167+
if has_sr_ref:
168+
self.other_conf = self.session.xenapi.SR.get_other_config(self.sr_ref)
169+
170+
self.lvm_conf = None
171+
if self.other_conf:
172+
self.lvm_conf = self.other_conf.get('lvm-conf')
173+
164174
try:
165-
self.lvmCache = lvmcache.LVMCache(self.vgname)
175+
self.lvmCache = lvmcache.LVMCache(self.vgname, self.lvm_conf)
166176
except:
167177
raise xs_errors.XenError('SRUnavailable', \
168178
opterr='Failed to initialise the LVMCache')
169179
self.lvActivator = LVActivator(self.uuid, self.lvmCache)
170180
self.journaler = Journaler(self.lvmCache)
171-
if not self.srcmd.params.get("sr_ref"):
181+
if not has_sr_ref:
172182
return # must be a probe call
173183
# Test for thick vs thin provisioning conf parameter
174184
if self.dconf.has_key('allocation'):
@@ -178,7 +188,6 @@ def load(self, sr_uuid):
178188
raise xs_errors.XenError('InvalidArg', \
179189
opterr='Allocation parameter must be one of %s' % self.PROVISIONING_TYPES)
180190

181-
self.other_conf = self.session.xenapi.SR.get_other_config(self.sr_ref)
182191
if self.other_conf.get(self.TEST_MODE_KEY):
183192
self.testMode = self.other_conf[self.TEST_MODE_KEY]
184193
self._prepareTestMode()

drivers/cleanup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2565,7 +2565,12 @@ def __init__(self, uuid, xapi, createLock, force):
25652565
SR.__init__(self, uuid, xapi, createLock, force)
25662566
self.vgName = "%s%s" % (lvhdutil.VG_PREFIX, self.uuid)
25672567
self.path = os.path.join(lvhdutil.VG_LOCATION, self.vgName)
2568-
self.lvmCache = lvmcache.LVMCache(self.vgName)
2568+
2569+
sr_ref = self.xapi.session.xenapi.SR.get_by_uuid(self.uuid)
2570+
other_conf = self.xapi.session.xenapi.SR.get_other_config(sr_ref)
2571+
lvm_conf = other_conf.get('lvm-conf') if other_conf else None
2572+
self.lvmCache = lvmcache.LVMCache(self.vgName, lvm_conf)
2573+
25692574
self.lvActivator = LVActivator(self.uuid, self.lvmCache)
25702575
self.journaler = journaler.Journaler(self.lvmCache)
25712576

drivers/lvmcache.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ class LVMCache:
5959
"""Per-VG object to store LV information. Can be queried for cached LVM
6060
information and refreshed"""
6161

62-
def __init__(self, vgName):
62+
def __init__(self, vgName, config=None):
6363
"""Create a cache for VG vgName, but don't scan the VG yet"""
6464
self.vgName = vgName
6565
self.vgPath = "/dev/%s" % self.vgName
66+
self.config = config
6667
self.lvs = dict()
6768
self.tags = dict()
6869
self.initialized = False
@@ -115,7 +116,7 @@ def create(self, lvName, size, tag = None):
115116
@lazyInit
116117
def remove(self, lvName):
117118
path = self._getPath(lvName)
118-
lvutil.remove(path)
119+
lvutil.remove(path, self.config)
119120
for tag in self.lvs[lvName].tags:
120121
self._removeTag(lvName, tag)
121122
del self.lvs[lvName]

0 commit comments

Comments
 (0)