-
Notifications
You must be signed in to change notification settings - Fork 37
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
Created hcloud_primary_ip_info #149
Conversation
There was a problem hiding this 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.
# 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() |
There was a problem hiding this comment.
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 :)
"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), |
There was a problem hiding this comment.
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
.
"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"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dns_ptr = primary_ip.dns_ptr[0]["dns_ptr"] | |
dns_ptr = primary_ip.dns_ptr[0]["dns_ptr"] |
SUMMARY
Created hcloud_primary_ip_info
ISSUE TYPE
COMPONENT NAME
hcloud_primary_ip_info
ADDITIONAL INFORMATION
Created missing module "hcloud_primary_ip_info" like "hcloud_floating_ip_info" for Primary IPs