You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/12/29 16:16:01 UTC
[1/5] git commit: Cleanup and improve some docstrings.
Updated Branches:
refs/heads/trunk b8adad947 -> 6c32efed2
Cleanup and improve some docstrings.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8b888006
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8b888006
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8b888006
Branch: refs/heads/trunk
Commit: 8b8880060f9139cb2468cf7e260b175a4eee21de
Parents: b8adad9
Author: Tomaz Muraus <to...@apache.org>
Authored: Sun Dec 29 15:02:16 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Dec 29 15:02:16 2013 +0100
----------------------------------------------------------------------
libcloud/compute/base.py | 63 ++++++++++++++++++++++++++-----------------
1 file changed, 39 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/8b888006/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index 3d7ce16..1bdadfd 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -1143,26 +1143,28 @@ class NodeDriver(BaseDriver):
def wait_until_running(self, nodes, wait_period=3, timeout=600,
ssh_interface='public_ips', force_ipv4=True):
"""
- Block until the given nodes are fully booted and have an IP address
- assigned.
+ Block until the provided nodes are considered running
- :param nodes: list of node instances.
- :type nodes: ``List`` of :class:`.Node`
+ Node is considered running when it's state is "running" and when it has
+ at least one IP address assigned.
- :param wait_period: How many seconds to between each loop
- iteration (default is 3)
+ :param nodes: List of nodes to wait for.
+ :type nodes: ``list`` of :class:`.Node`
+
+ :param wait_period: How many seconds to wait between each loop
+ iteration. (default is 3)
:type wait_period: ``int``
- :param timeout: How many seconds to wait before timing out
- (default is 600)
+ :param timeout: How many seconds to wait before giving up.
+ (default is 600)
:type timeout: ``int``
- :param ssh_interface: The interface to wait for.
- Default is 'public_ips', other option is
- 'private_ips'.
+ :param ssh_interface: Which attribute on the node to use to obtain
+ an IP address. Valid options: public_ips,
+ private_ips. Default is public_ips.
:type ssh_interface: ``str``
- :param force_ipv4: Ignore ipv6 IP addresses (default is True).
+ :param force_ipv4: Ignore IPv6 addresses (default is True).
:type force_ipv4: ``bool``
:return: ``[(Node, ip_addresses)]`` list of tuple of Node instance and
@@ -1170,14 +1172,18 @@ class NodeDriver(BaseDriver):
:rtype: ``list`` of ``tuple``
"""
def is_supported(address):
- """Return True for supported address"""
+ """
+ Return True for supported address
+ """
if force_ipv4 and not is_valid_ip_address(address=address,
family=socket.AF_INET):
return False
return True
def filter_addresses(addresses):
- """Return list of supported addresses"""
+ """
+ Return list of supported addresses
+ """
return [a for a in addresses if is_supported(a)]
start = time.time()
@@ -1265,11 +1271,11 @@ class NodeDriver(BaseDriver):
:type ssh_client: ``SSHClient``
:param wait_period: How many seconds to wait between each loop
- iteration (default is 1.5)
+ iteration. (default is 1.5)
:type wait_period: ``int``
- :param timeout: How many seconds to wait before timing out
- (default is 600)
+ :param timeout: How many seconds to wait before giving up.
+ (default is 300)
:type timeout: ``int``
:return: ``SSHClient`` on success
@@ -1296,6 +1302,10 @@ class NodeDriver(BaseDriver):
ssh_port, ssh_username,
ssh_password, ssh_key_file,
ssh_timeout, timeout, max_tries):
+ """
+ Establish an SSH connection to the node and run the provided deployment
+ task.
+ """
ssh_client = SSHClient(hostname=ssh_hostname,
port=ssh_port, username=ssh_username,
password=ssh_password,
@@ -1316,37 +1326,42 @@ class NodeDriver(BaseDriver):
Run the deployment script on the provided node. At this point it is
assumed that SSH connection has already been established.
- :param task: Deployment task to run on the node.
- :type task: ``Deployment``
+ :param task: Deployment task to run.
+ :type task: :class:`Deployment`
- :param node: Node to operate one
+ :param node: Node to run the task on.
:type node: ``Node``
- :param ssh_client: A configured and connected SSHClient instance
- :type ssh_client: ``SSHClient``
+ :param ssh_client: A configured and connected SSHClient instance.
+ :type ssh_client: :class:`SSHClient`
:param max_tries: How many times to retry if a deployment fails
- before giving up (default is 3)
+ before giving up. (default is 3)
:type max_tries: ``int``
:return: ``Node`` Node instance on success.
"""
tries = 0
+
while tries < max_tries:
try:
node = task.run(node, ssh_client)
except Exception:
- e = sys.exc_info()[1]
tries += 1
+
if tries >= max_tries:
e = sys.exc_info()[1]
raise LibcloudError(value='Failed after %d tries: %s'
% (max_tries, str(e)), driver=self)
else:
+ # Deployment succeeded
ssh_client.close()
return node
def _get_size_price(self, size_id):
+ """
+ Return pricing information for the provided size id.
+ """
return get_size_price(driver_type='compute',
driver_name=self.api_name,
size_id=size_id)
[4/5] git commit: Update Contributing document.
Posted by to...@apache.org.
Update Contributing document.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/810e1970
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/810e1970
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/810e1970
Branch: refs/heads/trunk
Commit: 810e1970b2535efceb3320a0f4d9b18a5e9ea83e
Parents: 2ebdee2
Author: Tomaz Muraus <to...@apache.org>
Authored: Sun Dec 29 15:49:06 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Dec 29 15:49:06 2013 +0100
----------------------------------------------------------------------
CONTRIBUTING.rst | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/810e1970/CONTRIBUTING.rst
----------------------------------------------------------------------
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 53aeb91..f9696c6 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -4,6 +4,11 @@ Contributing to Libcloud
We welcome contributions of any kind (ideas, code, tests, documentation,
examples, ...).
-For more information on how to contribute, please see the "Contributing"
-chapter in our documentation
-<https://libcloud.readthedocs.org/en/latest/development.html#contributing>
+For more information on how to contribute and the guidelines you should follow,
+please see the links listed bellow:
+
+* Contributing to Libcloud - https://libcloud.readthedocs.org/en/latest/development.html#general-guidelines
+* General Guidelines - https://libcloud.readthedocs.org/en/latest/development.html#general-guidelines
+* Style Guide - https://libcloud.readthedocs.org/en/latest/development.html#style-guide
+* Code Conventions - https://libcloud.readthedocs.org/en/latest/development.html#code-conventions
+* Docstring Conventions - https://libcloud.readthedocs.org/en/latest/development.html#docstring-conventions
[2/5] git commit: Modify _connect_and_run_deployment_script to return
a Node object on success.
Posted by to...@apache.org.
Modify _connect_and_run_deployment_script to return a Node object on success.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/805bb050
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/805bb050
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/805bb050
Branch: refs/heads/trunk
Commit: 805bb0503d302ee639406fdfe8dcc7787820671a
Parents: 8b88800
Author: Tomaz Muraus <to...@apache.org>
Authored: Sun Dec 29 15:03:39 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Dec 29 15:03:39 2013 +0100
----------------------------------------------------------------------
libcloud/compute/base.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/805bb050/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index 1bdadfd..491fa74 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -1305,6 +1305,9 @@ class NodeDriver(BaseDriver):
"""
Establish an SSH connection to the node and run the provided deployment
task.
+
+ :rtype: :class:`.Node`:
+ :return: Node instance on success.
"""
ssh_client = SSHClient(hostname=ssh_hostname,
port=ssh_port, username=ssh_username,
@@ -1317,9 +1320,10 @@ class NodeDriver(BaseDriver):
timeout=timeout)
# Execute the deployment task
- self._run_deployment_script(task=task, node=node,
- ssh_client=ssh_client,
- max_tries=max_tries)
+ node = self._run_deployment_script(task=task, node=node,
+ ssh_client=ssh_client,
+ max_tries=max_tries)
+ return node
def _run_deployment_script(self, task, node, ssh_client, max_tries=3):
"""
@@ -1339,6 +1343,7 @@ class NodeDriver(BaseDriver):
before giving up. (default is 3)
:type max_tries: ``int``
+ :rtype: :class:`.Node`
:return: ``Node`` Node instance on success.
"""
tries = 0
[3/5] git commit: Use better variable names, move check to the top.
Posted by to...@apache.org.
Use better variable names, move check to the top.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/2ebdee24
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/2ebdee24
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/2ebdee24
Branch: refs/heads/trunk
Commit: 2ebdee24775b13d02b985ed146594357c89bec44
Parents: 805bb05
Author: Tomaz Muraus <to...@apache.org>
Authored: Sun Dec 29 15:32:06 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Dec 29 15:32:06 2013 +0100
----------------------------------------------------------------------
libcloud/compute/base.py | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/2ebdee24/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index 491fa74..7e6b9e6 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -1143,7 +1143,7 @@ class NodeDriver(BaseDriver):
def wait_until_running(self, nodes, wait_period=3, timeout=600,
ssh_interface='public_ips', force_ipv4=True):
"""
- Block until the provided nodes are considered running
+ Block until the provided nodes are considered running.
Node is considered running when it's state is "running" and when it has
at least one IP address assigned.
@@ -1173,7 +1173,7 @@ class NodeDriver(BaseDriver):
"""
def is_supported(address):
"""
- Return True for supported address
+ Return True for supported address.
"""
if force_ipv4 and not is_valid_ip_address(address=address,
family=socket.AF_INET):
@@ -1182,32 +1182,36 @@ class NodeDriver(BaseDriver):
def filter_addresses(addresses):
"""
- Return list of supported addresses
+ Return list of supported addresses.
"""
- return [a for a in addresses if is_supported(a)]
-
- start = time.time()
- end = start + timeout
+ return [address for address in addresses if is_supported(address)]
if ssh_interface not in ['public_ips', 'private_ips']:
raise ValueError('ssh_interface argument must either be' +
'public_ips or private_ips')
- uuids = set([n.uuid for n in nodes])
+ start = time.time()
+ end = start + timeout
+
+ uuids = set([node.uuid for node in nodes])
+
while time.time() < end:
- nodes = self.list_nodes()
- nodes = list([n for n in nodes if n.uuid in uuids])
+ all_nodes = self.list_nodes()
+ matching_nodes = list([node for node in all_nodes
+ if node.uuid in uuids])
- if len(nodes) > len(uuids):
- found_uuids = [n.uuid for n in nodes]
+ if len(matching_nodes) > len(uuids):
+ found_uuids = [node.uuid for node in matching_nodes]
msg = ('Unable to match specified uuids ' +
'(%s) with existing nodes. Found ' % (uuids) +
'multiple nodes with same uuid: (%s)' % (found_uuids))
raise LibcloudError(value=msg, driver=self)
- running_nodes = [n for n in nodes if n.state == NodeState.RUNNING]
- addresses = [filter_addresses(getattr(n, ssh_interface)) for n in
- running_nodes]
+ running_nodes = [node for node in matching_nodes
+ if node.state == NodeState.RUNNING]
+ addresses = [filter_addresses(getattr(node, ssh_interface))
+ for node in running_nodes]
+
if len(running_nodes) == len(uuids) == len(addresses):
return list(zip(running_nodes, addresses))
else:
[5/5] git commit: Issue LIBCLOUD-480: Add additional attributes to
the "extra" dictionary of the VolumeSnapshot object in the EC2 driver.
Posted by to...@apache.org.
Issue LIBCLOUD-480: Add additional attributes to the "extra" dictionary of
the VolumeSnapshot object in the EC2 driver.
Also modify create_volume_snapshot method to correctly handle "name" argument.
Previous, "name" argument was used as a snapshot description, now it's used
as a Tag with a key "Name".
Signed-off-by: Tomaz Muraus <to...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/6c32efed
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/6c32efed
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/6c32efed
Branch: refs/heads/trunk
Commit: 6c32efed2cef9b69cbe22fd6d56a672a422e93dc
Parents: 810e197
Author: Chris DeRamus <ch...@divvycloud.com>
Authored: Sun Dec 29 07:36:49 2013 -0500
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Dec 29 15:57:41 2013 +0100
----------------------------------------------------------------------
libcloud/compute/drivers/ec2.py | 62 ++++++++++++++++----
.../compute/fixtures/ec2/describe_snapshots.xml | 4 ++
libcloud/test/compute/test_ec2.py | 7 ++-
3 files changed, 57 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6c32efed/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 571f494..2011826 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -940,21 +940,52 @@ class BaseEC2NodeDriver(NodeDriver):
fixxpath(xpath='snapshotSet/item', namespace=NAMESPACE))
]
- def _to_snapshot(self, element):
+ def _to_snapshot(self, element, name=None):
snapId = findtext(element=element, xpath='snapshotId',
namespace=NAMESPACE)
- volId = findtext(element=element, xpath='volumeId',
- namespace=NAMESPACE)
size = findtext(element=element, xpath='volumeSize',
namespace=NAMESPACE)
- state = findtext(element=element, xpath='status',
- namespace=NAMESPACE)
- description = findtext(element=element, xpath='description',
- namespace=NAMESPACE)
- return VolumeSnapshot(snapId, size=int(size), driver=self,
- extra={'volume_id': volId,
- 'description': description,
- 'state': state})
+
+ # Get our tags
+ tags = self._get_resource_tags(element)
+
+ # If name was not passed into the method then
+ # fall back then use the snapshot id
+ name = name if name else tags.get('Name', snapId)
+
+ # Build our extra attributes map
+ extra_attributes_map = {
+ 'volume_id': {
+ 'xpath': 'volumeId',
+ 'transform_func': str
+ },
+ 'state': {
+ 'xpath': 'status',
+ 'transform_func': str
+ },
+ 'description': {
+ 'xpath': 'description',
+ 'transform_func': str
+ },
+ 'progress': {
+ 'xpath': 'progress',
+ 'transform_func': str
+ },
+ 'start_time': {
+ 'xpath': 'startTime',
+ 'transform_func': parse_date
+ }
+ }
+
+ # Get our extra dictionary
+ extra = self._get_extra_dict(element, extra_attributes_map)
+
+ # Add tags and name to the extra dict
+ extra['tags'] = tags
+ extra['name'] = name
+
+ return VolumeSnapshot(snapId, size=int(size),
+ driver=self, extra=extra)
def _to_networks(self, response):
return [self._to_network(el) for el in response.findall(
@@ -1257,7 +1288,7 @@ class BaseEC2NodeDriver(NodeDriver):
:param volume: Instance of ``StorageVolume``
:type volume: ``StorageVolume``
- :param name: Description for snapshot
+ :param name: Name of snapshot
:type name: ``str``
:rtype: :class:`VolumeSnapshot`
@@ -1266,12 +1297,17 @@ class BaseEC2NodeDriver(NodeDriver):
'Action': 'CreateSnapshot',
'VolumeId': volume.id,
}
+
if name:
params.update({
'Description': name,
})
response = self.connection.request(self.path, params=params).object
- snapshot = self._to_snapshot(response)
+ snapshot = self._to_snapshot(response, name)
+
+ if name:
+ self.ex_create_tags(snapshot, {'Name': name})
+
return snapshot
def list_volume_snapshots(self, snapshot):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6c32efed/libcloud/test/compute/fixtures/ec2/describe_snapshots.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ec2/describe_snapshots.xml b/libcloud/test/compute/fixtures/ec2/describe_snapshots.xml
index 52f7076..b884c79 100644
--- a/libcloud/test/compute/fixtures/ec2/describe_snapshots.xml
+++ b/libcloud/test/compute/fixtures/ec2/describe_snapshots.xml
@@ -30,6 +30,10 @@
<description>Weekly backup</description>
<tagSet>
<item>
+ <key>Name</key>
+ <value>DB Backup 1</value>
+ </item>
+ <item>
<key>Key2</key>
<value>db_backup</value>
</item>
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6c32efed/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index aeb1ddb..81ac6bd 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -692,11 +692,11 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
def test_create_volume_snapshot(self):
vol = StorageVolume(id='vol-4282672b', name='test',
size=10, driver=self.driver)
- snap = self.driver.create_volume_snapshot(vol, 'Test description')
-
+ snap = self.driver.create_volume_snapshot(
+ vol, 'Test snapshot')
self.assertEqual('snap-a7cb2hd9', snap.id)
self.assertEqual(vol.size, snap.size)
- self.assertEqual('Test description', snap.extra['description'])
+ self.assertEqual('Test snapshot', snap.extra['name'])
self.assertEqual(vol.id, snap.extra['volume_id'])
self.assertEqual('pending', snap.extra['state'])
@@ -714,6 +714,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
self.assertEqual('vol-b5a2c1v9', snaps[1].extra['volume_id'])
self.assertEqual(15, snaps[1].size)
self.assertEqual('Weekly backup', snaps[1].extra['description'])
+ self.assertEqual('DB Backup 1', snaps[1].extra['name'])
def test_destroy_snapshot(self):
snap = VolumeSnapshot(id='snap-428abd35', size=10, driver=self.driver)