Skip to content

Commit

Permalink
Merge pull request #508 from cloudify-cosmo/RD-6735-no-stop-existing-…
Browse files Browse the repository at this point in the history
…instance

do not run stop on existing resource without force
  • Loading branch information
EarthmanT authored Mar 5, 2023
2 parents 4076e09 + 73c688d commit 47c6df4
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
3.1.5: RD-6735 Do not stop existing resource.
3.1.4: Update Check Drift Status
3.1.3: Add account ID property to roles in precreate.
3.1.2:
Expand Down
16 changes: 16 additions & 0 deletions cloudify_aws/common/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def get_special_condition(external,
node_type,
op_name,
create_op,
stop_op,
delete_op,
force,
waits_for_status):
Expand All @@ -310,6 +311,8 @@ def get_special_condition(external,
elif 'cloudify.relationships.aws.iam.access_key.connected_to' \
in node_type and op_name == 'establish':
return True
elif stop_op and (external and not force):
return False
return not create_op and not delete_op or force


Expand All @@ -325,6 +328,17 @@ def get_create_op(op_name):
# return 'create' in op or 'configure' in op


def get_stop_operation(op_name):
""" Determine if we are dealing with a stop operation.
Normally we just do the logic in the last return. However, we may want
special behavior for some types.
:param op_name: ctx.operation.name.split('.')[-1].
:return: bool
"""
return 'stop' == op_name


def get_delete_op(op_name):
""" Determine if we are dealing with a deletion operation.
Normally we just do the logic in the last return. However, we may want
Expand Down Expand Up @@ -420,6 +434,7 @@ def _aws_resource(function,
operation_name = ctx.operation.name.split(
'cloudify.interfaces.lifecycle.')[-1]
create_operation = get_create_op(operation_name)
stop_operation = get_stop_operation(operation_name)
delete_operation = get_delete_op(operation_name)
if create_operation and '__deleted' in ctx.instance.runtime_properties:
del ctx.instance.runtime_properties['__deleted']
Expand Down Expand Up @@ -494,6 +509,7 @@ def _aws_resource(function,
ctx.node.type_hierarchy,
operation_name,
create_operation,
stop_operation,
delete_operation,
kwargs.get('force_operation'),
kwargs.pop('waits_for_status', False))
Expand Down
19 changes: 10 additions & 9 deletions cloudify_aws/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,15 +919,16 @@ def update_expected_configuration(iface, runtime_props):

@with_rest_client
def post_start_related_nodes(node_instance_ids, deployment_id, rest_client):
return rest_client.executions.start(
deployment_id,
'execute_operation',
parameters={
'operation': 'cloudify.interfaces.lifecycle.poststart',
'node_instance_ids': node_instance_ids
},
force=True,
)
if node_instance_ids:
return rest_client.executions.start(
deployment_id,
'execute_operation',
parameters={
'operation': 'cloudify.interfaces.lifecycle.poststart',
'node_instance_ids': node_instance_ids
},
force=True,
)


def assign_previous_configuration(iface, runtime_props, prop=None):
Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins:
aws:
executor: central_deployment_agent
package_name: cloudify-aws-plugin
package_version: '3.1.4'
package_version: '3.1.5'

data_types:

Expand Down
2 changes: 1 addition & 1 deletion plugin_1_4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins:
aws:
executor: central_deployment_agent
package_name: cloudify-aws-plugin
package_version: '3.1.4'
package_version: '3.1.5'

data_types:

Expand Down
2 changes: 1 addition & 1 deletion plugin_1_5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins:
aws:
executor: central_deployment_agent
package_name: cloudify-aws-plugin
package_version: '3.1.4'
package_version: '3.1.5'
properties_description: |
Manage AWS resources.
Credentials documentation: https://docs.cloudify.co/latest/working_with/official_plugins/infrastructure/aws/#authentication-with-aws.
Expand Down
2 changes: 1 addition & 1 deletion v2_plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins:
aws:
executor: central_deployment_agent
package_name: cloudify-aws-plugin
package_version: '3.1.4'
package_version: '3.1.5'

data_types:

Expand Down

0 comments on commit 47c6df4

Please sign in to comment.