Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Commit

Permalink
Merge branch 'autoscale_spot' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
garnaat committed Jun 8, 2012
2 parents ebbf38f + 3035ed1 commit 9539206
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions boto/ec2/autoscale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
22 changes: 16 additions & 6 deletions boto/ec2/autoscale/launchconfig.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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.