]> xenbits.xensource.com Git - xenrt-citrix/xenrt.git/commitdiff
Add SRs to registry
authorJohn Dilley <john.dilley@citrix.com>
Thu, 5 Nov 2015 10:03:22 +0000 (10:03 +0000)
committerJohn Dilley <john.dilley@citrix.com>
Thu, 5 Nov 2015 10:03:22 +0000 (10:03 +0000)
exec/xenrt/lib/xenserver/sr.py
exec/xenrt/registry.py

index e7a86eafe1ffec971f08436dce298bf6d0f2ee88..12fcd13e6437fafad70c53b984ec5e3942da2721 100644 (file)
@@ -114,14 +114,18 @@ class StorageRepository(object):
         if not xsr:
             raise ValueError("Could not find sruuid %s on host %s" %(sruuid, host))
 
-        instance = cls(host, xsr.name)
-        instance.uuid = xsr.uuid
-        instance.srtype = xsr.srType
-        instance.host = host
-
-        xpbd = next((p for p in xsr.PBDs if p.host == host.xapiObject), None)
-        instance.dconf = xpbd.deviceConfig
-        instance.content_type = xsr.contentType
+        instance = xenrt.GEC().registry.srGet(sruuid)
+        if instance:
+            xenrt.TEC().logverbose("Found SR in registry")
+        else:
+            instance = cls(host, xsr.name)
+            instance.uuid = xsr.uuid
+            instance.srtype = xsr.srType
+            instance.host = host
+
+            xpbd = next((p for p in xsr.PBDs if p.host == host.xapiObject), None)
+            instance.dconf = xpbd.deviceConfig
+            instance.content_type = xsr.contentType
         return instance
 
     def __backupSMConf(self):
@@ -310,6 +314,7 @@ class StorageRepository(object):
         self.srtype = srtype
         self.dconf = actualDeviceConfiguration
         self.content_type = content_type
+        xenrt.GEC().registry.srPut(self.uuid, self)
 
     def check(self):
         self.checkCommon(self.srtype)
index 3fb1123baa782b6b8de2ac5ac93244f6921f9c2b..a7c484bf17b18b9f31730ecddd3707b195cc9944 100755 (executable)
@@ -438,8 +438,20 @@ class Registry(object):
     def centralResourceGet(self, id):
         return self.objGet("centralresource", id)
 
-    def centralResourceDelete(self, tag):
+    def centralResourceDelete(self, id):
         self.objDelete("centralresource", id)
 
     def centralResourceGetAll(self):
         return self.objGetAll("centralresource")
+    
+    def srPut(self, id, sr):
+        self.objPut("sr", id, sr)
+
+    def srGet(self, id):
+        return self.objGet("sr", id)
+
+    def srDelete(self, id):
+        self.objDelete("sr", id)
+
+    def srGetAll(self):
+        return self.objGetAll("sr")