diff options
author | Nikos Karandreas <nick@intracom-telecom.com> | 2018-09-27 09:16:26 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-09-27 09:16:26 +0000 |
commit | e97d0c53a5b15e590e03ba86972eed26db4009c0 (patch) | |
tree | 61bdc3a2c1a12bdd8efad6c90485635041b02a2b | |
parent | 785fed155091a3eeca81dd07c2d308145ef2d98d (diff) | |
parent | ea48239f99fdddd703bebb1727575f844c097702 (diff) |
Merge "Wait for instance deletion"
-rw-r--r-- | sdnvpn/lib/utils.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py index e43750c..9f4c883 100644 --- a/sdnvpn/lib/utils.py +++ b/sdnvpn/lib/utils.py @@ -371,6 +371,21 @@ def async_Wait_for_instances(instances, tries=40): logger.error("one or more instances is not yet booted up") +def wait_for_instance_delete(nova_client, instance_id, tries=30): + sleep_time = 2 + instances = [instance_id] + logger.debug("Waiting for instance %s to be deleted" + % (instance_id)) + while tries > 0 and instance_id in instances: + instances = [instance.id for instance in + os_utils.get_instances(nova_client)] + time.sleep(sleep_time) + tries -= 1 + if instance_id in instances: + logger.error("Deletion of instance %s failed" % + (instance_id)) + + def wait_for_bgp_net_assoc(neutron_client, bgpvpn_id, net_id): tries = 30 sleep_time = 1 @@ -702,7 +717,8 @@ def cleanup_nova(nova_client, instance_ids, flavor_ids=None): logger.error('Fail to delete all instances. ' 'Instance with id {} was not deleted.'. format(instance_id)) - return False + else: + wait_for_instance_delete(nova_client, instance_id) return True |