Merge pull request #82 from hltbra/associate-public-ip-address

Add support to launch configuration AssociatePublicIpAddress parameter
This commit is contained in:
Steve Pulec 2014-03-04 17:50:42 -05:00
commit b7c1de8275
3 changed files with 35 additions and 2 deletions

View File

@ -29,7 +29,7 @@ class FakeScalingPolicy(object):
class FakeLaunchConfiguration(object):
def __init__(self, name, image_id, key_name, security_groups, user_data,
instance_type, instance_monitoring, instance_profile_name,
spot_price, ebs_optimized):
spot_price, ebs_optimized, associate_public_ip_address):
self.name = name
self.image_id = image_id
self.key_name = key_name
@ -40,6 +40,7 @@ class FakeLaunchConfiguration(object):
self.instance_profile_name = instance_profile_name
self.spot_price = spot_price
self.ebs_optimized = ebs_optimized
self.associate_public_ip_address = associate_public_ip_address
@property
def instance_monitoring_enabled(self):
@ -129,7 +130,7 @@ class AutoScalingBackend(BaseBackend):
def create_launch_configuration(self, name, image_id, key_name,
security_groups, user_data, instance_type,
instance_monitoring, instance_profile_name,
spot_price, ebs_optimized):
spot_price, ebs_optimized, associate_public_ip_address):
launch_configuration = FakeLaunchConfiguration(
name=name,
image_id=image_id,
@ -141,6 +142,7 @@ class AutoScalingBackend(BaseBackend):
instance_profile_name=instance_profile_name,
spot_price=spot_price,
ebs_optimized=ebs_optimized,
associate_public_ip_address=associate_public_ip_address,
)
self.launch_configurations[name] = launch_configuration
return launch_configuration

View File

@ -34,6 +34,7 @@ class AutoScalingResponse(BaseResponse):
instance_profile_name=self._get_param('IamInstanceProfile'),
spot_price=self._get_param('SpotPrice'),
ebs_optimized=self._get_param('EbsOptimized'),
associate_public_ip_address=self._get_param("AssociatePublicIpAddress"),
)
template = Template(CREATE_LAUNCH_CONFIGURATION_TEMPLATE)
return template.render()
@ -152,6 +153,7 @@ DESCRIBE_LAUNCH_CONFIGURATIONS_TEMPLATE = """<DescribeLaunchConfigurationsRespon
<LaunchConfigurations>
{% for launch_configuration in launch_configurations %}
<member>
<AssociatePublicIpAddress>{{ launch_configuration.associate_public_ip_address }}</AssociatePublicIpAddress>
<SecurityGroups>
{% for security_group in launch_configuration.security_groups %}
<member>{{ security_group }}</member>

View File

@ -50,6 +50,35 @@ def test_create_launch_configuration_for_2_12():
launch_config.ebs_optimized.should.equal(True)
@requires_boto_gte("2.25.0")
@mock_autoscaling
def test_create_launch_configuration_using_ip_association():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
name='tester',
image_id='ami-abcd1234',
associate_public_ip_address=True,
)
conn.create_launch_configuration(config)
launch_config = conn.get_all_launch_configurations()[0]
launch_config.associate_public_ip_address.should.equal(True)
@requires_boto_gte("2.25.0")
@mock_autoscaling
def test_create_launch_configuration_using_ip_association_should_default_to_false():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
name='tester',
image_id='ami-abcd1234', )
conn.create_launch_configuration(config)
launch_config = conn.get_all_launch_configurations()[0]
launch_config.associate_public_ip_address.should.equal(False)
@mock_autoscaling
def test_create_launch_configuration_defaults():
""" Test with the minimum inputs and check that all of the proper defaults