Skip to content

Commit

Permalink
Merge pull request #163 from cloudify-cosmo/RD-672-Azure-Deployment-RG
Browse files Browse the repository at this point in the history
add resource group name property to deployment type
  • Loading branch information
EarthmanT authored Dec 2, 2020
2 parents 7081a4a + 0ec96e0 commit 8398084
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
20 changes: 13 additions & 7 deletions cloudify_azure/resources/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,22 @@ 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'),
}
api_version = \
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)
)

Expand All @@ -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)
)

Expand All @@ -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')
Expand Down
12 changes: 10 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8398084

Please sign in to comment.