You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2016/04/13 14:00:50 UTC
[4/5] libcloud git commit: allow for private IPv4 when adding a NIC
allow for private IPv4 when adding a NIC
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/44d72173
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/44d72173
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/44d72173
Branch: refs/heads/trunk
Commit: 44d721735706f6f0a0709d73eaee589e96e7a0f7
Parents: e69a7cb
Author: Bernard Paques <be...@gmail.com>
Authored: Tue Apr 12 22:26:04 2016 +0200
Committer: anthony-shaw <an...@apache.org>
Committed: Wed Apr 13 21:58:36 2016 +1000
----------------------------------------------------------------------
libcloud/compute/drivers/dimensiondata.py | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/44d72173/libcloud/compute/drivers/dimensiondata.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/dimensiondata.py b/libcloud/compute/drivers/dimensiondata.py
index d618a33..723f21c 100644
--- a/libcloud/compute/drivers/dimensiondata.py
+++ b/libcloud/compute/drivers/dimensiondata.py
@@ -794,25 +794,39 @@ class DimensionDataNodeDriver(NodeDriver):
rules.extend(self._to_anti_affinity_rules(result))
return rules
- def ex_attach_node_to_vlan(self, node, vlan):
+ def ex_attach_node_to_vlan(self, node, vlan=None, private_ipv4=None):
"""
Attach a node to a VLAN by adding an additional NIC to
the node on the target VLAN. The IP will be automatically
- assigned based on the VLAN IP network space.
+ assigned based on the VLAN IP network space. Alternatively, provide
+ a private IPv4 address instead of VLAN information, and this will
+ be assigned to the node on corresponding NIC.
:param node: Node which should be used
:type node: :class:`Node`
:param vlan: VLAN to attach the node to
+ (required unless private_ipv4)
:type vlan: :class:`DimensionDataVlan`
+ :keyword private_ipv4: Private nic IPv4 Address
+ (required unless vlan)
+ :type private_ipv4: ``str``
+
:rtype: ``bool``
"""
request = ET.Element('addNic',
{'xmlns': TYPES_URN})
ET.SubElement(request, 'serverId').text = node.id
nic = ET.SubElement(request, 'nic')
- ET.SubElement(nic, 'vlanId').text = vlan.id
+
+ if vlan is not None:
+ ET.SubElement(nic, 'vlanId').text = vlan.id
+ elif primary_ipv4 is not None:
+ ET.SubElement(nic, 'privateIpv4').text = private_ipv4
+ else:
+ raise ValueError("One of vlan or primary_ipv4 "
+ "must be specified")
response = self.connection.request_with_orgId_api_2(
'server/addNic',