[NEW PATCH] Change getChain() to return dictionary with chain itself and its template. (via gerrit-bot)
by Igor Lvovsky
New patch submitted by Igor Lvovsky (ilvovsky(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/692
commit 3a09f874889cb372ee84b04a234f7b653458e26f
Author: Igor Lvovsky <ilvovsky(a)redhat.com>
Date: Tue Jul 12 15:18:45 2011 +0300
Change getChain() to return dictionary with chain itself and its template.
This change will avoid unneeded produceVolume and improve
behaviour of different flows.
Change-Id: Ife46d592171aedea087e0d6462b735cd7e0d75e0
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index 1c70a34..102ea6c 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -104,7 +104,7 @@ class Image:
# 1. Remove template's image: Create 'fake' template instead of deleted one
# 2. Remove regular image: Remove parent-'fake' template if nobody need it already
try:
- pvol = self.getTemplate(sdUUID=sdUUID, imgUUID=imgUUID)
+ pvol = self.getChain(sdUUID, imgUUID)['template']
# 1. If we required to delete template's image that have VMs
# based on it, we should create similar 'fake' template instead
if pvol:
@@ -269,17 +269,16 @@ class Image:
return newImgUUID
- def __chainSizeCalc(self, sdUUID, imgUUID, volUUID, size):
+ def __chainSizeCalc(self, sdUUID, imgUUID, size):
"""
Compute an estimate of the whole chain size
using the sum of the actual size of the chain's volumes
"""
- chain = self.getChain(sdUUID, imgUUID, volUUID)
+ chainDict = self.getChain(sdUUID, imgUUID)
newsize = 0
- template = chain[0].getParentVolume()
- if template:
- newsize = template.getVolumeSize()
- for vol in chain:
+ if chainDict['template']:
+ newsize = chainDict['template'].getVolumeSize()
+ for vol in chainDict['chain']:
newsize += vol.getVolumeSize()
if newsize > size:
newsize = size
@@ -301,12 +300,14 @@ class Image:
newsize = int(newsize * 1.1) # allocate %10 more for cow metadata
return newsize
- def getChain(self, sdUUID, imgUUID, volUUID=None):
+ def getChain(self, sdUUID, imgUUID):
"""
- Return the chain of volumes of image as a sorted list
- (not including a shared base (template) if any)
+ Return the dictionary with chain of volumes of image as a sorted list
+ (not including a shared base (template)) and the template if any
"""
- chain = []
+ # 'chain' - chain of volumes of image as a sorted list
+ # 'template' - shared base (template) if any
+ chainDict = {'chain':[], 'template':None}
# Find all volumes of image
volclass = SDF.produce(sdUUID).getVolumeClass()
uuidlist = volclass.getImageVolumes(self.repoPath, sdUUID, imgUUID)
@@ -316,14 +317,13 @@ class Image:
srcVol = volclass(self.repoPath, sdUUID, imgUUID, uuidlist[0])
# For template image include only one volume (template itself)
if len(uuidlist) == 1 and srcVol.isShared():
- return [srcVol]
+ return {'chain':[srcVol], 'template':srcVol}
# find the leaf
for vol in uuidlist:
srcVol = volclass(self.repoPath, sdUUID, imgUUID, vol)
if srcVol.isLeaf():
- if not volUUID or volUUID == srcVol.volUUID:
- break
+ break
srcVol = None
if not srcVol:
@@ -332,38 +332,25 @@ class Image:
# Build up the sorted (parent->child) chain
while not srcVol.isShared():
- chain.insert(0, srcVol)
+ chainDict['chain'].insert(0, srcVol)
if srcVol.getParent() == volume.BLANK_UUID:
break
srcVol = srcVol.getParentVolume()
- self.log.info("sdUUID=%s imgUUID=%s chain=%s ", sdUUID, imgUUID, str(chain))
- return chain
+ if srcVol.isShared():
+ chainDict['template'] = srcVol
- def getTemplate(self, sdUUID, imgUUID):
- """
- Return template of the image
- """
- tmpl = None
- # Find all volumes of image (excluding template)
- chain = self.getChain(sdUUID, imgUUID)
- # check if the chain is build above a template, or it is a standalone
- pvol = chain[0].getParentVolume()
- if pvol:
- tmpl = pvol
- elif chain[0].isShared():
- tmpl = chain[0]
-
- return tmpl
+ self.log.info("sdUUID=%s imgUUID=%s chainDict=%s ", sdUUID, imgUUID, str(chainDict))
+ return chainDict
def validate(self, srcSdUUID, dstSdUUID, imgUUID, op=MOVE_OP):
"""
Validate template on destination domain
"""
- # Find all volumes of source image
- chain = self.getChain(srcSdUUID, imgUUID)
- leafVol = chain[-1]
srcDom = SDF.produce(srcSdUUID)
+ # Find all volumes of source image
+ chainDict = self.getChain(srcSdUUID, imgUUID)
+ leafVol = chainDict['chain'][-1]
# Avoid move template's image if there is a VM based on it (except 'Backup' domain)
if op == MOVE_OP and leafVol.isShared() and not srcDom.isBackup():
chList = leafVol.getAllChildrenList(self.repoPath, srcSdUUID, imgUUID, leafVol.volUUID)
@@ -371,18 +358,16 @@ class Image:
raise se.MoveTemplateImageError(imgUUID)
# check if the chain is build above a template, or it is a standalone
- pvol = chain[0].getParentVolume()
+ pvol = chainDict['template']
if pvol: # this is a shared template based chain
- if not pvol.isShared():
- raise se.ImageIsNotLegalChain("Base image parent vol %s is not shared" % pvol.volUUID)
pimg = pvol.getImage() # pimg == template image
try:
volclass = SDF.produce(dstSdUUID).getVolumeClass()
# Validate that the destination template exists and accessible
volclass(self.repoPath, dstSdUUID, pimg, pvol.volUUID)
- except se.StorageException, e:
- self.log.error("Unexpected error", exc_info=True)
- raise se.CouldNotValideTemplateOnTargetDomain("Template %s Destination domain %s: %s" % (pimg, dstSdUUID, str(e)))
+ except se.StorageException:
+ self.log.error("Cannot validate template %s on target domain %s", pimg, dstSdUUID, exc_info=True)
+ raise se.CouldNotValideTemplateOnTargetDomain()
def __templateRelink(self, destDom, imgUUID, volUUID):
"""
@@ -473,20 +458,15 @@ class Image:
def _createTargetImage(self, destDom, srcSdUUID, imgUUID):
# Before actual data copying we need perform several operation
# such as: create all volumes, create fake template if needed, ...
- try:
- # Find all volumes of source image
- srcChain = self.getChain(srcSdUUID, imgUUID)
- except se.StorageException:
- self.log.error("Unexpected error", exc_info=True)
- raise
- except Exception, e:
- self.log.error("Unexpected error", exc_info=True)
- raise se.SourceImageActionError(imgUUID, srcSdUUID, str(e))
+
+ # Find all volumes of source image
+ srcChainDict = self.getChain(srcSdUUID, imgUUID)
+ srcChain = srcChainDict['chain']
fakeTemplate = False
pimg = volume.BLANK_UUID # standalone chain
# check if the chain is build above a template, or it is a standalone
- pvol = srcChain[0].getParentVolume()
+ pvol = srcChainDict['template']
if pvol:
# find out parent volume parameters
volParams = pvol.getVolumeParams()
@@ -686,11 +666,9 @@ class Image:
"""
if not self.isLegal(sdUUID, imgUUID):
raise se.ImageIsNotLegalChain(imgUUID)
- chain = self.getChain(sdUUID, imgUUID)
- # check if the chain is build above a template, or it is a standalone
- pvol = chain[0].getParentVolume()
- if pvol:
- if not pvol.isLegal() or pvol.isFake():
+ chainDict = self.getChain(sdUUID, imgUUID)
+ if chainDict['template']:
+ if not chainDict['template'].isLegal() or chainDict['template'].isFake():
raise se.ImageIsNotLegalChain(imgUUID)
def copy(self, sdUUID, vmUUID, srcImgUUID, srcVolUUID, dstImgUUID, dstVolUUID,
@@ -735,8 +713,7 @@ class Image:
# using the sum of the actual size of the chain's volumes
if volParams['volFormat'] != volume.COW_FORMAT or volParams['prealloc'] != volume.SPARSE_VOL:
raise se.IncorrectFormat(self)
- volParams['apparentsize'] = self.__chainSizeCalc(sdUUID, srcImgUUID,
- srcVolUUID, volParams['size'])
+ volParams['apparentsize'] = self.__chainSizeCalc(sdUUID, srcImgUUID, volParams['size'])
# Find out dest volume parameters
if preallocate in [volume.PREALLOCATED_VOL, volume.SPARSE_VOL]:
diff --git a/vdsm/storage/resourceFactories.py b/vdsm/storage/resourceFactories.py
index ce3ec70..07df0f0 100644
--- a/vdsm/storage/resourceFactories.py
+++ b/vdsm/storage/resourceFactories.py
@@ -106,20 +106,18 @@ class ImageResourceFactory(rm.SimpleResourceFactory):
# Get the list of the volumes
repoPath = os.path.join(self.storage_repository, dom.getPools()[0])
try:
- chain = image.Image(repoPath).getChain(sdUUID=self.sdUUID, imgUUID=resourceName)
+ chainDict = image.Image(repoPath).getChain(sdUUID=self.sdUUID, imgUUID=resourceName)
+ chain = chainDict['chain']
except se.ImageDoesNotExistInSD:
log.debug("Image %s does not exist in domain %s", resourceName, self.sdUUID)
return []
- # check if the chain is build above a template, or it is a standalone
- pvol = chain[0].getParentVolume()
- if pvol:
- template = pvol.volUUID
- elif chain[0].isShared():
- # Image of template itself,
- # with no other volumes in chain
- template = chain[0].volUUID
- del chain[:]
+ # Image of template itself,
+ # with no other volumes in chain
+ if chainDict['template']:
+ template = chainDict['template'].volUUID
+ if chainDict['template'] in chain:
+ del chain[:]
volUUIDChain = [vol.volUUID for vol in chain]
volUUIDChain.sort()
11 years, 6 months
[NEW PATCH] BZ#729251 vds_bootstrap: Removed a reference to an obselete netconsole option. (via gerrit-bot)
by ghammer@redhat.com
New patch submitted by Gal Hammer (ghammer(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/909
commit b70673418d3bacb772c42acfc97d16c9635f61cf
Author: Gal Hammer <ghammer(a)redhat.com>
Date: Wed Sep 7 15:27:51 2011 +0300
BZ#729251 vds_bootstrap: Removed a reference to an obselete netconsole option.
Change-Id: Ie0b90a78f7c9c49af7b70e50db71f6621274ad4f
diff --git a/vds_bootstrap/vds_bootstrap.py b/vds_bootstrap/vds_bootstrap.py
index 3f8423c..bc64d93 100755
--- a/vds_bootstrap/vds_bootstrap.py
+++ b/vds_bootstrap/vds_bootstrap.py
@@ -785,7 +785,7 @@ def VdsValidation(iurl, subject, random_num, rev_num, orgName, systime, usevdcre
def main():
"""
Usage: vds_compat.py [-r rev_num] [-O organizationName] [-t systemTime]
- [-n netconsole_host:port] [-u (seProductRepo) true|false ] <url> <subject> <random_num>
+ [-u (seProductRepo) true|false ] <url> <subject> <random_num>
"""
try:
rev_num = None
@@ -800,9 +800,6 @@ def main():
orgName = v
if o == "-t":
systime = v
- if o == "-n":
- # TODO: remove me as soon as possible (BZ#689726)
- pass
if o == "-u":
usevdcrepo = (v.upper() == 'TRUE')
url = args[0]
11 years, 9 months
[NEW PATCH] BZ#736034 - Add metadataignore switch to pvcreate. (via gerrit-bot)
by ewarszaw@redhat.com
New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/908
commit 68353143d2d26a0f1e6e24e972e85970b9c17c23
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Wed Sep 7 14:00:04 2011 +0300
BZ#736034 - Add metadataignore switch to pvcreate.
Change-Id: Ib040902610fd2c5b0de04de95b57f0bfbdd1e11e
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 921cf3b..7550728 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -707,7 +707,7 @@ def _initpv(device, metadataSize=0):
metadatasize = str(metadataSize) + 'm'
cmd = ["pvcreate", "--metadatasize", metadatasize, device]
else:
- cmd = ["pvcreate", "--pvmetadatacopies", "0", device]
+ cmd = ["pvcreate", "--pvmetadatacopies", "0", "--metadataignore", "y", device]
#pvcreate on a dev that is already a PV but not in a VG returns rc = 0.
#The device is created with the new parameters.
11 years, 11 months
[NEW PATCH] BZ#727509 Vdsm-reg should get RHEVM certificates (via gerrit-bot)
by Federico Simoncelli
New patch submitted by Federico Simoncelli (fsimonce(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/779
commit 35adf49436ce00b4c8638fb87e20aa05e364a022
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Tue Aug 2 15:46:12 2011 +0000
BZ#727509 Vdsm-reg should get RHEVM certificates
Change-Id: I09673ab7bc9fa5dc99829eb6b8d6a65bc13d0e73
diff --git a/vdsm_reg/vdsm-reg-setup.py b/vdsm_reg/vdsm-reg-setup.py
index b1015b8..ed88f32 100755
--- a/vdsm_reg/vdsm-reg-setup.py
+++ b/vdsm_reg/vdsm-reg-setup.py
@@ -192,6 +192,10 @@ class Setup:
logging.debug("execute: after renameBridge: " + str(fOK))
if fOK:
+ fOK = deployUtil.getRhevmCert(self.vdcURL, self.vdcPORT)
+ logging.debug("execute: after getRhevmCert: " + str(fOK))
+
+ if fOK:
strKey = deployUtil.getAuthKeysFile(self.vdcURL, self.vdcPORT)
if strKey is not None:
fOKNow = deployUtil.handleSSHKey(strKey)
11 years, 11 months
[NEW PATCH] Related to 726960 - Restore higher version check. (via gerrit-bot)
by ewarszaw@redhat.com
New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/927
commit 8918ae22323fe2a829169d41ca67dfc5683cd57d
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Mon Sep 12 16:17:06 2011 +0300
Related to 726960 - Restore higher version check.
Change-Id: I9c7258361589fac7dc94361b88cabdf73cf48a83
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index bec3beb..55c6b45 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -779,6 +779,8 @@ class StoragePool:
#TODO: verify in masterMigrate().
if sdUUID == new_msdUUID:
raise se.InvalidParameterException("new_msdUUID", new_msdUUID)
+ #TODO: is this check irrelevant?
+ self.validatePoolMVerHigher(masterVersion)
self.masterMigrate(sdUUID, new_msdUUID, masterVersion)
elif dom.isBackup():
dom.unmountMaster()
12 years, 1 month
[NEW PATCH] Removing references to sdf.py. (via gerrit-bot)
by ewarszaw@redhat.com
New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/644
commit dd4884ae7cbf5d090c8e405dbd85705c72969b65
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Fri Jul 1 10:11:47 2011 +0300
Removing references to sdf.py.
Change-Id: I19d178e3b37fa119dc8a44815bb5055535c95241
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index ae411be..107ae69 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -23,7 +23,7 @@ import task
import lvm
import resourceManager as rm
from threadLocal import vars
-from sdf import StorageDomainFactory as SDF
+from sdc import StorageDomainFactory as SDF
from resourceFactories import LVM_ACTIVATION_NAMESPACE
import fileUtils
diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py
index 9ed54ff..fc4008f 100644
--- a/vdsm/storage/fileVolume.py
+++ b/vdsm/storage/fileVolume.py
@@ -13,7 +13,7 @@ import uuid
from config import config
import storage_exception as se
-from sdf import StorageDomainFactory as SDF
+from sdc import StorageDomainFactory as SDF
import volume
import image
import sd
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 296e923..f139b40 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -28,7 +28,7 @@ import spm
import lvm
import fileUtils
import multipath
-from sdf import StorageDomainFactory as SDF
+from sdc import StorageDomainFactory as SDF
import volume
import iscsi
import misc
@@ -1346,7 +1346,7 @@ class HSM:
domains = domList.keys()
else:
#getSharedLock(connectionsResource...)
- domains = SDF.getAllUUIDs()
+ domains = SDF.getUUIDs()
for sdUUID in domains[:]:
try:
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index 40a82c9..2e7c302 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -14,7 +14,7 @@ import threading
import uuid
import volume
-from sdf import StorageDomainFactory as SDF
+from sdc import StorageDomainFactory as SDF
import sd
import misc
import fileUtils
diff --git a/vdsm/storage/resourceFactories.py b/vdsm/storage/resourceFactories.py
index ce3ec70..42cd72a 100644
--- a/vdsm/storage/resourceFactories.py
+++ b/vdsm/storage/resourceFactories.py
@@ -13,7 +13,7 @@ import logging
import lvm
import resourceManager as rm
import storage_exception as se
-from sdf import StorageDomainFactory as SDF
+from sdc import StorageDomainFactory as SDF
import sd
import image
diff --git a/vdsm/storage/sdc.py b/vdsm/storage/sdc.py
index 883f7d2..8db7b11 100644
--- a/vdsm/storage/sdc.py
+++ b/vdsm/storage/sdc.py
@@ -13,6 +13,7 @@ for keeping storage related data that is expensive to harvest, but needed often
import logging
import threading
import weakref
+from config import config
import multipath
import lvm
@@ -22,6 +23,7 @@ import storage_exception as se
# Default cache age until forcibly refreshed
DEFAULT_REFRESH_INTERVAL = 300
+
class StorageDomainCache:
"""
Storage Domain List keeps track of all the storage domains accessible by the
@@ -58,7 +60,7 @@ class StorageDomainCache:
del self.__weakCache[sdUUID]
- def lookup(self, sdUUID):
+ def produce(self, sdUUID):
dom = self._getDomainFromCache(sdUUID)
if dom:
return dom
@@ -121,3 +123,8 @@ class StorageDomainCache:
def manuallyRemoveDomain(self, sdUUID):
with self._syncroot:
del self.__cache[sdUUID]
+
+
+storage_repository = config.get('irs', 'repository')
+StorageDomainFactory = StorageDomainCache(storage_repository)
+
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index c377ee4..39d1135 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -24,7 +24,7 @@ import misc
from misc import Event
import fileUtils
from config import config
-from sdf import StorageDomainFactory as SDF
+from sdc import StorageDomainFactory as SDF
import storage_exception as se
from persistentDict import DictValidator
diff --git a/vdsm/storage/spm.py b/vdsm/storage/spm.py
index 085d03b..dd603f2 100644
--- a/vdsm/storage/spm.py
+++ b/vdsm/storage/spm.py
@@ -29,7 +29,7 @@ import sd
import hsm
import blockSD
import image
-from sdf import StorageDomainFactory as SDF
+from sdc import StorageDomainFactory as SDF
import volume
import misc
import logging
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index 123ed37..6fb4dfb 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -16,7 +16,7 @@ import signal
import constants
import storage_exception as se
import sd
-from sdf import StorageDomainFactory as SDF
+from sdc import StorageDomainFactory as SDF
import misc
import fileUtils
import task
12 years, 1 month
[NEW PATCH] BZ#717658 - Simplify SDF.produce() (via gerrit-bot)
by ewarszaw@redhat.com
New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/643
commit f30ec1f48c499c1f74de19be88744a7fa70f5b51
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Fri Jul 1 08:04:43 2011 +0300
BZ#717658 - Simplify SDF.produce()
produce() calls lookup(),
lookup() calls (blockSD, localFsSD, nfsSD).findDomain(),
findDomain() calls __init__(),
__init__() calls findDomainPath(),
findDomainPath() will return or raise StorageDomainDoesNotExist!
Never None, never a false value, no need for this check.
Change-Id: I442c368a1266855b324eab96e4a7b02634984834
diff --git a/vdsm/storage/sdc.py b/vdsm/storage/sdc.py
index 1a8a3fa..883f7d2 100644
--- a/vdsm/storage/sdc.py
+++ b/vdsm/storage/sdc.py
@@ -73,6 +73,7 @@ class StorageDomainCache:
self._cleanStaleWeakrefs()
+ #_findDomain will raise StorageDomainDoesNotExist if sdUUID is not found in storage.
dom = self._findDomain(sdUUID)
self.__cache[sdUUID] = dom
self.__weakCache[sdUUID] = weakref.ref(dom)
diff --git a/vdsm/storage/sdf.py b/vdsm/storage/sdf.py
index 58fdea0..9d09b3b 100644
--- a/vdsm/storage/sdf.py
+++ b/vdsm/storage/sdf.py
@@ -11,7 +11,6 @@ from config import config
import logging
import sdc
-import storage_exception as se
class StorageDomainFactory:
@@ -34,10 +33,7 @@ class StorageDomainFactory:
Produce a new Storage domain
"""
- newSD = cls.__sdc.lookup(sdUUID)
- if not newSD:
- raise se.StorageDomainDoesNotExist(sdUUID)
- return newSD
+ return cls.__sdc.lookup(sdUUID)
@classmethod
12 years, 1 month
[NEW PATCH] BZ#717658 - Remove SDF.create() (via gerrit-bot)
by ewarszaw@redhat.com
New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/642
commit d15b149a4e5adc8d5763e4ff2aa31f4d050637a6
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Fri Jul 1 06:58:20 2011 +0300
BZ#717658 - Remove SDF.create()
Change-Id: I31b64def7aea87d4d3a94950abc8e96fbe3c4b8a
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index c4fa249..296e923 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -22,6 +22,8 @@ from itertools import imap
import sp
import sd
import blockSD
+import nfsSD
+import localFsSD
import spm
import lvm
import fileUtils
@@ -1171,8 +1173,15 @@ class HSM:
#getSharedLock(connectionsResource...)
#getExclusiveLock(sdUUID...)
- SDF.create(sdUUID=sdUUID, storageType=storageType, domainName=domainName,
- domClass=domClass, typeSpecificArg=typeSpecificArg, version=domVersion)
+ if storageType in sd.BLOCK_DOMAIN_TYPES:
+ newSD = blockSD.BlockStorageDomain.create(sdUUID, domainName, domClass, typeSpecificArg, storageType, domVersion)
+ elif storageType == sd.NFS_DOMAIN:
+ newSD = nfsSD.NfsStorageDomain.create(sdUUID, domainName, domClass, typeSpecificArg, storageType, domVersion)
+ elif storageType == sd.LOCALFS_DOMAIN:
+ newSD = localFsSD.LocalFsStorageDomain.create(sdUUID, domainName, domClass, typeSpecificArg, storageType, domVersion)
+ else:
+ raise se.StorageDomainTypeError(storageType)
+ SDF.manuallyAddDomain(newSD)
def public_validateStorageDomain(self, sdUUID, options = None):
diff --git a/vdsm/storage/sdf.py b/vdsm/storage/sdf.py
index 5e0577d..58fdea0 100644
--- a/vdsm/storage/sdf.py
+++ b/vdsm/storage/sdf.py
@@ -11,7 +11,6 @@ from config import config
import logging
import sdc
-import sd
import storage_exception as se
@@ -20,6 +19,11 @@ class StorageDomainFactory:
storage_repository = config.get('irs', 'repository')
__sdc = sdc.StorageDomainCache(storage_repository)
+ #WARNING! The parameters of the following two methods are not symmetric.
+ @classmethod
+ def manuallyAddDomain(cls, sd):
+ cls.__sdc.manuallyAddDomain(sd)
+
@classmethod
def manuallyRemoveDomain(cls, sdUUID):
cls.__sdc.manuallyRemoveDomain(sdUUID)
@@ -37,38 +41,6 @@ class StorageDomainFactory:
@classmethod
- def create(cls, sdUUID, storageType, domainName, domClass, typeSpecificArg, version):
- """
- Create a new Storage domain
- """
- import nfsSD
- import localFsSD
- import blockSD
-
- newSD = None
- if storageType in [sd.NFS_DOMAIN]:
- newSD = nfsSD.NfsStorageDomain.create(sdUUID=sdUUID,
- domainName=domainName, domClass=domClass,
- remotePath=typeSpecificArg, storageType=storageType,
- version=version)
- elif storageType in [sd.LOCALFS_DOMAIN]:
- newSD = localFsSD.LocalFsStorageDomain.create(sdUUID=sdUUID,
- domainName=domainName, domClass=domClass,
- remotePath=typeSpecificArg, storageType=storageType,
- version=version)
- elif storageType in [sd.ISCSI_DOMAIN, sd.FCP_DOMAIN]:
- newSD = blockSD.BlockStorageDomain.create(sdUUID=sdUUID,
- domainName=domainName, domClass=domClass,
- vgUUID=typeSpecificArg, storageType=storageType,
- version=version)
- else:
- raise se.StorageDomainTypeError(storageType)
-
- cls.__sdc.manuallyAddDomain(newSD)
- return newSD
-
-
- @classmethod
def getAllUUIDs(cls):
return cls.__sdc.getUUIDs()
12 years, 1 month
[NEW PATCH] BZ#717658 - Simplify recycle function. (via gerrit-bot)
by ewarszaw@redhat.com
New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/641
commit 4ef2f06aca02bc48f63c3b5f7d48ae83e191b3ba
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Thu Jun 30 16:18:50 2011 +0300
BZ#717658 - Simplify recycle function.
Change-Id: I9cf3106f0fb5d5cd067907d48ff02fe50493a66c
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 29206f5..c4fa249 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1190,6 +1190,15 @@ class HSM:
return SDF.produce(sdUUID=sdUUID).validate()
+ #TODO: Remove this function when formatStorageDomain() is removed.
+ def _recycle(self, sd):
+ try:
+ SDF.manuallyRemoveDomain(sd.sdUUID)
+ except KeyError:
+ self.log.warn("Storage domain %s doesn't exist in cache. Trying recycle leftovers ...", sd.sdUUID)
+
+ sd.format(sd.sdUUID)
+
def public_formatStorageDomain(self, sdUUID, autoDetach = False, options = None):
"""
Formats a detached storage domain.
@@ -1198,6 +1207,7 @@ class HSM:
This removes all data from the storage domain.
:param sdUUID: The UUID for the storage domain you want to format.
+ :param autoDetach: DEPRECATED
:type sdUUID: UUID
:param options: ?
@@ -1214,22 +1224,17 @@ class HSM:
raise se.CannotFormatStorageDomainInConnectedPool(sdUUID)
# For domains that attached to disconnected pool, format domain if 'autoDetach' flag set
- if not misc.parseBool(autoDetach):
+ sd = SDF.produce(sdUUID=sdUUID)
+ try:
+ #TODO: autoDetach is True
+ if not misc.parseBool(autoDetach) and sd.getPools():
+ raise se.CannotFormatAttachedStorageDomain(sdUUID)
# Allow format also for broken domain
- try:
- if len(SDF.produce(sdUUID=sdUUID).getPools()) > 0:
- raise se.CannotFormatAttachedStorageDomain(sdUUID)
-
- except (se.StorageDomainMetadataNotFound, se.MetaDataGeneralError, se.MiscFileReadException,
- se.MiscBlockReadException, se.MiscBlockReadIncomplete), e:
- self.log.warn("Domain %s has problem with metadata. Continue formating... (%s)", sdUUID, str(e))
- except se.CannotFormatAttachedStorageDomain:
- raise
- except Exception:
- self.log.warn("Domain %s can't be formated", sdUUID, exc_info=True)
- raise se.StorageDomainFormatError(sdUUID)
+ except (se.StorageDomainMetadataNotFound, se.MetaDataGeneralError, se.MiscFileReadException,
+ se.MiscBlockReadException, se.MiscBlockReadIncomplete), e:
+ self.log.warn("Domain %s has problem with metadata. Continue formating... (%s)", sdUUID, str(e))
- SDF.recycle(sdUUID=sdUUID)
+ self._recycle(sd)
def public_setStorageDomainDescription(self, sdUUID, description, options = None):
diff --git a/vdsm/storage/sdf.py b/vdsm/storage/sdf.py
index 16faa3e..5e0577d 100644
--- a/vdsm/storage/sdf.py
+++ b/vdsm/storage/sdf.py
@@ -20,6 +20,9 @@ class StorageDomainFactory:
storage_repository = config.get('irs', 'repository')
__sdc = sdc.StorageDomainCache(storage_repository)
+ @classmethod
+ def manuallyRemoveDomain(cls, sdUUID):
+ cls.__sdc.manuallyRemoveDomain(sdUUID)
@classmethod
def produce(cls, sdUUID):
@@ -66,33 +69,6 @@ class StorageDomainFactory:
@classmethod
- def recycle(cls, sdUUID):
- """
- Cleanly destroys the domain
- """
- import nfsSD
- import localFsSD
- import blockSD
-
- try:
- cls.__sdc.manuallyRemoveDomain(sdUUID)
- except Exception:
- cls.log.warn("Storage domain %s doesn't exist. Trying recycle leftovers ...", sdUUID)
-
- for domClass in (blockSD.BlockStorageDomain, nfsSD.NfsStorageDomain, localFsSD.LocalFsStorageDomain):
- try:
- domClass.findDomainPath(sdUUID)
- except (se.StorageDomainDoesNotExist):
- pass
- except Exception:
- cls.log.error("Can't find out domain %s", sdUUID, exc_info=True)
- else:
- return domClass.format(sdUUID)
-
- raise se.StorageDomainTypeError(sdUUID)
-
-
- @classmethod
def getAllUUIDs(cls):
return cls.__sdc.getUUIDs()
12 years, 1 month
[NEW PATCH] BZ#717658 - Change format signature. (via gerrit-bot)
by ewarszaw@redhat.com
New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/640
commit a609d198d38137374db72a7ac3fc416c36ad64d3
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Thu Jun 30 16:07:58 2011 +0300
BZ#717658 - Change format signature.
Change-Id: Iea1e5735563087195181c625e57b8ba8e75d3441
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 214e8a4..5c8f8e2 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -658,11 +658,12 @@ class BlockStorageDomain(sd.StorageDomain):
fileUtils.cleanupdir(os.path.join("/dev", self.sdUUID))
@classmethod
- def format(cls, sdUUID, domaindir):
+ def format(cls, sdUUID):
"""Format detached storage domain.
This removes all data from the storage domain.
"""
# Remove the directory tree
+ domaindir = cls.findDomainPath(sdUUID)
fileUtils.cleanupdir(domaindir, ignoreErrors = True)
# Remove special metadata and service volumes
# Remove all volumes LV if exists
diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py
index 8b40a59..023c197 100644
--- a/vdsm/storage/fileSD.py
+++ b/vdsm/storage/fileSD.py
@@ -195,12 +195,13 @@ class FileStorageDomain(sd.StorageDomain):
return imgList
@classmethod
- def format(cls, sdUUID, domaindir):
+ def format(cls, sdUUID):
"""
Format detached storage domain.
This removes all data from the storage domain.
"""
cls.log.info("Formating domain %s", sdUUID)
+ domaindir = cls.findDomainPath(sdUUID)
processPoolDict[sdUUID].fileUtils.cleanupdir(domaindir, ignoreErrors = False)
return True
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index 325da5d..579b282 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -552,14 +552,6 @@ class StorageDomain:
if self.isBackup():
self.unmountMaster()
-
- def format(self):
- """
- Format detached storage domain.
- This removes all data from the storage domain.
- """
- pass
-
def getAllImages(self):
"""
Fetch the list of the Image UUIDs
diff --git a/vdsm/storage/sdf.py b/vdsm/storage/sdf.py
index da8335c..16faa3e 100644
--- a/vdsm/storage/sdf.py
+++ b/vdsm/storage/sdf.py
@@ -81,13 +81,13 @@ class StorageDomainFactory:
for domClass in (blockSD.BlockStorageDomain, nfsSD.NfsStorageDomain, localFsSD.LocalFsStorageDomain):
try:
- domaindir = domClass.findDomainPath(sdUUID)
+ domClass.findDomainPath(sdUUID)
except (se.StorageDomainDoesNotExist):
pass
except Exception:
cls.log.error("Can't find out domain %s", sdUUID, exc_info=True)
else:
- return domClass.format(sdUUID, domaindir)
+ return domClass.format(sdUUID)
raise se.StorageDomainTypeError(sdUUID)
12 years, 1 month