Change in vdsm[master]: adding StorageDomain.activateHsm()
laravot at redhat.com
laravot at redhat.com
Thu Feb 25 16:35:19 UTC 2016
Liron Aravot has uploaded a new change for review.
Change subject: adding StorageDomain.activateHsm()
......................................................................
adding StorageDomain.activateHsm()
Change-Id: I68eccd300b8ba0cc45b2485f978eb3ae367c16e2
Signed-off-by: laravot at redhat.com <laravot at redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/storage/hsm.py
M vdsm/storage/sp.py
M vdsm/storage/storage_exception.py
7 files changed, 134 insertions(+), 17 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/43153/4
diff --git a/client/vdsClient.py b/client/vdsClient.py
index d59ae7c..6169be7 100755
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -647,6 +647,14 @@
return dom['status']['code'], dom['status']['message']
return 0, ''
+ def activateStorageDomainHsm(self, args):
+ sdUUID = args[0]
+ spUUID = args[1]
+ dom = self.s.activateStorageDomainHsm(sdUUID, spUUID)
+ if dom['status']['code']:
+ return dom['status']['code'], dom['status']['message']
+ return 0, ''
+
def deactivateStorageDomain(self, args):
sdUUID = args[0]
spUUID = args[1]
@@ -2502,6 +2510,10 @@
'Get list of VMs from the'
'given backup domain'
)),
+ 'updateStorageDomainVmData': (serv.updateStorageDomainVmData,
+ ('<sdUUID> <spUUID> <vmID> <vmDATA>',
+ 'Update VM on a Backup domain'
+ )),
'validateStorageDomain': (serv.validateStorageDomain,
('<domain UUID>',
'Validate storage domain'
@@ -2511,6 +2523,12 @@
'Activate a storage domain that is already '
'a member in a storage pool.'
)),
+ 'activateStorageDomainHsm': (serv.activateStorageDomainHsm,
+ ('<domain UUID> <pool UUID>',
+ 'Activate a storage domain that is '
+ 'already a member in a storage pool '
+ 'that operates without Spm.'
+ )),
'deactivateStorageDomain': (serv.deactivateStorageDomain,
('<domain UUID> <pool UUID> <new master '
'domain UUID> <masterVer>',
diff --git a/vdsm/API.py b/vdsm/API.py
index bc47e3f..3703d69 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -991,6 +991,9 @@
def activate(self, storagepoolID):
return self._irs.activateStorageDomain(self._UUID, storagepoolID)
+ def activateHsm(self, storagepoolID):
+ return self._irs.activateStorageDomainHsm(self._UUID, storagepoolID)
+
def attach(self, storagepoolID):
return self._irs.attachStorageDomain(self._UUID, storagepoolID)
@@ -1109,7 +1112,8 @@
return self._irs.fenceSpmStorage(self._UUID, lastOwner, lastLver)
def getBackedUpVmsInfo(self, storagedomainID, vmList):
- return self._irs.getVmsInfo(self._UUID, storagedomainID, vmList)
+ return self._irs.getBackedUpVmsInfo(self._UUID,
+ storagedomainID, vmList)
def getBackedUpVmsList(self, storagedomainID):
return self._irs.getVmsList(self._UUID, storagedomainID)
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 039d564..c6fb25d 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -607,6 +607,10 @@
domain = API.StorageDomain(sdUUID)
return domain.activate(spUUID)
+ def domainActivateHsm(self, sdUUID, spUUID):
+ domain = API.StorageDomain(sdUUID)
+ return domain.activateHsm(spUUID)
+
def domainAttach(self, sdUUID, spUUID, options=None):
domain = API.StorageDomain(sdUUID)
return domain.attach(spUUID)
@@ -1099,7 +1103,8 @@
'detachAnyStoragePoolHsm'),
(self.domainGetStoredVmsInfo, 'getStorageDomainStoredVmsInfo'),
(self.domainUpgradeVersion, 'upgradeStorageDomainVersion'),
- (self.domainUpdateVMData, 'updateStorageDomainVmData'))
+ (self.domainUpdateVMData, 'updateStorageDomainVmData'),
+ (self.domainActivateHsm, 'activateStorageDomainHsm'))
def getIrsMethods(self):
return ((self.domainActivate, 'activateStorageDomain'),
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index df11b53..d65ae22 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -4968,6 +4968,22 @@
'data': {'storagedomainID': 'UUID', 'storagepoolID': 'UUID'}}
##
+# @StorageDomain.activateHsm:
+#
+# Activate an attached but inactive Storage Domain.
+# Can be used only in Storage Pools that operate without SPM.
+#
+# @storagedomainID: The UUID of the Storage Domain
+#
+# @storagepoolID: The UUID of the Storage Pool to which the Storage Domain
+# is attached
+#
+# Since: 4.18.0
+##
+{'command': {'class': 'StorageDomain', 'name': 'activateHsm'},
+ 'data': {'storagedomainID': 'UUID', 'storagepoolID': 'UUID'}}
+
+##
# @StorageDomain.attach:
#
# Attach a Storage Domain to a Storage Pool.
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 1c76208..db82566 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1344,14 +1344,33 @@
:type spUUID: UUID
:param options: ?
"""
+ pool = self._prepareActivateStorageDomain(spUUID, sdUUID)
+ pool.activateSD(sdUUID)
+
+ @public
+ def activateStorageDomainHsm(self, sdUUID, spUUID):
+ """
+ Activates a storage domain that is already a member in a storage pool.
+
+ :param sdUUID: The UUID of the storage domain that you want to
+ activate.
+ :type sdUUID: UUID
+ :param spUUID: The UUID of the storage pool that contains the storage
+ domain being activated.
+ :type spUUID: UUID
+ :param options: ?
+ """
+ pool = self._prepareActivateStorageDomain(spUUID, sdUUID)
+ pool.activateSDHSM(sdUUID)
+
+ def _prepareActivateStorageDomain(self, spUUID, sdUUID):
vars.task.setDefaultException(
se.StorageDomainActionError(
"sdUUID=%s, spUUID=%s" % (sdUUID, spUUID)))
vars.task.getExclusiveLock(STORAGE, spUUID)
vars.task.getExclusiveLock(STORAGE, sdUUID)
- pool = self.getPool(spUUID)
- pool.activateSD(sdUUID)
+ return self.getPool(spUUID)
@public
def setStoragePoolDescription(self, spUUID, description, options=None):
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index d2ebec8..f6e03f8 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -530,6 +530,16 @@
return True
@unsecured
+ def validateDomainFormat(self, dom):
+ """
+ Avoid handling domains if not owned by pool.
+ """
+ if dom.getDomainClass() == sd.DATA_DOMAIN and \
+ dom.getFormat() != self.getFormat():
+ raise se.DomainFormatIncorrect(dom.sdUUID,
+ dom.getFormat(), self.getFormat())
+
+ @unsecured
def _acquireTemporaryClusterLock(self, msdUUID, leaseParams):
try:
# Master domain is unattached and all changes to unattached domains
@@ -911,8 +921,12 @@
@unsecured
def validateNoSpm(self):
- if self.masterDomain is not None:
+ if self.poolWithSpm():
raise se.StoragePoolWithSpm(self.spUUID)
+
+ @unsecured
+ def poolWithSpm(self):
+ return self.masterDomain is not None
@unsecured
def attachSDHsm(self, sdUUID):
@@ -1115,6 +1129,11 @@
Validate that the storage domain is owned by the storage pool.
'sdUUID' - storage domain UUID
"""
+ self._activateSD(sdUUID)
+ return True
+
+ @unsecured
+ def _activateSD(self, sdUUID):
self.log.info("sdUUID=%s spUUID=%s", sdUUID, self.spUUID)
dom = sdCache.produce(sdUUID)
@@ -1126,8 +1145,27 @@
if domainStatuses[sdUUID] == sd.DOM_ACTIVE_STATUS:
return True
- # Domain conversion requires the links to be present
- self._refreshDomainLinks(dom)
+ if self.poolWithSpm():
+ # Domain conversion requires the links to be present
+ self._refreshDomainLinks(dom)
+ self._activationDomainMetadataUpdate(dom)
+ else:
+ # currently the pool required format is determined from the master
+ # domain - if we want to have this check the format has to be
+ # passed to vdsm, maybe on connectStoragePool.
+ # self.validateDomainFormat(dom)
+ self._refreshDomainLinks(dom)
+ if dom.getDomainRole() != sd.REGULAR_DOMAIN:
+ self._performDomainClusterLockOp(dom, False,
+ self.
+ _setDomainRegularRole,
+ dom, securityOverride=True)
+ dom.activate()
+ # set domains also do rebuild
+ domainStatuses[sdUUID] = sd.DOM_ACTIVE_STATUS
+ self._backend.setDomainsMap(domainStatuses)
+ self.updateMonitoringThreads()
+ return True
@unsecured
def _performDomainClusterLockOp(self, domain, releaseHostId, method,
@@ -1143,16 +1181,25 @@
if releaseHostId:
domain.releaseHostId(self.id)
-
+ def _activationDomainMetadataUpdate(self, dom):
+ self._setDomainRegularRole(dom)
if dom.getDomainClass() == sd.DATA_DOMAIN:
self._convertDomain(dom)
- dom.activate()
- # set domains also do rebuild
- domainStatuses[sdUUID] = sd.DOM_ACTIVE_STATUS
- self._backend.setDomainsMap(domainStatuses)
- self.updateMonitoringThreads()
- return True
+ @unsecured
+ def _setDomainRegularRole(self, dom, securityOverride=False):
+ self._backend.setDomainRegularRole(dom,
+ __securityOverride=securityOverride)
+
+ @unsecured
+ def activateSDHSM(self, sdUUID):
+ """
+ Activate a storage domain that is already a member in a storage pool.
+ Validate that the storage domain is owned by the storage pool.
+ 'sdUUID' - storage domain UUID
+ """
+ self.validateNoSpm()
+ self._activateSD(sdUUID)
def deactivateSD(self, sdUUID, newMsdUUID, masterVersion):
"""
@@ -1366,15 +1413,14 @@
self.log.info("spUUID=%s sdUUID=%s", self.spUUID, sdUUID)
vms = self._getVMsPath(sdUUID)
# We should exclude 'masterd' link from IMG_METAPATTERN globing
- vmUUID = ovf = imgList = ''
+ vmUUID = ovf = ''
for vm in vmList:
if not vm:
continue
try:
vmUUID = vm['vm']
ovf = vm['ovf']
- imgList = vm['imglist'].split(',')
- self.log.info("vmUUID=%s imgList=%s", vmUUID, str(imgList))
+ self.log.info("vmUUID=%s", vmUUID)
except KeyError:
raise se.InvalidParameterException("vmList", str(vmList))
diff --git a/vdsm/storage/storage_exception.py b/vdsm/storage/storage_exception.py
index 50b522b..3f1cca2 100644
--- a/vdsm/storage/storage_exception.py
+++ b/vdsm/storage/storage_exception.py
@@ -932,6 +932,15 @@
code = 444
+class DomainFormatIncorrect(StorageException):
+ def __init__(self, sdUUID, domFormat, poolFormat):
+ self.value = "domain=%s" % sdUUID
+ self.message = ("As the domain `%s` is a data domain, and its format "
+ "`%s` doesn't match the pool format `%s` it cannot be "
+ "activated" % (sdUUID, domFormat, poolFormat,))
+ code = 445
+
+
class CannotUpgradeCurrVersionHigher(StorageException):
def __init__(self, sdUUID, currVersion, targetVersion):
self.value = "sdUUID=%s, currentVersion=%s, targetVersion=%s" % \
--
To view, visit https://gerrit.ovirt.org/43153
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I68eccd300b8ba0cc45b2485f978eb3ae367c16e2
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Liron Aravot <laravot at redhat.com>
Gerrit-Reviewer: Jenkins CI RO
Gerrit-Reviewer: Liron Aravot <laravot at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
More information about the vdsm-patches
mailing list