summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/utils/settings_utils.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-10-30 12:08:58 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-10-30 12:08:58 -0600
commit85eb362579efbbc57e2851b2da2fd9599461f1ae (patch)
tree42c3552eca410e5e7023b1339cb64ea42009a7c7 /snaps/openstack/utils/settings_utils.py
parent0dfca494ef7c2778babfac48d9b701953860b54f (diff)
Added method to OpenStackHeatStack to return OpenStackKeypair objects.
Continuation of the story SNAPS-153 for adding creator/state machine instances for OpenStack objects deployed via Heat. JIRA: SNAPS-175 Change-Id: I7196279086b1935b4ec4a01483d46921cc567b15 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils/settings_utils.py')
-rw-r--r--snaps/openstack/utils/settings_utils.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/snaps/openstack/utils/settings_utils.py b/snaps/openstack/utils/settings_utils.py
index 7169319..68dbf71 100644
--- a/snaps/openstack/utils/settings_utils.py
+++ b/snaps/openstack/utils/settings_utils.py
@@ -109,6 +109,32 @@ def create_volume_type_settings(volume_type):
qos_spec_name=qos_spec_name, public=volume_type.public)
+def create_keypair_settings(heat_cli, stack, keypair, pk_output_key):
+ """
+ Instantiates a KeypairSettings object from a Keypair domain objects
+ :param heat_cli: the heat client
+ :param stack: the Stack domain object
+ :param keypair: the Keypair SNAPS domain object
+ :param pk_output_key: the key to the heat template's outputs for retrieval
+ of the private key file
+ :return: a KeypairSettings object
+ """
+ if pk_output_key:
+ outputs = heat_utils.get_outputs(heat_cli, stack)
+ for output in outputs:
+ if output.key == pk_output_key:
+ # Save to file
+ guid = uuid.uuid4()
+ key_file = file_utils.save_string_to_file(
+ output.value, str(guid), 0o400)
+
+ # Use outputs, file and resources for the KeypairSettings
+ return KeypairSettings(
+ name=keypair.name, private_filepath=key_file.name)
+
+ return KeypairSettings(name=keypair.name)
+
+
def create_vm_inst_settings(nova, neutron, server):
"""
Returns a NetworkSettings object