Skip to content
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

Created hcloud_primary_ip_info #149

Conversation

kcastner
Copy link

SUMMARY

Created hcloud_primary_ip_info

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

hcloud_primary_ip_info

ADDITIONAL INFORMATION

Created missing module "hcloud_primary_ip_info" like "hcloud_floating_ip_info" for Primary IPs

@apricote apricote self-requested a review January 27, 2023 12:20
Copy link
Collaborator

@apricote apricote left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution! In general this looks good, I just found a few things I want to discuss.

Also, if you have the time it would be great if you could implement tests for this. You can just copy&paste the tests for hcloud_floating_ip_info (tests/integration/targets/hcloud_floating_ip_info/) and modify to use primary ips instead. Its fine if you do not have time for this, then I will add the tests later.

Comment on lines +164 to +176
# if self.module.params.get("id") is not None:
# self.hcloud_primary_ip_info = [self.client.primary_ips.get_by_id(
# self.module.params.get("id")
# )]
# elif self.module.params.get("name") is not None:
# self.hcloud_primary_ip_info = [self.client.primary_ips.get_by_name(
# self.module.params.get("name")
# )]
# elif self.module.params.get("label_selector") is not None:
# self.hcloud_primary_ip_info = self.client.primary_ips.get_all(
# label_selector=self.module.params.get("label_selector"))
# else:
# self.hcloud_primary_ip_info = self.client.primary_ips.get_all()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason why you commented out this section? This is required for the functionality of the module.

This works fine, I uncommented it and removed line 178, and everything worked as expected :)

Comment on lines +152 to +155
"assignee_id": to_native(primary_ip.assignee_id),
"assignee_type": to_native(primary_ip.assignee_type),
"home_location": to_native(primary_ip.datacenter.name),
"dns_ptr": to_native(dns_ptr),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Calling to_native on None causes the field to have the string value "None" instead of the expected null.

Suggested change
"assignee_id": to_native(primary_ip.assignee_id),
"assignee_type": to_native(primary_ip.assignee_type),
"home_location": to_native(primary_ip.datacenter.name),
"dns_ptr": to_native(dns_ptr),
"assignee_id": None if primary_ip.assignee_id is None else to_native(primary_ip.assignee_id),
"assignee_type": to_native(primary_ip.assignee_type),
"home_location": to_native(primary_ip.datacenter.name),
"dns_ptr": None if dns_ptr is None else to_native(dns_ptr),

if primary_ip is not None:
dns_ptr = None
if len(primary_ip.dns_ptr) > 0:
dns_ptr = primary_ip.dns_ptr[0]["dns_ptr"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
dns_ptr = primary_ip.dns_ptr[0]["dns_ptr"]
dns_ptr = primary_ip.dns_ptr[0]["dns_ptr"]

@jooola
Copy link
Collaborator

jooola commented Jun 19, 2023

@kcastner Thanks a lot for the contribution, I'll continue your work in #225.

@jooola jooola closed this Jun 20, 2023
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