Skip to content

Device.create: overrides ip_addresses #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packet/Manager.py
Original file line number Diff line number Diff line change
@@ -138,6 +138,10 @@ def create_device(
hardware_reservation_id="",
storage={},
customdata={},
ip_addresses=[
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about the defaults that are being provided in this PR. I see evidence that the default IP address allocation for a device includes:

  • IPv4 Public
  • IPv6 Public
  • IPv4 False

Could the defaulting behavior introduced here be avoided if =None was default? Unless I am missing something, If a user wants to request 'no IP addresses', they could then supply create_device(..., ip_addresses=[]).

If this results in ip_addresses: null being sent to the API, and the API treats this the same as [], then avoid adding ip_addresses to params when it is None.

Copy link
Member

Choose a reason for hiding this comment

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

ip_addresses=[] should be sent as an empty array to the API, to which the API will report that at least a management IP address must be included. I can imagine the API removing this limitation in the future.

ip_address=None should be omitted in API requests, this is how you request the default IP Addresses which are generally, but not necessarily (depending on OS and plan) the following:

    {"address_family": 4, "public": False},
    {"address_family": 4, "public": True},
    {"address_family": 6, "public": False}

{"address_family": 4, "public": True},
{"address_family": 6, "public": False}
],
):

params = {
@@ -154,6 +158,7 @@ def create_device(
"tags": tags,
"user_ssh_keys": user_ssh_keys,
"userdata": userdata,
"ip_addresses": ip_addresses,
}

if hardware_reservation_id != "":