From dbed8cee3bf81b0482ed6ba611e45fd6f73a5381 Mon Sep 17 00:00:00 2001 From: Jay Taylor Date: Fri, 24 Apr 2015 14:26:37 -0700 Subject: [PATCH 1/2] Added support for spot request type specification (to support persistent spot requests). --- cloud/amazon/ec2.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cloud/amazon/ec2.py b/cloud/amazon/ec2.py index 6d47fa6ac32..6fb6f4a5417 100644 --- a/cloud/amazon/ec2.py +++ b/cloud/amazon/ec2.py @@ -76,6 +76,13 @@ options: required: false default: null aliases: [] + spot_type: + description: + - Type of spot request; one of "one-time" or "persistent". Defaults to "one-time" if not supplied. + required: false + default: "one-time" + choices: [ "one-time", "persistent" ] + aliases: [] image: description: - I(ami) ID to use for the instance @@ -783,6 +790,7 @@ def create_instances(module, ec2, vpc, override_count=None): instance_type = module.params.get('instance_type') tenancy = module.params.get('tenancy') spot_price = module.params.get('spot_price') + spot_type = module.params.get('spot_type') image = module.params.get('image') if override_count: count = override_count @@ -976,6 +984,7 @@ def create_instances(module, ec2, vpc, override_count=None): params.update(dict( count = count_remaining, + type = spot_type, )) res = ec2.request_spot_instances(spot_price, **params) @@ -1220,6 +1229,7 @@ def main(): zone = dict(aliases=['aws_zone', 'ec2_zone']), instance_type = dict(aliases=['type']), spot_price = dict(), + spot_type = dict(default='one-time'), image = dict(), kernel = dict(), count = dict(type='int', default='1'), From 65c63b3afa9343b65ea3c919b632443cd5e7eade Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 24 Jun 2015 14:43:04 -0400 Subject: [PATCH 2/2] Updating version_added for new spot_type param in ec2 module Also made sure 'choices' were set on the module param, to catch errors in user's playbooks, etc. --- cloud/amazon/ec2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloud/amazon/ec2.py b/cloud/amazon/ec2.py index 6fb6f4a5417..b79395fb3a1 100644 --- a/cloud/amazon/ec2.py +++ b/cloud/amazon/ec2.py @@ -77,6 +77,7 @@ options: default: null aliases: [] spot_type: + version_added: "2.0" description: - Type of spot request; one of "one-time" or "persistent". Defaults to "one-time" if not supplied. required: false @@ -1229,7 +1230,7 @@ def main(): zone = dict(aliases=['aws_zone', 'ec2_zone']), instance_type = dict(aliases=['type']), spot_price = dict(), - spot_type = dict(default='one-time'), + spot_type = dict(default='one-time', choices=["one-time", "persistent"]), image = dict(), kernel = dict(), count = dict(type='int', default='1'),