Author: tomaz
Date: Tue Jul 31 23:11:15 2012
New Revision: 1367818
URL: http://svn.apache.org/viewvc?rev=1367818&view=rev
Log:
Update docstrings for DNS providers and remove redundand methods introduced by a
bad patch from the Gandi driver. Contributed by Ilgiz Islamgulov, part of
LIBCLOUD-237.
Modified:
libcloud/trunk/libcloud/compute/drivers/dummy.py
libcloud/trunk/libcloud/compute/drivers/gandi.py
libcloud/trunk/libcloud/compute/drivers/slicehost.py
Modified: libcloud/trunk/libcloud/compute/drivers/dummy.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/dummy.py?rev=1367818&r1=1367817&r2=1367818&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/dummy.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/dummy.py Tue Jul 31 23:11:15 2012
@@ -113,6 +113,12 @@ class DummyNodeDriver(NodeDriver):
self.connection = DummyConnection(self.creds)
def get_uuid(self, unique_field=None):
+ """
+
+ @param unique_field: Unique field
+ @type unique_field: C{bool}
+ @rtype: L{UUID}
+ """
return str(uuid.uuid4())
def list_nodes(self):
@@ -141,6 +147,8 @@ class DummyNodeDriver(NodeDriver):
'i2'
>>> sorted([node.name for node in driver.list_nodes()])
['dummy-1', 'dummy-2', 'dummy-3']
+
+ @inherits: L{NodeDriver.list_nodes}
"""
return self.nl
@@ -163,6 +171,8 @@ class DummyNodeDriver(NodeDriver):
True
Please note, dummy nodes never recover from the reboot.
+
+ @inherits: L{NodeDriver.reboot_node}
"""
node.state = NodeState.REBOOTING
@@ -184,6 +194,8 @@ class DummyNodeDriver(NodeDriver):
False
>>> [node for node in driver.list_nodes() if node.name == 'dummy-1']
[]
+
+ @inherits: L{NodeDriver.destroy_node}
"""
node.state = NodeState.TERMINATED
@@ -198,6 +210,8 @@ class DummyNodeDriver(NodeDriver):
>>> driver = DummyNodeDriver(0)
>>> sorted([image.name for image in driver.list_images()])
['Slackware 4', 'Ubuntu 9.04', 'Ubuntu 9.10']
+
+ @inherits: L{NodeDriver.list_images}
"""
return [
NodeImage(id=1, name="Ubuntu 9.10", driver=self),
@@ -213,6 +227,8 @@ class DummyNodeDriver(NodeDriver):
>>> driver = DummyNodeDriver(0)
>>> sorted([size.ram for size in driver.list_sizes()])
[128, 512, 4096, 8192]
+
+ @inherits: L{NodeDriver.list_images}
"""
return [
@@ -254,6 +270,8 @@ class DummyNodeDriver(NodeDriver):
>>> driver = DummyNodeDriver(0)
>>> sorted([loc.name + " in " + loc.country for loc in
driver.list_locations()])
['Island Datacenter in FJ', 'London Loft in GB', "Paul's Room in US"]
+
+ @inherits: L{NodeDriver.list_locations}
"""
return [
NodeLocation(id=1,
@@ -288,6 +306,8 @@ class DummyNodeDriver(NodeDriver):
True
>>> sorted([node.name for node in driver.list_nodes()])
['dummy-1', 'dummy-2', 'dummy-4']
+
+ @inherits: L{NodeDriver.create_node}
"""
l = len(self.nl) + 1
n = Node(id=l,
@@ -314,4 +334,5 @@ def _int_to_ip(ip):
if __name__ == "__main__":
import doctest
+
doctest.testmod()
Modified: libcloud/trunk/libcloud/compute/drivers/gandi.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/gandi.py?rev=1367818&r1=1367817&r2=1367818&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/gandi.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/gandi.py Tue Jul 31 23:11:15 2012
@@ -108,42 +108,6 @@ class GandiNodeDriver(BaseGandiDriver, N
def _to_volumes(self, disks):
return [self._to_volume(d) for d in disks]
- def _to_volume(self, disk):
- extra = {'can_snapshot': disk['can_snapshot']}
- return StorageVolume(
- id=disk['id'],
- name=disk['name'],
- size=int(disk['size']),
- driver=self,
- extra=extra)
-
- def _to_volumes(self, disks):
- return [self._to_volume(d) for d in disks]
-
- def _to_volume(self, disk):
- extra = {'can_snapshot': disk['can_snapshot']}
- return StorageVolume(
- id=disk['id'],
- name=disk['name'],
- size=int(disk['size']),
- driver=self,
- extra=extra)
-
- def _to_volumes(self, disks):
- return [self._to_volume(d) for d in disks]
-
- def _to_volume(self, disk):
- extra = {'can_snapshot': disk['can_snapshot']}
- return StorageVolume(
- id=disk['id'],
- name=disk['name'],
- size=int(disk['size']),
- driver=self,
- extra=extra)
-
- def _to_volumes(self, disks):
- return [self._to_volume(d) for d in disks]
-
def list_nodes(self):
vms = self.connection.request('vm.list')
ips = self.connection.request('ip.list')
@@ -173,7 +137,7 @@ class GandiNodeDriver(BaseGandiDriver, N
op_stop = self.connection.request('vm.stop', int(node.id))
if not self._wait_operation(op_stop['id']):
raise GandiException(1010, 'vm.stop failed')
- # Delete
+ # Delete
op = self.connection.request('vm.delete', int(node.id))
if self._wait_operation(op['id']):
return True
@@ -346,93 +310,10 @@ class GandiNodeDriver(BaseGandiDriver, N
return [self._to_loc(l) for l in res]
def list_volumes(self):
- """List all volumes"""
- res = self.connection.request('disk.list', {})
- return self._to_volumes(res)
-
- def create_volume(self, size, name, location=None, snapshot=None):
- disk_param = {
- 'name': name,
- 'size': int(size),
- 'datacenter_id': int(location.id)
- }
- if snapshot:
- op = self.connection.request('disk.create_from',
- disk_param, int(snapshot.id))
- else:
- op = self.connection.request('disk.create', disk_param)
- if self._wait_operation(op['id']):
- disk = self._volume_info(op['disk_id'])
- return self._to_volume(disk)
- return None
-
- def attach_volume(self, node, volume, device=None):
- """Attach a volume to a node"""
- op = self.connection.request('vm.disk_attach',
- int(node.id), int(volume.id))
- if self._wait_operation(op['id']):
- return True
- return False
-
- def detach_volume(self, node, volume):
- """Detach a volume from a node"""
- op = self.connection.request('vm.disk_detach',
- int(node.id), int(volume.id))
- if self._wait_operation(op['id']):
- return True
- return False
-
- def destroy_volume(self, volume):
- op = self.connection.request('disk.delete', int(volume.id))
- if self._wait_operation(op['id']):
- return True
- return False
-
- def list_volumes(self):
- """List all volumes"""
- res = self.connection.request('disk.list', {})
- return self._to_volumes(res)
-
- def create_volume(self, size, name, location=None, snapshot=None):
- disk_param = {
- 'name': name,
- 'size': int(size),
- 'datacenter_id': int(location.id)
- }
- if snapshot:
- op = self.connection.request('disk.create_from',
- disk_param, int(snapshot.id))
- else:
- op = self.connection.request('disk.create', disk_param)
- if self._wait_operation(op['id']):
- disk = self._volume_info(op['disk_id'])
- return self._to_volume(disk)
- return None
-
- def attach_volume(self, node, volume, device=None):
- """Attach a volume to a node"""
- op = self.connection.request('vm.disk_attach',
- int(node.id), int(volume.id))
- if self._wait_operation(op['id']):
- return True
- return False
-
- def detach_volume(self, node, volume):
- """Detach a volume from a node"""
- op = self.connection.request('vm.disk_detach',
- int(node.id), int(volume.id))
- if self._wait_operation(op['id']):
- return True
- return False
-
- def destroy_volume(self, volume):
- op = self.connection.request('disk.delete', int(volume.id))
- if self._wait_operation(op['id']):
- return True
- return False
+ """
- def list_volumes(self):
- """List all volumes"""
+ @rtype: C{list} of L{StorageVolume}
+ """
res = self.connection.request('disk.list', {})
return self._to_volumes(res)
@@ -444,7 +325,7 @@ class GandiNodeDriver(BaseGandiDriver, N
}
if snapshot:
op = self.connection.request('disk.create_from',
- disk_param, int(snapshot.id))
+ disk_param, int(snapshot.id))
else:
op = self.connection.request('disk.create', disk_param)
if self._wait_operation(op['id']):
@@ -453,60 +334,26 @@ class GandiNodeDriver(BaseGandiDriver, N
return None
def attach_volume(self, node, volume, device=None):
- """Attach a volume to a node"""
op = self.connection.request('vm.disk_attach',
- int(node.id), int(volume.id))
+ int(node.id), int(volume.id))
if self._wait_operation(op['id']):
return True
return False
def detach_volume(self, node, volume):
- """Detach a volume from a node"""
- op = self.connection.request('vm.disk_detach',
- int(node.id), int(volume.id))
- if self._wait_operation(op['id']):
- return True
- return False
-
- def destroy_volume(self, volume):
- op = self.connection.request('disk.delete', int(volume.id))
- if self._wait_operation(op['id']):
- return True
- return False
-
- def list_volumes(self):
- """List all volumes"""
- res = self.connection.request('disk.list', {})
- return self._to_volumes(res)
+ """
+ Detaches a volume from a node.
- def create_volume(self, size, name, location=None, snapshot=None):
- disk_param = {
- 'name': name,
- 'size': int(size),
- 'datacenter_id': int(location.id)
- }
- if snapshot:
- op = self.connection.request('disk.create_from',
- disk_param, int(snapshot.id))
- else:
- op = self.connection.request('disk.create', disk_param)
- if self._wait_operation(op['id']):
- disk = self._volume_info(op['disk_id'])
- return self._to_volume(disk)
- return None
+ @param node: Node which should be used
+ @type node: L{Node}
- def attach_volume(self, node, volume, device=None):
- """Attach a volume to a node"""
- op = self.connection.request('vm.disk_attach',
- int(node.id), int(volume.id))
- if self._wait_operation(op['id']):
- return True
- return False
+ @param volume: Volume to be detached
+ @type volume: L{StorageVolume}
- def detach_volume(self, node, volume):
- """Detach a volume from a node"""
+ @rtype: C{bool}
+ """
op = self.connection.request('vm.disk_detach',
- int(node.id), int(volume.id))
+ int(node.id), int(volume.id))
if self._wait_operation(op['id']):
return True
return False
@@ -678,10 +525,11 @@ class GandiNodeDriver(BaseGandiDriver, N
if not name:
suffix = datetime.today().strftime("%Y%m%d")
name = "snap_%s" % (suffix)
- op = self.connection.request('disk.create_from',
- {'name': name, 'type': 'snapshot', },
- int(disk.id),
- )
+ op = self.connection.request(
+ 'disk.create_from',
+ {'name': name, 'type': 'snapshot', },
+ int(disk.id),
+ )
if self._wait_operation(op['id']):
return True
return False
Modified: libcloud/trunk/libcloud/compute/drivers/slicehost.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/slicehost.py?rev=1367818&r1=1367817&r2=1367818&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/slicehost.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/slicehost.py Tue Jul 31 23:11:15
2012
@@ -119,8 +119,6 @@ class SlicehostNodeDriver(NodeDriver):
return node
def reboot_node(self, node):
- """Reboot the node by passing in the node object"""
-
# 'hard' could bubble up as kwarg depending on how reboot_node
# turns out. Defaulting to soft reboot.
#hard = False
@@ -142,6 +140,8 @@ class SlicehostNodeDriver(NodeDriver):
<error>You must enable slice deletes in the SliceManager</error>
<error>Permission denied</error>
</errors>
+
+ @inherits: L{NodeDriver.destroy_node}
"""
uri = '/slices/%s/destroy.xml' % (node.id)
self.connection.request(uri, method='PUT')