Permalink
Browse files

Merge branch 'autoscale_spot' into develop

  • Loading branch information...
2 parents ebbf38f + 3035ed1 commit 9539206ea82ca3a724675aa9f9e49e9b5d07c063 @garnaat garnaat committed Jun 8, 2012
Showing with 18 additions and 6 deletions.
  1. +2 −0 boto/ec2/autoscale/__init__.py
  2. +16 −6 boto/ec2/autoscale/launchconfig.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')
@@ -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)
-

0 comments on commit 9539206

Please sign in to comment.