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/27 16:32:50 UTC
[1/6] git commit: docs: Update contribution guide,
add note about git format-patch and commit squashing.
Updated Branches:
refs/heads/trunk 0cdfa4615 -> 9db6f5706
docs: Update contribution guide, add note about git format-patch and commit
squashing.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9092870d
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9092870d
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9092870d
Branch: refs/heads/trunk
Commit: 9092870d95b18da10e251e832d7c1b355f4ddf64
Parents: 0cdfa46
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Dec 27 15:11:17 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Dec 27 15:12:55 2013 +0100
----------------------------------------------------------------------
docs/development.rst | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/9092870d/docs/development.rst
----------------------------------------------------------------------
diff --git a/docs/development.rst b/docs/development.rst
index 7f7ff04..39af5c3 100644
--- a/docs/development.rst
+++ b/docs/development.rst
@@ -24,7 +24,7 @@ Style guide
Second command fill run flake8 on all the files in the repository.
And most importantly, follow the existing style in the files you are editing and
-be consistent.
+**be consistent**.
Git pre-commit hook
-------------------
@@ -153,17 +153,29 @@ pull request description contains link to the JIRA ticket.
Wait for your changes to be reviewed and address any outstanding comments.
-10. Attach a final patch with your changes to the corresponding JIRA ticket
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+10. Squash the committs and generate the patch
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Once the changes has been reviewed, all the outstanding issues have been
-addressed and the pull request has been +1'ed, close the pull request,
-generate a patch and attach it to the JIRA issue you have created earlier.
+addressed and the pull request has been +1'ed, close the pull request, squash
+the commits (if necessary) and generate a patch.
.. sourcecode:: bash
git format-patch --stdout trunk > patch_name.patch
+Make sure to use ``git format-patch`` and not ``git diff`` so we can preserve
+the commit authorship.
+
+Note: If you have never used rebase and squashed the commits before, you can
+find instructions on how to do that in the following guide:
+`squashing commits with rebase`_.
+
+11. Attach a final patch with your changes to the corresponding JIRA ticket
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Attach the generated patch to the JIRA issue you have created earlier.
+
Note about Github
~~~~~~~~~~~~~~~~~
@@ -289,3 +301,4 @@ code work with multiple versions on the following link -
.. _`Github git repository`: https://github.com/apache/libcloud
.. _`Apache website`: https://www.apache.org/licenses/#clas
.. _`Lessons learned while porting Libcloud to Python 3`: http://www.tomaz.me/2011/12/03/lessons-learned-while-porting-libcloud-to-python-3.html
+.. _`squashing commits with rebase`: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
[6/6] git commit: Fix lint issue.
Posted by to...@apache.org.
Fix lint issue.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9db6f570
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9db6f570
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9db6f570
Branch: refs/heads/trunk
Commit: 9db6f5706fa54f7e3302e8a6e443d6c4e27270d1
Parents: 4af067a
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Dec 27 16:25:20 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Dec 27 16:25:20 2013 +0100
----------------------------------------------------------------------
libcloud/compute/drivers/ec2.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/9db6f570/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index b61ecfa..abeec15 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -793,7 +793,7 @@ class BaseEC2NodeDriver(NodeDriver):
'status': findattr(element=element, xpath="instanceState/name",
namespace=NAMESPACE),
'key_name': findattr(element=element, xpath="keyName",
- namespace=NAMESPACE),
+ namespace=NAMESPACE),
'launchindex': findattr(element=element,
xpath="amiLaunchIndex",
namespace=NAMESPACE),
[4/6] git commit: LIBCLOUD-475 fix key_name in Ec2 and Cloudstack
drivers
Posted by to...@apache.org.
LIBCLOUD-475 fix key_name in Ec2 and Cloudstack drivers
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/1ab9da5c
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1ab9da5c
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1ab9da5c
Branch: refs/heads/trunk
Commit: 1ab9da5c87caddd8b5e0b5ff13cb39d3ded2693f
Parents: 4e8a91e
Author: gigimon <gi...@gmail.com>
Authored: Fri Dec 27 17:04:25 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Dec 27 16:11:58 2013 +0100
----------------------------------------------------------------------
libcloud/compute/drivers/cloudstack.py | 2 +-
libcloud/compute/drivers/ec2.py | 2 +-
libcloud/test/compute/fixtures/ec2/describe_instances.xml | 2 ++
libcloud/test/compute/test_cloudstack.py | 4 ++--
libcloud/test/compute/test_ec2.py | 1 +
5 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1ab9da5c/libcloud/compute/drivers/cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudstack.py b/libcloud/compute/drivers/cloudstack.py
index c2fed2f..1cc82b2 100644
--- a/libcloud/compute/drivers/cloudstack.py
+++ b/libcloud/compute/drivers/cloudstack.py
@@ -1536,7 +1536,7 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver):
'ip_forwarding_rules': [],
'port_forwarding_rules': [],
'password': password,
- 'keyname': keypair,
+ 'key_name': keypair,
'security_group': security_groups,
'created': created,
'image_id': data.get('templateid', None),
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1ab9da5c/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 48fbdbc..b61ecfa 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -792,7 +792,7 @@ class BaseEC2NodeDriver(NodeDriver):
namespace=NAMESPACE),
'status': findattr(element=element, xpath="instanceState/name",
namespace=NAMESPACE),
- 'keyname': findattr(element=element, xpath="keyName",
+ 'key_name': findattr(element=element, xpath="keyName",
namespace=NAMESPACE),
'launchindex': findattr(element=element,
xpath="amiLaunchIndex",
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1ab9da5c/libcloud/test/compute/fixtures/ec2/describe_instances.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ec2/describe_instances.xml b/libcloud/test/compute/fixtures/ec2/describe_instances.xml
index 3ba4071..c7f6594 100644
--- a/libcloud/test/compute/fixtures/ec2/describe_instances.xml
+++ b/libcloud/test/compute/fixtures/ec2/describe_instances.xml
@@ -20,6 +20,7 @@
<privateDnsName/>
<dnsName/>
<reason/>
+ <keyName>my-key-pair</keyName>
<privateIpAddress>1.2.3.5</privateIpAddress>
<ipAddress>1.2.3.5</ipAddress>
<amiLaunchIndex>0</amiLaunchIndex>
@@ -43,6 +44,7 @@
<privateDnsName/>
<dnsName/>
<reason/>
+ <keyName>my-key-pair2</keyName>
<privateIpAddress>1.2.3.5</privateIpAddress>
<ipAddress>1.2.3.5</ipAddress>
<amiLaunchIndex>0</amiLaunchIndex>
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1ab9da5c/libcloud/test/compute/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py
index 005ee58..146241e 100644
--- a/libcloud/test/compute/test_cloudstack.py
+++ b/libcloud/test/compute/test_cloudstack.py
@@ -133,7 +133,7 @@ class CloudStackCommonTestCase(TestCaseMixin):
size=size,
ex_keyname='foobar')
self.assertEqual(node.name, 'test')
- self.assertEqual(node.extra['keyname'], 'foobar')
+ self.assertEqual(node.extra['key_name'], 'foobar')
def test_list_images_no_images_available(self):
CloudStackMockHttp.fixture_tag = 'notemplates'
@@ -248,7 +248,7 @@ class CloudStackCommonTestCase(TestCaseMixin):
self.assertEqual('test', nodes[0].name)
self.assertEqual('2600', nodes[0].id)
self.assertEqual([], nodes[0].extra['security_group'])
- self.assertEqual(None, nodes[0].extra['keyname'])
+ self.assertEqual(None, nodes[0].extra['key_name'])
def test_list_locations(self):
location = self.driver.list_locations()[0]
http://git-wip-us.apache.org/repos/asf/libcloud/blob/1ab9da5c/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index 6d71202..aeb1ddb 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -176,6 +176,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
self.assertEqual(len(node.public_ips), 2)
self.assertEqual(node.extra['launchdatetime'],
'2009-08-07T05:47:04.000Z')
+ self.assertEqual(node.extra['key_name'], 'my-key-pair')
self.assertTrue('instancetype' in node.extra)
self.assertEqual(public_ips[0], '1.2.3.4')
[2/6] git commit: docs: Update contribution page - add "code
conventions" section.
Posted by to...@apache.org.
docs: Update contribution page - add "code conventions" section.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/df13c7ac
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/df13c7ac
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/df13c7ac
Branch: refs/heads/trunk
Commit: df13c7ac042895e23d9237f0b932a5a79d40531d
Parents: 9092870
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Dec 27 15:46:56 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Dec 27 15:46:56 2013 +0100
----------------------------------------------------------------------
docs/development.rst | 103 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/df13c7ac/docs/development.rst
----------------------------------------------------------------------
diff --git a/docs/development.rst b/docs/development.rst
index 39af5c3..504380c 100644
--- a/docs/development.rst
+++ b/docs/development.rst
@@ -44,6 +44,109 @@ After you have installed this hook it will automatically check modified Python
files for violations before a commit. If a violation is found, commit will be
aborted.
+Code conventions
+----------------
+
+This section contains some conventions you should follow when writing a
+Libcloud code.
+
+1. Import ordering
+~~~~~~~~~~~~~~~~~~
+
+Organize the imports in the following order:
+
+1. Standard library imports
+2. Third-party library imports
+3. Local libray (Libcloud) imports
+
+Each section should be separated with a blank line. For example:
+
+.. sourcecode:: python
+
+ import sys
+ import base64
+
+ import paramiko
+
+ from libcloud.compute.base import Node, NodeDriver
+ from libcloud.compute.providers import Provider
+
+2. Function and method ordering
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Functions in a module and methods on a class should be organized in the
+following order:
+
+1. "Public" functions / methods
+2. "Private" functions / methods (methods prefixed with an underscore)
+3. "Internal" methods (methods prefixed and suffixed with a double underscore)
+
+For example:
+
+.. sourcecode:: python
+
+ class Unicorn(object):
+ def __init__(self, name='fluffy'):
+ self._name = name
+
+ def make_a_rainbow(self):
+ pass
+
+ def _get_rainbow_colors(self):
+ pass
+
+ def __eq__(self, other):
+ return self.name == other.name
+
+3. Prefer keyword over regular arguments
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For better readability and understanding of the code, prefer keyword over
+regular arguments.
+
+Good:
+
+.. sourcecode:: python
+
+ some_method(public_ips=public_ips, private_ips=private_ips)
+
+Bad:
+
+.. sourcecode:: python
+
+ some_method(public_ips, private_ips)
+
+4. When returning a dictionary, document it's structure
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Dynamic nature of Python can be very nice and useful, but if (ab)use it in a
+wrong way it can also make it hard for the API consumer to understand what is
+going on and what kind of values are being returned.
+
+If you have a function or a method which returns a dictionary, make sure to
+explicitly document in the docstring which keys the returned dictionary
+contains.
+
+4. Prefer to use "is not None" when checking if a variable is provided or defined
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+When checking if a variable is provided or defined, prefer to use
+``is foo is not None`` instead of ``if foo``.
+
+If you use ``if foo`` approach, it's easy to make a mistake when a valid value
+can also be falsy (e.g. a number ``0``).
+
+For example:
+
+.. sourcecode:: python
+
+ class SomeClass(object):
+ def some_method(self, domain=None):
+ params = {}
+
+ if domain is not None:
+ params['Domain'] = domain
+
Docstring conventions
---------------------
[3/6] git commit: docs: Add a note about synchronizing the branch.
Posted by to...@apache.org.
docs: Add a note about synchronizing the branch.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/4e8a91e3
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/4e8a91e3
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/4e8a91e3
Branch: refs/heads/trunk
Commit: 4e8a91e337ea601820a17a2eca6b316462b44a73
Parents: df13c7a
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Dec 27 15:52:24 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Dec 27 15:52:24 2013 +0100
----------------------------------------------------------------------
docs/development.rst | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/4e8a91e3/docs/development.rst
----------------------------------------------------------------------
diff --git a/docs/development.rst b/docs/development.rst
index 504380c..fac8238 100644
--- a/docs/development.rst
+++ b/docs/development.rst
@@ -256,7 +256,7 @@ pull request description contains link to the JIRA ticket.
Wait for your changes to be reviewed and address any outstanding comments.
-10. Squash the committs and generate the patch
+10. Squash the commits and generate the patch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Once the changes has been reviewed, all the outstanding issues have been
@@ -270,7 +270,11 @@ the commits (if necessary) and generate a patch.
Make sure to use ``git format-patch`` and not ``git diff`` so we can preserve
the commit authorship.
-Note: If you have never used rebase and squashed the commits before, you can
+Note #1: Before you generate the patch and squash the commits, make sure to
+synchronize your branch with the latest trunk (run ``git pull upstream trunk``
+in your branch), otherwise we might have problems applying it cleanly.
+
+Note #2: If you have never used rebase and squashed the commits before, you can
find instructions on how to do that in the following guide:
`squashing commits with rebase`_.
[5/6] git commit: Update CHANGES.
Posted by to...@apache.org.
Update CHANGES.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/4af067a8
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/4af067a8
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/4af067a8
Branch: refs/heads/trunk
Commit: 4af067a8ba0d8d132e35e03f26653e91e01b9804
Parents: 1ab9da5
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Dec 27 16:13:27 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Dec 27 16:13:27 2013 +0100
----------------------------------------------------------------------
CHANGES | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/4af067a8/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index a56d823..8923d45 100644
--- a/CHANGES
+++ b/CHANGES
@@ -127,6 +127,10 @@ Changes with Apache Libcloud in development
of the StorageVolume class in the EC2 driver. (LIBCLOUD-473)
[Chris DeRamus]
+ - Change attribute name in the 'extra' dictionary of EC2 and CloudStack
+ Node object from "keyname" to "key_name". (LIBCLOUD-475)
+ [Oleg Suharev]
+
*) Storage
- Allow user to specify 'Content-Disposition' header in the CloudFiles