Fix minor wait_server bug, discover a cli bug
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Thu, 8 Nov 2012 13:20:21 +0000 (15:20 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Thu, 8 Nov 2012 13:20:21 +0000 (15:20 +0200)
CLI bug: deep-level commands malfunction

kamaki/cli/commands/quotaholder_cli.py
kamaki/clients/cyclades.py

index 08ec0ad..155a7ad 100644 (file)
@@ -47,6 +47,25 @@ class _quotaholder_init(_command_init):
             or self.config.get('global', 'url')
         self.client = QuotaHolderClient(self.base_url, self.token)
 
+@command()
+class quotaholder_test_specific(_quotaholder_init):
+    """Test quota holder commands - devel/testing only"""
+
+    def main(self):
+        super(self.__class__, self).main()
+        print('We will test quota holder stuff')
+        r = self.client.test_quota()
+        print('That is what we got {%s}' % r)
+
+@command()
+class quotaholder_test_all(_quotaholder_init):
+    """Test quota holder commands - devel/testing only"""
+
+    def main(self):
+        super(self.__class__, self).main()
+        print('We will test quota holder stuff')
+        r = self.client.test_quota()
+        print('That is what we got {%s}' % r)
 
 @command()
 class quotaholder_test(_quotaholder_init):
index 7d2cf8d..fde35ad 100644 (file)
@@ -229,20 +229,20 @@ class CycladesClient(ComputeClient):
         r = self.get_server_details(server_id)
         if r['status'] != current_status:
             return r['status']
-        total_wait = 1
-        old_wait = total_wait
+        old_wait = total_wait = 0
 
         if current_status == 'BUILD':
-            max_wait = delay * 100
+            max_wait = 100 * delay
 
         if wait_cb:
             wait_gen = wait_cb(1 + max_wait // delay)
+            wait_gen.next()
 
         while r['status'] == current_status and total_wait <= max_wait:
             if current_status == 'BUILD':
-                total_wait = r['progress']
+                total_wait = int(r['progress']) * delay
                 if wait_cb:
-                    for i in range(old_wait, total_wait):
+                    for i in range(int(old_wait), int(total_wait)):
                         wait_gen.next()
                     old_wait = total_wait
             else:
@@ -252,11 +252,12 @@ class CycladesClient(ComputeClient):
             sleep(delay)
             r = self.get_server_details(server_id)
 
-        if wait_cb and r['status'] != current_status:
-            try:
-                while True:
-                    wait_gen.next()
-            except:
-                pass
+        if r['status'] != current_status:
+            if wait_cb:
+                try:
+                    while True:
+                        wait_gen.next()
+                except:
+                    pass
             return r['status']
         return False