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

fix: enable metal_reserved_ip_block to create VRF IP reservations #233

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions docs/modules/metal_reserved_ip_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ When a user provisions first device in a facility, Equinix Metal API automatical
| `customdata` | <center>`str`</center> | <center>Optional</center> | Custom data to associate with the reserved IP block |
| `comments` | <center>`str`</center> | <center>Optional</center> | Comments to associate with the reserved IP block |
| `vrf_id` | <center>`str`</center> | <center>Optional</center> | The ID of the VRF in which this VRF IP Reservation is created. The VRF must have an existing IP Range that contains the requested subnet. |
| `network` | <center>`str`</center> | <center>Optional</center> | The starting address for this VRF IP Reservation's subnet. Both IPv4 and IPv6 are supported. |
| `cidr` | <center>`int`</center> | <center>Optional</center> | The size of the VRF IP Reservation's subnet. The following subnet sizes are supported:<br>- IPv4: between 22 - 29 inclusive<br>- IPv6: exactly 64 |
| `project_id` | <center>`str`</center> | <center>Optional</center> | The ID of the project to which the reserved IP block will be assigned |
| `tags` | <center>`list`</center> | <center>Optional</center> | Tags to associate with the reserved IP block |

Expand Down
14 changes: 12 additions & 2 deletions plugins/modules/metal_reserved_ip_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@
'The VRF must have an existing IP Range that contains the requested subnet.',
],
),
network=SpecField(
type=FieldType.string,
description=['''The starting address for this VRF IP Reservation's subnet. Both IPv4 and IPv6 are supported.'''],
),
cidr=SpecField(
type=FieldType.integer,
description=['''The size of the VRF IP Reservation's subnet. The following subnet sizes are supported:<br>- IPv4: between 22 - 29 inclusive<br>- IPv6: exactly 64'''],
),
project_id=SpecField(
type=FieldType.string,
description=['The ID of the project to which the reserved IP block will be assigned'],
Expand Down Expand Up @@ -278,10 +286,12 @@ def main():
# argument_spec=argument_spec,
argument_spec=SPECDOC_META.ansible_spec,
required_one_of=[['id', 'project_id']],
required_by=dict(project_id=['quantity', 'type']),
required_by=dict(project_id=['type']),
required_if=[
['type', 'vrf', ['vrf_id', 'cidr', 'network']],
['type', 'public_ipv4', ['metro']]
['type', 'public_ipv4', ['quantity', 'metro']],
['type', 'private_ipv4', ['quantity']],
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't we also need metro for private_ipv4? (not sure that this is a generally consumable request type, so perhaps it is moot)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's possible, but this PR isn't a broad fix for all possible parameter validation in the metal_reserved_ip_block module; it's focused narrowly on fixing some validation that made the module completely unusable for VRF IP reservations. Adding the quantity requirement here and for global blocks maintains the previous validation behavior for those types while allowing VRF blocks to implement the correct validation.

['type', 'global_ipv4', ['quantity']]
],
)

Expand Down