Skip to content

Commit

Permalink
fix issue in ami
Browse files Browse the repository at this point in the history
  • Loading branch information
EarthmanT committed Dec 2, 2021
1 parent 770c425 commit 82e1ba2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cloudify_aws/common/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@ def _aws_resource(function,
resource_config = kwargs['resource_config']
resource_id = utils.get_resource_id(node=ctx.node, instance=ctx.instance)
# Check if using external
iface = kwargs.get('iface')
if props.get('use_external_resource') and \
'cloudify.nodes.aws.ec2.Image' in ctx.node.type_hierarchy and \
operation_name == 'create':
pass
iface = kwargs.get('iface')
if ctx.node.properties.get('use_external_resource', False):
elif ctx.node.properties.get('use_external_resource', False):
ctx.logger.info('{t} ID# {i} is user-provided.'.format(
t=resource_type, i=resource_id))
if not kwargs.get('force_operation', False) and \
Expand Down
9 changes: 7 additions & 2 deletions cloudify_aws/ec2/resources/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, ctx_node, resource_id=None, client=None, logger=None):
self.type_name = RESOURCE_TYPE
image_filters = ctx_node.properties["resource_config"].get(
"kwargs", {}).get("Filters")
self.describe_image_filters = None
self._describe_image_filters = None
if resource_id:
self.prepare_describe_image_filter({IMAGE_IDS: [resource_id]})
elif image_filters:
Expand All @@ -52,6 +52,7 @@ def __init__(self, ctx_node, resource_id=None, client=None, logger=None):
def properties(self):
"""Gets the properties of an external resource"""
params = self.describe_image_filters
self.logger.info('Params: {}'.format(params))
if not params:
return
try:
Expand Down Expand Up @@ -96,14 +97,18 @@ def delete(self, params=None):
self.logger.debug('Deregistering ImageId %s' % params.get('ImageId'))
self.client.deregister_image(**params)

@property
def describe_image_filters(self):
return self._describe_image_filters

def prepare_describe_image_filter(self, params):
dry_run = params.get(DRY_RUN, False)
image_ids = params.get(IMAGE_IDS, [])
owners = params.get(OWNERS, [])
executable_users = params.get(EXECUTABLE_USERS, [])
filters = params.get(FILTERS, [])
if any([dry_run, image_ids, owners, executable_users, filters]):
self.describe_image_filters = {
self._describe_image_filters = {
DRY_RUN: dry_run,
IMAGE_IDS: image_ids,
OWNERS: owners,
Expand Down

0 comments on commit 82e1ba2

Please sign in to comment.