You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2020/11/05 22:21:19 UTC

[GitHub] [libcloud] sergerdn commented on a change in pull request #1506: allow vultr.list_nodes to return extra values

sergerdn commented on a change in pull request #1506:
URL: https://github.com/apache/libcloud/pull/1506#discussion_r518405283



##########
File path: libcloud/compute/drivers/vultr.py
##########
@@ -15,20 +15,574 @@
 """
 Vultr Driver
 """
-
 import time
 from functools import update_wrapper
 
-from libcloud.utils.py3 import httplib
-from libcloud.utils.py3 import urlencode
-
 from libcloud.common.base import ConnectionKey, JsonResponse
-from libcloud.compute.types import Provider, NodeState
 from libcloud.common.types import InvalidCredsError
 from libcloud.common.types import LibcloudError
 from libcloud.common.types import ServiceUnavailableError
-from libcloud.compute.base import NodeDriver
 from libcloud.compute.base import Node, NodeImage, NodeSize, NodeLocation
+from libcloud.compute.base import NodeDriver
+from libcloud.compute.types import Provider, NodeState
+from libcloud.utils.iso8601 import parse_date
+from libcloud.utils.py3 import httplib
+from libcloud.utils.py3 import urlencode
+
+# For matching region by id
+VULTR_COMPUTE_INSTANCE_LOCATIONS = {
+    "1": {
+        "DCID": "1",
+        "name": "New Jersey",
+        "country": "US",
+        "continent": "North America",
+        "state": "NJ",
+        "regioncode": "EWR"
+    },
+    "2": {
+        "DCID": "2",
+        "name": "Chicago",
+        "country": "US",
+        "continent": "North America",
+        "state": "IL",
+        "regioncode": "ORD"
+    },
+    "3": {
+        "DCID": "3",
+        "name": "Dallas",
+        "country": "US",
+        "continent": "North America",
+        "state": "TX",
+        "regioncode": "DFW"
+    },
+    "4": {
+        "DCID": "4",
+        "name": "Seattle",
+        "country": "US",
+        "continent": "North America",
+        "state": "WA",
+        "regioncode": "SEA"
+    },
+    "5": {
+        "DCID": "5",
+        "name": "Los Angeles",
+        "country": "US",
+        "continent": "North America",
+        "state": "CA",
+        "regioncode": "LAX"
+    },
+    "6": {
+        "DCID": "6",
+        "name": "Atlanta",
+        "country": "US",
+        "continent": "North America",
+        "state": "GA",
+        "regioncode": "ATL"
+    },
+    "7": {
+        "DCID": "7",
+        "name": "Amsterdam",
+        "country": "NL",
+        "continent": "Europe",
+        "state": "",
+        "regioncode": "AMS"
+    },
+    "8": {
+        "DCID": "8",
+        "name": "London",
+        "country": "GB",
+        "continent": "Europe",
+        "state": "",
+        "regioncode": "LHR"
+    },
+    "9": {
+        "DCID": "9",
+        "name": "Frankfurt",
+        "country": "DE",
+        "continent": "Europe",
+        "state": "",
+        "regioncode": "FRA"
+    },
+    "12": {
+        "DCID": "12",
+        "name": "Silicon Valley",
+        "country": "US",
+        "continent": "North America",
+        "state": "CA",
+        "regioncode": "SJC"
+    },
+    "19": {
+        "DCID": "19",
+        "name": "Sydney",
+        "country": "AU",
+        "continent": "Australia",
+        "state": "",
+        "regioncode": "SYD"
+    },
+    "22": {
+        "DCID": "22",
+        "name": "Toronto",
+        "country": "CA",
+        "continent": "North America",
+        "state": "",
+        "regioncode": "YTO"
+    },
+    "24": {
+        "DCID": "24",
+        "name": "Paris",
+        "country": "FR",
+        "continent": "Europe",
+        "state": "",
+        "regioncode": "CDG"
+    },
+    "25": {
+        "DCID": "25",
+        "name": "Tokyo",
+        "country": "JP",
+        "continent": "Asia",
+        "state": "",
+        "regioncode": "NRT"
+    },
+    "34": {
+        "DCID": "34",
+        "name": "Seoul",
+        "country": "KR",
+        "continent": "Asia",
+        "state": "",
+        "regioncode": "ICN"
+    },
+    "39": {
+        "DCID": "39",
+        "name": "Miami",
+        "country": "US",
+        "continent": "North America",
+        "state": "FL",
+        "regioncode": "MIA"
+    },
+    "40": {
+        "DCID": "40",
+        "name": "Singapore",
+        "country": "SG",
+        "continent": "Asia",
+        "state": "",
+        "regioncode": "SGP"
+    }
+}
+# For matching image by id
+VULTR_COMPUTE_INSTANCE_IMAGES = {

Review comment:
       Thank you for comments. I didn't it because I "stolen" this logic from other cloud provider. But your way is better in any case. Please keep in mind that this project is pretty new for me, therefor I do not know how to make this project better with clean code.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org