[GitHub] libcloud pull request #822: Lazy entry
GitHub user tonybaloney opened a pull request: https://github.com/apache/libcloud/pull/822 Lazy entry ## Introduce a convenience method to the libcloud module for getting drivers ### Description I find the current mechanism for fetching drivers a little cumbersome, 2 namespaces to import. After using the `requests` library I really like the module `__init__` accessors for common attributes. The most common factory is `get_driver` and the most common enum is the Provider enum. This code allows for this example: ```python import libcloud cls = libcloud.get_driver(libcloud.DriverType.COMPUTE, libcloud.DriverType.COMPUTE.RACKSPACE) ``` ### 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/tonybaloney/libcloud lazy_entry Alternatively you can review and apply these changes as the patch at: https://github.com/apache/libcloud/pull/822.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 #822 commit f33df13476b6a3a0db5e3dc448c7d7c266abead2 Author: Anthony ShawDate: 2016-06-24T05:18:29Z added lazy entry commit 93d387006d0eb5a1a194098aa480809d2d7baa03 Author: Anthony Shaw Date: 2016-06-24T05:53:31Z added doc example and test --- 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 #799: refactored _parse_arp_table
Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/799 --- 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. ---
[3/5] libcloud git commit: refactored _parse_arp_table
refactored _parse_arp_table split _parse_arp_table into 1 general and 2 specialized functions Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/fa63096a Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/fa63096a Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/fa63096a Branch: refs/heads/trunk Commit: fa63096af079ff39873d7b62c3da8b93aab9d617 Parents: 20c924b Author: Rene KjellerupAuthored: Fri Jun 3 17:02:19 2016 -0700 Committer: Anthony Shaw Committed: Fri Jun 24 14:27:46 2016 +1000 -- libcloud/compute/drivers/libvirt_driver.py | 39 ++--- 1 file changed, 28 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/fa63096a/libcloud/compute/drivers/libvirt_driver.py -- diff --git a/libcloud/compute/drivers/libvirt_driver.py b/libcloud/compute/drivers/libvirt_driver.py index c8a6a7c..9d4e1a0 100644 --- a/libcloud/compute/drivers/libvirt_driver.py +++ b/libcloud/compute/drivers/libvirt_driver.py @@ -306,15 +306,14 @@ class LibvirtNodeDriver(NodeDriver): child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, _ = child.communicate() -arp_table = self._parse_arp_table(arp_output=stdout) +arp_table = self._parse_ip_table_arp(arp_output=stdout) except OSError as e: if e.errno == 2: cmd = ['ip', 'neigh'] child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, _ = child.communicate() -arp_table = self._parse_arp_table(arp_output=stdout, - arp_cmd='ip') +arp_table = self._parse_ip_table_neigh(arp_output=stdout) for mac_address in mac_addresses: if mac_address in arp_table: @@ -361,23 +360,41 @@ class LibvirtNodeDriver(NodeDriver): return result -def _parse_arp_table(self, arp_output, arp_cmd='arp'): +def _parse_ip_table_arp(self, arp_output): """ -Parse arp command output and return a dictionary which maps mac address +Sets up the regexp for parsing out IP addresses from the 'arp -an' +command and pass it along to the parser function. + +:return: Dictionary from the parsing funtion +:rtype: ``dict`` +""" +arp_regex = re.compile('.*?\((.*?)\) at (.*?)\s+') +return self._parse_mac_addr_table(arp_output, arp_regex) + +def _parse_ip_table_neigh(self, ip_output): +""" +Sets up the regexp for parsing out IP addresses from the 'ip neighbor' +command and pass it along to the parser function. + +:return: Dictionary from the parsing funtion +:rtype: ``dict`` +""" +ip_regex = re.compile('(.*?)\s+.*lladdr\s+(.*?)\s+') +return self._parse_mac_addr_table(ip_output, ip_regex) + +def _parse_mac_addr_table(self, cmd_output, mac_regex): +""" +Parse the command output and return a dictionary which maps mac address to an IP address. :return: Dictionary which maps mac address to IP address. :rtype: ``dict`` """ -re_match = {} -re_match['arp'] = '.*?\((.*?)\) at (.*?)\s+' -re_match['ip'] = '(.*?)\s+.*lladdr\s+(.*?)\s+' -ip_mac = re.compile(re_match[arp_cmd]) -lines = arp_output.split('\n') +lines = cmd_output.split('\n') arp_table = defaultdict(list) for line in lines: -match = ip_mac.match(line) +match = mac_regex.match(line) if not match: continue
[4/5] libcloud git commit: adding tests for libvirt
adding tests for libvirt Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/fff60870 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/fff60870 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/fff60870 Branch: refs/heads/trunk Commit: fff608705e0bb7ad3ecd419e79f7a69f0cb2c559 Parents: fa63096 Author: Rene KjellerupAuthored: Wed Jun 15 17:15:21 2016 -0700 Committer: Anthony Shaw Committed: Fri Jun 24 14:27:46 2016 +1000 -- libcloud/test/compute/test_libvirt_driver.py | 59 +++ 1 file changed, 59 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/fff60870/libcloud/test/compute/test_libvirt_driver.py -- diff --git a/libcloud/test/compute/test_libvirt_driver.py b/libcloud/test/compute/test_libvirt_driver.py new file mode 100644 index 000..b6175fd --- /dev/null +++ b/libcloud/test/compute/test_libvirt_driver.py @@ -0,0 +1,59 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys + +from libcloud.compute.drivers.libvirt_driver import LibvirtNodeDriver + + +from libcloud.test import unittest + + +class LibvirtNodeDriverTestCase( unittest.TestCase): + + +def setUp(self): +self.driver = LibvirtNodeDriver('') + +def _assert_arp_table(self, arp_table): +self.assertIn('52:54:00:bc:f9:6c', arp_table) +self.assertIn('52:54:00:04:89:51', arp_table) +self.assertIn('52:54:00:c6:40:ec', arp_table) +self.assertIn('52:54:00:77:1c:83', arp_table) +self.assertEqual(arp_table['52:54:00:bc:f9:6c'], '1.2.10.80') +self.assertEqual(arp_table['52:54:00:04:89:51'], '1.2.10.33') +self.assertEqual(arp_table['52:54:00:c6:40:ec'], '1.2.10.97') +self.assertEqual(arp_table['52:54:00:77:1c:83'], '1.2.10.40') + +def test_arp_map(self): +arp_output_str = """? (1.2.10.80) at 52:54:00:bc:f9:6c [ether] on br0 +? (1.2.10.33) at 52:54:00:04:89:51 [ether] on br0 +? (1.2.10.97) at 52:54:00:c6:40:ec [ether] on br0 +? (1.2.10.40) at 52:54:00:77:1c:83 [ether] on br0 +""" +arp_table = self.driver._parse_ip_table_arp(arp_output_str) +self._assert_arp_table(arp_table) + +def test_ip_map(self): +arp_output_str = """1.2.10.80 dev br0 lladdr 52:54:00:bc:f9:6c STALE +1.2.10.33 dev br0 lladdr 52:54:00:04:89:51 REACHABLE +1.2.10.97 dev br0 lladdr 52:54:00:c6:40:ec DELAY +1.2.10.40 dev br0 lladdr 52:54:00:77:1c:83 STALE +""" +arp_table = self.driver._parse_ip_table_neigh(arp_output_str) +self._assert_arp_table(arp_table) + +if __name__ == '__main__': +sys.exit(unittest.main())
[2/5] libcloud git commit: fixed the 2 testcases I know about, and got a working test
fixed the 2 testcases I know about, and got a working test Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8cab1104 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8cab1104 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8cab1104 Branch: refs/heads/trunk Commit: 8cab11040e4d0f9ca25dbbc74032a3b783919063 Parents: fff6087 Author: René KjellerupAuthored: Thu Jun 16 00:01:42 2016 -0700 Committer: Anthony Shaw Committed: Fri Jun 24 14:27:46 2016 +1000 -- libcloud/test/compute/test_libvirt_driver.py | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/8cab1104/libcloud/test/compute/test_libvirt_driver.py -- diff --git a/libcloud/test/compute/test_libvirt_driver.py b/libcloud/test/compute/test_libvirt_driver.py index b6175fd..7b2d275 100644 --- a/libcloud/test/compute/test_libvirt_driver.py +++ b/libcloud/test/compute/test_libvirt_driver.py @@ -21,21 +21,21 @@ from libcloud.compute.drivers.libvirt_driver import LibvirtNodeDriver from libcloud.test import unittest -class LibvirtNodeDriverTestCase( unittest.TestCase): - - -def setUp(self): -self.driver = LibvirtNodeDriver('') +class LibvirtNodeDriverTestCase(LibvirtNodeDriver, unittest.TestCase): +def __init__(self, argv=None): +unittest.TestCase.__init__(self,argv) +self._uri = 'qemu:///system' +self.connection = None def _assert_arp_table(self, arp_table): self.assertIn('52:54:00:bc:f9:6c', arp_table) self.assertIn('52:54:00:04:89:51', arp_table) self.assertIn('52:54:00:c6:40:ec', arp_table) self.assertIn('52:54:00:77:1c:83', arp_table) -self.assertEqual(arp_table['52:54:00:bc:f9:6c'], '1.2.10.80') -self.assertEqual(arp_table['52:54:00:04:89:51'], '1.2.10.33') -self.assertEqual(arp_table['52:54:00:c6:40:ec'], '1.2.10.97') -self.assertEqual(arp_table['52:54:00:77:1c:83'], '1.2.10.40') +self.assertIn('1.2.10.80', arp_table['52:54:00:bc:f9:6c']) +self.assertIn('1.2.10.33', arp_table['52:54:00:04:89:51']) +self.assertIn('1.2.10.97', arp_table['52:54:00:c6:40:ec']) +self.assertIn('1.2.10.40', arp_table['52:54:00:77:1c:83']) def test_arp_map(self): arp_output_str = """? (1.2.10.80) at 52:54:00:bc:f9:6c [ether] on br0 @@ -43,7 +43,7 @@ class LibvirtNodeDriverTestCase( unittest.TestCase): ? (1.2.10.97) at 52:54:00:c6:40:ec [ether] on br0 ? (1.2.10.40) at 52:54:00:77:1c:83 [ether] on br0 """ -arp_table = self.driver._parse_ip_table_arp(arp_output_str) +arp_table = self._parse_ip_table_arp(arp_output_str) self._assert_arp_table(arp_table) def test_ip_map(self): @@ -52,7 +52,7 @@ class LibvirtNodeDriverTestCase( unittest.TestCase): 1.2.10.97 dev br0 lladdr 52:54:00:c6:40:ec DELAY 1.2.10.40 dev br0 lladdr 52:54:00:77:1c:83 STALE """ -arp_table = self.driver._parse_ip_table_neigh(arp_output_str) +arp_table = self._parse_ip_table_neigh(arp_output_str) self._assert_arp_table(arp_table) if __name__ == '__main__':
[5/5] libcloud git commit: Added a mock virConnect class
Added a mock virConnect class in this I took all the functions defined on a libvirt.virConnect class and added them to the class as a stub function. the stub function will take any number of arguments and return 0 making creation and API calls super fast ;) for testing purposes and we can add correct Mocking behavior later. Closes #799 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/d960e651 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/d960e651 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/d960e651 Branch: refs/heads/trunk Commit: d960e651f30546a69f1dd2606908df6ef16745d1 Parents: a6c828c Author: Rene KjellerupAuthored: Fri Jun 17 16:29:58 2016 -0700 Committer: Anthony Shaw Committed: Fri Jun 24 14:28:02 2016 +1000 -- libcloud/test/compute/test_libvirt_driver.py | 142 +- 1 file changed, 141 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/d960e651/libcloud/test/compute/test_libvirt_driver.py -- diff --git a/libcloud/test/compute/test_libvirt_driver.py b/libcloud/test/compute/test_libvirt_driver.py index 2e3179f..2993ebd 100644 --- a/libcloud/test/compute/test_libvirt_driver.py +++ b/libcloud/test/compute/test_libvirt_driver.py @@ -21,11 +21,151 @@ from libcloud.compute.drivers.libvirt_driver import LibvirtNodeDriver from libcloud.test import unittest +class virConnect: +""" +A stub/Mock implementation of the libvirt.virConnect class returned by +the libvirt.openX calles +""" +def stub(self, *args, **kwargs): +return 0 + +def __init__(self): +stub = self.stub +fnt = [ +'_dispatchCloseCallback', +'_dispatchDomainEventAgentLifecycleCallback', +'_dispatchDomainEventBalloonChangeCallback', +'_dispatchDomainEventBlockJobCallback', +'_dispatchDomainEventCallbacks', +'_dispatchDomainEventDeviceAddedCallback', +'_dispatchDomainEventDeviceRemovalFailedCallback', +'_dispatchDomainEventDeviceRemovedCallback', +'_dispatchDomainEventDiskChangeCallback', +'_dispatchDomainEventGenericCallback', +'_dispatchDomainEventGraphicsCallback', +'_dispatchDomainEventIOErrorCallback', +'_dispatchDomainEventIOErrorReasonCallback', +'_dispatchDomainEventJobCompletedCallback', +'_dispatchDomainEventLifecycleCallback', +'_dispatchDomainEventMigrationIterationCallback', +'_dispatchDomainEventPMSuspendCallback', +'_dispatchDomainEventPMSuspendDiskCallback', +'_dispatchDomainEventPMWakeupCallback', +'_dispatchDomainEventRTCChangeCallback', +'_dispatchDomainEventTrayChangeCallback', +'_dispatchDomainEventTunableCallback', +'_dispatchDomainEventWatchdogCallback', +'_dispatchNetworkEventLifecycleCallback', +'_o', 'allocPages', 'baselineCPU', 'c_pointer', 'changeBegin', +'changeCommit', 'changeRollback', 'close', 'compareCPU', +'createLinux', 'createXML', 'createXMLWithFiles', 'defineXML', +'defineXMLFlags', 'domainEventDeregister', +'domainEventDeregisterAny', 'domainEventRegister', +'domainEventRegisterAny', 'domainListGetStats', +'domainXMLFromNative', 'domainXMLToNative', +'findStoragePoolSources', 'getAllDomainStats', 'getCPUMap', +'getCPUModelNames', 'getCPUStats', 'getCapabilities', +'getCellsFreeMemory', +'getDomainCapabilities', +'getFreeMemory', +'getFreePages', +'getHostname', +'getInfo', +'getLibVersion', +'getMaxVcpus', +'getMemoryParameters', +'getMemoryStats', +'getSecurityModel', +'getSysinfo', +'getType', +'getURI', +'getVersion', +'interfaceDefineXML', +'interfaceLookupByMACString', +'interfaceLookupByName', +'isAlive', +'isEncrypted', +'isSecure', +'listAllDevices', +'listAllDomains', +'listAllInterfaces', +'listAllNWFilters', +'listAllNetworks', +'listAllSecrets', +'listAllStoragePools', +'listDefinedDomains', +'listDefinedInterfaces', +'listDefinedNetworks', +'listDefinedStoragePools', +'listDevices', +'listDomainsID', +'listInterfaces', +
[3/6] libcloud git commit: Implement {attach, detach}_volume for DigitalOcean
Implement {attach,detach}_volume for DigitalOcean Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a796810a Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a796810a Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a796810a Branch: refs/heads/trunk Commit: a796810a138eaade2808dba78529e56ec20e33e4 Parents: cbda630 Author: Adam Wolfe GordonAuthored: Mon Jun 6 15:13:07 2016 -0400 Committer: Anthony Shaw Committed: Fri Jun 24 14:15:16 2016 +1000 -- libcloud/compute/drivers/digitalocean.py | 44 +++ 1 file changed, 44 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/a796810a/libcloud/compute/drivers/digitalocean.py -- diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py index e73d6ad..aefa099 100644 --- a/libcloud/compute/drivers/digitalocean.py +++ b/libcloud/compute/drivers/digitalocean.py @@ -584,6 +584,50 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver, method='DELETE') return res.status == httplib.NO_CONTENT +def attach_volume(self, node, volume, device=None): +""" +Attaches volume to node. + +:param node: Node to attach volume to. +:type node: :class:`.Node` + +:param volume: Volume to attach. +:type volume: :class:`.StorageVolume` + +:param device: Where the device is exposed, e.g. '/dev/sdb' +:type device: ``str`` + +:rytpe: ``bool`` +""" +attr = {'type': 'attach', 'droplet_id': node.id, +'volume_id': volume.id, 'region': volume.extra['region_slug']} + +res = self.connection.request('/v2/volumes/actions', + data=json.dumps(attr), method='POST') + +return res.status == httplib.ACCEPTED + +def detach_volume(self, volume): +""" +Detaches a volume from a node. + +:param volume: Volume to be detached +:type volume: :class:`.StorageVolume` + +:rtype: ``bool`` +""" +attr = {'type': 'detach', 'volume_id': volume.id, +'region': volume.extra['region_slug']} + +responses = [] +for droplet_id in volume.extra['droplet_ids']: +attr['droplet_id'] = droplet_id +res = self.connection.request('/v2/volumes/actions', + data=json.dumps(attr), method='POST') +responses.append(res) + +return all([r.status == httplib.ACCEPTED for r in responses]) + def _to_node(self, data): extra_keys = ['memory', 'vcpus', 'disk', 'region', 'image', 'size_slug', 'locked', 'created_at', 'networks',
[2/6] libcloud git commit: Implement list_volumes for DigitalOcean
Implement list_volumes for DigitalOcean Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/71eb9565 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/71eb9565 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/71eb9565 Branch: refs/heads/trunk Commit: 71eb9565e1092dcf4468ee88692745868c3f2d44 Parents: 74a2ce7 Author: Adam Wolfe GordonAuthored: Mon Jun 6 15:12:23 2016 -0400 Committer: Anthony Shaw Committed: Fri Jun 24 14:15:16 2016 +1000 -- libcloud/compute/drivers/digitalocean.py | 15 +++ 1 file changed, 15 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/71eb9565/libcloud/compute/drivers/digitalocean.py -- diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py index 0428cbb..f326bca 100644 --- a/libcloud/compute/drivers/digitalocean.py +++ b/libcloud/compute/drivers/digitalocean.py @@ -27,6 +27,7 @@ from libcloud.common.types import InvalidCredsError from libcloud.compute.types import Provider, NodeState from libcloud.compute.base import NodeImage, NodeSize, NodeLocation, KeyPair from libcloud.compute.base import Node, NodeDriver +from libcloud.compute.base import StorageVolume __all__ = [ 'DigitalOceanNodeDriver', @@ -352,6 +353,10 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver, data = self._paginated_request('/v2/sizes', 'sizes') return list(map(self._to_size, data)) +def list_volumes(self): +data = self._paginated_request('/v2/volumes', 'volumes') +return list(map(self._to_volume, data)) + def create_node(self, name, size, image, location, ex_create_attr=None, ex_ssh_key_ids=None, ex_user_data=None): """ @@ -571,6 +576,16 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver, return NodeImage(id=data['id'], name=data['name'], driver=self, extra=extra) +def _to_volume(self, data): +extra = {'created_at': data['created_at'], + 'droplet_ids': data['droplet_ids'], + 'region': data['region'], + 'region_slug': data['region']['slug']} + +return StorageVolume(id=data['id'], name=data['name'], + size=data['size_gigabytes'], driver=self, + extra=extra) + def _to_location(self, data): return NodeLocation(id=data['slug'], name=data['name'], country=None, driver=self)
[6/6] libcloud git commit: update changes for #807
update changes for #807 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/20c924bf Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/20c924bf Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/20c924bf Branch: refs/heads/trunk Commit: 20c924bf1ba67322edd3404016babe6c0e45a62c Parents: f1c2361 Author: Anthony ShawAuthored: Fri Jun 24 14:17:03 2016 +1000 Committer: Anthony Shaw Committed: Fri Jun 24 14:17:03 2016 +1000 -- CHANGES.rst | 4 1 file changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/20c924bf/CHANGES.rst -- diff --git a/CHANGES.rst b/CHANGES.rst index 1e27a32..faa4f22 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,10 @@ Changes with current version of Apache Libcloud Compute ~~~ +- Add block storage support to DigitalOcean node driver + (GITHUB-807) + [Adam Wolfe Gordon] + - Add SASL auth support to libvirt driver (GITHUB-809) [Katana-Steel]
[1/6] libcloud git commit: Add tests for storage-related operations on the DigitalOcean driver
Repository: libcloud Updated Branches: refs/heads/trunk 74a2ce762 -> 20c924bf1 Add tests for storage-related operations on the DigitalOcean driver Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e450d9ee Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e450d9ee Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e450d9ee Branch: refs/heads/trunk Commit: e450d9eeb6bcc713dc61a1e02033637978764b02 Parents: a796810 Author: Adam Wolfe GordonAuthored: Mon Jun 6 17:26:04 2016 -0400 Committer: Anthony Shaw Committed: Fri Jun 24 14:15:16 2016 +1000 -- .../fixtures/digitalocean_v2/attach_volume.json | 34 ++ .../fixtures/digitalocean_v2/create_volume.json | 32 + .../fixtures/digitalocean_v2/detach_volume.json | 34 ++ .../fixtures/digitalocean_v2/list_volumes.json | 38 +++ .../digitalocean_v2/list_volumes_empty.json | 7 ++ libcloud/test/compute/test_digitalocean_v2.py | 69 6 files changed, 214 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/fixtures/digitalocean_v2/attach_volume.json -- diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/attach_volume.json b/libcloud/test/compute/fixtures/digitalocean_v2/attach_volume.json new file mode 100644 index 000..398bca0 --- /dev/null +++ b/libcloud/test/compute/fixtures/digitalocean_v2/attach_volume.json @@ -0,0 +1,34 @@ +{ + "action": { +"region_slug": "nyc1", +"region": { + "available": true, + "features": [ +"private_networking", +"backups", +"ipv6", +"metadata" + ], + "sizes": [ +"512mb", +"1gb", +"2gb", +"4gb", +"8gb", +"16gb", +"32gb", +"48gb", +"64gb" + ], + "slug": "nyc1", + "name": "New York 1" +}, +"resource_type": "backend", +"resource_id": null, +"completed_at": null, +"started_at": "2016-06-06T21:01:30Z", +"type": "attach_volume", +"status": "in-progress", +"id": 110956293 + } +} http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/fixtures/digitalocean_v2/create_volume.json -- diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/create_volume.json b/libcloud/test/compute/fixtures/digitalocean_v2/create_volume.json new file mode 100644 index 000..dd336aa --- /dev/null +++ b/libcloud/test/compute/fixtures/digitalocean_v2/create_volume.json @@ -0,0 +1,32 @@ +{ + "volume": { +"created_at": "2016-06-06T20:51:04Z", +"size_gigabytes": 4, +"description": "Block store for examples", +"name": "example", +"droplet_ids": [], +"region": { + "available": true, + "features": [ +"private_networking", +"backups", +"ipv6", +"metadata" + ], + "sizes": [ +"512mb", +"1gb", +"2gb", +"4gb", +"8gb", +"16gb", +"32gb", +"48gb", +"64gb" + ], + "slug": "nyc1", + "name": "New York 1" +}, +"id": "62766883-2c28-11e6-b8e6-000f53306ae1" + } +} http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/fixtures/digitalocean_v2/detach_volume.json -- diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/detach_volume.json b/libcloud/test/compute/fixtures/digitalocean_v2/detach_volume.json new file mode 100644 index 000..9ef1c33 --- /dev/null +++ b/libcloud/test/compute/fixtures/digitalocean_v2/detach_volume.json @@ -0,0 +1,34 @@ +{ + "action": { +"region_slug": "nyc1", +"region": { + "available": true, + "features": [ +"private_networking", +"backups", +"ipv6", +"metadata" + ], + "sizes": [ +"512mb", +"1gb", +"2gb", +"4gb", +"8gb", +"16gb", +"32gb", +"48gb", +"64gb" + ], + "slug": "nyc1", + "name": "New York 1" +}, +"resource_type": "backend", +"resource_id": null, +"completed_at": null, +"started_at": "2016-06-06T21:02:20Z", +"type": "detach_volume", +"status": "in-progress", +"id": 110956599 + } +} http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes.json -- diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes.json
[5/6] libcloud git commit: Update docs to reflect that DigitalOcean has block storage Closes #807
Update docs to reflect that DigitalOcean has block storage Closes #807 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f1c23615 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f1c23615 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f1c23615 Branch: refs/heads/trunk Commit: f1c236154b34cb8c70f514adfdac9f53782d0cd8 Parents: e450d9e Author: Adam Wolfe GordonAuthored: Mon Jun 6 18:44:18 2016 -0400 Committer: Anthony Shaw Committed: Fri Jun 24 14:16:15 2016 +1000 -- docs/compute/_supported_methods_block_storage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/f1c23615/docs/compute/_supported_methods_block_storage.rst -- diff --git a/docs/compute/_supported_methods_block_storage.rst b/docs/compute/_supported_methods_block_storage.rst index d184c85..60a33c6 100644 --- a/docs/compute/_supported_methods_block_storage.rst +++ b/docs/compute/_supported_methods_block_storage.rst @@ -14,7 +14,7 @@ Provider list volumes create volume destroy volume `CloudSigma (API v2.0)`_ no nono nonono no `CloudStack`_ yes yes yes yes yes no yes `Cloudwatt`_ yes yes yes yes yes yesyes -`DigitalOcean`_ no nono nonono no +`DigitalOcean`_ yes yes yes yes yes no no `DimensionData`_ no nono nonono no `Amazon EC2`_ yes yes yes yes yes yesyes `Enomaly Elastic Computing Platform`_ no nono nonono no
[4/4] libcloud git commit: update changes for #809
update changes for #809 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/74a2ce76 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/74a2ce76 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/74a2ce76 Branch: refs/heads/trunk Commit: 74a2ce762b43c3911e7c3a8069db1b0e247bbf4a Parents: 00b70ef Author: Anthony ShawAuthored: Fri Jun 24 14:09:04 2016 +1000 Committer: Anthony Shaw Committed: Fri Jun 24 14:09:04 2016 +1000 -- CHANGES.rst | 4 1 file changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/74a2ce76/CHANGES.rst -- diff --git a/CHANGES.rst b/CHANGES.rst index 94cab51..1e27a32 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,10 @@ Changes with current version of Apache Libcloud Compute ~~~ +- Add SASL auth support to libvirt driver + (GITHUB-809) + [Katana-Steel] + - Allow VIPs in Dimension Data driver to bind to any port (GITHUB-818) [Mark Maglana]
[GitHub] libcloud pull request #809: Libvirt/include sasl auth
Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/809 --- 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/4] libcloud git commit: added documentation
Repository: libcloud Updated Branches: refs/heads/trunk a60e070a0 -> 74a2ce762 added documentation updated the constructor documentation and added description for the callback function. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9118eb53 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9118eb53 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9118eb53 Branch: refs/heads/trunk Commit: 9118eb533f1e788f325ed0065de6dcd461799fd1 Parents: 901ff36 Author: René KjellerupAuthored: Fri Jun 10 17:26:26 2016 -0700 Committer: Anthony Shaw Committed: Fri Jun 24 13:56:08 2016 +1000 -- libcloud/compute/drivers/libvirt_driver.py | 18 ++ 1 file changed, 18 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/9118eb53/libcloud/compute/drivers/libvirt_driver.py -- diff --git a/libcloud/compute/drivers/libvirt_driver.py b/libcloud/compute/drivers/libvirt_driver.py index 7216538..40ef0a9 100644 --- a/libcloud/compute/drivers/libvirt_driver.py +++ b/libcloud/compute/drivers/libvirt_driver.py @@ -68,6 +68,12 @@ class LibvirtNodeDriver(NodeDriver): :param uri: Hypervisor URI (e.g. vbox:///session, qemu:///system, etc.). :type uri: ``str`` + +:param key: the username for a remote libvirtd server +:type key: ``str`` + +:param secret: the password for a remote libvirtd server +:type key: ``str`` """ if not have_libvirt: raise RuntimeError('Libvirt driver requires \'libvirt\' Python ' + @@ -88,6 +94,18 @@ class LibvirtNodeDriver(NodeDriver): self.connection = libvirt.openAuth(uri, auth, 0) def _cred_callback(self, cred, user_data): +""" +Callback for the authentication scheme, which will provide username +and password for the login. Reference: ( http://bit.ly/1U5yyQg ) + +:param cred: The credentials requested and the return +:type cred: ``list`` + +:param user_data: Custom data provided to the authentication routine +:type user_data: ``list`` + +:rtype: ``int`` +""" for credential in cred: if credential[0] == libvirt.VIR_CRED_AUTHNAME: credential[4] = self._key
[2/4] libcloud git commit: Libvirt include sasl authentication setup
Libvirt include sasl authentication setup inlude sasl auth for uri='qemu+tcp:///system' to provide access to remote libvirtd servers providing user and pass authentication. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/901ff369 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/901ff369 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/901ff369 Branch: refs/heads/trunk Commit: 901ff369046d6ade2940f648b5ba295feed99339 Parents: a60e070 Author: Rene KjellerupAuthored: Wed Jun 8 23:53:10 2016 -0700 Committer: Anthony Shaw Committed: Fri Jun 24 13:56:08 2016 +1000 -- libcloud/compute/drivers/libvirt_driver.py | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/901ff369/libcloud/compute/drivers/libvirt_driver.py -- diff --git a/libcloud/compute/drivers/libvirt_driver.py b/libcloud/compute/drivers/libvirt_driver.py index 006a13b..7216538 100644 --- a/libcloud/compute/drivers/libvirt_driver.py +++ b/libcloud/compute/drivers/libvirt_driver.py @@ -63,7 +63,7 @@ class LibvirtNodeDriver(NodeDriver): 7: NodeState.UNKNOWN, # domain is suspended by guest power management } -def __init__(self, uri): +def __init__(self, uri, key=None, secret=None): """ :param uri: Hypervisor URI (e.g. vbox:///session, qemu:///system, etc.). @@ -74,7 +74,26 @@ class LibvirtNodeDriver(NodeDriver): 'package') self._uri = uri -self.connection = libvirt.open(uri) +self._key = key +self._secret = secret +try: +self.connection = libvirt.open(uri) +except libvirt.libvirtError: +if key is None or secret is None: +raise RuntimeError('The remote Libvirt instance requires ' + + 'authenication, please set \'key\' and ' + + '\'secret\' parameters') +auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], +self._cred_callback, None] +self.connection = libvirt.openAuth(uri, auth, 0) + +def _cred_callback(self, cred, user_data): +for credential in cred: +if credential[0] == libvirt.VIR_CRED_AUTHNAME: +credential[4] = self._key +elif credential[0] == libvirt.VIR_CRED_PASSPHRASE: +credential[4] = self._secret +return 0 def list_nodes(self): domains = self.connection.listAllDomains()
[3/4] libcloud git commit: typo fix Closes #809
typo fix Closes #809 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/00b70ef1 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/00b70ef1 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/00b70ef1 Branch: refs/heads/trunk Commit: 00b70ef1c582c98dcd387b2aa35ab26ccc48fc31 Parents: 9118eb5 Author: Rene KjellerupAuthored: Tue Jun 14 21:20:05 2016 -0700 Committer: Anthony Shaw Committed: Fri Jun 24 14:05:06 2016 +1000 -- libcloud/compute/drivers/libvirt_driver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/00b70ef1/libcloud/compute/drivers/libvirt_driver.py -- diff --git a/libcloud/compute/drivers/libvirt_driver.py b/libcloud/compute/drivers/libvirt_driver.py index 40ef0a9..c8a6a7c 100644 --- a/libcloud/compute/drivers/libvirt_driver.py +++ b/libcloud/compute/drivers/libvirt_driver.py @@ -87,7 +87,7 @@ class LibvirtNodeDriver(NodeDriver): except libvirt.libvirtError: if key is None or secret is None: raise RuntimeError('The remote Libvirt instance requires ' + - 'authenication, please set \'key\' and ' + + 'authentication, please set \'key\' and ' + '\'secret\' parameters') auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], self._cred_callback, None]
[8/8] libcloud git commit: update changes for #816
update changes for #816 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a60e070a Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a60e070a Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a60e070a Branch: refs/heads/trunk Commit: a60e070a0126026ab57b30b969ee869b73089f10 Parents: 4005559 Author: Anthony ShawAuthored: Fri Jun 24 13:54:08 2016 +1000 Committer: Anthony Shaw Committed: Fri Jun 24 13:54:08 2016 +1000 -- CHANGES.rst | 4 1 file changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/a60e070a/CHANGES.rst -- diff --git a/CHANGES.rst b/CHANGES.rst index 4605cad..94cab51 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,10 @@ Compute (GITHUB-818) [Mark Maglana] +- Add support for deleting security group in Aliyun ECS driver + (GITHUB-816) + [Heng Wu] + Changes with Apache Libcloud in 1.0.0 -
[GitHub] libcloud pull request #816: Aliyun ecs: Add support for deleting security gr...
Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/816 --- 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. ---
[3/8] libcloud git commit: rename to ex_create_security_group(self, description=None, client_token=None)
rename to ex_create_security_group(self, description=None, client_token=None) Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/5edbb6a9 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/5edbb6a9 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/5edbb6a9 Branch: refs/heads/trunk Commit: 5edbb6a99e71231bc454b5f948739adc58cdd8d6 Parents: 1e5c631 Author: netgeniusAuthored: Sat Jun 11 17:36:53 2016 +0800 Committer: Anthony Shaw Committed: Fri Jun 24 13:50:17 2016 +1000 -- example_aliyun_ecs.py | 6 +++--- libcloud/compute/drivers/ecs.py | 26 ++ 2 files changed, 17 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/5edbb6a9/example_aliyun_ecs.py -- diff --git a/example_aliyun_ecs.py b/example_aliyun_ecs.py index 5c223c6..c7de072 100644 --- a/example_aliyun_ecs.py +++ b/example_aliyun_ecs.py @@ -54,10 +54,10 @@ print('Use image %s' % image) sgs = ecs.ex_list_security_groups() print('Found %d security groups' % len(sgs)) if len(sgs) == 0: -sg = ecs.ex_create_security_groups(ex_description='test') +sg = ecs.ex_create_security_group(description='test') print('Create security group %s' % sg) else: -sg = sgs[0] +sg = sgs[0].id print('Use security group %s' % sg) nodes = ecs.list_nodes() @@ -73,7 +73,7 @@ if len(nodes) == 0: auth = NodeAuthPassword('P@$$w0rd') node = ecs.create_node(image=image, size=small, name='test', - ex_security_group_id=sg.id, + ex_security_group_id=sg, ex_internet_charge_type=ecs.internet_charge_types.BY_TRAFFIC, ex_internet_max_bandwidth_out=1, ex_data_disk=data_disk, http://git-wip-us.apache.org/repos/asf/libcloud/blob/5edbb6a9/libcloud/compute/drivers/ecs.py -- diff --git a/libcloud/compute/drivers/ecs.py b/libcloud/compute/drivers/ecs.py index 787df7f..4198f07 100644 --- a/libcloud/compute/drivers/ecs.py +++ b/libcloud/compute/drivers/ecs.py @@ -768,26 +768,28 @@ class ECSDriver(NodeDriver): return resp.success() and \ self._wait_until_state([node], NodeState.STOPPED) -def ex_create_security_groups(self, ex_description=None, - ex_client_token=None): +def ex_create_security_group(self, description=None, + client_token=None): """ -Create a new security groups. +Create a new security group. -:keyword ex_description: volume description -:type ex_description: ``unicode`` +:keyword description: security group description +:type description: ``unicode`` -:keyword ex_client_token: a token generated by client to identify +:keyword client_token: a token generated by client to identify each request. -:type ex_client_token: ``str`` +:type client_token: ``str`` """ params = {'Action': 'CreateSecurityGroup', 'RegionId': self.region} -if ex_description: -params['Description'] = ex_description -if ex_client_token: -params['ClientToken'] = ex_client_token -return self.connection.request(self.path, params).object +if description: +params['Description'] = description +if client_token: +params['ClientToken'] = client_token +resp = self.connection.request(self.path, params) +return findtext(resp.object, 'SecurityGroupId', +namespace=self.namespace) def ex_list_security_groups(self, ex_filters=None): """
[4/8] libcloud git commit: delete a blank
delete a blank Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/5ee9158d Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/5ee9158d Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/5ee9158d Branch: refs/heads/trunk Commit: 5ee9158d86fdd0c68d007a75b7e71909d2ee7037 Parents: f9c5014 Author: net613Authored: Wed Jun 15 11:52:31 2016 -0400 Committer: Anthony Shaw Committed: Fri Jun 24 13:50:17 2016 +1000 -- example_aliyun_ecs.py | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/5ee9158d/example_aliyun_ecs.py -- diff --git a/example_aliyun_ecs.py b/example_aliyun_ecs.py index c7f57f5..c7de072 100644 --- a/example_aliyun_ecs.py +++ b/example_aliyun_ecs.py @@ -51,7 +51,6 @@ else: image = images[0] print('Use image %s' % image) - sgs = ecs.ex_list_security_groups() print('Found %d security groups' % len(sgs)) if len(sgs) == 0:
[7/8] libcloud git commit: fix:W293 blank line contains whitespace Closes #816
fix:W293 blank line contains whitespace Closes #816 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/40055598 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/40055598 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/40055598 Branch: refs/heads/trunk Commit: 40055598860fbf6176019b11fd55f481d9ef76cb Parents: a1940f7 Author: netgeniusAuthored: Thu Jun 16 23:25:21 2016 +0800 Committer: Anthony Shaw Committed: Fri Jun 24 13:53:02 2016 +1000 -- libcloud/compute/drivers/ecs.py | 2 +- libcloud/test/compute/test_ecs.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/40055598/libcloud/compute/drivers/ecs.py -- diff --git a/libcloud/compute/drivers/ecs.py b/libcloud/compute/drivers/ecs.py index 583b98f..5165ce2 100644 --- a/libcloud/compute/drivers/ecs.py +++ b/libcloud/compute/drivers/ecs.py @@ -802,7 +802,7 @@ class ECSDriver(NodeDriver): 'SecurityGroupId': group_id} resp = self.connection.request(self.path, params) return resp.success() - + def ex_list_security_groups(self, ex_filters=None): """ List security groups in the current region. http://git-wip-us.apache.org/repos/asf/libcloud/blob/40055598/libcloud/test/compute/test_ecs.py -- diff --git a/libcloud/test/compute/test_ecs.py b/libcloud/test/compute/test_ecs.py index 05e5e63..b04ce24 100644 --- a/libcloud/test/compute/test_ecs.py +++ b/libcloud/test/compute/test_ecs.py @@ -922,5 +922,6 @@ class ECSMockHttp(MockHttpTestCase): resp_body = self.fixtures.load('describe_zones.xml') return (httplib.OK, resp_body, {}, httplib.responses[httplib.OK]) + if __name__ == '__main__': sys.exit(unittest.main())
[5/8] libcloud git commit: add a blank
add a blank Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f9c5014d Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f9c5014d Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f9c5014d Branch: refs/heads/trunk Commit: f9c5014d061f3ad0d5e08ce56613810f0d6a5cf5 Parents: fffe7cd Author: net613Authored: Wed Jun 15 11:36:20 2016 -0400 Committer: Anthony Shaw Committed: Fri Jun 24 13:50:17 2016 +1000 -- example_aliyun_ecs.py | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/f9c5014d/example_aliyun_ecs.py -- diff --git a/example_aliyun_ecs.py b/example_aliyun_ecs.py index c7de072..c7f57f5 100644 --- a/example_aliyun_ecs.py +++ b/example_aliyun_ecs.py @@ -51,6 +51,7 @@ else: image = images[0] print('Use image %s' % image) + sgs = ecs.ex_list_security_groups() print('Found %d security groups' % len(sgs)) if len(sgs) == 0:
[6/8] libcloud git commit: Aliyun ecs: Add support for creating security group
Aliyun ecs: Add support for creating security group Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1e5c631b Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1e5c631b Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1e5c631b Branch: refs/heads/trunk Commit: 1e5c631bd60eaeaa4314286669c25ba409d95c70 Parents: 8b8e133 Author: netgeniusAuthored: Sat Jun 11 00:15:58 2016 +0800 Committer: Anthony Shaw Committed: Fri Jun 24 13:50:17 2016 +1000 -- example_aliyun_ecs.py | 10 -- libcloud/compute/drivers/ecs.py | 21 + 2 files changed, 29 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e5c631b/example_aliyun_ecs.py -- diff --git a/example_aliyun_ecs.py b/example_aliyun_ecs.py index bbaaf00..5c223c6 100644 --- a/example_aliyun_ecs.py +++ b/example_aliyun_ecs.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys + from libcloud.compute.types import Provider from libcloud.compute.providers import get_driver from libcloud.compute.base import NodeAuthPassword @@ -51,8 +53,12 @@ print('Use image %s' % image) sgs = ecs.ex_list_security_groups() print('Found %d security groups' % len(sgs)) -sg = sgs[0] -print('Use security group %s' % sg) +if len(sgs) == 0: +sg = ecs.ex_create_security_groups(ex_description='test') +print('Create security group %s' % sg) +else: +sg = sgs[0] +print('Use security group %s' % sg) nodes = ecs.list_nodes() print('Found %d nodes' % len(nodes)) http://git-wip-us.apache.org/repos/asf/libcloud/blob/1e5c631b/libcloud/compute/drivers/ecs.py -- diff --git a/libcloud/compute/drivers/ecs.py b/libcloud/compute/drivers/ecs.py index 2ac8afa..787df7f 100644 --- a/libcloud/compute/drivers/ecs.py +++ b/libcloud/compute/drivers/ecs.py @@ -768,6 +768,27 @@ class ECSDriver(NodeDriver): return resp.success() and \ self._wait_until_state([node], NodeState.STOPPED) +def ex_create_security_groups(self, ex_description=None, + ex_client_token=None): +""" +Create a new security groups. + +:keyword ex_description: volume description +:type ex_description: ``unicode`` + +:keyword ex_client_token: a token generated by client to identify + each request. +:type ex_client_token: ``str`` +""" +params = {'Action': 'CreateSecurityGroup', + 'RegionId': self.region} + +if ex_description: +params['Description'] = ex_description +if ex_client_token: +params['ClientToken'] = ex_client_token +return self.connection.request(self.path, params).object + def ex_list_security_groups(self, ex_filters=None): """ List security groups in the current region.
[2/8] libcloud git commit: fix E127 continuation line over-indented for visual indent
fix E127 continuation line over-indented for visual indent Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/fffe7cd7 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/fffe7cd7 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/fffe7cd7 Branch: refs/heads/trunk Commit: fffe7cd79e3f96e5c000eed30e850fc8bbdb5cdc Parents: 5edbb6a Author: netgeniusAuthored: Sat Jun 11 17:42:56 2016 +0800 Committer: Anthony Shaw Committed: Fri Jun 24 13:50:17 2016 +1000 -- libcloud/compute/drivers/ecs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/fffe7cd7/libcloud/compute/drivers/ecs.py -- diff --git a/libcloud/compute/drivers/ecs.py b/libcloud/compute/drivers/ecs.py index 4198f07..99c55d7 100644 --- a/libcloud/compute/drivers/ecs.py +++ b/libcloud/compute/drivers/ecs.py @@ -768,8 +768,7 @@ class ECSDriver(NodeDriver): return resp.success() and \ self._wait_until_state([node], NodeState.STOPPED) -def ex_create_security_group(self, description=None, - client_token=None): +def ex_create_security_group(self, description=None, client_token=None): """ Create a new security group. @@ -788,7 +787,7 @@ class ECSDriver(NodeDriver): if client_token: params['ClientToken'] = client_token resp = self.connection.request(self.path, params) -return findtext(resp.object, 'SecurityGroupId', +return findtext(resp.object, 'SecurityGroupId', namespace=self.namespace) def ex_list_security_groups(self, ex_filters=None):
[2/3] libcloud git commit: Allow setting of load balancer listener IP
Allow setting of load balancer listener IP The documentation for the Dimension Data Cloud REST API v2.2-20160222 states that a load balancer can be statically assigned a listener IP on creation. This change fixes the dimension data driver to conform to the docs. Closes #818 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/2d9f4388 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/2d9f4388 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/2d9f4388 Branch: refs/heads/trunk Commit: 2d9f438808c102c8c3315db8cca44a48b36321e0 Parents: 9a07d7e Author: Mark S. MaglanaAuthored: Thu Jun 16 01:21:50 2016 -0700 Committer: Anthony Shaw Committed: Fri Jun 24 13:43:25 2016 +1000 -- libcloud/loadbalancer/drivers/dimensiondata.py | 13 ++--- libcloud/test/loadbalancer/test_dimensiondata.py | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d9f4388/libcloud/loadbalancer/drivers/dimensiondata.py -- diff --git a/libcloud/loadbalancer/drivers/dimensiondata.py b/libcloud/loadbalancer/drivers/dimensiondata.py index ca5e75b..33c0ab4 100644 --- a/libcloud/loadbalancer/drivers/dimensiondata.py +++ b/libcloud/loadbalancer/drivers/dimensiondata.py @@ -99,7 +99,8 @@ class DimensionDataLBDriver(Driver): return kwargs def create_balancer(self, name, port=None, protocol=None, -algorithm=None, members=None): +algorithm=None, members=None, +ex_listener_ip_address=None): """ Create a new load balancer instance @@ -119,6 +120,10 @@ class DimensionDataLBDriver(Driver): :param algorithm: Load balancing algorithm, defaults to ROUND_ROBIN. :type algorithm: :class:`.Algorithm` +:param ex_listener_ip_address: Must be a valid IPv4 in dot-decimal + notation (x.x.x.x). +:type ex_listener_ip_address: ``str`` + :rtype: :class:`LoadBalancer` """ network_domain_id = self.network_domain_id @@ -153,7 +158,8 @@ class DimensionDataLBDriver(Driver): name=name, ex_description=name, port=port, -pool=pool) +pool=pool, +listener_ip_address=ex_listener_ip_address) return LoadBalancer( id=listener.id, @@ -163,7 +169,8 @@ class DimensionDataLBDriver(Driver): port=port, driver=self, extra={'pool_id': pool.id, - 'network_domain_id': network_domain_id} + 'network_domain_id': network_domain_id, + 'listener_ip_address': ex_listener_ip_address} ) def list_balancers(self): http://git-wip-us.apache.org/repos/asf/libcloud/blob/2d9f4388/libcloud/test/loadbalancer/test_dimensiondata.py -- diff --git a/libcloud/test/loadbalancer/test_dimensiondata.py b/libcloud/test/loadbalancer/test_dimensiondata.py index 86bafbe..79e9553 100644 --- a/libcloud/test/loadbalancer/test_dimensiondata.py +++ b/libcloud/test/loadbalancer/test_dimensiondata.py @@ -58,13 +58,15 @@ class DimensionDataTests(unittest.TestCase): port=80, protocol='http', algorithm=Algorithm.ROUND_ROBIN, -members=members) +members=members, +ex_listener_ip_address='5.6.7.8') self.assertEqual(balancer.name, 'test') self.assertEqual(balancer.id, '8334f461-0df0-42d5-97eb-f4678eb26bea') self.assertEqual(balancer.ip, '165.180.12.22') self.assertEqual(balancer.port, 80) self.assertEqual(balancer.extra['pool_id'], '9e6b496d-5261-4542-91aa-b50c7f569c54') self.assertEqual(balancer.extra['network_domain_id'], '1234') +self.assertEqual(balancer.extra['listener_ip_address'], '5.6.7.8') def test_create_balancer_with_defaults(self): self.driver.ex_set_current_network_domain('1234')
[3/3] libcloud git commit: update changes for #818
update changes for #818 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8b8e1338 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8b8e1338 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8b8e1338 Branch: refs/heads/trunk Commit: 8b8e13382c1bde3aa544aa9e6c9992104894d9bc Parents: 2d9f438 Author: Anthony ShawAuthored: Fri Jun 24 13:48:15 2016 +1000 Committer: Anthony Shaw Committed: Fri Jun 24 13:48:15 2016 +1000 -- CHANGES.rst | 11 +++ 1 file changed, 11 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/8b8e1338/CHANGES.rst -- diff --git a/CHANGES.rst b/CHANGES.rst index 781788f..4605cad 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,17 @@ Changelog = +Changes with current version of Apache Libcloud +--- + +Compute +~~~ + +- Allow VIPs in Dimension Data driver to bind to any port + (GITHUB-818) + [Mark Maglana] + + Changes with Apache Libcloud in 1.0.0 -