vavavr00m / boto

Automatically exported from code.google.com/p/boto
1 stars 0 forks source link

Boto cloudwatch in us-west-2 region not working #561

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Run the following code: 

CLOUDMGMT01:~/bin$ python
Python 2.6.6 (r266:84292, Apr 11 2011, 15:50:32)
[GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto
>>> boto.Version
'2.0'
>>> import boto.ec2.cloudwatch
>>> cloudwatch =  boto.ec2.cloudwatch.connect_to_region("us-west-2")
>>> print cloudwatch
None
>>>

What is the expected output? What do you see instead?

List of CloudWatch metrics (actually anything != None)

What version of the product are you using? On what operating system?

Boto = 2.0 
OS = RHEL6

Please provide any additional information below.

We have a auto inventory script. It uses "boto.ec2.regions()" call to query all 
regions and then iterates over all of those regions. 

According to 
http://aws.typepad.com/aws/2011/11/now-open-us-west-portland-region.html the 
region support CloudWatch, so the API call should work. 

Actually other API calls work just fine (descript instances etc.)

Regards, 
Robert

Original issue reported on code.google.com by elconas...@googlemail.com on 9 Nov 2011 at 9:25

GoogleCodeExporter commented 9 years ago
Actually from looking at the code this is a design issue: 

https://github.com/boto/boto/blob/master/boto/ec2/cloudwatch/__init__.py

It has explicit region definition in it: 

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

Same is true for: 
 - autoscaling
 - cloudwatch
 - elb

Programmatic Solution withour needing to query EC2 for regions first: 

  <pseudo>
  '%s' => 'FEATURE.%s.amazonaws.com' % (region.name,region.name)
  </pseudo>

Original comment by elconas...@googlemail.com on 9 Nov 2011 at 9:31

GoogleCodeExporter commented 9 years ago
Dirty Fix: 
-----

[root@CLOUDMGMT01 software]# diff -r -u boto-2.0 boto-2.0.FIXED/
diff -r -u boto-2.0/boto/ec2/autoscale/__init__.py 
boto-2.0.FIXED/boto/ec2/autoscale/__init__.py
--- boto-2.0/boto/ec2/autoscale/__init__.py     2011-07-14 02:45:30.000000000 
+0200
+++ boto-2.0.FIXED/boto/ec2/autoscale/__init__.py       2011-11-09 
10:40:54.634484190 +0100
@@ -42,6 +42,7 @@
 RegionData = {
     'us-east-1' : 'autoscaling.us-east-1.amazonaws.com',
     'us-west-1' : 'autoscaling.us-west-1.amazonaws.com',
+    'us-west-2' : 'autoscaling.us-west-2.amazonaws.com',
     'eu-west-1' : 'autoscaling.eu-west-1.amazonaws.com',
     'ap-northeast-1' : 'autoscaling.ap-northeast-1.amazonaws.com',
     'ap-southeast-1' : 'autoscaling.ap-southeast-1.amazonaws.com'}
diff -r -u boto-2.0/boto/ec2/cloudwatch/__init__.py 
boto-2.0.FIXED/boto/ec2/cloudwatch/__init__.py
--- boto-2.0/boto/ec2/cloudwatch/__init__.py    2011-07-14 02:45:30.000000000 
+0200
+++ boto-2.0.FIXED/boto/ec2/cloudwatch/__init__.py      2011-11-09 
10:41:10.696496737 +0100
@@ -154,6 +154,7 @@
 RegionData = {
     'us-east-1' : 'monitoring.us-east-1.amazonaws.com',
     'us-west-1' : 'monitoring.us-west-1.amazonaws.com',
+    'us-west-2' : 'monitoring.us-west-2.amazonaws.com',
     'eu-west-1' : 'monitoring.eu-west-1.amazonaws.com',
     'ap-northeast-1' : 'monitoring.ap-northeast-1.amazonaws.com',
     'ap-southeast-1' : 'monitoring.ap-southeast-1.amazonaws.com'}
diff -r -u boto-2.0/boto/ec2/elb/__init__.py 
boto-2.0.FIXED/boto/ec2/elb/__init__.py
--- boto-2.0/boto/ec2/elb/__init__.py   2011-07-14 02:45:30.000000000 +0200
+++ boto-2.0.FIXED/boto/ec2/elb/__init__.py     2011-11-09 10:41:27.570485241 
+0100
@@ -34,6 +34,7 @@
 RegionData = {
     'us-east-1' : 'elasticloadbalancing.us-east-1.amazonaws.com',
     'us-west-1' : 'elasticloadbalancing.us-west-1.amazonaws.com',
+    'us-west-2' : 'elasticloadbalancing.us-west-2.amazonaws.com',
     'eu-west-1' : 'elasticloadbalancing.eu-west-1.amazonaws.com',
     'ap-northeast-1' : 'elasticloadbalancing.ap-northeast-1.amazonaws.com',
     'ap-southeast-1' : 'elasticloadbalancing.ap-southeast-1.amazonaws.com'}
diff -r -u boto-2.0/boto.egg-info/SOURCES.txt 
boto-2.0.FIXED/boto.egg-info/SOURCES.txt
--- boto-2.0/boto.egg-info/SOURCES.txt  2011-07-14 03:03:35.000000000 +0200
+++ boto-2.0.FIXED/boto.egg-info/SOURCES.txt    2011-08-23 11:45:40.060015432 
+0200
---

Original comment by elconas...@googlemail.com on 9 Nov 2011 at 9:43

GoogleCodeExporter commented 9 years ago
The explicit list of regions is important because people occasionally want to 
query a service for a list of possible region endpoints.  You can do this 
programmatically with the EC2 service but no other service provides this so the 
hard-coded lists are there to mimic the capability.

I will probably refactor this code in the near future and will try to come up 
with a more flexible way of handling this.

The easy fix has been committed in 
https://github.com/boto/boto/commit/f4f4b9ec528f3af20221b9a18abe7b7c1bdbbb72

Original comment by Mitch.Ga...@gmail.com on 9 Nov 2011 at 1:17