diff options
author | Stamatis Katsaounis <mokats@intracom-telecom.com> | 2018-09-10 11:11:49 +0300 |
---|---|---|
committer | Stamatis Katsaounis <mokats@intracom-telecom.com> | 2018-09-27 12:08:41 +0300 |
commit | ea48239f99fdddd703bebb1727575f844c097702 (patch) | |
tree | b1b32b433eb2f780f82366df21d2c2e1836a9424 | |
parent | 64a5e7dc89be1c52253a48fb5ccfa045b6619d0f (diff) |
Wait for instance deletion
JIRA: SDNVPN-222
Confirm the deletion of instance in order to prevent its port
existence when trying to delete relevant subnet in a later stage.
Change-Id: Iace0fbbd90d50f05764ac09682caae59baba22fa
Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
-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 |