summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2018-01-16 07:46:29 -0700
committerspisarski <s.pisarski@cablelabs.com>2018-01-16 07:46:29 -0700
commit1634f6ed27e33c52334d97c1c85f96eb6e651426 (patch)
tree75cd741754e73372ecfbe2fb40537f51be502f7e
parent97cee572f017696415b212024fc28c85b892b0cd (diff)
Added post processing task after application of an Ansible playbook.
The only task currently supported is reboot. Change-Id: I9089c593af30db071508a47667381238fe91e44e Signed-off-by: spisarski <s.pisarski@cablelabs.com>
-rw-r--r--snaps/openstack/utils/launch_utils.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/snaps/openstack/utils/launch_utils.py b/snaps/openstack/utils/launch_utils.py
index abf04b5..217a5c6 100644
--- a/snaps/openstack/utils/launch_utils.py
+++ b/snaps/openstack/utils/launch_utils.py
@@ -21,6 +21,7 @@ import socket
import struct
import os
+import time
from keystoneauth1.exceptions import Unauthorized
from snaps.config.flavor import FlavorConfig
@@ -466,9 +467,19 @@ def __apply_ansible_playbook(ansible_config, os_creds, vm_dict, image_dict,
proxy_setting=proxy_settings)
if retval != 0:
# Not a fatal type of event
- logger.warning(
+ raise Exception(
'Unable to apply playbook found at location - %s',
ansible_config.get('playbook_location'))
+ elif ansible_config.get('post_processing'):
+ post_proc_config = ansible_config['post_processing']
+ if 'sleep' in post_proc_config:
+ time.sleep(post_proc_config['sleep'])
+ if 'reboot' in post_proc_config:
+ for vm_name in post_proc_config['reboot']:
+ if vm_name in vm_dict:
+ logger.info('Rebooting VM - %s', vm_name)
+ vm_dict[vm_name].reboot()
+
return retval