它正确删除了第一个循环中的所有内容,但是在删除第二个循环中的快照时抛出了这个问题,知道为什么吗?我可能一直在运行 python 3,现在又回到了 2.7,这可能是我的问题吗?它似乎从列表中删除了一项,然后无法再删除。
for i in range(0, numOfSnap):
tempName = baseVv.name + ".ro" + str(i)
snapVv = baseVv.createSv(name=baseVv.name + ".ro" + str(i), svOptions="-ro -i %s" % x)
x += 1
dlog.info("Creating %s" % tempName)
baseVv.name + ".rw" + str(i)
tempName = baseVv.name + ".rw" + str(i)
rwSnap = snapVv.createSv(name=baseVv.name + ".rw" + str(i), svOptions="-i %s" % x)
x += 1
snapRwVlun = self.cluster.createVlun(vv=rwSnap, host=host)
dlog.info("Creating %s" % tempName)
rwSnapList.append(rwSnap)
vlunList.append(snapRwVlun)
## delay random seconds between RO snapshot creation
time.sleep(random.randint(5,30))
snapRoList = baseVv.snapSvList
dlog.info("Stopping IO on VV")
self.cluster.stopSnapIOOnHosts()
dlog.info("Starting IO on snaps and VV")
self.cluster.startSnapIOOnHosts()
dlog.info("Sleep 60 seconds for IO to go through")
time.sleep(60)
dlog.info("Stopping IO")
self.cluster.stopSnapIOOnHosts()
time.sleep(60)
for vluns in vlunList:
vluns.remove()
dlog.info("Waiting 60 seconds")
time.sleep(60)
## randomly pick 1 rw snapshot to delete till removal of all snapshot
for i in range(0, numOfSnap)[:]:
snapIndex = random.randint(0, len(rwSnapList)-1)
dlog.info("remove %s" % rwSnapList[snapIndex].name)
roSnapshot = rwSnapList[snapIndex]
roSnapshot.remove()
#self.cluster.waitForClusterIntegrated()
## remove it from object list
rwSnapList.remove(roSnapshot)
time.sleep(random.randint(5,10))
## randomly pick 1 ro snapshot to delete till removal of all snapshot
for i in range(0, numOfSnap)[:]:
snapIndex = random.randint(0, len(snapRoList)-1)
dlog.info("remove %s" % snapRoList[snapIndex].name)
roSnapshot = snapRoList[snapIndex]
roSnapshot.remove()
#self.cluster.waitForClusterIntegrated()
## remove it from object list
snapRoList.remove(roSnapshot)
time.sleep(random.randint(5,10))