Skip to content

Commit

Permalink
Auto Scaling Interface with connect_to_region
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Gaiser committed Feb 25, 2011
1 parent dc7f75d commit b96f51d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions boto/ec2/autoscale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,43 @@
from boto.ec2.autoscale.group import AutoScalingGroup
from boto.ec2.autoscale.activity import Activity

RegionData = {
'us-east-1' : 'autoscaling.us-east-1.amazonaws.com',
'us-west-1' : 'autoscaling.us-west-1.amazonaws.com',
'eu-west-1' : 'autoscaling.eu-west-1.amazonaws.com',
'ap-southeast-1' : 'autoscaling.ap-southeast-1.amazonaws.com'}

def regions():
"""
Get all available regions for the Auto Scaling service.
:rtype: list
:return: A list of :class:`boto.RegionInfo` instances
"""
regions = []
for region_name in RegionData:
region = RegionInfo(name=region_name,
endpoint=RegionData[region_name],
connection_cls=AutoScaleConnection)
regions.append(region)
return regions

def connect_to_region(region_name, **kw_params):
"""
Given a valid region name, return a
:class:`boto.ec2.autoscale.AutoScaleConnection`.
:param str region_name: The name of the region to connect to.
:rtype: :class:`boto.ec2.AutoScaleConnection` or ``None``
:return: A connection to the given region, or None if an invalid region
name is given
"""
for region in regions():
if region.name == region_name:
return region.connect(**kw_params)
return None


class AutoScaleConnection(AWSQueryConnection):
APIVersion = boto.config.get('Boto', 'autoscale_version', '2009-05-15')
Expand Down

0 comments on commit b96f51d

Please sign in to comment.