From e91e160c8fc96414d2a744ba7c79c17a657ee7f2 Mon Sep 17 00:00:00 2001 From: Aymeric Barantal Date: Thu, 2 Feb 2012 15:36:36 +0100 Subject: [PATCH] public_ips fix for gandi driver, to not retain only the last ip for a node, but full list (include inet6 one) --- libcloud/compute/drivers/gandi.py | 7 +++++-- test/compute/test_gandi.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libcloud/compute/drivers/gandi.py b/libcloud/compute/drivers/gandi.py index 3f19bf7..1f8c877 100644 --- a/libcloud/compute/drivers/gandi.py +++ b/libcloud/compute/drivers/gandi.py @@ -15,6 +15,7 @@ """ Gandi driver for compute """ +import sys from datetime import datetime from libcloud.common.gandi import BaseGandiDriver, GandiException, \ @@ -68,7 +69,7 @@ class GandiNodeDriver(BaseGandiDriver, NodeDriver): vm['state'], NodeState.UNKNOWN ), - public_ips=vm.get('ip'), + public_ips=vm.get('ips', []), private_ips=[], driver=self, extra={ @@ -85,9 +86,11 @@ class GandiNodeDriver(BaseGandiDriver, NodeDriver): vms = self.connection.request('vm.list') ips = self.connection.request('ip.list') for vm in vms: + vm['ips'] = [] for ip in ips: if vm['ifaces_id'][0] == ip['iface_id']: - vm['ip'] = ip.get('ip') + if ip.get('ip'): + vm['ips'].append(ip['ip']) nodes = self._to_nodes(vms) return nodes diff --git a/test/compute/test_gandi.py b/test/compute/test_gandi.py index 4ec0d79..d763eff 100644 --- a/test/compute/test_gandi.py +++ b/test/compute/test_gandi.py @@ -59,6 +59,7 @@ class GandiTests(unittest.TestCase): def test_list_nodes(self): nodes = self.driver.list_nodes() self.assertTrue(len(nodes) > 0) + self.assertTrue(len(nodes[0].public_ips) > 1) def test_list_locations(self): loc = list(filter(lambda x: 'france' in x.country.lower(), -- 1.7.6.1