You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by pq...@apache.org on 2010/04/22 02:03:21 UTC
svn commit: r936574 - in /incubator/libcloud/trunk/libcloud: base.py
drivers/ec2.py providers.py types.py
Author: pquerna
Date: Thu Apr 22 00:03:21 2010
New Revision: 936574
URL: http://svn.apache.org/viewvc?rev=936574&view=rev
Log:
Start a eucalyptus driver.
Modified:
incubator/libcloud/trunk/libcloud/base.py
incubator/libcloud/trunk/libcloud/drivers/ec2.py
incubator/libcloud/trunk/libcloud/providers.py
incubator/libcloud/trunk/libcloud/types.py
Modified: incubator/libcloud/trunk/libcloud/base.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/base.py?rev=936574&r1=936573&r2=936574&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/base.py (original)
+++ incubator/libcloud/trunk/libcloud/base.py Thu Apr 22 00:03:21 2010
@@ -319,7 +319,7 @@ class ConnectionKey(object):
secure = 1
driver = None
- def __init__(self, key, secure=True):
+ def __init__(self, key, secure=True, host=None):
"""
Initialize `user_id` and `key`; set `secure` to an C{int} based on
passed value.
@@ -327,6 +327,8 @@ class ConnectionKey(object):
self.key = key
self.secure = secure and 1 or 0
self.ua = []
+ if host:
+ self.host = host
def connect(self, host=None, port=None):
"""
@@ -454,8 +456,8 @@ class ConnectionUserAndKey(ConnectionKey
user_id = None
- def __init__(self, user_id, key, secure=True):
- super(ConnectionUserAndKey, self).__init__(key, secure)
+ def __init__(self, user_id, key, secure=True, host=None):
+ super(ConnectionUserAndKey, self).__init__(key, secure, host)
self.user_id = user_id
@@ -480,7 +482,7 @@ class NodeDriver(object):
"""
NODE_STATE_MAP = {}
- def __init__(self, key, secret=None, secure=True):
+ def __init__(self, key, secret=None, secure=True, host=None):
"""
@keyword key: API key or username to used
@type key: str
@@ -495,10 +497,17 @@ class NodeDriver(object):
self.key = key
self.secret = secret
self.secure = secure
+ args = [self.key]
+
if self.secret:
- self.connection = self.connectionCls(key, secret, secure)
- else:
- self.connection = self.connectionCls(key, secure)
+ args.append(self.secret)
+
+ args.append(secure)
+
+ if host:
+ args.append(host)
+
+ self.connection = self.connectionCls(*args)
self.connection.driver = self
self.connection.connect()
Modified: incubator/libcloud/trunk/libcloud/drivers/ec2.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/ec2.py?rev=936574&r1=936573&r2=936574&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/ec2.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/ec2.py Thu Apr 22 00:03:21 2010
@@ -444,3 +444,15 @@ class EC2USWestNodeDriver(EC2NodeDriver)
_instance_types = EC2_US_WEST_INSTANCE_TYPES
def list_locations(self):
return [NodeLocation(0, 'Amazon US N. California', 'US', self)]
+
+class EucConnection(EC2Connection):
+
+ host = None
+
+class EucNodeDriver(EC2NodeDriver):
+
+ connectionCls = EucConnection
+ _instance_types = EC2_US_WEST_INSTANCE_TYPES
+ def list_locations(self):
+ raise NotImplementedError, \
+ 'list_locations not implemented for this driver'
Modified: incubator/libcloud/trunk/libcloud/providers.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/providers.py?rev=936574&r1=936573&r2=936574&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/providers.py (original)
+++ incubator/libcloud/trunk/libcloud/providers.py Thu Apr 22 00:03:21 2010
@@ -43,6 +43,8 @@ DRIVERS = {
('libcloud.drivers.voxel', 'VoxelNodeDriver'),
Provider.SOFTLAYER:
('libcloud.drivers.softlayer', 'SoftLayerNodeDriver'),
+ Provider.EUCALYPTUS:
+ ('libcloud.drivers.ec2', 'EucNodeDriver'),
}
def get_driver(provider):
Modified: incubator/libcloud/trunk/libcloud/types.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/types.py?rev=936574&r1=936573&r2=936574&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/types.py (original)
+++ incubator/libcloud/trunk/libcloud/types.py Thu Apr 22 00:03:21 2010
@@ -47,6 +47,7 @@ class Provider(object):
EC2_US_WEST = 10
VOXEL = 11
SOFTLAYER = 12
+ EUCALYPTUS = 13
class NodeState(object):
"""