libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [1/7] libcloud git commit: Added GandiNodeDriver.list_key_pairs and get_key_pair
Date Sat, 13 Jun 2015 12:44:11 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 699584f90 -> 78b95fd9d


Added GandiNodeDriver.list_key_pairs and get_key_pair

Closes #534

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/562e4d2a
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/562e4d2a
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/562e4d2a

Branch: refs/heads/trunk
Commit: 562e4d2ae0e7aa8585072bc7ec3a3822f3d11d84
Parents: 699584f
Author: ZuluPro <montheanthony@hotmail.com>
Authored: Wed May 27 16:13:44 2015 -0400
Committer: Tomaz Muraus <tomaz@tomaz.me>
Committed: Sat Jun 13 20:31:46 2015 +0800

----------------------------------------------------------------------
 libcloud/compute/drivers/cloudstack.py |  8 +++++++
 libcloud/compute/drivers/gandi.py      | 35 +++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/562e4d2a/libcloud/compute/drivers/cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudstack.py b/libcloud/compute/drivers/cloudstack.py
index b226c55..41b5c06 100644
--- a/libcloud/compute/drivers/cloudstack.py
+++ b/libcloud/compute/drivers/cloudstack.py
@@ -2260,6 +2260,14 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver):
         return key_pairs
 
     def get_key_pair(self, name):
+        """
+        Retrieve a single key pair.
+
+        :param name: Name of the key pair to retrieve.
+        :type name: ``str``
+
+        :rtype: :class:`.KeyPair`
+        """
         params = {'name': name}
         res = self._sync_request(command='listSSHKeyPairs',
                                  params=params,

http://git-wip-us.apache.org/repos/asf/libcloud/blob/562e4d2a/libcloud/compute/drivers/gandi.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gandi.py b/libcloud/compute/drivers/gandi.py
index e5593b4..7a54ada 100644
--- a/libcloud/compute/drivers/gandi.py
+++ b/libcloud/compute/drivers/gandi.py
@@ -20,6 +20,7 @@ from datetime import datetime
 
 from libcloud.common.gandi import BaseGandiDriver, GandiException,\
     NetworkInterface, IPAddress, Disk
+from libcloud.compute.base import KeyPair
 from libcloud.compute.base import StorageVolume
 from libcloud.compute.types import NodeState, Provider
 from libcloud.compute.base import Node, NodeDriver
@@ -617,3 +618,37 @@ class GandiNodeDriver(BaseGandiDriver, NodeDriver):
         if self._wait_operation(op.object['id']):
             return True
         return False
+
+    def _to_key_pair(self, data):
+        key_pair = KeyPair(name=data['name'],
+                           fingerprint=data['fingerprint'],
+                           public_key=data.get('value', None),
+                           private_key=data.get('privatekey', None),
+                           driver=self, extra={'id': data['id']})
+        return key_pair
+
+    def _to_key_pairs(self, data):
+        return [self._to_key_pair(k) for k in data]
+
+    def list_key_pairs(self):
+        """
+        List registered key pairs.
+
+        :return:   A list of key par objects.
+        :rtype:   ``list`` of :class:`libcloud.compute.base.KeyPair`
+        """
+        kps = self.connection.request('hosting.ssh.list').object
+        return self._to_key_pairs(kps)
+
+    def get_key_pair(self, name):
+        """
+        Retrieve a single key pair.
+
+        :param name: Name of the key pair to retrieve.
+        :type name: ``str``
+
+        :rtype: :class:`.KeyPair`
+        """
+        filter_params = {'name': name}
+        kps = self.connection.request('hosting.ssh.list', filter_params).object
+        return self._to_key_pair(kps[0])


Mime
View raw message