summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-07-30 15:03:42 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-07-30 15:06:40 +0200
commitcfb241ab63898eb4a550fc571d34952d33996e9c (patch)
treeef0d1f16185f0e5dc384cdd746104b259311fca9
parent3d6f7e8b3a6cfe4c926bd93d45861c80970e35f7 (diff)
Protect vs exceptions when creating secrets
cloudify_ims sometimes faces with exceptions when creating secrets [1]. [1] https://build.opnfv.org/ci/view/functest/job/functest-apex-baremetal-daily-master/188/console Change-Id: I197748bf97752575dc14650e1e1c382774811cce Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
index c5003e1c6..8fa8c612b 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -121,12 +121,23 @@ class CloudifyIms(cloudify.Cloudify):
project_domain_name=os.environ.get(
'OS_PROJECT_DOMAIN_NAME', 'Default'))
self.__logger.info("Set creds for cloudify manager %s", cfy_creds)
- secrets_list = self.cfy_client.secrets.list()
- for k, val in six.iteritems(cfy_creds):
- if not any(d.get('key', None) == k for d in secrets_list):
- self.cfy_client.secrets.create(k, val)
- else:
- self.cfy_client.secrets.update(k, val)
+
+ for loop in range(10):
+ try:
+ secrets_list = self.cfy_client.secrets.list()
+ for k, val in six.iteritems(cfy_creds):
+ if not any(d.get('key', None) == k for d in secrets_list):
+ self.cfy_client.secrets.create(k, val)
+ else:
+ self.cfy_client.secrets.update(k, val)
+ break
+ except Exception: # pylint: disable=broad-except
+ self.__logger.info(
+ "try %s: Cannot create secrets", loop + 1)
+ time.sleep(30)
+ else:
+ self.__logger.error("Cannot create secrets")
+ return 1
duration = time.time() - start_time