diff --git a/boto/ec2/autoscale/__init__.py b/boto/ec2/autoscale/__init__.py index 74f01d5209..5d4828fab3 100644 --- a/boto/ec2/autoscale/__init__.py +++ b/boto/ec2/autoscale/__init__.py @@ -218,6 +218,8 @@ def create_launch_configuration(self, launch_config): 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 526f4686a0..be8e44355a 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 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 @@ def endElement(self, name, value, connection): 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 @@ def __init__(self, connection=None, name=None, image_id=None, :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 @@ def __init__(self, connection=None, name=None, image_id=None, :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 @@ def __init__(self, connection=None, name=None, image_id=None, 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 @@ def endElement(self, name, value, connection): 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) -