@@ -268,18 +268,6 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
268268 "kvm" : "" ,
269269 "xenserver" : ".vhd" }
270270
271- from base import ImageStore
272- secondaryStores = ImageStore .list (apiclient , zoneid = zoneid )
273-
274- assert isinstance (secondaryStores , list ), "Not a valid response for listImageStores"
275- assert len (secondaryStores ) != 0 , "No image stores found in zone %s" % zoneid
276-
277- secondaryStore = secondaryStores [0 ]
278-
279- if str (secondaryStore .providername ).lower () != "nfs" :
280- raise Exception (
281- "is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str (secondaryStore .providername ))
282-
283271 qresultset = dbconn .execute (
284272 "select id from snapshots where uuid = '%s';" \
285273 % str (snapshotid )
@@ -291,7 +279,7 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
291279
292280 snapshotid = qresultset [0 ][0 ]
293281 qresultset = dbconn .execute (
294- "select install_path from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
282+ "select install_path,store_id from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
295283 )
296284
297285 assert isinstance (qresultset , list ), "Invalid db query response for snapshot %s" % snapshotid
@@ -300,6 +288,19 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
300288 #Snapshot does not exist
301289 return False
302290
291+ from base import ImageStore
292+ #pass store_id to get the exact storage pool where snapshot is stored
293+ secondaryStores = ImageStore .list (apiclient , zoneid = zoneid , id = int (qresultset [0 ][1 ]))
294+
295+ assert isinstance (secondaryStores , list ), "Not a valid response for listImageStores"
296+ assert len (secondaryStores ) != 0 , "No image stores found in zone %s" % zoneid
297+
298+ secondaryStore = secondaryStores [0 ]
299+
300+ if str (secondaryStore .providername ).lower () != "nfs" :
301+ raise Exception (
302+ "is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str (secondaryStore .providername ))
303+
303304 hypervisor = get_hypervisor_type (apiclient )
304305 # append snapshot extension based on hypervisor, to the snapshot path
305306 snapshotPath = str (qresultset [0 ][0 ]) + snapshot_extensions [str (hypervisor ).lower ()]
0 commit comments