Skip to content

Commit

Permalink
Add support for the new Amazon region (Tokyo).
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/libcloud/trunk@1076474 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Kami committed Mar 3, 2011
1 parent 60afd81 commit 06e556f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
30 changes: 30 additions & 0 deletions libcloud/drivers/ec2.py
Expand Up @@ -32,6 +32,7 @@
EC2_US_WEST_HOST = 'ec2.us-west-1.amazonaws.com'
EC2_EU_WEST_HOST = 'ec2.eu-west-1.amazonaws.com'
EC2_AP_SOUTHEAST_HOST = 'ec2.ap-southeast-1.amazonaws.com'
EC2_AP_NORTHEAST_HOST = 'ec2.ap-northeast-1.amazonaws.com'

API_VERSION = '2010-08-31'

Expand Down Expand Up @@ -127,6 +128,7 @@
EC2_US_WEST_INSTANCE_TYPES = dict(EC2_INSTANCE_TYPES)
EC2_EU_WEST_INSTANCE_TYPES = dict(EC2_INSTANCE_TYPES)
EC2_AP_SOUTHEAST_INSTANCE_TYPES = dict(EC2_INSTANCE_TYPES)
EC2_AP_NORTHEAST_INSTANCE_TYPES = dict(EC2_INSTANCE_TYPES)

#
# On demand prices must also be hardcoded, because Amazon doesn't provide an
Expand Down Expand Up @@ -167,6 +169,15 @@
# prices are the same
EC2_AP_SOUTHEAST_INSTANCE_TYPES = dict(EC2_EU_WEST_INSTANCE_TYPES)

EC2_AP_NORTHEAST_INSTANCE_TYPES['t1.micro']['price'] = '.027'
EC2_AP_NORTHEAST_INSTANCE_TYPES['m1.small']['price'] = '.10'
EC2_AP_NORTHEAST_INSTANCE_TYPES['m1.large']['price'] = '.40'
EC2_AP_NORTHEAST_INSTANCE_TYPES['m1.xlarge']['price'] = '.80'
EC2_AP_NORTHEAST_INSTANCE_TYPES['c1.medium']['price'] = '.20'
EC2_AP_NORTHEAST_INSTANCE_TYPES['c1.xlarge']['price'] = '.80'
EC2_AP_NORTHEAST_INSTANCE_TYPES['m2.xlarge']['price'] = '.60'
EC2_AP_NORTHEAST_INSTANCE_TYPES['m2.2xlarge']['price'] = '1.20'
EC2_AP_NORTHEAST_INSTANCE_TYPES['m2.4xlarge']['price'] = '2.39'

class EC2NodeLocation(NodeLocation):
def __init__(self, id, name, country, driver, availability_zone):
Expand Down Expand Up @@ -864,6 +875,13 @@ class EC2APSEConnection(EC2Connection):

host = EC2_AP_SOUTHEAST_HOST

class EC2APNEConnection(EC2Connection):
"""
Connection class for EC2 in the Northeast Asia Pacific Region
"""

host = EC2_AP_NORTHEAST_HOST

class EC2APSENodeDriver(EC2NodeDriver):
"""
Driver class for EC2 in the Southeast Asia Pacific Region
Expand All @@ -876,6 +894,18 @@ class EC2APSENodeDriver(EC2NodeDriver):
connectionCls = EC2APSEConnection
_instance_types = EC2_AP_SOUTHEAST_INSTANCE_TYPES

class EC2APNENodeDriver(EC2NodeDriver):
"""
Driver class for EC2 in the Northeast Asia Pacific Region
"""

name = 'Amazon EC2 (ap-northeast-1)'
friendly_name = 'Amazon Asia-Pacific Tokyo'
country = 'JP'
region_name = 'ap-northeast-1'
connectionCls = EC2APNEConnection
_instance_types = EC2_AP_NORTHEAST_INSTANCE_TYPES

class EucConnection(EC2Connection):
"""
Connection class for Eucalyptus
Expand Down
2 changes: 2 additions & 0 deletions libcloud/providers.py
Expand Up @@ -29,6 +29,8 @@
('libcloud.drivers.ec2', 'EC2USWestNodeDriver'),
Provider.EC2_AP_SOUTHEAST:
('libcloud.drivers.ec2', 'EC2APSENodeDriver'),
Provider.EC2_AP_NORTHEAST:
('libcloud.drivers.ec2', 'EC2APNENodeDriver'),
Provider.ECP:
('libcloud.drivers.ecp', 'ECPNodeDriver'),
Provider.ELASTICHOSTS_UK1:
Expand Down
1 change: 1 addition & 0 deletions libcloud/types.py
Expand Up @@ -66,6 +66,7 @@ class Provider(object):
RACKSPACE_UK = 23
BRIGHTBOX = 24
CLOUDSIGMA = 25
EC2_AP_NORTHEAST = 26

class NodeState(object):
"""
Expand Down
8 changes: 8 additions & 0 deletions test/test_ec2.py
Expand Up @@ -16,6 +16,7 @@
import unittest

from libcloud.drivers.ec2 import EC2NodeDriver, EC2APSENodeDriver, IdempotentParamError
from libcloud.drivers.ec2 import EC2APNENodeDriver
from libcloud.base import Node, NodeImage, NodeSize, NodeLocation

from test import MockHttp, TestCaseMixin
Expand Down Expand Up @@ -261,5 +262,12 @@ def setUp(self):
EC2MockHttp.type = None
self.driver = EC2APSENodeDriver(EC2_ACCESS_ID, EC2_SECRET)

class EC2APNETests(EC2Tests):
def setUp(self):
EC2APNENodeDriver.connectionCls.conn_classes = (None, EC2MockHttp)
EC2MockHttp.use_param = 'Action'
EC2MockHttp.type = None
self.driver = EC2APNENodeDriver(EC2_ACCESS_ID, EC2_SECRET)

if __name__ == '__main__':
sys.exit(unittest.main())

0 comments on commit 06e556f

Please sign in to comment.