From d79bece0e93b8624dcabf3ac45527e4202b4677d Mon Sep 17 00:00:00 2001 From: mabuaisha Date: Tue, 19 Dec 2017 14:50:40 +0200 Subject: [PATCH] Fix bug with storing aws_resource_id when using external resource flag (#103) * Fix bug with storing aws_resource_id when using external resource flag * adding to plugin yaml version --- CHANGELOG.txt | 7 +++++++ cloudify_awssdk/common/decorators.py | 14 +++++++++++++- cloudify_awssdk/common/tests/test_decorators.py | 2 +- plugin.yaml | 4 ++-- setup.py | 2 +- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1b8cc1e..f390f3a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,10 @@ +1.2.0.1: +- Fix bug with empty runtime properties for node when ``use_external_resource`` + is set True + +1.2.0: +- VPC Peering. + 1.0.1: - Add ECS support (Cluster, Service, Task Definition) + Blueprint Example. - Fix several bugs with ELBv2. diff --git a/cloudify_awssdk/common/decorators.py b/cloudify_awssdk/common/decorators.py index 6ab2678..ee4eaed 100644 --- a/cloudify_awssdk/common/decorators.py +++ b/cloudify_awssdk/common/decorators.py @@ -17,8 +17,10 @@ ~~~~~~~~~~~~~~~~~ AWS decorators ''' -# Cloudify +# Cloudify imports from cloudify.exceptions import (OperationRetry, NonRecoverableError) + +# Local imports from cloudify_awssdk.common import utils from cloudify_awssdk.common.constants import ( EXTERNAL_RESOURCE_ARN as EXT_RES_ARN, @@ -96,6 +98,8 @@ def wrapper_inner(**kwargs): resource_id=utils.get_resource_id( node=ctx.node, instance=ctx.instance)) if class_decl else None + + resource_config = None if not ignore_properties: # Normalize resource_config property resource_config = props.get('resource_config') or dict() @@ -115,6 +119,7 @@ def wrapper_inner(**kwargs): and runtime_instance_properties.get('resource_config'): kwargs['resource_config'] =\ runtime_instance_properties['resource_config'] + resource_config = kwargs['resource_config'] # Check if using external if ctx.node.properties.get('use_external_resource', False): @@ -123,6 +128,13 @@ def wrapper_inner(**kwargs): ctx.logger.info('%s ID# "%s" is user-provided.' % (resource_type, resource_id)) if not kwargs.get('force_operation', False): + # If ``force_operation`` is not set then we need to make + # sure that runtime properties for node instance are + # setting correctly + # Set ``resource_config`` and ``EXT_RES_ID`` + ctx.instance.runtime_properties[ + 'resource_config'] = resource_config + ctx.instance.runtime_properties[EXT_RES_ID] = resource_id return ctx.logger.warn('%s ID# "%s" has force_operation set.' % (resource_type, resource_id)) diff --git a/cloudify_awssdk/common/tests/test_decorators.py b/cloudify_awssdk/common/tests/test_decorators.py index ba29065..6a2bc8c 100644 --- a/cloudify_awssdk/common/tests/test_decorators.py +++ b/cloudify_awssdk/common/tests/test_decorators.py @@ -280,7 +280,7 @@ def test_with_mock(*args, **kwargs): {'aws_resource_arn': 'res_id', 'aws_resource_id': 'aws_id', 'a': 'b', - 'resource_config': {}}) + 'resource_config': {'c': 'd'}}) mock_func.assert_not_called() diff --git a/plugin.yaml b/plugin.yaml index a0c721e..dbca2bc 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -2,9 +2,9 @@ plugins: awssdk: executor: central_deployment_agent - source: https://github.com//cloudify-incubator/cloudify-awssdk-plugin/archive/1.2.0.zip + source: https://github.com//cloudify-incubator/cloudify-awssdk-plugin/archive/1.2.0.1.zip package_name: cloudify-awssdk-plugin - package_version: '1.2.0' + package_version: '1.2.0.1' data_types: diff --git a/setup.py b/setup.py index c902c49..f31a086 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( name='cloudify-awssdk-plugin', - version='1.2.0', + version='1.2.0.1', license='LICENSE', packages=find_packages(exclude=['tests*']), description='A Cloudify plugin for AWS',