diff --git a/libcloud/base.py b/libcloud/base.py index 66fe847..f8eafe8 100644 --- a/libcloud/base.py +++ b/libcloud/base.py @@ -124,6 +124,18 @@ class NodeLocation(object): return (('') % (self.id, self.name, self.country, self.driver.name)) +class NodeVolume(object): + """ + A base NodeVolume class to derive from. + """ + + def __init__(self, id, size, driver, extra=None): + self.id = id + self.size = size + self.driver = driver + self.extra = extra + + class NodeAuthSSHKey(object): """ An SSH key to be installed for authentication to a node. @@ -686,6 +698,43 @@ class NodeDriver(object): raise DeploymentException(node, e) return n + def create_volume(self, **kwargs): + """Create a new node instance. + + @keyword size: Size of volume in gigabytes (required) + @type size: int + + @keyword location: Which data center to create a volume in. If empty, + undefined behavoir will be selected. (optional) + @type location: L{NodeLocation} + + @keyword snapshot: Name of snapshot from which to create the new volume. + (optional) + @type snapshot: string + + @return: The newly created L{NodeVolume}. + """ + raise NotImplementedError, \ + 'create_node not implemented for this driver' + + def attach(self, node, volume, device): + """Attaches volume to node + + @keyword node: Node to attach volume to + @type node: L{Node} + + @keyword volume: Volume to attach + @type volume: L{NodeVolume} + + @keyword device: Where the device is exposed e.g., (/dev/sdb) + @type device: string + + @return: C{bool} + """ + raise NotImplementedError, \ + 'attach not implemented for this driver' + + def is_private_subnet(ip): """ Utility function to check if an IP address is inside a private subnet.