libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [27/45] libcloud git commit: Finished ssl import and list
Date Thu, 13 Dec 2018 11:26:36 GMT
Finished ssl import and list


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

Branch: refs/heads/trunk
Commit: 35131c86fdf0117a600c4e698112166ba4356be2
Parents: 9319bbb
Author: mitch <mitch.raful@itaas.dimensiondata.com>
Authored: Fri Nov 16 15:59:35 2018 -0500
Committer: mitch <mitch.raful@itaas.dimensiondata.com>
Committed: Fri Nov 16 15:59:35 2018 -0500

----------------------------------------------------------------------
 libcloud/loadbalancer/drivers/nttcis.py | 39 ++++++++++++++++++++++++++--
 tests/lib_list_test.py                  |  4 ++-
 2 files changed, 40 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/35131c86/libcloud/loadbalancer/drivers/nttcis.py
----------------------------------------------------------------------
diff --git a/libcloud/loadbalancer/drivers/nttcis.py b/libcloud/loadbalancer/drivers/nttcis.py
index ee1bd53..690ecf8 100644
--- a/libcloud/loadbalancer/drivers/nttcis.py
+++ b/libcloud/loadbalancer/drivers/nttcis.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import OpenSSL.crypto
-
+import functools
 from libcloud.utils.py3 import ET
 from libcloud.common.nttcis import NttCisConnection
 from libcloud.common.nttcis import NttCisPool
@@ -28,6 +28,7 @@ from libcloud.common.nttcis import NttCisDefaultiRule
 from libcloud.common.nttcis import API_ENDPOINTS
 from libcloud.common.nttcis import DEFAULT_REGION
 from libcloud.common.nttcis import TYPES_URN
+from libcloud.common.nttcis import process_xml
 from libcloud.utils.misc import reverse_dict
 from libcloud.utils.xml import fixxpath, findtext, findall
 from libcloud.loadbalancer.types import State
@@ -37,6 +38,26 @@ from libcloud.loadbalancer.base import Member
 from libcloud.loadbalancer.types import Provider
 
 
+def get_params(func):
+    @functools.wraps(func)
+    def paramed(*args, **kwargs):
+
+        if kwargs:
+            for k, v in kwargs.items():
+                old_key = k
+                matches = re.findall(r'_(\w)', k)
+                for match in matches:
+                    k = k.replace('_' + match, match.upper())
+                del kwargs[old_key]
+                kwargs[k] = v
+            params = kwargs
+            result = func(args[0], params)
+        else:
+            result = func(args[0])
+        return result
+    return paramed
+
+
 class NttCisLBDriver(Driver):
     """
     NttCis LB driver.
@@ -1072,8 +1093,13 @@ class NttCisLBDriver(Driver):
             method='GET').object
         return self._to_irules(result)
 
+    @get_params
     def ex_list_ssl_domain_certs(self, params={}):
-        pass
+        result = self.connection.request_with_orgId_api_2(
+            action="networkDomainVip/sslDomainCertificate",
+            params=params,
+            method="GET").object
+        return self._to_certs(result)
 
     def _to_irules(self, object):
         irules = []
@@ -1262,3 +1288,12 @@ class NttCisLBDriver(Driver):
             slow_ramp_time=findtext(element, 'slowRampTime', TYPES_URN),
         )
         return pool
+
+    def _to_certs(self, object):
+        certs = []
+        for element in object.findall(fixxpath("sslDomainCertificate", TYPES_URN)):
+            certs.append(self._to_cert(element))
+        return certs
+
+    def _to_cert(self, el):
+        return process_xml(ET.tostring(el))

http://git-wip-us.apache.org/repos/asf/libcloud/blob/35131c86/tests/lib_list_test.py
----------------------------------------------------------------------
diff --git a/tests/lib_list_test.py b/tests/lib_list_test.py
index bf572e3..650984e 100644
--- a/tests/lib_list_test.py
+++ b/tests/lib_list_test.py
@@ -427,4 +427,6 @@ def test_get_snapshots_by_min(drsdriver):
 
 
 def test_list_domain_certs(compute_driver, lbdriver):
-    pass
\ No newline at end of file
+    certs = lbdriver.ex_list_ssl_domain_certs()
+    for cert in certs:
+        print(cert)
\ No newline at end of file


Mime
View raw message