libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [04/21] libcloud git commit: Address build failures from provider matrix generation - Removed hack to load DigitalOcean_v2_NodeDriver as DigitalOceanNodeDriver will handle v1/v2 properly - Restored DigitalOceanNodeDriver (v1) ex_ssh* methods with Warning
Date Sun, 14 Jun 2015 10:52:15 GMT
Address build failures from provider matrix generation - Removed hack to load DigitalOcean_v2_NodeDriver
as DigitalOceanNodeDriver will handle v1/v2 properly - Restored DigitalOceanNodeDriver (v1)
ex_ssh* methods with Warning of deprecation

Signed-off-by: Tomaz Muraus <tomaz@tomaz.me>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/003e0f67
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/003e0f67
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/003e0f67

Branch: refs/heads/trunk
Commit: 003e0f6781a37cc524f9ff9504ce288c98895857
Parents: 950fa94
Author: Javier Castillo II <j.castillo.2nd@gmail.com>
Authored: Wed Apr 15 22:05:21 2015 +0000
Committer: Tomaz Muraus <tomaz@tomaz.me>
Committed: Sun Jun 14 18:05:58 2015 +0800

----------------------------------------------------------------------
 .../generate_provider_feature_matrix_table.py   |  4 --
 libcloud/compute/drivers/digitalocean.py        | 39 ++++++++++++++++++++
 libcloud/test/compute/test_digitalocean_v1.py   | 13 +++++++
 3 files changed, 52 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/003e0f67/contrib/generate_provider_feature_matrix_table.py
----------------------------------------------------------------------
diff --git a/contrib/generate_provider_feature_matrix_table.py b/contrib/generate_provider_feature_matrix_table.py
index 834a514..2538568 100755
--- a/contrib/generate_provider_feature_matrix_table.py
+++ b/contrib/generate_provider_feature_matrix_table.py
@@ -221,10 +221,6 @@ def generate_providers_table(api):
             from libcloud.compute.drivers.cloudsigma import \
                 CloudSigma_2_0_NodeDriver
             cls = CloudSigma_2_0_NodeDriver
-        elif name.lower() == 'digital_ocean':
-            from libcloud.compute.drivers.digitalocean import \
-                DigitalOcean_v2_NodeDriver
-            cls = DigitalOcean_v2_NodeDriver
         elif name.lower() == 'opennebula':
             from libcloud.compute.drivers.opennebula import \
                 OpenNebula_3_8_NodeDriver

http://git-wip-us.apache.org/repos/asf/libcloud/blob/003e0f67/libcloud/compute/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py
index 0d9c0e7..9176be9 100644
--- a/libcloud/compute/drivers/digitalocean.py
+++ b/libcloud/compute/drivers/digitalocean.py
@@ -15,6 +15,7 @@
 """
 Digital Ocean Driver
 """
+import warnings
 
 from libcloud.utils.py3 import httplib
 
@@ -157,6 +158,17 @@ class DigitalOcean_v1_NodeDriver(DigitalOcean_v1_BaseDriver,
         data = self.connection.request('/v1/ssh_keys').object['ssh_keys']
         return list(map(self._to_key_pair, data))
 
+    def ex_list_ssh_keys(self):
+        """
+        List all the available SSH keys.
+        :return: Available SSH keys.
+        :rtype: ``list`` of :class:`SSHKey`
+        """
+        warnings.warn("This method has been deprecated in favor of the list_key_pairs method")
+
+        data = self.connection.request('/v1/ssh_keys').object['ssh_keys']
+        return list(map(self._to_ssh_key, data))
+
     def get_key_pair(self, name):
         """
         Retrieve a single key pair.
@@ -191,6 +203,22 @@ class DigitalOcean_v1_NodeDriver(DigitalOcean_v1_BaseDriver,
         #      a return value. This looks like it should return a KeyPair
         return self._to_key_pair(data=data['ssh_key'])
 
+    def ex_create_ssh_key(self, name, ssh_key_pub):
+        """
+        Create a new SSH key.
+        :param      name: Key name (required)
+        :type       name: ``str``
+        :param      name: Valid public key string (required)
+        :type       name: ``str``
+        """
+        warnings.warn("This method has been deprecated in favor of the create_key_pair method")
+
+        params = {'name': name, 'ssh_pub_key': ssh_key_pub}
+        data = self.connection.request('/v1/ssh_keys/new/', method='GET',
+                                       params=params).object
+        assert 'ssh_key' in data
+        return self._to_ssh_key(data=data['ssh_key'])
+
     def delete_key_pair(self, key_pair):
         """
         Delete an existing key pair.
@@ -203,6 +231,17 @@ class DigitalOcean_v1_NodeDriver(DigitalOcean_v1_BaseDriver,
         # TODO: This looks like it should return bool like the other delete_*
         return res.status == httplib.OK
 
+    def ex_destroy_ssh_key(self, key_id):
+        """
+        Delete an existing SSH key.
+        :param      key_id: SSH key id (required)
+        :type       key_id: ``str``
+        """
+        warnings.warn("This method has been deprecated in favor of the delete_key_pair method")
+
+        res = self.connection.request('/v1/ssh_keys/%s/destroy/' % (key_id))
+        return res.status == httplib.OK
+
     def _to_node(self, data):
         extra_keys = ['backups_active', 'region_id', 'image_id', 'size_id']
         if 'status' in data:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/003e0f67/libcloud/test/compute/test_digitalocean_v1.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_digitalocean_v1.py b/libcloud/test/compute/test_digitalocean_v1.py
index 654935e..33c7f1c 100644
--- a/libcloud/test/compute/test_digitalocean_v1.py
+++ b/libcloud/test/compute/test_digitalocean_v1.py
@@ -119,11 +119,24 @@ class DigitalOcean_v1_Tests(LibcloudTestCase):
         self.assertEqual(keys[0].name, 'test1')
         self.assertEqual(keys[0].public_key, None)
 
+    def test_ex_list_ssh_keys(self):
+        keys = self.driver.ex_list_ssh_keys()
+        self.assertEqual(len(keys), 1)
+
+        self.assertEqual(keys[0].id, 7717)
+        self.assertEqual(keys[0].name, 'test1')
+        self.assertEqual(keys[0].pub_key, None)
+
     def test_delete_key_pair(self):
         key = self.driver.list_key_pairs()[0]
         result = self.driver.delete_key_pair(key)
         self.assertTrue(result)
 
+    def test_ex_destroy_ssh_key(self):
+        key = self.driver.ex_list_ssh_keys()[0]
+        result = self.driver.ex_destroy_ssh_key(key.id)
+        self.assertTrue(result)
+
 
 class DigitalOceanMockHttp(MockHttpTestCase):
     fixtures = ComputeFileFixtures('digitalocean_v1')


Mime
View raw message