Skip to content

feat(oci): add instance property to get all ip addresses#492

Merged
uhryniuk merged 4 commits intocanonical:mainfrom
uhryniuk:oci-get-all-ips
Oct 30, 2025
Merged

feat(oci): add instance property to get all ip addresses#492
uhryniuk merged 4 commits intocanonical:mainfrom
uhryniuk:oci-get-all-ips

Conversation

@uhryniuk
Copy link
Copy Markdown
Contributor

@uhryniuk uhryniuk commented Oct 27, 2025

Description

An OCI instance is able to have multiple public IP addresses, for both IPv4 and IPv6, however no functionality exists to list all available public IP addresses. These changes include instance.ips which provides a list of all publicly available IP addresses.

Additionally, pycloudlib did not support allocating both IPv4 and IPv6 IPs on dual stack subnets. Changes were included to ensure that both IPs would be allocated when a subnet with both an v4 and v6 CIDR block was provided.

Additional Context and Relevant Issues

If an instance is launched with IPv6 only, the address is assigned to the instance,ip and same situation with IPv4 only. However, with dual stack subnets, the IPv4 address is prioritized for instance.ip but without these commits, there is not clean way to access the other IP addresses.

Test Steps

Existing unit tests were updated to reflect the additional functionality.

@uhryniuk uhryniuk force-pushed the oci-get-all-ips branch 2 times, most recently from c4ee28f to 07d7eb7 Compare October 27, 2025 19:40
@uhryniuk
Copy link
Copy Markdown
Contributor Author

Additionally added None check for for the azure diagnostics uri. The underlying azure library had changed their return type causing the linter error.

@uhryniuk uhryniuk force-pushed the oci-get-all-ips branch 6 times, most recently from 2325768 to 24c54b0 Compare October 28, 2025 21:34
@uhryniuk uhryniuk force-pushed the oci-get-all-ips branch 2 times, most recently from 53d061e to 8976edf Compare October 28, 2025 22:04
Copy link
Copy Markdown
Contributor

@Gisaldjo Gisaldjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a couple of small changes and some clarifying questions for my own understanding

Comment thread pycloudlib/oci/instance.py Outdated
if self._ip is None:
self._ip = primary_vnic.ipv6_addresses[0]
self._log.info("Using ipv6 address: %s", self._ip)
self.ips.extend(primary_vnic.ipv6_addresses)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be self._ips.extend()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should! changing 🫡

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Comment thread pycloudlib/oci/cloud.py
Comment thread pycloudlib/oci/cloud.py
Comment thread pycloudlib/oci/instance.py
Comment thread pycloudlib/oci/instance.py
@uhryniuk uhryniuk force-pushed the oci-get-all-ips branch 3 times, most recently from 8976edf to 641541b Compare October 29, 2025 16:04
@uhryniuk uhryniuk requested a review from Gisaldjo October 29, 2025 16:25
@uhryniuk uhryniuk requested a review from holmanb October 29, 2025 18:24
@uhryniuk uhryniuk merged commit 9e2a4b4 into canonical:main Oct 30, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants