libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From quent...@apache.org
Subject [1/3] libcloud git commit: Add private IP functionality to GCE
Date Tue, 31 Oct 2017 04:29:42 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 5e1972e48 -> a94f92826


Add private IP functionality to GCE

Signed-off-by: Quentin Pradet <quentinp@apache.org>


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

Branch: refs/heads/trunk
Commit: 718fd951c31f4c29e0f1e356a6cbbf06cdc6a4b6
Parents: 5e1972e
Author: Gareth Mcfarlane <gmcfarlane@google.com>
Authored: Thu Sep 7 20:53:08 2017 +1000
Committer: Quentin Pradet <quentinp@apache.org>
Committed: Tue Oct 31 08:25:13 2017 +0400

----------------------------------------------------------------------
 libcloud/compute/drivers/gce.py | 64 ++++++++++++++++++++++++++----------
 1 file changed, 47 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/718fd951/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index f49aaf0..21183a0 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -3727,8 +3727,9 @@ class GCENodeDriver(NodeDriver):
             self, name, size, image, location=None, ex_network='default',
             ex_subnetwork=None, ex_tags=None, ex_metadata=None,
             ex_boot_disk=None, use_existing_disk=True, external_ip='ephemeral',
-            ex_disk_type='pd-standard', ex_disk_auto_delete=True,
-            ex_service_accounts=None, description=None, ex_can_ip_forward=None,
+            internal_ip=None, ex_disk_type='pd-standard',
+            ex_disk_auto_delete=True, ex_service_accounts=None,
+            description=None, ex_can_ip_forward=None,
             ex_disks_gce_struct=None, ex_nic_gce_struct=None,
             ex_on_host_maintenance=None, ex_automatic_restart=None,
             ex_preemptible=None, ex_image_family=None, ex_labels=None):
@@ -3776,6 +3777,9 @@ class GCENodeDriver(NodeDriver):
                                a GCEAddress object should be passed in.
         :type     external_ip: :class:`GCEAddress` or ``str`` or ``None``
 
+        :keyword  internal_ip: The private IP address to use.
+        :type     internal_ip: :class:`GCEAddress` or ``str`` or ``None``
+
         :keyword  ex_disk_type: Specify a pd-standard (default) disk or pd-ssd
                                 for an SSD disk.
         :type     ex_disk_type: ``str`` or :class:`GCEDiskType`
@@ -3911,17 +3915,18 @@ class GCENodeDriver(NodeDriver):
 
         request, node_data = self._create_node_req(
             name, size, image, location, ex_network, ex_tags, ex_metadata,
-            ex_boot_disk, external_ip, ex_disk_type, ex_disk_auto_delete,
-            ex_service_accounts, description, ex_can_ip_forward,
-            ex_disks_gce_struct, ex_nic_gce_struct, ex_on_host_maintenance,
-            ex_automatic_restart, ex_preemptible, ex_subnetwork, ex_labels)
+            ex_boot_disk, external_ip, internal_ip, ex_disk_type,
+            ex_disk_auto_delete, ex_service_accounts, description,
+            ex_can_ip_forward, ex_disks_gce_struct, ex_nic_gce_struct,
+            ex_on_host_maintenance, ex_automatic_restart, ex_preemptible,
+            ex_subnetwork, ex_labels)
         self.connection.async_request(request, method='POST', data=node_data)
         return self.ex_get_node(name, location.name)
 
     def ex_create_instancetemplate(
             self, name, size, source=None, image=None, disk_type='pd-standard',
             disk_auto_delete=True, network='default', subnetwork=None,
-            can_ip_forward=None, external_ip='ephemeral',
+            can_ip_forward=None, external_ip='ephemeral', internal_ip=None,
             service_accounts=None, on_host_maintenance=None,
             automatic_restart=None, preemptible=None, tags=None, metadata=None,
             description=None, disks_gce_struct=None, nic_gce_struct=None):
@@ -3965,6 +3970,9 @@ class GCENodeDriver(NodeDriver):
                                a GCEAddress object should be passed in.
         :type     external_ip: :class:`GCEAddress` or ``str`` or ``None``
 
+        :keyword  internal_ip: The private IP address to use.
+        :type     internal_ip: :class:`GCEAddress` or ``str`` or ``None``
+
         :keyword  disk_type: Specify a pd-standard (default) disk or pd-ssd
                                 for an SSD disk.
         :type     disk_type: ``str`` or :class:`GCEDiskType`
@@ -4046,7 +4054,7 @@ class GCENodeDriver(NodeDriver):
             disk_type=disk_type, disk_auto_delete=True,
             external_ip=external_ip, network=network, subnetwork=subnetwork,
             can_ip_forward=can_ip_forward, service_accounts=service_accounts,
-            on_host_maintenance=on_host_maintenance,
+            on_host_maintenance=on_host_maintenance, internal_ip=internal_ip,
             automatic_restart=automatic_restart, preemptible=preemptible,
             tags=tags, metadata=metadata, description=description,
             disks_gce_struct=disks_gce_struct, nic_gce_struct=nic_gce_struct,
@@ -4064,9 +4072,10 @@ class GCENodeDriver(NodeDriver):
     def _create_instance_properties(
             self, name, node_size, source=None, image=None,
             disk_type='pd-standard', disk_auto_delete=True, network='default',
-            subnetwork=None, external_ip='ephemeral', can_ip_forward=None,
-            service_accounts=None, on_host_maintenance=None,
-            automatic_restart=None, preemptible=None, tags=None, metadata=None,
+            subnetwork=None, external_ip='ephemeral', internal_ip=None,
+            can_ip_forward=None, service_accounts=None,
+            on_host_maintenance=None, automatic_restart=None,
+            preemptible=None, tags=None, metadata=None,
             description=None, disks_gce_struct=None, nic_gce_struct=None,
             use_selflinks=True, labels=None):
         """
@@ -4110,6 +4119,9 @@ class GCENodeDriver(NodeDriver):
                                a GCEAddress object should be passed in.
         :type     external_ip: :class:`GCEAddress` or ``str`` or ``None``
 
+        :keyword  internal_ip: The private IP address to use.
+        :type     internal_ip: :class:`GCEAddress` or ``str`` or ``None``
+
         :keyword  can_ip_forward: Set to ``True`` to allow this node to
                                   send/receive non-matching src/dst packets.
         :type     can_ip_forward: ``bool`` or ``None``
@@ -4234,7 +4246,8 @@ class GCENodeDriver(NodeDriver):
             instance_properties['networkInterfaces'] = [
                 self._build_network_gce_struct(
                     network=network, subnetwork=subnetwork,
-                    external_ip=external_ip, use_selflinks=True)
+                    external_ip=external_ip, use_selflinks=True,
+                    internal_ip=internal_ip)
             ]
 
         # build scheduling
@@ -4408,7 +4421,8 @@ class GCENodeDriver(NodeDriver):
                 return obj.name
 
     def _build_network_gce_struct(self, network, subnetwork=None,
-                                  external_ip=None, use_selflinks=True):
+                                  external_ip=None, use_selflinks=True,
+                                  internal_ip=None):
         """
         Build network interface dict for use in the GCE API.
 
@@ -4427,6 +4441,9 @@ class GCENodeDriver(NodeDriver):
                                a GCEAddress object should be passed in.
         :type     external_ip: :class:`GCEAddress`
 
+        :keyword  internal_ip: The private IP address to use.
+        :type     internal_ip: :class:`GCEAddress` or ``str``
+
         :return:  network interface dict
         :rtype:   ``dict``
         """
@@ -4450,6 +4467,9 @@ class GCENodeDriver(NodeDriver):
                 access_configs[0]['natIP'] = external_ip.address
             ni['accessConfigs'] = access_configs
 
+        if internal_ip:
+            ni['networkIP'] = internal_ip
+
         return ni
 
     def _build_service_account_gce_struct(
@@ -4602,7 +4622,7 @@ class GCENodeDriver(NodeDriver):
             self, base_name, size, image, number, location=None,
             ex_network='default', ex_subnetwork=None, ex_tags=None,
             ex_metadata=None, ignore_errors=True, use_existing_disk=True,
-            poll_interval=2, external_ip='ephemeral',
+            poll_interval=2, external_ip='ephemeral', internal_ip=None,
             ex_disk_type='pd-standard', ex_disk_auto_delete=True,
             ex_service_accounts=None, timeout=DEFAULT_TASK_COMPLETION_TIMEOUT,
             description=None, ex_can_ip_forward=None, ex_disks_gce_struct=None,
@@ -4664,6 +4684,10 @@ class GCENodeDriver(NodeDriver):
                                multiple node creation.)
         :type     external_ip: ``str`` or None
 
+
+        :keyword  internal_ip: The private IP address to use.
+        :type     internal_ip: :class:`GCEAddress` or ``str`` or ``None``
+
         :keyword  ex_disk_type: Specify a pd-standard (default) disk or pd-ssd
                                 for an SSD disk.
         :type     ex_disk_type: ``str`` or :class:`GCEDiskType`
@@ -4788,6 +4812,7 @@ class GCENodeDriver(NodeDriver):
                       'ignore_errors': ignore_errors,
                       'use_existing_disk': use_existing_disk,
                       'external_ip': external_ip,
+                      'internal_ip': internal_ip,
                       'ex_disk_type': ex_disk_type,
                       'ex_disk_auto_delete': ex_disk_auto_delete,
                       'ex_service_accounts': ex_service_accounts,
@@ -7686,8 +7711,9 @@ class GCENodeDriver(NodeDriver):
     def _create_node_req(
             self, name, size, image, location, network=None, tags=None,
             metadata=None, boot_disk=None, external_ip='ephemeral',
-            ex_disk_type='pd-standard', ex_disk_auto_delete=True,
-            ex_service_accounts=None, description=None, ex_can_ip_forward=None,
+            internal_ip=None, ex_disk_type='pd-standard',
+            ex_disk_auto_delete=True, ex_service_accounts=None,
+            description=None, ex_can_ip_forward=None,
             ex_disks_gce_struct=None, ex_nic_gce_struct=None,
             ex_on_host_maintenance=None, ex_automatic_restart=None,
             ex_preemptible=None, ex_subnetwork=None, ex_labels=None):
@@ -7731,6 +7757,9 @@ class GCENodeDriver(NodeDriver):
                                ex_nic_gce_struct param.
         :type     external_ip: :class:`GCEAddress` or ``str`` or None
 
+        :keyword  internal_ip: The private IP address to use.
+        :type     internal_ip: :class:`GCEAddress` or ``str`` or ``None``
+
         :keyword  ex_disk_type: Specify a pd-standard (default) disk or pd-ssd
                                 for an SSD disk.
         :type     ex_disk_type: ``str`` or :class:`GCEDiskType` or ``None``
@@ -7831,7 +7860,7 @@ class GCENodeDriver(NodeDriver):
             name, node_size=size, image=image, source=source,
             disk_type=ex_disk_type, disk_auto_delete=ex_disk_auto_delete,
             external_ip=external_ip, network=network, subnetwork=ex_subnetwork,
-            can_ip_forward=ex_can_ip_forward,
+            can_ip_forward=ex_can_ip_forward, internal_ip=internal_ip,
             service_accounts=ex_service_accounts,
             on_host_maintenance=ex_on_host_maintenance,
             automatic_restart=ex_automatic_restart, preemptible=ex_preemptible,
@@ -7931,6 +7960,7 @@ class GCENodeDriver(NodeDriver):
             status['name'], node_attrs['size'], node_attrs['image'],
             node_attrs['location'], node_attrs['network'], node_attrs['tags'],
             node_attrs['metadata'], external_ip=node_attrs['external_ip'],
+            internal_ip=node_attrs['internal_ip'],
             ex_service_accounts=node_attrs['ex_service_accounts'],
             description=node_attrs['description'],
             ex_can_ip_forward=node_attrs['ex_can_ip_forward'],


Mime
View raw message