Skip to content

Commit

Permalink
Merge pull request #345 from cloudify-cosmo/RD-1802-Spot-Instances
Browse files Browse the repository at this point in the history
Rd 1802 spot instances
  • Loading branch information
EarthmanT authored Apr 11, 2021
2 parents 2d7f331 + 59195a1 commit 86e1e6a
Show file tree
Hide file tree
Showing 12 changed files with 874 additions and 236 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,6 @@
2.6.0:
- Add support for Transit Gateway create, delete, vpc attach.
2.7.0:
- Add pull operation for cloudformation.
- Add pull operation for cloudformation.
2.8.0:
- RD-1802 Support Spot Instances
2 changes: 1 addition & 1 deletion cloudify_aws/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def make_client_call(self,
elif isinstance(client_method_args, list):
res = client_method(*client_method_args)
else:
res = client_method_args()
res = client_method()
except fatal_handled_exceptions as error:
_, _, tb = sys.exc_info()
if isinstance(error, ClientError) and hasattr(error, 'message'):
Expand Down
2 changes: 2 additions & 0 deletions cloudify_aws/common/tests/test_iface_requirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def perform_operation(self, operation_callable, args, kwargs):
return
elif 'Found no AMIs matching provided filters' in str(e):
return
elif 'ctx.agent' in str(e):
return
raise
except OperationRetry as e:
if 'pending state' in str(e):
Expand Down
40 changes: 31 additions & 9 deletions cloudify_aws/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
'''

# Standard imports
import sys
import re
import sys
import uuid

# Third party imports
Expand Down Expand Up @@ -518,37 +518,59 @@ def dedup_tags(tags):

def exit_on_substring(iface,
method,
request,
substring,
request=None,
substrings=None,
raisable=OperationRetry):
"""This method is useful for deleting something that may have already been
deleted. We really want to make sure that the resource no longer exists.
:param iface: Resource interface derived from EC2Base.
:param method: The method on the Resource interface object.
:param request: The parameters to method.
:param substrings: Substrings to look for in the exception.
:param raisable: The exception to raise if substrings are not found.
:return:
"""

if isinstance(substrings, text_type):
substrings = [substrings]

callable = getattr(iface, method)
try:
return callable(request)
if request:
return callable(request)
else:
return callable()
except (NonRecoverableError, ClientError) as e:
if hasattr(e, 'message'):
message = e.message
else:
message = _compat.text_type(e)
if substring in message:
if any(substring in message for substring in substrings):
return {}
raise raisable(message)


def raise_on_substring(iface,
method,
request,
substring,
request=None,
substrings=None,
raisable=OperationRetry):

if isinstance(substrings, text_type):
substrings = [substrings]

callable = getattr(iface, method)
try:
return callable(request)
if request:
return callable(request)
else:
return callable()
except (NonRecoverableError, ClientError) as e:
if hasattr(e, 'message'):
message = e.message
else:
message = _compat.text_type(e)
if substring in message:
if any(substring in message for substring in substrings):
raise raisable(message)
return {}
Loading

0 comments on commit 86e1e6a

Please sign in to comment.