libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [2/2] libcloud git commit: Fix HostVirtual list_locations Closes #1050
Date Thu, 04 May 2017 01:46:22 GMT
Fix HostVirtual list_locations
Closes #1050


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

Branch: refs/heads/trunk
Commit: a421668d14004c41d47bece269f321707a20bfef
Parents: 74c6ae5
Author: T. Tran <t-tran@users.noreply.github.com>
Authored: Wed May 3 12:09:02 2017 +0700
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Thu May 4 10:16:24 2017 +1000

----------------------------------------------------------------------
 libcloud/compute/drivers/hostvirtual.py         |   5 +-
 .../fixtures/hostvirtual/list_locations.json    | 150 +++++++++++++------
 libcloud/test/compute/test_hostvirtual.py       |   2 +-
 3 files changed, 109 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a421668d/libcloud/compute/drivers/hostvirtual.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/hostvirtual.py b/libcloud/compute/drivers/hostvirtual.py
index e56889e..b5d8784 100644
--- a/libcloud/compute/drivers/hostvirtual.py
+++ b/libcloud/compute/drivers/hostvirtual.py
@@ -85,13 +85,14 @@ class HostVirtualNodeDriver(NodeDriver):
     def list_locations(self):
         result = self.connection.request(API_ROOT + '/cloud/locations/').object
         locations = []
-        for dc in result:
+        for k in result:
+            dc = result[k]
             locations.append(NodeLocation(
                 dc["id"],
                 dc["name"],
                 dc["name"].split(',')[1].replace(" ", ""),  # country
                 self))
-        return locations
+        return sorted(locations, key=lambda x: int(x.id))
 
     def list_sizes(self, location=None):
         params = {}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a421668d/libcloud/test/compute/fixtures/hostvirtual/list_locations.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/hostvirtual/list_locations.json b/libcloud/test/compute/fixtures/hostvirtual/list_locations.json
index 4172105..3c23099 100644
--- a/libcloud/test/compute/fixtures/hostvirtual/list_locations.json
+++ b/libcloud/test/compute/fixtures/hostvirtual/list_locations.json
@@ -1,46 +1,106 @@
-[
-  {
-    "id": "3",
-    "name": "SJC - San Jose, CA"
-  },
-  {
-    "id": "13",
-    "name": "IAD2- Reston, VA"
-  },
-  {
-    "id": "21",
-    "name": "LAX3 - Los Angeles, CA"
-  },
-  {
-    "id": "31",
-    "name": "CHI - Chicago, IL"
-  },
-  {
-    "id": "41",
-    "name": "NYC - New York, NY"
-  },
-  {
-    "id": "61",
-    "name": "MAA - Chennai (Madras), India"
-  },
-  {
-    "id": "71",
-    "name": "LON - London, United Kingdom"
-  },
-  {
-    "id": "72",
-    "name": "AMS2 - Amsterdam, NL"
-  },
-  {
-    "id": "82",
-    "name": "FRA - Paris, France"
-  },
-  {
-    "id": "83",
-    "name": "HK - Hong Kong, HK"
-  },
-  {
-    "id": "101",
-    "name": "DFW - Dallas, TX"
+{
+  "SJC - San Jose, CA": {
+    "name": "SJC - San Jose, CA",
+    "id": "3"
+  },
+  "IAD - Reston, VA": {
+    "name": "IAD - Reston, VA",
+    "id": "13"
+  },
+  "LAX - Los Angeles, CA": {
+    "name": "LAX - Los Angeles, CA",
+    "id": "21"
+  },
+  "CHI - Chicago, IL": {
+    "name": "CHI - Chicago, IL",
+    "id": "31"
+  },
+  "LGA - New York, NY": {
+    "name": "LGA - New York, NY",
+    "id": "41"
+  },
+  "MAA - Chennai (Madras), India": {
+    "name": "MAA - Chennai (Madras), India",
+    "id": "61"
+  },
+  "LHR - London, United Kingdom": {
+    "name": "LHR - London, United Kingdom",
+    "id": "71"
+  },
+  "AMS - Amsterdam, NL": {
+    "name": "AMS - Amsterdam, NL",
+    "id": "72"
+  },
+  "CDG - Paris, France": {
+    "name": "CDG - Paris, France",
+    "id": "82"
+  },
+  "HKG - Hong Kong, HK": {
+    "name": "HKG - Hong Kong, HK",
+    "id": "83"
+  },
+  "DFW - Dallas, TX": {
+    "name": "DFW - Dallas, TX",
+    "id": "101"
+  },
+  "SVM - StrongVM, DDoS Protected": {
+    "name": "SVM - StrongVM, DDoS Protected",
+    "id": "121"
+  },
+  "DEN - Denver, CO": {
+    "name": "DEN - Denver, CO",
+    "id": "122"
+  },
+  "MIA - Miami, FL": {
+    "name": "MIA - Miami, FL",
+    "id": "123"
+  },
+  "SEA - Seattle, WA": {
+    "name": "SEA - Seattle, WA",
+    "id": "124"
+  },
+  "TOR - Toronto, CA": {
+    "name": "TOR - Toronto, CA",
+    "id": "127"
+  },
+  "SYD - Sydney, AU": {
+    "name": "SYD - Sydney, AU",
+    "id": "137"
+  },
+  "OTP - Bucharest, RO": {
+    "name": "OTP - Bucharest, RO",
+    "id": "146"
+  },
+  "FRA - Frankfurt, DE": {
+    "name": "FRA - Frankfurt, DE",
+    "id": "164"
+  },
+  "SIN - Singapore, SG": {
+    "name": "SIN - Singapore, SG",
+    "id": "173"
+  },
+  "GRU - Sao Paulo, Brazil": {
+    "name": "GRU - Sao Paulo, Brazil",
+    "id": "182"
+  },
+  "SJC2 - San Jose, CA": {
+    "name": "SJC2 - San Jose, CA",
+    "id": "227"
+  },
+  "RDU - Raleigh, NC": {
+    "name": "RDU - Raleigh, NC",
+    "id": "236"
+  },
+  "IAD3 - Ashburn, VA": {
+    "name": "IAD3 - Ashburn, VA",
+    "id": "245"
+  },
+  "DFW2 - Dallas, TX": {
+    "name": "DFW2 - Dallas, TX",
+    "id": "281"
+  },
+  "PHX - Phoenix, AZ": {
+    "name": "PHX - Phoenix, AZ",
+    "id": "290"
   }
-]
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a421668d/libcloud/test/compute/test_hostvirtual.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_hostvirtual.py b/libcloud/test/compute/test_hostvirtual.py
index 35d0fe1..0260d43 100644
--- a/libcloud/test/compute/test_hostvirtual.py
+++ b/libcloud/test/compute/test_hostvirtual.py
@@ -64,7 +64,7 @@ class HostVirtualTest(unittest.TestCase):
         self.assertEqual(locations[0].id, '3')
         self.assertEqual(locations[0].name, 'SJC - San Jose, CA')
         self.assertEqual(locations[1].id, '13')
-        self.assertEqual(locations[1].name, 'IAD2- Reston, VA')
+        self.assertEqual(locations[1].name, 'IAD - Reston, VA')
 
     def test_reboot_node(self):
         node = self.driver.list_nodes()[0]


Mime
View raw message