Fix merge conflicts. Add basic cloudformation support. Closes #111.
This commit is contained in:
parent
069c48b43a
commit
ef876dd27e
28 changed files with 2473 additions and 11 deletions
|
|
@ -33,7 +33,7 @@ class FakeLaunchConfiguration(object):
|
|||
self.name = name
|
||||
self.image_id = image_id
|
||||
self.key_name = key_name
|
||||
self.security_groups = security_groups
|
||||
self.security_groups = security_groups if security_groups else []
|
||||
self.user_data = user_data
|
||||
self.instance_type = instance_type
|
||||
self.instance_monitoring = instance_monitoring
|
||||
|
|
@ -42,6 +42,31 @@ class FakeLaunchConfiguration(object):
|
|||
self.ebs_optimized = ebs_optimized
|
||||
self.associate_public_ip_address = associate_public_ip_address
|
||||
|
||||
@classmethod
|
||||
def create_from_cloudformation_json(cls, resource_name, cloudformation_json):
|
||||
properties = cloudformation_json['Properties']
|
||||
|
||||
instance_profile_name = properties.get("IamInstanceProfile")
|
||||
|
||||
config = autoscaling_backend.create_launch_configuration(
|
||||
name=resource_name,
|
||||
image_id=properties.get("ImageId"),
|
||||
key_name=properties.get("KeyName"),
|
||||
security_groups=properties.get("SecurityGroups"),
|
||||
user_data=properties.get("UserData"),
|
||||
instance_type=properties.get("InstanceType"),
|
||||
instance_monitoring=properties.get("InstanceMonitoring"),
|
||||
instance_profile_name=instance_profile_name,
|
||||
spot_price=properties.get("SpotPrice"),
|
||||
ebs_optimized=properties.get("EbsOptimized"),
|
||||
associate_public_ip_address=properties.get("AssociatePublicIpAddress"),
|
||||
)
|
||||
return config
|
||||
|
||||
@property
|
||||
def physical_resource_id(self):
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def instance_monitoring_enabled(self):
|
||||
if self.instance_monitoring:
|
||||
|
|
@ -73,6 +98,34 @@ class FakeAutoScalingGroup(object):
|
|||
self.instances = []
|
||||
self.set_desired_capacity(desired_capacity)
|
||||
|
||||
@classmethod
|
||||
def create_from_cloudformation_json(cls, resource_name, cloudformation_json):
|
||||
properties = cloudformation_json['Properties']
|
||||
|
||||
launch_config_name = properties.get("LaunchConfigurationName")
|
||||
load_balancer_names = properties.get("LoadBalancerNames", [])
|
||||
|
||||
group = autoscaling_backend.create_autoscaling_group(
|
||||
name=resource_name,
|
||||
availability_zones=properties.get("AvailabilityZones", []),
|
||||
desired_capacity=properties.get("DesiredCapacity"),
|
||||
max_size=properties.get("MaxSize"),
|
||||
min_size=properties.get("MinSize"),
|
||||
launch_config_name=launch_config_name,
|
||||
vpc_zone_identifier=properties.get("VPCZoneIdentifier"),
|
||||
default_cooldown=properties.get("Cooldown"),
|
||||
health_check_period=properties.get("HealthCheckGracePeriod"),
|
||||
health_check_type=properties.get("HealthCheckType"),
|
||||
load_balancers=load_balancer_names,
|
||||
placement_group=None,
|
||||
termination_policies=properties.get("TerminationPolicies", []),
|
||||
)
|
||||
return group
|
||||
|
||||
@property
|
||||
def physical_resource_id(self):
|
||||
return self.name
|
||||
|
||||
def update(self, availability_zones, desired_capacity, max_size, min_size,
|
||||
launch_config_name, vpc_zone_identifier, default_cooldown,
|
||||
health_check_period, health_check_type, load_balancers,
|
||||
|
|
@ -164,6 +217,15 @@ class AutoScalingBackend(BaseBackend):
|
|||
default_cooldown, health_check_period,
|
||||
health_check_type, load_balancers,
|
||||
placement_group, termination_policies):
|
||||
|
||||
def make_int(value):
|
||||
return int(value) if value is not None else value
|
||||
|
||||
max_size = make_int(max_size)
|
||||
min_size = make_int(min_size)
|
||||
default_cooldown = make_int(default_cooldown)
|
||||
health_check_period = make_int(health_check_period)
|
||||
|
||||
group = FakeAutoScalingGroup(
|
||||
name=name,
|
||||
availability_zones=availability_zones,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue