Skip to content

Commit

Permalink
Merge pull request #408 from cloudify-cosmo/RD-3638-Nic-Scaling
Browse files Browse the repository at this point in the history
fix issue in ami
  • Loading branch information
EarthmanT authored Dec 2, 2021
2 parents 770c425 + fefaace commit c716875
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 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
2 changes: 1 addition & 1 deletion cloudify_aws/ec2/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def setUp(self):
mock_decorator)
mock1.start()
reload_module(image)
self.image.describe_image_filters = \
self.image._describe_image_filters = \
{'Filters': {
'name': 'CentOS 7.7.1908 x86_64 with cloud-init (HVM)',
'owner-id': '057448758665'}}
Expand Down

0 comments on commit c716875

Please sign in to comment.