Add "--unlockfailed" to tct/resource_locking.py 63/79763/6
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Tue, 12 Jul 2016 16:04:49 +0000 (18:04 +0200)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Fri, 7 Oct 2016 15:13:06 +0000 (17:13 +0200)
Change-Id: I6c00f39d69fcf617c0dcbfb266335c5b44a29604
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
tct/resource_locking.py

index 6eea39b..af25f7d 100755 (executable)
@@ -141,6 +141,13 @@ class UUIDmanager:
         while not self.lock():
             time.sleep(60)
 
+    def unlockfailed(self):
+        # unlock target as usual and increase its counter by 10
+        if not self.unlock():
+            logging.warn("Unlock failed: %s", self.target)
+        uuid = UUID_PREFIX + self.target
+        UUIDlist.set_cnt(uuid, UUIDlist.get_cnt(uuid)+10)
+
 def parse_arguments():
     parser = argparse.ArgumentParser(description="Manager of locks on UUID files")
 
@@ -161,6 +168,10 @@ def parse_arguments():
             action="store_true", default=False, dest="unlock",
             help="Unlock a device")
 
+    group.add_argument("-f", "--unlockfailed",
+            action="store_true", default=False, dest="unlockfailed",
+            help="Unlock a device and increment counter by 10")
+
     parser.add_argument("-L", "--log",
             action="store", dest="loglevel",
             help="Verbosity level")
@@ -186,6 +197,8 @@ def main():
             logging.warn("File unlocking unsuccessful!")
     elif args.retrylock:
         uuid_man.retrylock()
+    elif args.unlockfailed:
+        uuid_man.unlockfailed()
     logging.debug("End")
 
 if __name__ == '__main__':