def create_autoscale_group(gname, lconfig_name, placement_group, size, zones=None): existing_group = CompEC2._get_autoscale_group(gname) if existing_group is not None: Cluster.log_error("Autoscale group %s already exists!", gname) return None tags = [ Tag(key='Name', value=gname, propagate_at_launch=True, resource_id=gname) ] if zones is None: zones = [x.name for x in Cluster._ec2().get_all_zones()] Cluster.log_info("zones: %r", zones) ag = AutoScalingGroup(group_name=gname, availability_zones=zones, launch_config=lconfig_name, placement_group=placement_group, tags=tags, desired_capacity=0, min_size=0, max_size=size) conn = Cluster._autoscale() return conn.create_auto_scaling_group(ag)
def delete_autoscale_group(gname, force=False): existing_group = CompEC2._get_autoscale_group(gname) if existing_group is not None: existing_group.delete(force_delete=force) Cluster.log_error("Autoscale group %s deleted (forced=%r)", gname, force) else: Cluster.log_info("Autoscale group %s does not exist", gname) return None
def create_autoscale_group(gname, lconfig_name, placement_group, size, zones=None): existing_group = CompEC2._get_autoscale_group(gname) if existing_group is not None: Cluster.log_error("Autoscale group %s already exists!", gname) return None tags = [Tag(key='Name', value=gname, propagate_at_launch=True, resource_id=gname)] if zones is None: zones = [x.name for x in Cluster._ec2().get_all_zones()] Cluster.log_info("zones: %r", zones) ag = AutoScalingGroup(group_name=gname, availability_zones=zones, launch_config=lconfig_name, placement_group=placement_group, tags=tags, desired_capacity=0, min_size=0, max_size=size) conn = Cluster._autoscale() return conn.create_auto_scaling_group(ag)
def get_autoscaled_instances(gname=None): return CompEC2.get_all_instances(gname)
def get_autoscale_group(gname): return CompEC2._get_autoscale_group(gname)
def _autoscale(): return CompEC2._connect_autoscale()
def _ec2(): return CompEC2._connect_ec2()