]> xenbits.xensource.com Git - xenrt-citrix/xenrt.git/commitdiff
Change SR obj to query smconf when requested
authorJunWook Kwak <junwook.kwak@citrix.com>
Wed, 21 Oct 2015 14:48:55 +0000 (15:48 +0100)
committerJunWook Kwak <junwook.kwak@citrix.com>
Wed, 21 Oct 2015 15:14:55 +0000 (16:14 +0100)
smconf var in StorageRepository object may not reflect current sm-config of SR
as it is associated when SR is created. By querying everytime whenever it is requested,
this 'old data return' can be avoidable.

exec/testcases/xenserver/tc/thinlvhd.py
exec/xenrt/lib/xenserver/sr.py

index 7b383409e469ecf2360407efaa5c1a5a48b54793..942ea49f1ac93ca3464540470f815d0cdf6ba6fa 100644 (file)
@@ -72,7 +72,7 @@ class _ThinLVHDBase(xenrt.TestCase):
                 smconf[key.strip()] = val.strip()
         else:
             smconf = obj.smconf
-            
+
         return smconf
 
     def getInitialAllocation(self, obj=None):
index 6fbc91a1ba9031f3579cccb3bbd23be3fac5d625..f633fe3285c50efa33ef5f80c45454194d8b54e3 100644 (file)
@@ -93,7 +93,6 @@ class StorageRepository(object):
         self.srtype = None
         self.dconf = None
         self.content_type = ""
-        self.smconf = {}
 
     @classmethod
     def fromExistingSR(cls, host, sruuid):
@@ -119,10 +118,28 @@ class StorageRepository(object):
 
         xpbd = next((p for p in xsr.PBD() if p.host() == host.asXapiObject()), None)
         instance.dconf = xpbd.deviceConfig()
-        instance.smconf = xsr.smConfig()
         instance.content_type = xsr.contentType()
         return instance
 
+    @property
+    def smconf(self):
+        """
+        Query current sm-config object and return as Dict form
+
+        @return: Dict of sm-config of SR.
+        """
+        confstr = self.host.genParamGet("sr", self.uuid, "sm-config")
+        conf = {}
+        for item in confstr.split(";"):
+            key, val = item.split(":", 1)
+            conf[key.strip()] = val.strip()
+
+        return conf
+    
+    @property
+    def smconfig(self):
+        return self.smconf
+
     @property
     def thinProvisioning(self):
         """Return whether sr is thinly provisioned."""
@@ -264,7 +281,6 @@ class StorageRepository(object):
         self.srtype = srtype
         self.dconf = actualDeviceConfiguration
         self.content_type = content_type
-        self.smconf = smconf
 
     def check(self):
         self.checkCommon(self.srtype)