Skip to content

Commit

Permalink
CY-3629 Decode decrypted password for windows instance (#374)
Browse files Browse the repository at this point in the history
* CY-3629 Decode decrypted password for windows instance

* CY-3630 Add private key node property to be used for external resource (#375)

* CY-3629 Disable integration tests for 505 & 501
  • Loading branch information
mabuaisha authored Oct 6, 2020
1 parent 3f4b3d5 commit 2b32688
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 55 deletions.
98 changes: 49 additions & 49 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,24 +261,24 @@ jobs:
- checkout
- generate_rhel_py27py36_wagon

integration_tests_505:
executor: cloudify-machine
environment:
CLOUDIFY_SSL_TRUST_ALL: true
IAAS: openstack
TEST_NAME: cloudformation
steps:
- checkout
- run_integration_tests_505

integration_tests_510:
executor: cloudify-machine-510
environment:
CLOUDIFY_SSL_TRUST_ALL: true
IAAS: openstack
steps:
- checkout
- run_integration_tests_510
# integration_tests_505:
# executor: cloudify-machine
# environment:
# CLOUDIFY_SSL_TRUST_ALL: true
# IAAS: openstack
# TEST_NAME: cloudformation
# steps:
# - checkout
# - run_integration_tests_505
#
# integration_tests_510:
# executor: cloudify-machine-510
# environment:
# CLOUDIFY_SSL_TRUST_ALL: true
# IAAS: openstack
# steps:
# - checkout
# - run_integration_tests_510

build_bundle:
executor: wagon_generator
Expand Down Expand Up @@ -316,27 +316,27 @@ workflows:
requires:
- wagon
- rhel_wagon
- integration_tests_505:
requires:
- unittests_py27
- build_bundle
filters:
branches:
only: /([0-9\.]*\-build|master|dev)/
- integration_tests_510:
requires:
- unittests_py36
- build_bundle
filters:
branches:
only: /([0-9\.]*\-build|master|dev)/
# - integration_tests_505:
# requires:
# - unittests_py27
# - build_bundle
# filters:
# branches:
# only: /([0-9\.]*\-build|master|dev)/
# - integration_tests_510:
# requires:
# - unittests_py36
# - build_bundle
# filters:
# branches:
# only: /([0-9\.]*\-build|master|dev)/
- release:
filters:
branches:
only: /master/
requires:
- integration_tests_505
- integration_tests_510
# requires:
# - integration_tests_505
# - integration_tests_510

nightly:
triggers:
Expand All @@ -358,17 +358,17 @@ workflows:
filters:
branches:
only: /([0-9\.]*\-build|master|dev)/
- integration_tests_505:
requires:
- wagon
- rhel_wagon
filters:
branches:
only: /([0-9\.]*\-build|master|dev)/
- integration_tests_510:
requires:
- wagon
- rhel_wagon
filters:
branches:
only: /([0-9\.]*\-build|master|dev)/
# - integration_tests_505:
# requires:
# - wagon
# - rhel_wagon
# filters:
# branches:
# only: /([0-9\.]*\-build|master|dev)/
# - integration_tests_510:
# requires:
# - wagon
# - rhel_wagon
# filters:
# branches:
# only: /([0-9\.]*\-build|master|dev)/
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
3.2.19: Fix issues with windows password decrypt
3.2.18: Fix issue in no networks.
3.2.17: Support no networks.
3.2.16:
Expand Down
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
20 changes: 17 additions & 3 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 Expand Up @@ -1268,7 +1279,10 @@ def _decrypt_password(password, private_key):
# Append the decrypted password chunk to the overall decrypted
# decrypted password
error_decrypt = 'Error while trying to decrypt password'
decrypted_password += rsa_key.decrypt(chunk_data, error_decrypt)
decrypted_password += rsa_key.decrypt(
chunk_data,
error_decrypt
).decode('utf-8')

# Increase the offset by chunk size
offset += chunk_size
Expand Down
11 changes: 9 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ plugins:

openstack:
executor: central_deployment_agent
source: https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/3.2.18.zip
source: https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/3.2.19.zip
package_name: cloudify-openstack-plugin
package_version: '3.2.18'
package_version: '3.2.19'

dsl_definitions:

Expand Down 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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='cloudify-openstack-plugin',
version='3.2.18',
version='3.2.19',
author='Cloudify',
author_email='[email protected]',
license='LICENSE',
Expand Down

0 comments on commit 2b32688

Please sign in to comment.