Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openstack_plugin/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
KEY_USE_CFY_LOGGER = 'use_cfy_logger'
KEY_GROUPS = 'groups'
KEY_LOGGERS = 'loggers'
PRIVATE_KEY_PREFIX = '-----BEGIN'

DEFAULT_LOGGING_CONFIG = {
KEY_USE_CFY_LOGGER: True,
Expand Down
15 changes: 13 additions & 2 deletions openstack_plugin/resources/compute/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
OPENSTACK_TYPE_PROPERTY,
USE_EXTERNAL_RESOURCE_PROPERTY,
SERVER_PUBLIC_IP_PROPERTY,
SERVER_IP_PROPERTY)
SERVER_IP_PROPERTY,
PRIVATE_KEY_PREFIX)

from openstack_plugin.utils import \
(handle_userdata,
Expand Down Expand Up @@ -1227,9 +1228,19 @@ def _get_server_private_key():

# Try to get the private key from keypair instance
private_key = \
rel_keyname.target.instance.runtime_properties.get('private_key')
rel_keyname.target.instance.runtime_properties.get('private_key') or \
rel_keyname.target.node.properties.get('private_key')
# if private_key is None, that means the KeyPair is external, so we need
# to check the "private_key" node property
if not private_key:
return None

if private_key.startswith(PRIVATE_KEY_PREFIX):
return private_key

with open(private_key) as _file:
private_key = _file.read()

return private_key


Expand Down
7 changes: 7 additions & 0 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,13 @@ node_types:
<<: *external_resource
<<: *create_if_missing
<<: *client_config
private_key:
description: >
The private ssh key to use. It can be filename or content of the
private key. This is only relevant when Keypair is using
use_external_resource as True otherwise it will be ignored
required: false
type: string
resource_config:
type: cloudify.types.openstack.KeyPair
description: https://developer.openstack.org/api-ref/compute/?expanded=create-or-import-keypair-detail
Expand Down