Allow creating keypair with pub key contents
Relates to PROD-12506
Change-Id: I6173cffb384ce845aa54fa21f418c8ac813752e5
diff --git a/_states/novang.py b/_states/novang.py
index 00c74d8..a3376e7 100644
--- a/_states/novang.py
+++ b/_states/novang.py
@@ -252,7 +252,7 @@
'comment': 'Instance "{0}" was successfuly created'.format(name)}
-def keypair_present(name, pub_file, profile=None):
+def keypair_present(name, pub_file=None, pub_key=None, profile=None):
"""
Ensures that the Nova key-pair exists
"""
@@ -262,7 +262,7 @@
return _already_exists(name, 'Keypair')
else:
res = __salt__['novang.keypair_add'](name, pubfile=pub_file,
- profile=profile)
+ pubkey=pub_key, profile=profile)
if res and res['name'] == name:
return _created(name, 'Keypair', res)
return _create_failed(name, 'Keypair')
diff --git a/nova/client.sls b/nova/client.sls
index ea4aaa0..87ae2cb 100644
--- a/nova/client.sls
+++ b/nova/client.sls
@@ -39,7 +39,12 @@
nova_keypair_{{ keypair_name }}:
novang.keypair_present:
- name: {{ keypair_name }}
+ {%- if keypair.pub_file is defined %}
- pub_file: {{ keypair.pub_file }}
+ {%- endif %}
+ {%- if keypair.pub_key is defined %}
+ - pub_key: {{ keypair.pub_key }}
+ {%- endif %}
- profile: {{ identity_name }}
{%- endfor %}