From 080a5abdebb49022ac5a40f409baeb58f50d1c30 Mon Sep 17 00:00:00 2001 From: sayoun Date: Tue, 30 May 2017 12:17:23 +0200 Subject: [PATCH] Gandi compute driver should use a unique location name Closes #1065 --- docs/examples/compute/gandi/create_node.py | 2 +- libcloud/compute/drivers/gandi.py | 2 +- .../test/compute/fixtures/gandi/datacenter_list.xml | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/examples/compute/gandi/create_node.py b/docs/examples/compute/gandi/create_node.py index 213f9ebecd..8f33facf43 100644 --- a/docs/examples/compute/gandi/create_node.py +++ b/docs/examples/compute/gandi/create_node.py @@ -6,7 +6,7 @@ image = [i for i in driver.list_images() if 'Debian 8 64' in i.name][0] size = [s for s in driver.list_sizes() if s.name == 'Medium instance'][0] -location = [l for l in driver.list_locations() if l.name == 'Equinix Paris'][0] +location = [l for l in driver.list_locations() if l.name == 'FR-SD2'][0] node = driver.create_node(name='yournode', size=size, image=image, location=location, login="youruser", password="pass") diff --git a/libcloud/compute/drivers/gandi.py b/libcloud/compute/drivers/gandi.py index 844850a325..af039cf179 100644 --- a/libcloud/compute/drivers/gandi.py +++ b/libcloud/compute/drivers/gandi.py @@ -436,7 +436,7 @@ def list_sizes(self, location=None): def _to_loc(self, loc): return NodeLocation( id=loc['id'], - name=loc['name'], + name=loc['dc_code'], country=loc['country'], driver=self ) diff --git a/libcloud/test/compute/fixtures/gandi/datacenter_list.xml b/libcloud/test/compute/fixtures/gandi/datacenter_list.xml index 9d8cc688af..09135a4d20 100644 --- a/libcloud/test/compute/fixtures/gandi/datacenter_list.xml +++ b/libcloud/test/compute/fixtures/gandi/datacenter_list.xml @@ -19,6 +19,10 @@ id 1 + + dc_code + FR-SD2 + name Equinix Paris @@ -35,6 +39,10 @@ iso US + + dc_code + US-BA1 + id 2 @@ -50,4 +58,4 @@ - \ No newline at end of file +