libcloud git commit: Adding tagging feature to DimensionDataNodeDriver Closes #773
Repository: libcloud Updated Branches: refs/heads/trunk 0789cb58d -> b9a5586e9 Adding tagging feature to DimensionDataNodeDriver Closes #773 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b9a5586e Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b9a5586e Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b9a5586e Branch: refs/heads/trunk Commit: b9a5586e9672a64fcc618f087d8675c902a4b265 Parents: 0789cb5 Author: Jeffrey DunhamAuthored: Fri Apr 22 19:51:27 2016 -0400 Committer: anthony-shaw Committed: Sat Apr 23 13:20:05 2016 +1000 -- libcloud/common/dimensiondata.py| 84 +++- libcloud/compute/drivers/dimensiondata.py | 373 ++ .../fixtures/dimensiondata/tag_applyTags.xml| 6 + .../dimensiondata/tag_applyTags_BADREQUEST.xml | 6 + .../fixtures/dimensiondata/tag_createTagKey.xml | 7 + .../tag_createTagKey_BADREQUEST.xml | 6 + .../fixtures/dimensiondata/tag_deleteTagKey.xml | 6 + .../tag_deleteTagKey_BADREQUEST.xml | 6 + .../fixtures/dimensiondata/tag_editTagKey.xml | 6 + .../dimensiondata/tag_editTagKey_BADREQUEST.xml | 6 + .../fixtures/dimensiondata/tag_removeTag.xml| 6 + .../dimensiondata/tag_removeTag_BADREQUEST.xml | 6 + ...Key_5ab77f5f_5aa9_426f_8459_4eab34e03d54.xml | 6 + ...f_5aa9_426f_8459_4eab34e03d54_BADREQUEST.xml | 6 + .../fixtures/dimensiondata/tag_tagKey_list.xml | 19 + .../dimensiondata/tag_tagKey_list_SINGLE.xml| 8 + .../fixtures/dimensiondata/tag_tag_list.xml | 36 ++ libcloud/test/compute/test_dimensiondata.py | 388 +++ 18 files changed, 980 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/b9a5586e/libcloud/common/dimensiondata.py -- diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py index 50870e7..8410106 100644 --- a/libcloud/common/dimensiondata.py +++ b/libcloud/common/dimensiondata.py @@ -472,7 +472,8 @@ class DimensionDataConnection(ConnectionUserAndKey): yield paged_resp paged_resp = paged_resp or {} -while paged_resp.get('pageCount') >= paged_resp.get('pageSize'): +while int(paged_resp.get('pageCount')) >= \ +int(paged_resp.get('pageSize')): params['pageNumber'] = int(paged_resp.get('pageNumber')) + 1 paged_resp = self.request_with_orgId_api_2(action, params, data, headers, @@ -1408,3 +1409,84 @@ class DimensionDataBackupSchedulePolicy(object): def __repr__(self): return (('') % (self.name)) + + +class DimensionDataTag(object): +""" +A representation of a Tag in Dimension Data +A Tag first must have a Tag Key, then an asset is tag with +a key and an option value. Tags can be queried later to filter assets +and also show up on usage report if so desired. +""" +def __init__(self, asset_type, asset_id, asset_name, + datacenter, key, value): +""" +Initialize an instance of :class:`DimensionDataTag` + +:param asset_type: The type of asset. Current asset types: + SERVER, VLAN, NETWORK_DOMAIN, CUSTOMER_IMAGE, + PUBLIC_IP_BLOCK, ACCOUNT +:type asset_type: ``str`` + +:param asset_id: The GUID of the asset that is tagged +:type asset_id: ``str`` + +:param asset_name: The name of the asset that is tagged +:type asset_name: ``str`` + +:param datacenter: The short datacenter name of the tagged asset +:type datacenter: ``str`` + +:param key: The tagged key +:type key: :class:`DimensionDataTagKey` + +:param value: The tagged value +:type value: ``None`` or ``str`` +""" +self.asset_type = asset_type +self.asset_id = asset_id +self.asset_name = asset_name +self.datacenter = datacenter +self.key = key +self.value = value + +def __repr__(self): +return (('') +% (self.asset_name, self.key.name, self.value)) + + +class DimensionDataTagKey(object): +""" +A representation of a Tag Key in Dimension Data +A tag key is required to tag an asset +""" +def __init__(self, id, name, description, + value_required, display_on_report): +""" +Initialize an instance of :class:`DimensionDataTagKey` + +:param id: GUID of the tag key +:type id: ``str`` + +:param name: Name of the tag key +:type name: ``str`` + +
[1/3] libcloud git commit: azure_blobs.py: Apply lxml ElementTree import pattern properly
Repository: libcloud Updated Branches: refs/heads/trunk e6a6676a5 -> 0789cb58d azure_blobs.py: Apply lxml ElementTree import pattern properly Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1588cc73 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1588cc73 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1588cc73 Branch: refs/heads/trunk Commit: 1588cc738ce472c329f1bba81bdef5ca977e9d64 Parents: 3a20e92 Author: Peter SchmidtAuthored: Fri Apr 22 22:45:31 2016 +1000 Committer: anthony-shaw Committed: Sat Apr 23 13:13:17 2016 +1000 -- libcloud/storage/drivers/azure_blobs.py | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/1588cc73/libcloud/storage/drivers/azure_blobs.py -- diff --git a/libcloud/storage/drivers/azure_blobs.py b/libcloud/storage/drivers/azure_blobs.py index 13d42f6..4e10df6 100644 --- a/libcloud/storage/drivers/azure_blobs.py +++ b/libcloud/storage/drivers/azure_blobs.py @@ -19,7 +19,10 @@ import base64 import os import binascii -from xml.etree.ElementTree import Element, SubElement +try: +from lxml import etree as ET +except ImportError: +from xml.etree import ElementTree as ET from libcloud.utils.py3 import PY3 from libcloud.utils.py3 import httplib @@ -693,10 +696,10 @@ class AzureBlobsStorageDriver(StorageDriver): :type upload_id: ``list`` """ -root = Element('BlockList') +root = ET.Element('BlockList') for block_id in chunks: -part = SubElement(root, 'Uncommitted') +part = ET.SubElement(root, 'Uncommitted') part.text = str(block_id) data = tostring(root)
libcloud git commit: PY3: Reduce AWS S3 test errors if lxml is present
Repository: libcloud Updated Branches: refs/heads/trunk 77afd30dc -> e6a6676a5 PY3: Reduce AWS S3 test errors if lxml is present At least lxml should raise ValueError pretty quickly if self.body is a str type, and it was almost certainly assumed to be 'utf-8', this being the web, so we'll pay the price of the decode & encode on the production happy path to get a probable overall speedup from lxml. http://lxml.de/performance.html Seems cleaner than alternate approaches like trying to inject an additional Response.content attribute to work with the Python 3 bytes type or changing the response.body to a bytes type (causes JSON tests to break). e.g. See https://github.com/apache/libcloud/pull/767 I don't have an aliyun.py, etc driver to test against so don't feel comfortable changing that though happy for others to do so. In my local Python 3.5+lxml virtualenv, running "python setup.py test": BEFORE -- Ran 5439 tests in 24.415s FAILED (failures=4, errors=595, skipped=14) AFTER -- Ran 5439 tests in 27.036s FAILED (failures=4, errors=176, skipped=14) Closes #769 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e6a6676a Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e6a6676a Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e6a6676a Branch: refs/heads/trunk Commit: e6a6676a5753569541b914cae614819113a8b042 Parents: 77afd30 Author: Peter SchmidtAuthored: Wed Apr 20 16:33:37 2016 +1000 Committer: anthony-shaw Committed: Sat Apr 23 13:11:09 2016 +1000 -- libcloud/common/base.py | 6 +- libcloud/test/storage/test_s3.py | 6 +- 2 files changed, 10 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/e6a6676a/libcloud/common/base.py -- diff --git a/libcloud/common/base.py b/libcloud/common/base.py index bda758b..318d28e 100644 --- a/libcloud/common/base.py +++ b/libcloud/common/base.py @@ -270,7 +270,11 @@ class XmlResponse(Response): return self.body try: -body = ET.XML(self.body) +try: +body = ET.XML(self.body) +except ValueError: +# lxml wants a bytes and tests are basically hard-coded to str +body = ET.XML(self.body.encode('utf-8')) except: raise MalformedResponseError('Failed to parse XML', body=self.body, http://git-wip-us.apache.org/repos/asf/libcloud/blob/e6a6676a/libcloud/test/storage/test_s3.py -- diff --git a/libcloud/test/storage/test_s3.py b/libcloud/test/storage/test_s3.py index 2a6e873..af44f6d 100644 --- a/libcloud/test/storage/test_s3.py +++ b/libcloud/test/storage/test_s3.py @@ -338,7 +338,11 @@ class S3MockRawResponse(MockRawResponse): return self.body try: -body = ET.XML(self.body) +try: +body = ET.XML(self.body) +except ValueError: +# lxml wants a bytes and tests are basically hard-coded to str +body = ET.XML(self.body.encode('utf-8')) except: raise MalformedResponseError("Failed to parse XML", body=self.body,
[GitHub] libcloud pull request: PY3: Reduce AWS S3 test errors if lxml is p...
Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/769 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[jira] [Commented] (LIBCLOUD-811) GoDaddy driver mishandling shopper ID parameter
[ https://issues.apache.org/jira/browse/LIBCLOUD-811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15255100#comment-15255100 ] ASF GitHub Bot commented on LIBCLOUD-811: - Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/770 > GoDaddy driver mishandling shopper ID parameter > --- > > Key: LIBCLOUD-811 > URL: https://issues.apache.org/jira/browse/LIBCLOUD-811 > Project: Libcloud > Issue Type: Bug > Components: DNS > Environment: This has been tested with following operating systems > and Python versions: > Windows 7: Python 2.7 and Python 3.0 > Linux: Python 2.7 >Reporter: Teemu Vesala > > GoDaddy driver is not able to do any action because it sets the > 'X-Shopper-Id' header to 'True'. After that all requests to GoDaddy API are > resulting: > {"code":"NOT_FOUND","message":"Resource not found","name":"ApiError"} > Log output from driver.list_zones(): > # begin 3069020076 request -- > curl -i -X GET -H 'Host: api.godaddy.com' -H 'X-Shopper-Id: True' -H > 'Accept-Encoding: gzip,deflate' -H 'X-LC-Request-ID: 3069020076' -H > 'Authorization: sso-key ACCESS KEY:SECRET KEY' -H 'User-Agent: > libcloud/1.0.0-rc2 (GoDaddy DNS) ' --compress > https://api.godaddy.com:443/v1/domains/ > # begin 3069020076:3069040908 response -- > HTTP/1.1 404 Not Found > Via: 1.1 api.godaddy.com > X-Powered-By: Express > Transfer-Encoding: chunked > Vary: Origin,Accept-Encoding > Connection: close > Etag: W/"45-K7cRahIguKtXFPRJXsuOkg" > Access-Control-Allow-Credentials: true > Date: Wed, 20 Apr 2016 06:51:54 GMT > Content-Type: application/json; charset=utf-8 > 45 > {"code":"NOT_FOUND","message":"Resource not found","name":"ApiError"} > 0 > # end 3069020076:3069040908 response -- -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[2/2] libcloud git commit: If shopper_id is set to None, then the X-shopper-id header is not submitted to GoDaddy at all. Closes #770
If shopper_id is set to None, then the X-shopper-id header is not submitted to GoDaddy at all. Closes #770 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/77afd30d Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/77afd30d Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/77afd30d Branch: refs/heads/trunk Commit: 77afd30dc0399e7117b84ca0f2b9f8b5a39de86d Parents: a1ca65d Author: Teemu VesalaAuthored: Thu Apr 21 19:26:31 2016 + Committer: anthony-shaw Committed: Sat Apr 23 13:06:44 2016 +1000 -- libcloud/dns/drivers/godaddy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/77afd30d/libcloud/dns/drivers/godaddy.py -- diff --git a/libcloud/dns/drivers/godaddy.py b/libcloud/dns/drivers/godaddy.py index 62f2b6d..62c21d6 100644 --- a/libcloud/dns/drivers/godaddy.py +++ b/libcloud/dns/drivers/godaddy.py @@ -87,7 +87,8 @@ class GoDaddyDNSConnection(ConnectionKey): self.shopper_id = shopper_id def add_default_headers(self, headers): -headers['X-Shopper-Id'] = self.shopper_id +if self.shopper_id is not None: +headers['X-Shopper-Id'] = self.shopper_id headers['Authorization'] = "sso-key %s:%s" % \ (self.key, self.secret) return headers
[GitHub] libcloud pull request: [LIBCLOUD-811] Fix to mishandled shopper_id...
Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/770 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[1/2] libcloud git commit: Added the _ex_connection_class_kwargs way to handle dynamic parametrs at GoDaddyDNSDriver.
Repository: libcloud Updated Branches: refs/heads/trunk 988e3bf32 -> 77afd30dc Added the _ex_connection_class_kwargs way to handle dynamic parametrs at GoDaddyDNSDriver. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a1ca65d5 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a1ca65d5 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a1ca65d5 Branch: refs/heads/trunk Commit: a1ca65d5f4c356098bb89724dace6b5f837be7e5 Parents: 988e3bf Author: Teemu VesalaAuthored: Wed Apr 20 11:44:11 2016 + Committer: anthony-shaw Committed: Sat Apr 23 13:06:43 2016 +1000 -- libcloud/dns/drivers/godaddy.py | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/a1ca65d5/libcloud/dns/drivers/godaddy.py -- diff --git a/libcloud/dns/drivers/godaddy.py b/libcloud/dns/drivers/godaddy.py index 1a18e3a..62f2b6d 100644 --- a/libcloud/dns/drivers/godaddy.py +++ b/libcloud/dns/drivers/godaddy.py @@ -71,7 +71,7 @@ class GoDaddyDNSConnection(ConnectionKey): allow_insecure = False -def __init__(self, key, secret, shopper_id, secure=True, host=None, +def __init__(self, key, secret, secure=True, shopper_id=None, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None): super(GoDaddyDNSConnection, self).__init__( @@ -130,6 +130,7 @@ class GoDaddyDNSDriver(DNSDriver): :param secret: Your access key secret :type secret: ``str`` """ +self.shopper_id = shopper_id super(GoDaddyDNSDriver, self).__init__(key=key, secret=secret, secure=secure, host=host, port=port, @@ -469,6 +470,9 @@ class GoDaddyDNSDriver(DNSDriver): def _get_id_of_record(self, name, type): return '%s:%s' % (name, type) +def _ex_connection_class_kwargs(self): +return {'shopper_id': self.shopper_id} + class GoDaddyAvailability(object): def __init__(self, domain, available, price, currency, period):
libcloud git commit: Update patch script
Repository: libcloud Updated Branches: refs/heads/trunk 3dcb4cfdb -> 988e3bf32 Update patch script Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/988e3bf3 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/988e3bf3 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/988e3bf3 Branch: refs/heads/trunk Commit: 988e3bf32b3619d72b93f12a5316b9309d40dcb9 Parents: 3dcb4cf Author: anthony-shawAuthored: Sat Apr 23 13:05:08 2016 +1000 Committer: anthony-shaw Committed: Sat Apr 23 13:05:08 2016 +1000 -- contrib/apply-patch.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/988e3bf3/contrib/apply-patch.ps1 -- diff --git a/contrib/apply-patch.ps1 b/contrib/apply-patch.ps1 index aa99dc5..ecc0c35 100644 --- a/contrib/apply-patch.ps1 +++ b/contrib/apply-patch.ps1 @@ -5,5 +5,5 @@ git checkout trunk Invoke-WebRequest https://patch-diff.githubusercontent.com/raw/apache/libcloud/pull/${pull_request}.patch -OutFile ${env:temp}/${pull_request}.patch git am ${env:temp}/${pull_request}.patch $last_message = git log -1 --pretty=%B -$new_message = $last_message+"\n Closes ${pull_request}" -git commit --amend -m $new_message +$new_message = $last_message+" Closes #${pull_request}" +git commit --amend -m "${new_message}"
[GitHub] libcloud pull request: Adding tagging feature to DimensionDataNode...
GitHub user jadunham1 opened a pull request: https://github.com/apache/libcloud/pull/773 Adding tagging feature to DimensionDataNodeDriver ## Adding Tagging features to DimensionDataNodeDriver ### Description This is adding the tagging features. There is still more nice to haves, but this will give the core functionallity of: Creating Tag Keys Modifying Tag Keys Deleting Tag Keys Listing Tag Keys Creating Tags on an Asset Delete Tags on an Asset Listing Tags ### Status Ready for review ### Checklist (tick everything that applies) - [ ] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide) (required, can be done after the PR checks) - [ ] Documentation - [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html) - [ ] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes) (required for bigger changes) You can merge this pull request into a Git repository by running: $ git pull https://github.com/jadunham1/libcloud feature/dd_tagging Alternatively you can review and apply these changes as the patch at: https://github.com/apache/libcloud/pull/773.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #773 commit d797dc74cd7968a6ff88d8791903b84f139a6f2f Author: Jeffrey DunhamDate: 2016-04-22T23:51:27Z Adding tagging feature to DimensionDataNodeDriver --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] libcloud pull request: Fix most Python 2 lxml tests
GitHub user pzrq opened a pull request: https://github.com/apache/libcloud/pull/772 Fix most Python 2 lxml tests ## Fix libcloud + lxml tests under Python 2.x (ex. vcloud) ### Description Travis will hopefully confirm this improves the Python 2.x lxml tests from: `FAILED (failures=1, errors=52, skipped=14)` To: `FAILED (failures=1, errors=9, skipped=14)` I spent an hour trying to understand VCloud's XML builder but it's just a bit complicated for me at this time, which is all that's left to fix under Python 2.7 for me at least. If I can make time to figure it out I'll create another PR. Context Hopefully #769 gets a better chance of going through or getting some feedback so Mathspace isn't forced to switch to boto3, this being our third cloud provider in the last year (long story) which theoretically at least makes sticking with libcloud very attractive as long as we can get it working under Python 3, preferably without forking it. ### Status - done, ready for review ### Checklist (tick everything that applies) - [ ] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide) (required, can be done after the PR checks) - [ ] Documentation - [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html) - [ ] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes) (required for bigger changes) You can merge this pull request into a Git repository by running: $ git pull https://github.com/mathspace/libcloud py2-lxml Alternatively you can review and apply these changes as the patch at: https://github.com/apache/libcloud/pull/772.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #772 commit c8761e6a257a999aef2b5e117bd82e6689d3e877 Author: Peter SchmidtDate: 2016-04-22T12:00:44Z abiquo.py: Apply lxml ElementTree import pattern properly commit fe7c5ee2da5461d7570363efd4221c6fbdc6cce0 Author: Peter Schmidt Date: 2016-04-22T12:45:31Z azure_blobs.py: Apply lxml ElementTree import pattern properly commit 0f322dfa4e4dd5b2a0e991cc4778d2d1e5a9088c Author: Peter Schmidt Date: 2016-04-22T13:11:53Z profitbricks.py: Figure out a pattern that works with xml + lxml --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---