Skip to content

Commit

Permalink
fix: enable metal_reserved_ip_block to create VRF IP reservations (#…
Browse files Browse the repository at this point in the history
…233)

This fixes a couple problems with the parameter definitions for the
reserved IP block module:

1. The `cidr` and `network` parameters, needed for VRF IP reservations,
were not defined in the module spec
2. The `quantity` parameter, which is unsupported for VRF IP
reservations, was required in order to create _any_ IP reservation

This PR updates the reserved IP block module so that it can be used to
create a VRF IP reservation. The docs are also updated to reference the
`cidr` and `network` parameters.

This was broken out of #232.
  • Loading branch information
ctreatma authored Oct 4, 2024
1 parent 78e2439 commit d31f17a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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']],
['type', 'global_ipv4', ['quantity']]
],
)

Expand Down

0 comments on commit d31f17a

Please sign in to comment.