Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Auto Scaling Interface with connect_to_region

  • Loading branch information...
commit b96f51d3d345e9df05dd0772ef17ddcee8730645 1 parent dc7f75d
Roberto Gaiser authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 boto/ec2/autoscale/__init__.py
37 boto/ec2/autoscale/__init__.py
View
@@ -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')
Please sign in to comment.
Something went wrong with that request. Please try again.