Change in vdsm[master]: Remove force parameter in StoragePool.spmStop()
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Remove force parameter in StoragePool.spmStop()
......................................................................
Remove force parameter in StoragePool.spmStop()
Change-Id: I7eaf8883e62a72445e27f0bc9876fe61a10bcb3f
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/sp.py
1 file changed, 20 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/13929/1
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index ca20f9a..70c5802 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -340,8 +340,8 @@
except Exception as e:
self.log.error("Unexpected error", exc_info=True)
- self.log.error("failed: %s" % str(e))
- self.stopSpm(force=True, __securityOverride=True)
+ self.log.error("failed: spmRole:%s %s", self.spmRole, str(e))
+ self.stopSpm(__securityOverride=True)
raise
@unsecured
@@ -392,44 +392,46 @@
else:
cls.log.debug("master `%s` is not mounted, skipping", master)
- def stopSpm(self, force=False):
+ def stopSpm(self):
with self.lock:
- if not force and self.spmRole == SPM_FREE:
+ if self.spmRole == SPM_FREE:
return True
self._shutDownUpgrade()
self._setUnsafe()
- stopFailed = False
-
+ failedStops = []
try:
self.cleanupMasterMount()
except:
# If unmounting fails the vdsm panics.
- stopFailed = True
+ failedStops.append("cleanupMasterMount")
- try:
- if self.spmMailer:
+ if self.spmMailer:
+ try:
self.spmMailer.stop()
- except:
- # Here we are just begin polite.
- # SPM will also clean this on start up.
- pass
+ except:
+ # Here we are just begin polite.
+ # SPM will also clean this on start up.
+ self.log.debug("fail: spmMailer %s", self.spmMailer)
- if not stopFailed:
+ if not failedStops:
try:
self.setMetaParam(PMDK_SPM_ID, SPM_ID_FREE,
__securityOverride=True)
except:
- pass # The system can handle this inconsistency
+ # The system can handle this inconsistency
+ self.log.debug("fail: reset %s to %s",
+ PMDK_SPM_ID, SPM_ID_FREE)
try:
self.masterDomain.releaseClusterLock()
except:
- stopFailed = True
+ failedStops.append("releaseClusterLock")
- if stopFailed:
- misc.panic("Unrecoverable errors during SPM stop process.")
+ if failedStops:
+ misc.panic("Unrecoverable errors during SPM stop process: %s.",
+ ", ".join(failedStops))
self.spmRole = SPM_FREE
--
To view, visit http://gerrit.ovirt.org/13929
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7eaf8883e62a72445e27f0bc9876fe61a10bcb3f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 1 month
Change in vdsm[master]: Stop spm if refresh fail on bad parameters.
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Stop spm if refresh fail on bad parameters.
......................................................................
Stop spm if refresh fail on bad parameters.
Change-Id: I0f85c3e731551b6974483cffe38c7ac37281370b
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 6 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/30/13930/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index fd5d7d6..ba59348 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -788,12 +788,16 @@
se.StoragePoolActionError(
"spUUID=%s, msdUUID=%s, masterVersion=%s" %
(spUUID, msdUUID, masterVersion)))
- vars.task.getSharedLock(STORAGE, spUUID)
+ self.getPool(spUUID) # Validate that is the correct pool.
+ vars.task.getExclusiveLock(STORAGE, spUUID)
pool = self.getPool(spUUID)
try:
self.validateSdUUID(msdUUID)
pool.refresh(msdUUID, masterVersion)
- except:
+ except (se.StorageDomainAccessError, se.StorageDomainDoesNotExist,
+ se.StoragePoolWrongMaster):
+ self.log.error("refreshStoragePool failed", exc_info=True)
+ pool.stopSpm()
self._disconnectPool(pool, pool.id, pool.scsiKey, False)
raise
--
To view, visit http://gerrit.ovirt.org/13930
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f85c3e731551b6974483cffe38c7ac37281370b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 1 month
Change in vdsm[master]: hotunplug: Identify a nic according to its alias
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: hotunplug: Identify a nic according to its alias
......................................................................
hotunplug: Identify a nic according to its alias
MAC addresses may change. The "alias" is immutable.
Change-Id: Iae7619c2547d667103e33777180e01b285f4b18d
Bug-Url: https://bugzilla.redhat.com/919356
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/libvirtvm.py
1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/12892/1
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 39d1b5b..99bf548 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1669,7 +1669,8 @@
# Find NIC object in vm's NICs list
nic = None
for dev in self._devices[vm.NIC_DEVICES][:]:
- if dev.macAddr.lower() == nicParams['macAddr'].lower():
+ if dev.alias == nicParams.get('alias') or \
+ dev.macAddr.lower() == nicParams['macAddr'].lower():
nic = dev
break
--
To view, visit http://gerrit.ovirt.org/12892
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iae7619c2547d667103e33777180e01b285f4b18d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
9 years, 1 month
Change in vdsm[master]: Change mom policy related interface to support multi-policy
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: Change mom policy related interface to support multi-policy
......................................................................
Change mom policy related interface to support multi-policy
Change-Id: I09c40fee74b10d3eb41f4ec3ca18096a9b20dfcd
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M .gitignore
M tests/functional/Makefile.am
R tests/functional/momTests.py.in
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/momIF.py
M vdsm_cli/vdsClient.py
7 files changed, 56 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/12466/1
diff --git a/.gitignore b/.gitignore
index 41066dd..b9b992c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@
config.status
configure
results.log
+tests/functional/momTests.py
tests/run_tests.sh
tests/run_tests_local.sh
vdsm-*.tar.gz
diff --git a/tests/functional/Makefile.am b/tests/functional/Makefile.am
index 030242b..fe4f276 100644
--- a/tests/functional/Makefile.am
+++ b/tests/functional/Makefile.am
@@ -17,12 +17,21 @@
#
# Refer to the README and COPYING files for full details of the license
#
+include $(top_srcdir)/build-aux/Makefile.subs
vdsmfunctestsdir = ${vdsmtestsdir}/functional
dist_vdsmfunctests_PYTHON = \
- momTests.py \
sosPluginTests.py \
xmlrpcTests.py \
$(NULL)
+nodist_vdsmfunctests_PYTHON = \
+ momTests.py
+
+EXTRA_DIST = \
+ momTests.py.in
+
+CLEANFILES = \
+ $(nodist_vdsmfunctests_PYTHON)
+
diff --git a/tests/functional/momTests.py b/tests/functional/momTests.py.in
similarity index 76%
rename from tests/functional/momTests.py
rename to tests/functional/momTests.py.in
index 1981e05..c54b427 100644
--- a/tests/functional/momTests.py
+++ b/tests/functional/momTests.py.in
@@ -18,6 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
import imp
+import os
import random
import time
@@ -54,3 +55,17 @@
hostStats = s.getVdsStats()['info']
self.assertEqual(bool(run), hostStats['ksmState'])
self.assertEqual(pages_to_scan, hostStats['ksmPages'])
+
+ @testValidation.ValidateRunningAsRoot
+ def testDefaultPolicy(self):
+ s = vdscli.connect()
+ r = s.getMOMPolicy()
+
+ policy_dir = '@CONFDIR@/mom-policy-dir'
+ names = sorted(os.listdir(policy_dir))
+ for name in names:
+ if name.startswith('.') or not name.endswith('.policy'):
+ fname = os.path.join(policy_dir, name)
+ with open(fname, 'r') as f:
+ policyStr = f.read()
+ self.assertEqual(policyStr, r['policyDict'].get(name))
diff --git a/vdsm/API.py b/vdsm/API.py
index 0046b57..0f02fde 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1379,6 +1379,12 @@
except:
return errCode['momErr']
+ def getMOMPolicy(self):
+ try:
+ return dict(status=doneCode,
+ policyDict=self._cif.mom.getPolicy())
+ except:
+ return errCode['momErr']
# take a rough estimate on how much free mem is available for new vm
# memTotal = memFree + memCached + mem_used_by_non_qemu + resident .
# simply returning (memFree + memCached) is not good enough, as the
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 9a4db12..a540900 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -401,6 +401,10 @@
api = API.Global()
return api.setMOMPolicy(policy)
+ def getMOMPolicy(self):
+ api = API.Global()
+ return api.getMOMPolicy()
+
def domainActivate(self, sdUUID, spUUID, options=None):
domain = API.StorageDomain(sdUUID)
return domain.activate(spUUID)
@@ -807,6 +811,7 @@
(self.fenceNode, 'fenceNode'),
(self.prepareForShutdown, 'prepareForShutdown'),
(self.setLogLevel, 'setLogLevel'),
+ (self.getMOMPolicy, 'getMOMPolicy'),
(self.setMOMPolicy, 'setMOMPolicy'),
(self.vmHotplugDisk, 'hotplugDisk'),
(self.vmHotunplugDisk, 'hotunplugDisk'),
diff --git a/vdsm/momIF.py b/vdsm/momIF.py
index d0f63d1..831b649 100644
--- a/vdsm/momIF.py
+++ b/vdsm/momIF.py
@@ -56,9 +56,16 @@
ret['ksmCpu'] = stats['ksmd_cpu_usage']
return ret
- def setPolicy(self, policyStr):
- # mom.setPolicy will raise an exception on failure.
- self._mom.setPolicy(policyStr)
+ def setPolicy(self, policyParam):
+ if isinstance(policyParam, dict) and len(policyParam) == 1:
+ policy = policyParam.popItem()
+ self._mom.setNamedPolicy(policy[0], policy[1])
+ else:
+ # mom.setPolicy will raise an exception on failure.
+ self._mom.setPolicy(policyParam)
+
+ def getPolicy(self):
+ return self._mom.getNamedPolicies()
def stop(self):
if self._mom is not None:
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index 1da7d5f..1fa0d22 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -1404,6 +1404,12 @@
return stats['status']['code'], stats['status']['message']
return 0, ''
+ def do_getMOMPolicy(self, policyFile):
+ stats = self.s.getMOMPolicy()
+ if stats['status']['code']:
+ return stats['status']['code'], stats['status']['message']
+ return 0, ''
+
def do_setMOMPolicy(self, policyFile):
stats = self.s.setMOMPolicy(policyFile)
if stats['status']['code']:
@@ -2253,6 +2259,9 @@
('<level> [logName][,logName]...', 'set log verbosity'
' level (10=DEBUG, 50=CRITICAL'
)),
+ 'getMOMPolicy': (serv.do_getMOMPolicy,
+ ('', 'get MOM policy')),
+
'setMOMPolicy': (serv.do_setMOMPolicy,
('<policyfile>', 'set MOM policy')),
'deleteImage': (serv.deleteImage,
--
To view, visit http://gerrit.ovirt.org/12466
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I09c40fee74b10d3eb41f4ec3ca18096a9b20dfcd
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
9 years, 1 month
Change in vdsm[master]: netconf: enable multiple gateways for iproute2 configurator
by wudxw@linux.vnet.ibm.com
Mark Wu has uploaded a new change for review.
Change subject: netconf: enable multiple gateways for iproute2 configurator
......................................................................
netconf: enable multiple gateways for iproute2 configurator
Change-Id: I76e1225caffdb2de3073041e541c7c978eefb396
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
---
M vdsm/netconf/iproute2.py
1 file changed, 11 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/16276/1
diff --git a/vdsm/netconf/iproute2.py b/vdsm/netconf/iproute2.py
index d474e09..795dd9b 100644
--- a/vdsm/netconf/iproute2.py
+++ b/vdsm/netconf/iproute2.py
@@ -45,6 +45,8 @@
utils.execCmd(['brctl', 'addif', bridge.name, bridge.port.name])
self.configApplier.setIpConfig(bridge)
self.configApplier.setIfaceMtu(bridge.name, bridge.mtu)
+ ipaddr, netmask, gateway, bootproto, _ = bridge.getIpConfig()
+ self._addSourceRoute(bridge, ipaddr, netmask, gateway, bootproto)
self.configApplier.ifup(bridge)
def configureVlan(self, vlan, bridge=None, **opts):
@@ -53,6 +55,8 @@
if vlan.ip:
self.configApplier.setIpConfig(vlan)
self.configApplier.setIfaceMtu(vlan.name, vlan.mtu)
+ ipaddr, netmask, gateway, bootproto, _ = vlan.getIpConfig()
+ self._addSourceRoute(vlan, ipaddr, netmask, gateway, bootproto)
self.configApplier.ifup(vlan)
def configureBond(self, bond, bridge=None, **opts):
@@ -76,6 +80,8 @@
if bond.ip:
self.configApplier.setIpConfig(bond)
self.configApplier.setIfaceMtu(bond.name, bond.mtu)
+ ipaddr, netmask, gateway, bootproto, _ = bond.getIpConfig()
+ self._addSourceRoute(bond, ipaddr, netmask, gateway, bootproto)
self.configApplier.ifup(bond)
def editBonding(self, bond, _netinfo):
@@ -91,22 +97,27 @@
if nic.ip:
self.configApplier.setIpConfig(nic)
self.configApplier.setIfaceMtu(nic.name, nic.mtu)
+ ipaddr, netmask, gateway, bootproto, _ = nic.getIpConfig()
+ self._addSourceRoute(nic, ipaddr, netmask, gateway, bootproto)
self.configApplier.ifup(nic)
def removeBridge(self, bridge):
self.configApplier.ifdown(bridge)
+ self._removeSourceRoute(bridge)
utils.execCmd([constants.EXT_BRCTL, 'delbr', bridge.name])
if bridge.port:
bridge.port.remove()
def removeVlan(self, vlan):
self.configApplier.ifdown(vlan)
+ self._removeSourceRoute(vlan)
ipwrapper.linkDel(['dev', vlan.name])
vlan.device.remove()
def _ifaceDownAndCleanup(self, iface, _netinfo):
"""Returns True iff the iface is to be removed."""
self.configApplier.ifdown(iface)
+ self._removeSourceRoute(iface)
if iface.master is None:
self.configApplier.removeIpConfig(iface)
return not _netinfo.ifaceUsers(iface.name)
--
To view, visit http://gerrit.ovirt.org/16276
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I76e1225caffdb2de3073041e541c7c978eefb396
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Mark Wu <wudxw(a)linux.vnet.ibm.com>
9 years, 1 month
Change in vdsm[master]: remove symlink when connect local storage failed
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: remove symlink when connect local storage failed
......................................................................
remove symlink when connect local storage failed
if connectStorageServer failed for some reason,
symlink remains in /rhev/data-center/mnt,
which makes second failure call connectStorageServer
falsely success, so remove the symlink
Change-Id: I0e44605fb6c6e2512a6aa1acefb3d1d7e09a67aa
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M vdsm/storage/storageServer.py
1 file changed, 7 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/40/6140/1
--
To view, visit http://gerrit.ovirt.org/6140
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e44605fb6c6e2512a6aa1acefb3d1d7e09a67aa
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
9 years, 1 month
Change in vdsm[master]: [wip] drbd: initial implementation
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: [wip] drbd: initial implementation
......................................................................
[wip] drbd: initial implementation
Change-Id: I33bb867ba6c7cfca54d31334554cb37db11aeeea
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M client/vdsClient.py
M configure.ac
M lib/vdsm/constants.py.in
M vdsm.spec.in
M vdsm/storage/Makefile.am
A vdsm/storage/drbd.py
M vdsm/storage/hsm.py
M vdsm/storage/lvm.py
M vdsm/storage/storage_exception.py
M vdsm/sudoers.vdsm.in
10 files changed, 530 insertions(+), 12 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/85/13585/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 1da7d5f..9e9fb2e 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1676,6 +1676,56 @@
return status['status']['code'], status['status']['message']
+ def createReplicatedDevice(self, args):
+ dev = self.s.createReplicatedDevice(*args)
+ if dev['status']['code']:
+ return dev['status']['code'], dev['status']['message']
+ return 0, dev['uuid']
+
+ def getReplicatedResourcesList(self, args):
+ res = self.s.getReplicatedResourcesList()
+ if res['status']['code']:
+ return res['status']['code'], res['status']['message']
+ for res in res['resList']:
+ print res
+ return 0, ''
+
+ def getReplicatedResourceInfo(self, args):
+ rdUUID = args[0]
+ res = self.s.getReplicatedResourceInfo(rdUUID)
+ if res['status']['code']:
+ return res['status']['code'], res['status']['message']
+ for key, value in res['resInfo'].items():
+ print key, "=", value
+ return 0, ''
+
+ def attachReplicatedResource(self, args):
+ rdUUID = args[0]
+ device = args[1]
+ res = self.s.attachReplicatedResource(rdUUID, device)
+ if res['status']['code']:
+ return res['status']['code'], res['status']['message']
+ return 0, ''
+
+ def connectReplicatedResource(self, args):
+ rdUUID = args[0]
+ target = args[1]
+ res = self.s.connectReplicatedResource(rdUUID, target)
+ if res['status']['code']:
+ return res['status']['code'], res['status']['message']
+ return 0, ''
+
+ def activateReplicatedResource(self, args):
+ rdUUID = args[0]
+ if len(args) == 2:
+ force = args[1]
+ else:
+ force = 'False'
+ res = self.s.activateReplicatedResource(rdUUID, force)
+ if res['status']['code']:
+ return res['status']['code'], res['status']['message']
+ return 0, ''
+
if __name__ == '__main__':
if _glusterEnabled:
serv = ge.GlusterService()
@@ -2392,6 +2442,32 @@
'Finish live replication to the destination '
'domain'
)),
+ 'createReplicatedDevice': (
+ serv.createReplicatedDevice, (
+ '<device>', 'Creates new replicated device'
+ )),
+ 'getReplicatedResourcesList': (
+ serv.getReplicatedResourcesList, (
+ '', 'Get replicated resources list'
+ )),
+ 'getReplicatedResourceInfo': (
+ serv.getReplicatedResourceInfo, (
+ '<rdUUID>', 'Get replicated device info.'
+ )),
+ 'attachReplicatedResource': (
+ serv.attachReplicatedResource, (
+ '<rdUUID> <device>',
+ 'Attach a replicated resource to a block device.'
+ )),
+ 'connectReplicatedResource': (
+ serv.connectReplicatedResource, (
+ '<rdUUID> <target>',
+ 'Connects a replicated resource to a remote peer'
+ )),
+ 'activateReplicatedResource': (
+ serv.activateReplicatedResource, (
+ '<rdUUID> [<force>]', 'Activates a replicated resource'
+ )),
}
if _glusterEnabled:
commands.update(ge.getGlusterCmdDict(serv))
diff --git a/configure.ac b/configure.ac
index 6baa950..9553cc5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -147,6 +147,8 @@
AC_PATH_PROG([DD_PATH], [dd], [/bin/dd])
AC_PATH_PROG([DMIDECODE_PATH], [dmidecode], [/usr/sbin/dmidecode])
AC_PATH_PROG([DMSETUP_PATH], [dmsetup], [/sbin/dmsetup])
+AC_PATH_PROG([DRBDMETA_PATH], [drbdmeta], [/sbin/drbdmeta])
+AC_PATH_PROG([DRBDSETUP_PATH], [drbdsetup], [/sbin/drbdsetup])
AC_PATH_PROG([ECHO_PATH], [echo], [/bin/echo])
AC_PATH_PROG([FSCK_PATH], [fsck], [/sbin/fsck])
AC_PATH_PROG([FENCE_AGENT_PATH], [fence_ilo], [/usr/sbin/fence_ilo])
diff --git a/lib/vdsm/constants.py.in b/lib/vdsm/constants.py.in
index e7e2f83..e36de0b 100644
--- a/lib/vdsm/constants.py.in
+++ b/lib/vdsm/constants.py.in
@@ -91,6 +91,9 @@
EXT_DMIDECODE = '@DMIDECODE_PATH@'
EXT_DMSETUP = '@DMSETUP_PATH@'
+EXT_DRBDMETA = '@DRBDMETA_PATH@'
+EXT_DRBDSETUP = '@DRBDSETUP_PATH@'
+
EXT_EDITNETWORK = '@VDSMDIR@/editNetwork'
EXT_FENCE_PREFIX = os.path.dirname('@FENCE_AGENT_PATH@') + '/fence_'
diff --git a/vdsm.spec.in b/vdsm.spec.in
index dbb9d04..0711007 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -750,6 +750,7 @@
%{_datadir}/%{vdsm_name}/storage/devicemapper.py*
%{_datadir}/%{vdsm_name}/storage/dispatcher.py*
%{_datadir}/%{vdsm_name}/storage/domainMonitor.py*
+%{_datadir}/%{vdsm_name}/storage/drbd.py*
%{_datadir}/%{vdsm_name}/storage/fileSD.py*
%{_datadir}/%{vdsm_name}/storage/fileUtils.py*
%{_datadir}/%{vdsm_name}/storage/fileVolume.py*
diff --git a/vdsm/storage/Makefile.am b/vdsm/storage/Makefile.am
index ab3c387..0478add 100644
--- a/vdsm/storage/Makefile.am
+++ b/vdsm/storage/Makefile.am
@@ -29,6 +29,7 @@
devicemapper.py \
dispatcher.py \
domainMonitor.py \
+ drbd.py \
fileSD.py \
fileUtils.py \
fileVolume.py \
diff --git a/vdsm/storage/drbd.py b/vdsm/storage/drbd.py
new file mode 100644
index 0000000..3bbc954
--- /dev/null
+++ b/vdsm/storage/drbd.py
@@ -0,0 +1,324 @@
+#
+# Copyright 2009-2011 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+import random
+import socket
+
+import utils
+import constants
+import threading
+import storage_exception as se
+
+DRBD_VERSION = "v08"
+DRBD_MAXUUID = 256 ** 8
+DRBD_MAXMINOR = 255
+DRBD_DEVPREFIX = "drbd"
+DRBD_BASEPORT = 7800
+
+KNOWN_VALUES = (
+ "Configured",
+ "Unconfigured",
+ "NA",
+)
+
+CONN_STATE_VALUES = (
+ "StandAlone",
+ "Disconnecting",
+ "Unconnected",
+ "Timeout",
+ "BrokenPipe",
+ "NetworkFailure",
+ "ProtocolError",
+ "WFConnection",
+ "WFReportParams",
+ "TearDown",
+ "Connected",
+ "StartingSyncS",
+ "StartingSyncT",
+ "WFBitMapS",
+ "WFBitMapT",
+ "WFSyncUUID",
+ "SyncSource",
+ "SyncTarget",
+ "PausedSyncS",
+ "PausedSyncT",
+ "VerifyS",
+ "VerifyT",
+ "Ahead",
+ "Behind",
+)
+
+ROLE_STATE_VALUES = (
+ "Primary",
+ "Secondary",
+ "Unknown",
+)
+
+DISK_STATE_VALUES = (
+ "Diskless",
+ "Attaching",
+ "Failed",
+ "Negotiating",
+ "Inconsistent",
+ "Outdated",
+ "DUnknown",
+ "Consistent",
+ "UpToDate",
+)
+
+
+class ReplicatedDevice(object):
+ @classmethod
+ def newUUID(cls):
+ return "%016X" % (random.randint(0, DRBD_MAXUUID),)
+
+ @classmethod
+ def readUUID(cls, device):
+ rc, out, err = utils.execCmd([
+ constants.EXT_DRBDMETA, "0", DRBD_VERSION, device,
+ "internal", "read-dev-uuid"
+ ])
+
+ if rc != 0 or len(out) != 1:
+ raise se.ReplicatedDeviceError()
+
+ return out[0]
+
+ @classmethod
+ def writeUUID(cls, device, uuid):
+ rc, out, err = utils.execCmd([
+ constants.EXT_DRBDMETA, "0", DRBD_VERSION, device,
+ "internal", "write-dev-uuid", uuid
+ ])
+
+ if rc != 0:
+ raise se.ReplicatedDeviceError()
+
+ @classmethod
+ def create(cls, device):
+ # Checking if the device was already initialized
+ try:
+ uuid = cls.readUUID(device)
+ raise se.ReplicatedDeviceInitialized(uuid)
+ except se.ReplicatedDeviceError:
+ pass
+
+ rc, out, err = utils.execCmd([
+ constants.EXT_DRBDMETA, "0", DRBD_VERSION, device,
+ "internal", "create-md", "--force"
+ ])
+
+ if rc != 0:
+ raise se.ReplicatedDeviceError()
+
+ uuid = cls.newUUID()
+ cls.writeUUID(device, uuid)
+
+ if uuid != cls.readUUID(device):
+ raise se.ReplicatedDeviceError()
+
+ return uuid
+
+
+class ReplicatedStatus(dict):
+ # format:
+ # "inkey" ("outkey", default, "_decodeMethod", methodArgs...),
+ _statusMap = {
+ "_minor": ("minor", None, "_decodeMinor"),
+ "_res_name": ("resName", "", "_decodeValue", str),
+ "_volume": ("volume", 0, "_decodeValue", int),
+ "_known": ("known", "NA", "_decodeEnum", KNOWN_VALUES),
+ "_cstate": ("connState",
+ "Unconnected", "_decodeEnum", CONN_STATE_VALUES),
+ "_role": ("roleState",
+ "Unknown", "_decodeEnum", ROLE_STATE_VALUES),
+ "_peer": ("peerState",
+ "Unknown", "_decodeEnum", ROLE_STATE_VALUES),
+ "_disk": ("diskState",
+ "DUnknown", "_decodeEnum", DISK_STATE_VALUES),
+ "_pdisk": ("peerDiskState",
+ "DUnknown", "_decodeEnum", DISK_STATE_VALUES),
+ # This is a drbd bug, the same key is called in two different ways
+ # depending on the state of the resource. Remove me in the future.
+ "_pdsk": ("peerDiskState",
+ "DUnknown", "_decodeEnum", DISK_STATE_VALUES),
+ "_flags_susp": ("flagsSusp", False, "_decodeFlags"),
+ "_flags_aftr_isp": ("flagsAfterIsp", False, "_decodeFlags"),
+ "_flags_peer_isp": ("flagsPeerIsp", False, "_decodeFlags"),
+ "_flags_user_isp": ("flagsUserIsp", False, "_decodeFlags"),
+ "_resynced_percent": ("resyncedPercent", 0, "_decodeValue", float),
+ }
+
+ def __init__(self, *args, **kwargs):
+ dict.__init__(self, *args, **kwargs)
+
+ for key, description in self._statusMap.items():
+ dict.__setitem__(self, description[0], description[1])
+
+ def __setitem__(self, item, value):
+ if item not in self._statusMap:
+ raise KeyError(item)
+
+ description = self._statusMap[item]
+
+ # Validating key value
+ validate = getattr(self, description[2])
+ value = validate(value, description[1], *description[3:])
+
+ dict.__setitem__(self, description[0], value)
+
+ def _decodeMinor(self, value, default):
+ value = int(value)
+ return value if value != 4294967295 else default
+
+ def _decodeValue(self, value, default, newtype):
+ return default if value == "" else newtype(value)
+
+ def _decodeEnum(self, value, default, enums):
+ if value in enums:
+ return value
+ elif default in enums:
+ return default
+ raise ValueError(default)
+
+ def _decodeFlags(self, value, default):
+ return True if value == "1" else default
+
+
+class ReplicatedResource(object):
+ minorLock = threading.Lock()
+
+ def __init__(self, rdUUID):
+ self.rdUUID = rdUUID
+
+ @classmethod
+ def attach(cls, rdUUID, device):
+ rc, out, err = utils.execCmd([
+ constants.EXT_DRBDSETUP, "new-resource", rdUUID
+ ])
+
+ if rc != 0:
+ raise se.ReplicatedResourceError()
+
+ with cls.minorLock:
+ minor = str(cls._getFreeMinor())
+
+ rc, out, err = utils.execCmd([
+ constants.EXT_DRBDSETUP, "new-minor", rdUUID,
+ minor, "0"
+ ])
+
+ if rc != 0:
+ raise se.ReplicatedResourceError()
+
+ rc, out, err = utils.execCmd([
+ constants.EXT_DRBDMETA, minor, DRBD_VERSION, device,
+ "internal", "apply-al"
+ ])
+
+ if rc != 0:
+ raise se.ReplicatedResourceError()
+
+ rc, out, err = utils.execCmd([
+ constants.EXT_DRBDSETUP, "attach", minor, device,
+ device, "internal"
+ ])
+
+ if rc != 0:
+ raise se.ReplicatedResourceError()
+
+ @property
+ def status(self):
+ return ReplicatedResource.info(self.rdUUID)
+
+ @classmethod
+ def _getFreeMinor(cls):
+ usedminors = set(map(lambda x: x['minor'], cls.info()))
+
+ for minor in xrange(1, DRBD_MAXMINOR):
+ if minor not in usedminors:
+ return minor
+
+ raise se.ReplicatedResourceError()
+
+ @classmethod
+ def info(cls, resource=None):
+ target = resource if resource else "all"
+
+ rc, out, err = utils.execCmd([
+ constants.EXT_DRBDSETUP, "sh-status", target
+ ])
+
+ if rc != 20:
+ raise se.ReplicatedResourceError()
+
+ result = []
+ status = ReplicatedStatus()
+
+ for line in filter(lambda x: len(x) > 0, out):
+ if line == "_sh_status_process":
+ result.append(status)
+ status = ReplicatedStatus()
+ continue
+
+ key, value = line.split("=", 1)
+ status[key] = value
+
+ if resource:
+ if len(result) == 1:
+ return result[0]
+ else:
+ raise se.ReplicatedResourceError()
+
+ return result
+
+ # XXX: Using the force flag might lead to data corruption! It should be
+ # used only during the device initialization or in an unrecoverable
+ # split-brain situation.
+ def primary(self, force=False):
+ primary_minor = str(self.status['minor'])
+ primary_force = ["--force"] if force is True else []
+
+ rc, out, err = utils.execCmd([constants.EXT_DRBDSETUP, "primary",
+ primary_minor] + primary_force)
+ if rc != 0:
+ raise se.ReplicatedResourceError()
+
+ def connect(self, remote):
+ drbdport = DRBD_BASEPORT + self.status['minor']
+ remoteip = socket.gethostbyname(remote)
+
+ connect_opts = [
+ "ipv4:0.0.0.0:%d" % (drbdport,),
+ "ipv4:%s:%d" % (remoteip, drbdport),
+ "--protocol=C",
+ "--allow-two-primaries=yes",
+ ]
+
+ rc, out, err = utils.execCmd([constants.EXT_DRBDSETUP, "connect",
+ self.rdUUID] + connect_opts)
+ if rc != 0:
+ raise se.ReplicatedResourceError()
+
+
+def getReplicatedDevices():
+ for status in ReplicatedResource.info():
+ if status['minor'] and status['roleState'] == "Primary":
+ yield DRBD_DEVPREFIX + str(status['minor'])
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index ae35b11..eb342a2 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -45,6 +45,7 @@
import glusterSD
import localFsSD
import lvm
+import drbd
import fileUtils
import multipath
from sdc import sdCache
@@ -1969,17 +1970,23 @@
vars.task.setDefaultException(
se.VolumeGroupCreateError(str(vgname), str(devlist)))
misc.validateUUID(vgname, 'vgname')
- # getSharedLock(connectionsResource...)
- knowndevs = set(multipath.getMPDevNamesIter())
+ #getSharedLock(connectionsResource...)
+ knownmpath = list(multipath.getMPDevNamesIter())
+ knowndrbd = list(drbd.getReplicatedDevices())
size = 0
devices = []
for dev in devlist:
- if dev in knowndevs:
- devices.append(dev)
- size += multipath.getDeviceSize(devicemapper.getDmId(dev))
+ # Finding the device in the known ones
+ if dev in knownmpath:
+ devname = devicemapper.getDmId(dev)
+ elif dev in knowndrbd:
+ devname = dev
else:
raise se.InvalidPhysDev(dev)
+
+ devices.append(dev)
+ size += multipath.getDeviceSize(devname)
# Minimal size check
if size < MINIMALVGSIZE:
@@ -3417,3 +3424,80 @@
result[d] = repo_stats[d]['result']
return result
+
+ @public
+ def createReplicatedDevice(self, device):
+ """
+ Creates a new replicated device (drbd).
+
+ :param device: The block device to be used.
+ :type device: str
+
+ :returns: The new device uuid.
+ :rtype: str
+ """
+ newUUID = drbd.ReplicatedDevice.create(device)
+ return dict(uuid=newUUID)
+
+ @public
+ def getReplicatedResourcesList(self):
+ """
+ List all the replicated resources in the system (drbd).
+
+ :returns: The replicated resources list.
+ :rtype: list
+ """
+ resources = drbd.ReplicatedResource.info()
+ return dict(resList=map(lambda x: x['resName'], resources))
+
+ @public
+ def getReplicatedResourceInfo(self, rdUUID):
+ """
+ Gets the info of a replicated resource (drbd).
+
+ :param rdUUID: The resource UUID.
+ :type rdUUID: UUID
+
+ :returns: The replicated resources information.
+ :rtype: dict
+ """
+ resource = dict(drbd.ReplicatedResource.info(rdUUID))
+ return dict(resInfo=resource)
+
+ @public
+ def attachReplicatedResource(self, rdUUID, device):
+ """
+ Attaches a replicated resource (drbd) to a block device.
+
+ :param rdUUID: The resource UUID.
+ :type rdUUID: UUID
+ :param device: The block device to be used.
+ :type device: str
+ """
+ drbd.ReplicatedResource.attach(rdUUID, device)
+
+ @public
+ def connectReplicatedResource(self, rdUUID, target):
+ """
+ Connects a replicated resource (drbd) to a remote peer.
+
+ :param rdUUID: The resource UUID.
+ :type rdUUID: UUID
+ :param target: The peer target address.
+ :type device: str
+ """
+ rd = drbd.ReplicatedResource(rdUUID)
+ rd.connect(target)
+
+ @public
+ def activateReplicatedResource(self, rdUUID, force=False):
+ """
+ Connects a replicated resource (drbd) to a remote peer.
+
+ :param rdUUID: The resource UUID.
+ :type rdUUID: UUID
+ :param target: The peer target address.
+ :type device: str
+ """
+ rd = drbd.ReplicatedResource(rdUUID)
+ rd.primary(misc.parseBool(force))
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 97fe38a..351fca4 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -40,6 +40,7 @@
from vdsm import constants
import misc
import multipath
+import drbd
import storage_exception as se
from vdsm.config import config
import devicemapper
@@ -83,9 +84,8 @@
LVM_FLAGS = ("--noheadings", "--units", "b", "--nosuffix", "--separator",
SEPARATOR)
-PV_PREFIX = "/dev/mapper"
-# Assuming there are no spaces in the PV name
-re_pvName = re.compile(PV_PREFIX + '[^\s\"]+', re.MULTILINE)
+DEVICE_PREFIX = "/dev"
+MAPPER_PREFIX = "/dev/mapper"
# operations lock
LVM_OP_INVALIDATE = "lvm invalidate operation"
@@ -263,7 +263,12 @@
if not self._filterStale:
return self._extraCfg
- self._extraCfg = _buildConfig(multipath.getMPDevNamesIter())
+ devList = (
+ list(multipath.getMPDevNamesIter()) +
+ list(drbd.getReplicatedDevices())
+ )
+
+ self._extraCfg = _buildConfig(devList)
_updateLvmConf(self._extraCfg)
self._filterStale = False
@@ -635,8 +640,11 @@
def _fqpvname(pv):
- if pv and not pv.startswith(PV_PREFIX):
- pv = os.path.join(PV_PREFIX, pv)
+ if pv and not pv.startswith(DEVICE_PREFIX):
+ if pv.startswith(drbd.DRBD_DEVPREFIX):
+ pv = os.path.join(DEVICE_PREFIX, pv)
+ else:
+ pv = os.path.join(MAPPER_PREFIX, pv)
return pv
@@ -795,7 +803,10 @@
Receives guids iterable.
Returns (un)pvables, (un)succeed guids.
"""
- devs = tuple("%s/%s" % (PV_PREFIX, dev) for dev in devices)
+ # FIXME: these new MAPPER_PREFIX entries should be handled to include
+ # drbd too, see the function _fqpvname.
+ devs = tuple("%s/%s" % (MAPPER_PREFIX, dev) for dev in devices)
+ re_pvName = re.compile(MAPPER_PREFIX + '[^\s\"]+', re.MULTILINE)
options = ("--test",)
rc, out, err = _createpv(devs, metadataSize, options)
diff --git a/vdsm/storage/storage_exception.py b/vdsm/storage/storage_exception.py
index c2c3dc8..d0a946e 100644
--- a/vdsm/storage/storage_exception.py
+++ b/vdsm/storage/storage_exception.py
@@ -1721,3 +1721,17 @@
code = 855
message = ("Could not acquire resource. "
"Probably resource factory threw an exception.")
+
+
+#################################################
+# Replicated Device Exceptions
+#################################################
+
+class ReplicatedDeviceError(StorageException):
+ code = 900
+ message = "Replicated device general error"
+
+
+class ReplicatedResourceError(StorageException):
+ code = 901
+ message = "Replicated resource general error"
diff --git a/vdsm/sudoers.vdsm.in b/vdsm/sudoers.vdsm.in
index 24031ec..c673688 100644
--- a/vdsm/sudoers.vdsm.in
+++ b/vdsm/sudoers.vdsm.in
@@ -24,6 +24,8 @@
@SERVICE_PATH@ multipathd reload, \
@ISCSIADM_PATH@ *, \
@LVM_PATH@, \
+ @DRBDMETA_PATH@, \
+ @DRBDSETUP_PATH@, \
@CAT_PATH@ /sys/block/*/device/../../*, \
@CAT_PATH@ /sys/devices/platform/host*, \
@CAT_PATH@ /etc/iscsi/iscsid.conf, \
--
To view, visit http://gerrit.ovirt.org/13585
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I33bb867ba6c7cfca54d31334554cb37db11aeeea
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 1 month
Change in vdsm[master]: Remove block size validation from blockSD instatiation.
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Remove block size validation from blockSD instatiation.
......................................................................
Remove block size validation from blockSD instatiation.
This check is unnecessary at this point since vdsm will
fail before if blocks are not 512 sized.
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=955993
Change-Id: I296b4bd3a697078c89451b167b1f9e0f64cc015e
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/blockSD.py
M vdsm/storage/hsm.py
2 files changed, 5 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/14/14514/1
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 86ffb66..0c7771c 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -409,10 +409,6 @@
self.logBlkSize = 512
self.phyBlkSize = 512
- # Check that all devices in the VG have the same logical and physical
- # block sizes.
- lvm.checkVGBlockSizes(sdUUID, (self.logBlkSize, self.phyBlkSize))
-
# _extendlock is used to prevent race between
# VG extend and LV extend.
self._extendlock = threading.Lock()
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 25363dc..a196105 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -2238,6 +2238,11 @@
if domType in (sd.FCP_DOMAIN, sd.ISCSI_DOMAIN):
uuids = tuple(blockSD.getStorageDomainsList())
+ logBlkSize = 512
+ phyBlkSize = 512
+ for uuid in uuids:
+ lvm.checkVGBlockSizes(uuid, (logBlkSize, phyBlkSize))
+
elif domType is sd.NFS_DOMAIN:
lPath = conObj._mountCon._getLocalPath()
self.log.debug("nfs local path: %s", lPath)
--
To view, visit http://gerrit.ovirt.org/14514
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I296b4bd3a697078c89451b167b1f9e0f64cc015e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 1 month
Change in vdsm[master]: Related to BZ#854151 - Fix disconnect iscsi connections.
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Related to BZ#854151 - Fix disconnect iscsi connections.
......................................................................
Related to BZ#854151 - Fix disconnect iscsi connections.
Change-Id: Ic390cf1a63594a87ee03c010df31f68a432ebff4
Bug-Id: https://bugzilla.redhat.com/show_bug.cgi?id=854151
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/hsm.py
M vdsm/storage/storageServer.py
2 files changed, 26 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/8305/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index a89274a..330b7c0 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -2032,10 +2032,11 @@
conObj = storageServer.ConnectionFactory.createConnection(conInfo)
try:
conObj.disconnect()
- status = 0
except Exception as err:
self.log.error("Could not disconnect from storageServer", exc_info=True)
status, _ = self._translateConnectionError(err)
+ else:
+ status = 0
res.append({'id': conDef["id"], 'status': status})
diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index 269b8eb..963a019 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -282,6 +282,7 @@
return hash(type(self)) ^ hash(self._mountCon)
class IscsiConnection(object):
+ log = logging.getLogger("StorageServer.IscsiConnection")
@property
def target(self):
return self._target
@@ -314,43 +315,48 @@
host = self._target.portal.hostname
try:
ip = socket.gethostbyname(host)
+ except socket.gaierror:
+ return False
+ else:
if ip != portal.hostname:
return False
- except socket.gaierror:
- return False
-
- if self._target.portal.port != portal.port:
+ elif self._target.portal.port != portal.port:
return False
- if self._target.tpgt != None and self._target.tpgt != target.tpgt:
+ elif self._target.tpgt != None and self._target.tpgt != target.tpgt:
return False
- if self._target.iqn != target.iqn:
+ elif self._target.iqn != target.iqn:
return False
- if self._iface.name != iface.name:
+ elif self._iface.name != iface.name:
return False
- if self._cred != cred:
+ elif self._cred != cred:
return False
- return True
+ else:
+ return True
def getSessionInfo(self):
sessions = iscsi.iterateIscsiSessions()
try:
info = iscsi.getSessionInfo(self._lastSessionId)
- sessions = chain(info, sessions)
except Exception:
- pass
+ self.log.warning("Can't get session info, self._lastSessionId %s", self._lastSessionId)
+ else:
+ sessions = chain(info, sessions)
- for session in iscsi.iterateIscsiSessions():
+ self.log.debug("self._target: %s", self._target)
+ for session in sessions:
+ self.log.debug("session %s", session)
if self.isSession(session):
self._lastSessionId = session.id
+ self.log.debug("self._lastSessionId: %s", self._lastSessionId)
return session
-
- raise OSError(errno.ENOENT, "Session not found")
+ else:
+ raise OSError(errno.ENOENT, "Session not found in sessions: %s", sessions)
def isConnected(self):
try:
@@ -362,13 +368,17 @@
raise
def disconnect(self):
+ self.log.debug("Iscsi disconnect called.")
try:
sid = self.getSessionInfo().id
except OSError, e:
if e.errno == errno.ENOENT:
+ self.log.warning("Can't get iscsi session id, ENOENT: %s", e.errno)
return
+ self.log.warning("Cant get iscsi session id, errno: %s", e.errno)
raise
+ self.log.debug("Disconnecting iscsi session id: %s", sid)
iscsi.disconnectiScsiSession(sid)
def __eq__(self, other):
--
To view, visit http://gerrit.ovirt.org/8305
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic390cf1a63594a87ee03c010df31f68a432ebff4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 1 month
Change in vdsm[master]: sp: asynchronous convertDomain in activateSD
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: sp: asynchronous convertDomain in activateSD
......................................................................
sp: asynchronous convertDomain in activateSD
Change-Id: I679a992f689ee6ae97c82c267d0da69b4f0e6725
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/hsm.py
M vdsm/storage/sp.py
2 files changed, 42 insertions(+), 35 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/34/13634/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index ae35b11..5471c54 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3396,7 +3396,9 @@
def upgradeStoragePool(self, spUUID, targetDomVersion):
targetDomVersion = int(targetDomVersion)
pool = self.getPool(spUUID)
- pool._upgradePool(targetDomVersion)
+ # TODO: this request should become asynchronous using a task
+ pool._upgradeMasterDomain(targetDomVersion)
+ pool._upgradeRegularDomains()
return {"upgradeStatus": "started"}
@public
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index fe54dd9..374c948 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -119,7 +119,7 @@
Securable.__init__(self)
self._formatConverter = DefaultFormatConverter()
- self._domainsToUpgrade = []
+ self._domainsToUpgrade = set()
self.lock = threading.RLock()
self._setUnsafe()
self.spUUID = str(spUUID)
@@ -207,14 +207,6 @@
return
self._domainsToUpgrade.remove(sdUUID)
- if len(self._domainsToUpgrade) == 0:
- self.log.debug("All domains are upgraded, unregistering "
- "from state change event")
- try:
- self.domainMonitor.onDomainConnectivityStateChange.\
- unregister(self._upgradeCallback)
- except KeyError:
- pass
@unsecured
def startSpm(self, prevID, prevLVER, scsiFencing, maxHostID,
@@ -287,8 +279,9 @@
PMDK_SPM_ID: self.id}, __securityOverride=True)
self._maxHostID = maxHostID
- # Upgrade the master domain now if needed
- self._upgradePool(expectedDomVersion, __securityOverride=True)
+ # Upgrade the master domain now
+ self._upgradeMasterDomain(expectedDomVersion,
+ __securityOverride=True)
self.masterDomain.mountMaster()
self.masterDomain.createMasterTree()
@@ -308,6 +301,10 @@
# Once setSafe completes we are running as SPM
self._setSafe()
+
+ # Upgrade all the remaining domains
+ self._startUpUpgrade()
+ self._upgradeRegularDomains()
# Mailbox issues SPM commands, therefore we start it AFTER spm
# commands are allowed to run to prevent a race between the
@@ -346,11 +343,17 @@
raise
@unsecured
+ def _startUpUpgrade(self):
+ self.log.debug("Registering with state change event")
+ self.domainMonitor.onDomainConnectivityStateChange.register(
+ self._upgradeCallback)
+
+ @unsecured
def _shutDownUpgrade(self):
self.log.debug("Shutting down upgrade process")
with rmanager.acquireResource(STORAGE, "upgrade_" + self.spUUID,
rm.LockType.exclusive):
- domains = self._domainsToUpgrade[:]
+ domains = set(self._domainsToUpgrade)
try:
self.domainMonitor.onDomainConnectivityStateChange.unregister(
self._upgradeCallback)
@@ -434,7 +437,28 @@
self.spmRole = SPM_FREE
- def _upgradePool(self, targetDomVersion):
+ def _upgradeRegularDomains(self):
+ with rmanager.acquireResource(STORAGE, "upgrade_" + self.spUUID,
+ rm.LockType.exclusive):
+ regularDomains = set(self.getDomains(activeOnly=True).keys())
+
+ try:
+ regularDomains.remove(self.masterDomain.sdUUID)
+ except ValueError:
+ pass
+
+ # Removing the domains that are already in the upgrade process
+ sdUUIDThreadsToStart = regularDomains - self._domainsToUpgrade
+
+ self.log.debug("Marking all domains for upgrade")
+ self._domainsToUpgrade.update(regularDomains)
+
+ for sdUUID in sdUUIDThreadsToStart:
+ self.log.debug("Running upgrade thread for domain %s", sdUUID)
+ threading.Thread(
+ target=self._upgradeCallback, args=(sdUUID, True)).start()
+
+ def _upgradeMasterDomain(self, targetDomVersion):
with rmanager.acquireResource(STORAGE, "upgrade_" + self.spUUID,
rm.LockType.exclusive):
if len(self._domainsToUpgrade) > 0:
@@ -446,22 +470,6 @@
with rmanager.acquireResource(STORAGE, self.masterDomain.sdUUID,
rm.LockType.exclusive):
self._convertDomain(self.masterDomain, str(targetDomVersion))
-
- self.log.debug("Marking all domains for upgrade")
- self._domainsToUpgrade = self.getDomains(activeOnly=True).keys()
- try:
- self._domainsToUpgrade.remove(self.masterDomain.sdUUID)
- except ValueError:
- pass
-
- self.log.debug("Registering with state change event")
- self.domainMonitor.onDomainConnectivityStateChange.register(
- self._upgradeCallback)
- self.log.debug("Running initial domain upgrade threads")
- for sdUUID in self._domainsToUpgrade:
- threading.Thread(target=self._upgradeCallback,
- args=(sdUUID, True),
- kwargs={"__securityOverride": True}).start()
@unsecured
def __createMailboxMonitor(self):
@@ -1109,15 +1117,12 @@
if domainStatuses[sdUUID] == sd.DOM_ACTIVE_STATUS:
return True
- # Domain conversion requires the links to be present
- self._refreshDomainLinks(dom)
- if dom.getDomainClass() == sd.DATA_DOMAIN:
- self._convertDomain(dom)
-
dom.activate()
# set domains also do rebuild
domainStatuses[sdUUID] = sd.DOM_ACTIVE_STATUS
self.setMetaParam(PMDK_DOMAINS, domainStatuses)
+ self._refreshDomainLinks(dom)
+ self._upgradeRegularDomains()
self.updateMonitoringThreads()
return True
--
To view, visit http://gerrit.ovirt.org/13634
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I679a992f689ee6ae97c82c267d0da69b4f0e6725
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 1 month