From 0ec96e02ae152755653ff362fa894b2f95c0cc32 Mon Sep 17 00:00:00 2001 From: earthmant Date: Wed, 2 Dec 2020 10:48:38 +0200 Subject: [PATCH] add resource group name property to deployment type --- CHANGELOG.txt | 1 + cloudify_azure/resources/deployment.py | 20 +++++++++++++------- plugin.yaml | 12 ++++++++++-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3da5c571..b4c270db 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,4 @@ +3.0.8: Add resource group name to deployment and default to deployment name. 3.0.7: Handle Public IPs. 3.0.6: Handle regression in network profile. 3.0.5: Fix Build Error. diff --git a/cloudify_azure/resources/deployment.py b/cloudify_azure/resources/deployment.py index 9851a7ec..2b4b6589 100644 --- a/cloudify_azure/resources/deployment.py +++ b/cloudify_azure/resources/deployment.py @@ -84,7 +84,9 @@ def create(ctx, **kwargs): else: ctx.logger.warn("azure_config is deprecated please use client_config, " "in later version it will be removed") - name = utils.get_resource_name(ctx) + deployment_name = utils.get_resource_name(ctx) + resource_group_name = ctx.node.properties.get( + 'resource_group_name', deployment_name) resource_group_params = { 'location': ctx.node.properties.get('location'), } @@ -92,11 +94,12 @@ def create(ctx, **kwargs): ctx.node.properties.get('api_version', constants.API_VER_RESOURCES) resource_group = ResourceGroup(azure_config, ctx.logger, api_version) try: - resource_group.create_or_update(name, resource_group_params) + resource_group.create_or_update( + resource_group_name, resource_group_params) except CloudError as cr: raise cfy_exc.NonRecoverableError( "create deployment resource_group '{0}' " - "failed with this error : {1}".format(name, + "failed with this error : {1}".format(resource_group_name, cr.message) ) @@ -116,12 +119,15 @@ def create(ctx, **kwargs): try: result = \ - deployment.create_or_update(name, name, deployment_params, - properties.get('timeout')) + deployment.create_or_update( + resource_group_name, + deployment_name, + deployment_params, + properties.get('timeout')) except CloudError as cr: raise cfy_exc.NonRecoverableError( "create deployment '{0}' " - "failed with this error : {1}".format(name, + "failed with this error : {1}".format(deployment_name, cr.message) ) @@ -132,7 +138,7 @@ def create(ctx, **kwargs): @operation(resumable=True) -def delete(ctx, **kwargs): +def delete(ctx, **_): if ctx.node.properties.get('use_external_resource', False): return azure_config = ctx.node.properties.get('azure_config') diff --git a/plugin.yaml b/plugin.yaml index 7c871d1f..fc9d70e7 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -6,9 +6,9 @@ plugins: azure: executor: central_deployment_agent - source: https://github.com/cloudify-cosmo/cloudify-azure-plugin/archive/3.0.7.zip + source: https://github.com/cloudify-cosmo/cloudify-azure-plugin/archive/3.0.8.zip package_name: cloudify-azure-plugin - package_version: '3.0.7' + package_version: '3.0.8' data_types: cloudify.datatypes.azure.Config: @@ -1887,6 +1887,14 @@ node_types: name: required: true type: string + resource_group_name: + type: string + description: > + Name of the Resource Group that the existing resource belongs to + (this is only useful when not using a relationship between a resource + node and a Resource Group node) + default: { get_property: [ SELF, name ] } + required: false location: required: true type: string