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/08/21 17:54:45 UTC
svn commit: r987774 - /incubator/libcloud/trunk/libcloud/drivers/dummy.py
Author: pquerna
Date: Sat Aug 21 15:54:44 2010
New Revision: 987774
URL: http://svn.apache.org/viewvc?rev=987774&view=rev
Log:
Move _ip_to_int and _int_to_ip out of the driver class, since they didn't take self anyways, Fixing LIBCLOUD-47
Submitted by: Tomaz Muraus <tomaz cloudkick.com>
Modified:
incubator/libcloud/trunk/libcloud/drivers/dummy.py
Modified: incubator/libcloud/trunk/libcloud/drivers/dummy.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/dummy.py?rev=987774&r1=987773&r2=987774&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/dummy.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/dummy.py Sat Aug 21 15:54:44 2010
@@ -41,11 +41,6 @@ class DummyNodeDriver(NodeDriver):
name = "Dummy Node Provider"
type = Provider.DUMMY
- def _ip_to_int(ip):
- return socket.htonl(struct.unpack('I', socket.inet_aton(ip))[0])
- def _int_to_ip(ip):
- return socket.inet_ntoa(struct.pack('I', socket.ntohl(ip)))
-
def __init__(self, creds):
self.creds = creds
try:
@@ -54,9 +49,9 @@ class DummyNodeDriver(NodeDriver):
num = None
if num:
self.nl = []
- startip = self._ip_to_int('127.0.0.1')
+ startip = _ip_to_int('127.0.0.1')
for i in xrange(num):
- ip = self._int_to_ip(startip + i)
+ ip = _int_to_ip(startip + i)
self.nl.append(
Node(id=i,
name='dummy-%d' % (i),
@@ -166,3 +161,9 @@ class DummyNodeDriver(NodeDriver):
extra={'foo': 'bar'})
self.nl.append(n)
return n
+
+def _ip_to_int(ip):
+ return socket.htonl(struct.unpack('I', socket.inet_aton(ip))[0])
+
+def _int_to_ip(ip):
+ return socket.inet_ntoa(struct.pack('I', socket.ntohl(ip)))