danielshahaf opened a new issue, #1738: URL: https://github.com/apache/libcloud/issues/1738
## Summary Digital Ocean compute nodes' `.public_ips` attribute doesn't list IPv6 addresses. Patch for 3.6 tested against 3.4 included. ## Detailed Information Create a node with a public IPv6 address: ```python driver.create_node( name = ..., size = driver.list_sizes()[0], image = driver.list_images()[0], location = driver.list_locations()}[0], ex_create_attr = dict(ipv6=True), ) driver.wait_until_running([node]) ``` ([docs for `ex_create_attr`](https://libcloud.readthedocs.io/en/stable/compute/drivers/digital_ocean.html#libcloud.compute.drivers.digitalocean.DigitalOcean_v2_NodeDriver.create_node)). Now inspect the node's public IP addresses: ```python >>> print(driver.list_nodes()[0].public_ips) ['159.223.187.157'] ``` The IPv6 address is missing. (Observed in libcloud 3.4.1-5 in Debian sid — the latest I can easily test — but by code inspection applies to HEAD too.) ## Patch Here's a patch too. Not packaging it as a PR because I haven't done all the legwork (test it in 3.6 by hand and by test suite) yet, but posting it here since I didn't want to sit on it until I had time to finish it. ```diff diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py index df7f0ae..0ea5346 100644 --- a/libcloud/compute/drivers/digitalocean.py +++ b/libcloud/compute/drivers/digitalocean.py @@ -689,11 +689,11 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver, DigitalOceanNodeDri private_ips = [] public_ips = [] if networks: - for net in networks["v4"]: + for net in networks.get('v4', []) + networks.get('v6', []): if net["type"] == "private": - private_ips = [net["ip_address"]] + private_ips.append(net["ip_address"]) if net["type"] == "public": - public_ips = [net["ip_address"]] + public_ips.append(net["ip_address"]) extra = {} for key in extra_keys: ``` This was written against 3.4 but applied cleanly to 3.6 after changing single quotes to double quotes. ## Result ```python >>> print(driver.list_nodes()[0].public_ips) ['159.223.187.157', '2604:a880:400:d0::1c58:e001'] ``` I'm not sure whether the API contract allows this change. -- 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. To unsubscribe, e-mail: notifications-unsubscr...@libcloud.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org