def multi(session, args): """Perform several actions in one call (to save on round trips)""" util.SMlog("on-slave.multi: %s" % args) vgName = args["vgName"] lvmCache = LVMCache(vgName) i = 1 while True: action = args.get("action%d" % i) if not action: break util.SMlog("on-slave.action %d: %s" % (i, action)) if action == "activate": try: lvmCache.activate(args["ns%d" % i], args["uuid%d" % i], args["lvName%d" % i], False) except util.CommandException: util.SMlog("on-slave.activate failed") raise elif action == "deactivate": try: lvmCache.deactivate(args["ns%d" % i], args["uuid%d" % i], args["lvName%d" % i], False) except util.SMException: util.SMlog("on-slave.deactivate failed") raise elif action == "deactivateNoRefcount": try: lvmCache.deactivateNoRefcount(args["lvName%d" % i]) except util.SMException: util.SMlog("on-slave.deactivateNoRefcount failed") raise elif action == "refresh": try: lvmCache.activateNoRefcount(args["lvName%d" % i], True) except util.CommandException: util.SMlog("on-slave.refresh failed") raise elif action == "cleanupLockAndRefcount": from refcounter import RefCounter lock.Lock.cleanup(args["uuid%d" % i], args["ns%d" % i]) RefCounter.reset(args["uuid%d" % i], args["ns%d" % i]) else: raise util.SMException("unrecognized action: %s" % action) i += 1 return str(True)
vdi = vdiInfo[vdi.parentUuid] vdi.refcount += 1 pathsNotInUse = [] for uuid, vdi in vdiInfo.iteritems(): if vdi.hidden: util.SMlog("Setting refcount for %s to %d" % (uuid, vdi.refcount)) RefCounter.set(uuid, vdi.refcount, 0, ns) if vdi.refcount == 0 and vdi.lvActive: path = os.path.join("/dev", lvmCache.vgName, vdi.lvName) pathsNotInUse.append(path) return pathsNotInUse if __name__ == "__main__": # used by the master changeover script from lvmcache import LVMCache try: cmd = sys.argv[1] srUuid = sys.argv[2] if cmd == "fixrefcounts": vgName = VG_PREFIX + srUuid lvmCache = LVMCache(vgName) setInnerNodeRefcounts(lvmCache, srUuid) else: util.SMlog("Invalid usage") print "Usage: %s fixrefcounts <sr_uuid>" % sys.argv[0] except: util.logException("setInnerNodeRefcounts")