Add support to launch configuration AssociatePublicIpAddress parameter
This commit is contained in:
parent
15e529a4be
commit
8b6facf133
@ -29,7 +29,7 @@ class FakeScalingPolicy(object):
|
|||||||
class FakeLaunchConfiguration(object):
|
class FakeLaunchConfiguration(object):
|
||||||
def __init__(self, name, image_id, key_name, security_groups, user_data,
|
def __init__(self, name, image_id, key_name, security_groups, user_data,
|
||||||
instance_type, instance_monitoring, instance_profile_name,
|
instance_type, instance_monitoring, instance_profile_name,
|
||||||
spot_price, ebs_optimized):
|
spot_price, ebs_optimized, associate_public_ip_address):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.image_id = image_id
|
self.image_id = image_id
|
||||||
self.key_name = key_name
|
self.key_name = key_name
|
||||||
@ -40,6 +40,7 @@ class FakeLaunchConfiguration(object):
|
|||||||
self.instance_profile_name = instance_profile_name
|
self.instance_profile_name = instance_profile_name
|
||||||
self.spot_price = spot_price
|
self.spot_price = spot_price
|
||||||
self.ebs_optimized = ebs_optimized
|
self.ebs_optimized = ebs_optimized
|
||||||
|
self.associate_public_ip_address = associate_public_ip_address
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def instance_monitoring_enabled(self):
|
def instance_monitoring_enabled(self):
|
||||||
@ -129,7 +130,7 @@ class AutoScalingBackend(BaseBackend):
|
|||||||
def create_launch_configuration(self, name, image_id, key_name,
|
def create_launch_configuration(self, name, image_id, key_name,
|
||||||
security_groups, user_data, instance_type,
|
security_groups, user_data, instance_type,
|
||||||
instance_monitoring, instance_profile_name,
|
instance_monitoring, instance_profile_name,
|
||||||
spot_price, ebs_optimized):
|
spot_price, ebs_optimized, associate_public_ip_address):
|
||||||
launch_configuration = FakeLaunchConfiguration(
|
launch_configuration = FakeLaunchConfiguration(
|
||||||
name=name,
|
name=name,
|
||||||
image_id=image_id,
|
image_id=image_id,
|
||||||
@ -141,6 +142,7 @@ class AutoScalingBackend(BaseBackend):
|
|||||||
instance_profile_name=instance_profile_name,
|
instance_profile_name=instance_profile_name,
|
||||||
spot_price=spot_price,
|
spot_price=spot_price,
|
||||||
ebs_optimized=ebs_optimized,
|
ebs_optimized=ebs_optimized,
|
||||||
|
associate_public_ip_address=associate_public_ip_address,
|
||||||
)
|
)
|
||||||
self.launch_configurations[name] = launch_configuration
|
self.launch_configurations[name] = launch_configuration
|
||||||
return launch_configuration
|
return launch_configuration
|
||||||
|
@ -34,6 +34,7 @@ class AutoScalingResponse(BaseResponse):
|
|||||||
instance_profile_name=self._get_param('IamInstanceProfile'),
|
instance_profile_name=self._get_param('IamInstanceProfile'),
|
||||||
spot_price=self._get_param('SpotPrice'),
|
spot_price=self._get_param('SpotPrice'),
|
||||||
ebs_optimized=self._get_param('EbsOptimized'),
|
ebs_optimized=self._get_param('EbsOptimized'),
|
||||||
|
associate_public_ip_address=self._get_param("AssociatePublicIpAddress"),
|
||||||
)
|
)
|
||||||
template = Template(CREATE_LAUNCH_CONFIGURATION_TEMPLATE)
|
template = Template(CREATE_LAUNCH_CONFIGURATION_TEMPLATE)
|
||||||
return template.render()
|
return template.render()
|
||||||
@ -152,6 +153,7 @@ DESCRIBE_LAUNCH_CONFIGURATIONS_TEMPLATE = """<DescribeLaunchConfigurationsRespon
|
|||||||
<LaunchConfigurations>
|
<LaunchConfigurations>
|
||||||
{% for launch_configuration in launch_configurations %}
|
{% for launch_configuration in launch_configurations %}
|
||||||
<member>
|
<member>
|
||||||
|
<AssociatePublicIpAddress>{{ launch_configuration.associate_public_ip_address }}</AssociatePublicIpAddress>
|
||||||
<SecurityGroups>
|
<SecurityGroups>
|
||||||
{% for security_group in launch_configuration.security_groups %}
|
{% for security_group in launch_configuration.security_groups %}
|
||||||
<member>{{ security_group }}</member>
|
<member>{{ security_group }}</member>
|
||||||
|
@ -50,6 +50,35 @@ def test_create_launch_configuration_for_2_12():
|
|||||||
launch_config.ebs_optimized.should.equal(True)
|
launch_config.ebs_optimized.should.equal(True)
|
||||||
|
|
||||||
|
|
||||||
|
@requires_boto_gte("2.23")
|
||||||
|
@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.23")
|
||||||
|
@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
|
@mock_autoscaling
|
||||||
def test_create_launch_configuration_defaults():
|
def test_create_launch_configuration_defaults():
|
||||||
""" Test with the minimum inputs and check that all of the proper defaults
|
""" Test with the minimum inputs and check that all of the proper defaults
|
||||||
|
Loading…
Reference in New Issue
Block a user