<s> from boto . ec2 . elb . listelement import ListElement <EOL> from boto . resultset import ResultSet <EOL> from boto . ec2 . autoscale . launchconfig import LaunchConfiguration <EOL> from boto . ec2 . autoscale . request import Request <EOL> from boto . ec2 . autoscale . instance import Instance <EOL> from boto . ec2 . autoscale . tag import Tag <EOL> class ProcessType ( object ) : <EOL> def __init__ ( self , connection = None ) : <EOL> self . connection = connection <EOL> self . process_name = None <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . process_name <EOL> def startElement ( self , name , attrs , connection ) : <EOL> pass <EOL> def endElement ( self , name , value , connection ) : <EOL> if name == '<STR_LIT>' : <EOL> self . process_name = value <EOL> class SuspendedProcess ( object ) : <EOL> def __init__ ( self , connection = None ) : <EOL> self . connection = connection <EOL> self . process_name = None <EOL> self . reason = None <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . process_name , self . reason ) <EOL> def startElement ( self , name , attrs , connection ) : <EOL> pass <EOL> def endElement ( self , name , value , connection ) : <EOL> if name == '<STR_LIT>' : <EOL> self . process_name = value <EOL> elif name == '<STR_LIT>' : <EOL> self . reason = value <EOL> class EnabledMetric ( object ) : <EOL> def __init__ ( self , connection = None , metric = None , granularity = None ) : <EOL> self . connection = connection <EOL> self . metric = metric <EOL> self . granularity = granularity <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . metric , self . granularity ) <EOL> def startElement ( self , name , attrs , connection ) : <EOL> pass <EOL> def endElement ( self , name , value , connection ) : <EOL> if name == '<STR_LIT>' : <EOL> self . granularity = value <EOL> elif name == '<STR_LIT>' : <EOL> self . metric = value <EOL> class AutoScalingGroup ( object ) : <EOL> def __init__ ( self , connection = None , name = None , <EOL> launch_config = None , availability_zones = None , <EOL> load_balancers = None , default_cooldown = None , <EOL> health_check_type = None , health_check_period = None , <EOL> placement_group = None , vpc_zone_identifier = None , <EOL> desired_capacity = None , min_size = None , max_size = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . name = name or kwargs . get ( '<STR_LIT>' ) <EOL> self . connection = connection <EOL> self . min_size = int ( min_size ) if min_size is not None else None <EOL> self . max_size = int ( max_size ) if max_size is not None else None <EOL> self . created_time = None <EOL> default_cooldown = default_cooldown or kwargs . get ( '<STR_LIT>' ) <EOL> if default_cooldown is not None : <EOL> default_cooldown = int ( default_cooldown ) <EOL> self . default_cooldown = default_cooldown <EOL> self . launch_config_name = launch_config <EOL> if launch_config and isinstance ( launch_config , LaunchConfiguration ) : <EOL> self . launch_config_name = launch_config . name <EOL> self . desired_capacity = desired_capacity <EOL> lbs = load_balancers or [ ] <EOL> self . load_balancers = ListElement ( lbs ) <EOL> zones = availability_zones or [ ] <EOL> self . availability_zones = ListElement ( zones ) <EOL> self . health_check_period = health_check_period <EOL> self . health_check_type = health_check_type <EOL> self . placement_group = placement_group <EOL> self . autoscaling_group_arn = None <EOL> self . vpc_zone_identifier = vpc_zone_identifier <EOL> self . instances = None <EOL> self . tags = None <EOL> def _get_cooldown ( self ) : <EOL> return self . default_cooldown <EOL> def _set_cooldown ( self , val ) : <EOL> self . default_cooldown = val <EOL> cooldown = property ( _get_cooldown , _set_cooldown ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . name <EOL> def startElement ( self , name , attrs , connection ) : <EOL> if name == '<STR_LIT>' : <EOL> self . instances = ResultSet ( [ ( '<STR_LIT>' , Instance ) ] ) <EOL> return self . instances <EOL> elif name == '<STR_LIT>' : <EOL> return self . load_balancers <EOL> elif name == '<STR_LIT>' : <EOL> return self . availability_zones <EOL> elif name == '<STR_LIT>' : <EOL> self . enabled_metrics = ResultSet ( [ ( '<STR_LIT>' , EnabledMetric ) ] ) <EOL> return self . enabled_metrics <EOL> elif name == '<STR_LIT>' : <EOL> self . suspended_processes = ResultSet ( [ ( '<STR_LIT>' , SuspendedProcess ) ] ) <EOL> return self . suspended_processes <EOL> elif name == '<STR_LIT>' : <EOL> self . tags = ResultSet ( [ ( '<STR_LIT>' , Tag ) ] ) <EOL> return self . tags <EOL> else : <EOL> return <EOL> def endElement ( self , name , value , connection ) : <EOL> if name == '<STR_LIT>' : <EOL> self . min_size = int ( value ) <EOL> elif name == '<STR_LIT>' : <EOL> self . autoscaling_group_arn = value <EOL> elif name == '<STR_LIT>' : <EOL> self . created_time = value <EOL> elif name == '<STR_LIT>' : <EOL> self . default_cooldown = int ( value ) <EOL> elif name == '<STR_LIT>' : <EOL> self . launch_config_name = value <EOL> elif name == '<STR_LIT>' : <EOL> self . desired_capacity = int ( value ) <EOL> elif name == '<STR_LIT>' : <EOL> self . max_size = int ( value ) <EOL> elif name == '<STR_LIT>' : <EOL> self . name = value <EOL> elif name == '<STR_LIT>' : <EOL> self . placement_group = value <EOL> elif name == '<STR_LIT>' : <EOL> try : <EOL> self . health_check_period = int ( value ) <EOL> except ValueError : <EOL> self . health_check_period = None <EOL> elif name == '<STR_LIT>' : <EOL> self . health_check_type = value <EOL> elif name == '<STR_LIT>' : <EOL> self . vpc_zone_identifier = value <EOL> else : <EOL> setattr ( self , name , value ) <EOL> def set_capacity ( self , capacity ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : self . name , <EOL> '<STR_LIT>' : capacity } <EOL> req = self . connection . get_object ( '<STR_LIT>' , params , <EOL> Request ) <EOL> self . connection . last_request = req <EOL> return req <EOL> def update ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . connection . _update_group ( '<STR_LIT>' , self ) <EOL> def shutdown_instances ( self ) : <EOL> """<STR_LIT>""" <EOL> self . min_size = <NUM_LIT:0> <EOL> self . max_size = <NUM_LIT:0> <EOL> self . desired_capacity = <NUM_LIT:0> <EOL> self . update ( ) <EOL> def delete ( self , force_delete = False ) : <EOL> """<STR_LIT>""" <EOL> return self . connection . delete_auto_scaling_group ( self . name , force_delete ) <EOL> def get_activities ( self , activity_ids = None , max_records = <NUM_LIT:50> ) : <EOL> """<STR_LIT>""" <EOL> return self . connection . get_all_activities ( self , activity_ids , <EOL> max_records ) <EOL> def suspend_processes ( self , scaling_processes = None ) : <EOL> """<STR_LIT>""" <EOL> return self . connection . suspend_processes ( self . name , scaling_processes ) <EOL> def resume_processes ( self , scaling_processes = None ) : <EOL> """<STR_LIT>""" <EOL> return self . connection . resume_processes ( self . name , scaling_processes ) <EOL> class AutoScalingGroupMetric ( object ) : <EOL> def __init__ ( self , connection = None ) : <EOL> self . connection = connection <EOL> self . metric = None <EOL> self . granularity = None <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . metric <EOL> def startElement ( self , name , attrs , connection ) : <EOL> return <EOL> def endElement ( self , name , value , connection ) : <EOL> if name == '<STR_LIT>' : <EOL> self . metric = value <EOL> elif name == '<STR_LIT>' : <EOL> self . granularity = value <EOL> else : <EOL> setattr ( self , name , value ) </s>
