summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/create_instance.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-05-19 11:12:22 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-05-19 11:14:29 -0600
commit0f6dc6e618b5546a652b9a06ac46ae332ea1c4c3 (patch)
treec7cc7bc8ab028ad9aecd8bbd7d24387134f35054 /snaps/openstack/create_instance.py
parent8d8af3c360b360c982b44ba343a97cf5949c8c20 (diff)
Fixed error in ansible_utils_tests.py and added ansible helper
method to the OpenStackVMInstance class. Test error was due to the image configuration having the incorrect user applied. The helper method will make it easier for adhoc ansible playbooks to be applied to running instances. JIRA: SNAPS-83 Change-Id: I6b229e0adb836dd3d5ea7b468d38d93f880589a2 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/create_instance.py')
-rw-r--r--snaps/openstack/create_instance.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/snaps/openstack/create_instance.py b/snaps/openstack/create_instance.py
index bb101ba..3e4fd93 100644
--- a/snaps/openstack/create_instance.py
+++ b/snaps/openstack/create_instance.py
@@ -412,6 +412,7 @@ class OpenStackVmInstance:
:param nic_name: Name of the interface
:param port: The port information containing the expected IP values.
:param floating_ip: The floating IP on which to apply the playbook.
+ :return: the return value from ansible
"""
ip = port['port']['fixed_ips'][0]['ip_address']
variables = {
@@ -421,13 +422,23 @@ class OpenStackVmInstance:
}
if self.image_settings.nic_config_pb_loc and self.keypair_settings:
- ansible_utils.apply_playbook(self.image_settings.nic_config_pb_loc,
- [floating_ip], self.get_image_user(), self.keypair_settings.private_filepath,
- variables, self.__os_creds.proxy_settings)
+ return self.apply_ansible_playbook(self.image_settings.nic_config_pb_loc, variables)
else:
logger.warning('VM ' + self.instance_settings.name + ' cannot self configure NICs eth1++. ' +
'No playbook or keypairs found.')
+ def apply_ansible_playbook(self, pb_file_loc, variables=None, fip_name=None):
+ """
+ Applies a playbook to a VM
+ :param pb_file_loc: the file location of the playbook to be applied
+ :param variables: a dict() of substitution values required by the playbook
+ :param fip_name: the name of the floating IP to use for applying the playbook (default - will take the first)
+ :return: the return value from ansible
+ """
+ return ansible_utils.apply_playbook(pb_file_loc, [self.get_floating_ip(fip_name=fip_name).ip],
+ self.get_image_user(), self.keypair_settings.private_filepath,
+ variables, self.__os_creds.proxy_settings)
+
def get_image_user(self):
"""
Returns the instance sudo_user if it has been configured in the instance_settings else it returns the