diff options
author | Mitch Garnaat <mitch@garnaat.com> | 2012-06-04 12:59:04 -0700 |
---|---|---|
committer | Mitch Garnaat <mitch@garnaat.com> | 2012-06-04 12:59:04 -0700 |
commit | 3035ed1a2426a6e34ba2cb309cae558c98646ade (patch) | |
tree | 1ed9dcec764d0205b3c60b6a22bebf585846a407 /boto/ec2/autoscale | |
parent | 0d598163384e2b9bd178f6db34e5ef264bafafd3 (diff) | |
download | boto-3035ed1a2426a6e34ba2cb309cae558c98646ade.tar.gz |
Initial support for spot instances in autoscaling groups.
Diffstat (limited to 'boto/ec2/autoscale')
-rw-r--r-- | boto/ec2/autoscale/__init__.py | 2 | ||||
-rw-r--r-- | boto/ec2/autoscale/launchconfig.py | 22 |
2 files changed, 18 insertions, 6 deletions
diff --git a/boto/ec2/autoscale/__init__.py b/boto/ec2/autoscale/__init__.py index 74f01d52..5d4828fa 100644 --- a/boto/ec2/autoscale/__init__.py +++ b/boto/ec2/autoscale/__init__.py @@ -218,6 +218,8 @@ class AutoScaleConnection(AWSQueryConnection): params['InstanceMonitoring.Enabled'] = 'true' else: params['InstanceMonitoring.Enabled'] = 'false' + if launch_config.spot_price is not None: + params['SpotPrice'] = str(launch_config.spot_price) return self.get_object('CreateLaunchConfiguration', params, Request, verb='POST') diff --git a/boto/ec2/autoscale/launchconfig.py b/boto/ec2/autoscale/launchconfig.py index 526f4686..be8e4435 100644 --- a/boto/ec2/autoscale/launchconfig.py +++ b/boto/ec2/autoscale/launchconfig.py @@ -1,4 +1,5 @@ # Copyright (c) 2009 Reza Lotun http://reza.lotun.name/ +# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the @@ -26,6 +27,8 @@ import boto.utils import base64 # this should use the corresponding object from boto.ec2 + + class Ebs(object): def __init__(self, connection=None, snapshot_id=None, volume_size=None): self.connection = connection @@ -84,12 +87,13 @@ class BlockDeviceMapping(object): elif name == 'VirtualName': self.virtual_name = value + class LaunchConfiguration(object): def __init__(self, connection=None, name=None, image_id=None, key_name=None, security_groups=None, user_data=None, instance_type='m1.small', kernel_id=None, ramdisk_id=None, block_device_mappings=None, - instance_monitoring=False): + instance_monitoring=False, spot_price=None): """ A launch configuration. @@ -98,14 +102,14 @@ class LaunchConfiguration(object): :type image_id: str :param image_id: Unique ID of the Amazon Machine Image (AMI) which was - assigned during registration. + assigned during registration. :type key_name: str :param key_name: The name of the EC2 key pair. :type security_groups: list :param security_groups: Names of the security groups with which to - associate the EC2 instances. + associate the EC2 instances. :type user_data: str :param user_data: The user data available to launched EC2 instances. @@ -121,11 +125,15 @@ class LaunchConfiguration(object): :type block_device_mappings: list :param block_device_mappings: Specifies how block devices are exposed - for instances + for instances :type instance_monitoring: bool :param instance_monitoring: Whether instances in group are launched - with detailed monitoring. + with detailed monitoring. + + :type spot_price: float + :param spot_price: The spot price you are bidding. Only applies + if you are building an autoscaling group with spot instances. """ self.connection = connection self.name = name @@ -141,6 +149,7 @@ class LaunchConfiguration(object): self.user_data = user_data self.created_time = None self.instance_monitoring = instance_monitoring + self.spot_price = spot_price self.launch_configuration_arn = None def __repr__(self): @@ -181,10 +190,11 @@ class LaunchConfiguration(object): self.launch_configuration_arn = value elif name == 'InstanceMonitoring': self.instance_monitoring = value + elif name == 'SpotPrice': + self.spot_price = float(value) else: setattr(self, name, value) def delete(self): """ Delete this launch configuration. """ return self.connection.delete_launch_configuration(self.name) - |