Details
-
New Feature
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
This patch will allow ex_create_multiple_nodes to create the nodes on a subnetwork as opposed to the current setup which only allows creation on a legacy network.
From 8c070181faa63a78aa624fe80607e3d8df23e6c2 Mon Sep 17 00:00:00 2001 From: John Baublitz <john@cambridgesemantics.com> Date: Wed, 1 Jun 2016 23:40:18 +0000 Subject: [PATCH] Fix to allow multiple node creation with subnets --- libcloud/compute/drivers/gce.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py index 9f9b8c1..1cc5d02 100644 --- a/libcloud/compute/drivers/gce.py +++ b/libcloud/compute/drivers/gce.py @@ -2590,12 +2590,11 @@ class GCENodeDriver(NodeDriver): size = self.ex_get_size(size, location) if not hasattr(ex_network, 'name'): ex_network = self.ex_get_network(ex_network) - if ex_subnetwork: - if not hasattr(ex_subnetwork, 'name'): - ex_subnetwork = \ - self.ex_get_subnetwork(ex_subnetwork, - region=self._get_region_from_zone( - location)) + if ex_subnetwork and not hasattr(ex_subnetwork, 'name'): + ex_subnetwork = \ + self.ex_get_subnetwork(ex_subnetwork, + region=self._get_region_from_zone( + location)) if ex_image_family: image = self.ex_get_image_from_family(ex_image_family) if image and not hasattr(image, 'name'): @@ -2640,6 +2639,7 @@ class GCENodeDriver(NodeDriver): def ex_create_multiple_nodes(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', @@ -2802,6 +2802,11 @@ class GCENodeDriver(NodeDriver): size = self.ex_get_size(size, location) if not hasattr(ex_network, 'name'): ex_network = self.ex_get_network(ex_network) + if ex_subnetwork and not hasattr(ex_subnetwork, 'name'): + ex_subnetwork = \ + self.ex_get_subnetwork(ex_subnetwork, + region=self._get_region_from_zone( + location)) if ex_image_family: image = self.ex_get_image_from_family(ex_image_family) if image and not hasattr(image, 'name'): @@ -2813,6 +2818,7 @@ class GCENodeDriver(NodeDriver): 'image': image, 'location': location, 'network': ex_network, + 'subnetwork': ex_subnetwork, 'tags': ex_tags, 'metadata': ex_metadata, 'ignore_errors': ignore_errors, @@ -5158,7 +5164,8 @@ class GCENodeDriver(NodeDriver): if not ex_disk_type: ex_disk_type = 'pd-standard' if not hasattr(ex_disk_type, 'name'): - ex_disk_type = self.ex_get_disktype(ex_disk_type) + ex_disk_type = self.ex_get_disktype(ex_disk_type, + zone=location) disks = [{'boot': True, 'type': 'PERSISTENT', 'mode': 'READ_WRITE', @@ -5321,7 +5328,8 @@ class GCENodeDriver(NodeDriver): ex_disks_gce_struct=node_attrs['ex_disks_gce_struct'], ex_nic_gce_struct=node_attrs['ex_nic_gce_struct'], ex_on_host_maintenance=node_attrs['ex_on_host_maintenance'], - ex_automatic_restart=node_attrs['ex_automatic_restart']) + ex_automatic_restart=node_attrs['ex_automatic_restart'], + ex_subnetwork=node_attrs['subnetwork']) try: node_res = self.connection.request( -- 1.8.3.1