فهرست منبع

Storage account wait

almahmoud 7 سال پیش
والد
کامیت
15a2bb1ae4
3فایلهای تغییر یافته به همراه17 افزوده شده و 13 حذف شده
  1. 13 11
      cloudbridge/cloud/providers/azure/azure_client.py
  2. 3 1
      cloudbridge/cloud/providers/azure/provider.py
  3. 1 1
      setup.cfg

+ 13 - 11
cloudbridge/cloud/providers/azure/azure_client.py

@@ -147,7 +147,7 @@ class AzureClient(object):
     """
     def __init__(self, config):
         self._config = config
-        self.subscription_id = config.get('azure_subscription_id')
+        self.subscription_id = str(config.get('azure_subscription_id'))
         self._credentials = ServicePrincipalCredentials(
             client_id=config.get('azure_client_id'),
             secret=config.get('azure_secret'),
@@ -168,6 +168,7 @@ class AzureClient(object):
     @property
     def access_key_result(self):
         if not self._access_key_result:
+            storage_account = self.storage_account
             timeout = self._config.get("default_wait_timeout")
             interval = self._config.get("default_wait_interval")
 
@@ -177,22 +178,23 @@ class AzureClient(object):
 
             end_time = time.time() + timeout
 
-            while self.storage_account.provisioning_state != "Succeeded":
+            while self.get_storage_account(storage_account).\
+                    provisioning_state.value != 'Succeeded':
                 log.debug(
-                    "Object %s is in state: %s. Waiting another %s"
-                    " seconds to reach target state: Succeeded...",
-                    self.storage_account,
-                    self.storage_account.provisioning_state,
+                    "Storage account %s is not in Succeeded state. "
+                    "Waiting another %s seconds to reach that state.",
+                    storage_account,
                     int(end_time - time.time()))
                 time.sleep(interval)
                 if time.time() > end_time:
                     raise WaitStateException(
-                        "Waited too long for object: {0} to become ready. It's"
-                        " still in state: {1}".format(self.storage_account,
-                                                      self.storage_account.
-                                                      provisioning_state))
+                        "Waited too long for storage account: {0} to "
+                        "become ready. It's still in state: {1}".format(
+                            storage_account,
+                            self.get_storage_account(storage_account).
+                            provisioning_state))
             self._access_key_result = self.storage_client.storage_accounts. \
-                list_keys(self.resource_group, self.storage_account)
+                list_keys(self.resource_group, storage_account)
         return self._access_key_result
 
     @property

+ 3 - 1
cloudbridge/cloud/providers/azure/provider.py

@@ -93,7 +93,9 @@ class AzureCloudProvider(BaseCloudProvider):
                 'azure_resource_group': self.resource_group,
                 'azure_storage_account': self.storage_account,
                 'azure_public_key_storage_table_name':
-                    self.public_key_storage_table_name
+                    self.public_key_storage_table_name,
+                'default_wait_timeout': self.config.default_wait_timeout,
+                'default_wait_interval': self.config.default_wait_interval
             }
 
             self._azure_client = AzureClient(provider_config)

+ 1 - 1
setup.cfg

@@ -8,7 +8,7 @@ omit =
 with-coverage=1
 cover-branches=1
 cover-package=cloudbridge
-processes=10
+processes=5
 process-timeout=3000
 match=^[Tt]est 
 # Don't capture stdout - print immediately