libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject libcloud git commit: Add the ability to specify primary and secondary DNS for a node
Date Mon, 06 Jun 2016 21:28:24 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 8d755bfc0 -> efff64fc4


Add the ability to specify primary and secondary DNS for a node

This change adds two arguments to the create_node() method of the
dimensiondata driver. These arguments, ex_primary_dns and
ex_secondary_dns, allow the client to set the node's DNS servers
at launch time.

Closes #806


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

Branch: refs/heads/trunk
Commit: efff64fc4bbf348bac57262a995f8bef971fcd36
Parents: 8d755bf
Author: Mark S. Maglana <mmaglana@gmail.com>
Authored: Mon Jun 6 13:02:44 2016 -0700
Committer: anthony-shaw <anthonyshaw@apache.org>
Committed: Tue Jun 7 07:27:52 2016 +1000

----------------------------------------------------------------------
 libcloud/compute/drivers/dimensiondata.py   | 20 +++++++++++++++++++-
 libcloud/test/compute/test_dimensiondata.py | 15 +++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/efff64fc/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index 0d4ae62..38dba1a 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -129,7 +129,9 @@ class DimensionDataNodeDriver(NodeDriver):
                     ex_memory_gb=None,
                     ex_cpu_specification=None,
                     ex_is_started=True, ex_additional_nics_vlan=None,
-                    ex_additional_nics_ipv4=None, **kwargs):
+                    ex_additional_nics_ipv4=None,
+                    ex_primary_dns=None,
+                    ex_secondary_dns=None, **kwargs):
         """
         Create a new DimensionData node
 
@@ -188,6 +190,14 @@ class DimensionDataNodeDriver(NodeDriver):
                                               nics to add by ipv4 address
         :type       ex_additional_nics_ipv4: ``list`` of ``str``
 
+        :keyword    ex_primary_dns: The node's primary DNS
+
+        :type       ex_primary_dns: ``str``
+
+        :keyword    ex_secondary_dns: The node's secondary DNS
+
+        :type       ex_secondary_dns: ``str``
+
         :return: The newly created :class:`Node`.
         :rtype: :class:`Node`
         """
@@ -268,6 +278,14 @@ class DimensionDataNodeDriver(NodeDriver):
                 raise TypeError("ex_additional_nics_vlan"
                                 "must be None or tuple/list")
 
+        if ex_primary_dns:
+            dns_elm = ET.SubElement(server_elm, "primaryDns")
+            dns_elm.text = ex_primary_dns
+
+        if ex_secondary_dns:
+            dns_elm = ET.SubElement(server_elm, "secondaryDns")
+            dns_elm.text = ex_secondary_dns
+
         response = self.connection.request_with_orgId_api_2(
             'server/deployServer',
             method='POST',

http://git-wip-us.apache.org/repos/asf/libcloud/blob/efff64fc/libcloud/test/compute/test_dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_dimensiondata.py b/libcloud/test/compute/test_dimensiondata.py
index f4f03bc..152e150 100644
--- a/libcloud/test/compute/test_dimensiondata.py
+++ b/libcloud/test/compute/test_dimensiondata.py
@@ -432,6 +432,21 @@ class DimensionDataTests(unittest.TestCase, TestCaseMixin):
                                     ex_additional_nics_vlan='badstring',
                                     ex_is_started=False)
 
+    def test_create_node_mcp2_indicate_dns(self):
+        rootPw = NodeAuthPassword('pass123')
+        image = self.driver.list_images()[0]
+        node = self.driver.create_node(name='test2',
+                                       image=image,
+                                       auth=rootPw,
+                                       ex_description='test node dns',
+                                       ex_network_domain='fakenetworkdomain',
+                                       ex_primary_ipv4='10.0.0.1',
+                                       ex_primary_dns='8.8.8.8',
+                                       ex_secondary_dns='8.8.4.4',
+                                       ex_is_started=False)
+        self.assertEqual(node.id, 'e75ead52-692f-4314-8725-c8a4f4d13a87')
+        self.assertEqual(node.extra['status'].action, 'DEPLOY_SERVER')
+
     def test_ex_shutdown_graceful(self):
         node = Node(id='11', name=None, state=None,
                     public_ips=None, private_ips=None, driver=self.driver)


Mime
View raw message