lord-kyron / terraform-provider-phpipam

Terrform provider for PHPIPAM
https://registry.terraform.io/providers/lord-kyron/phpipam/latest
Apache License 2.0
54 stars 30 forks source link

Feature Request: Please add the "is_pool" field to the phpipam_subnet resource #78

Closed JonTheNiceGuy closed 6 months ago

JonTheNiceGuy commented 1 year ago

Setting a subnet as a "pool" makes the "network" and "broadcast" IPs available to allocation in the address space.

This is used when defining supernets (such as 192.168.0.0/16) or when partitioning subnets into smaller portions (e.g. 192.0.2.64/29 as a DHCP pool or a static IP range).

Version 1.5.2 of the terraform module does not currently provide this.

lord-kyron commented 1 year ago

@pavel-z1

pavel-z1 commented 1 year ago

Hi @JonTheNiceGuy I don't see pool in the PHPIPAM REST API documentation https://phpipam.net/api/api_reference/

Can you provides HTTP POST and GET examples?

JonTheNiceGuy commented 1 year ago

Sure :)

isPool is a flag on the subnet;

~$ curl --silent https://phpipam.example.org/api/terraform/subnets/218/ --header "token: DECAFbad123456789-." -X GET | jq .
{
  "code": 200,
  "success": true,
  "data": {
    "id": "218",
    "subnet": "198.51.100.0",
    "mask": "24",
    "sectionId": "19",
    "description": "demo",
    "linked_subnet": null,
    "firewallAddressObject": null,
    "vrfId": null,
    "masterSubnetId": "0",
    "allowRequests": "0",
    "vlanId": null,
    "showName": "0",
    "device": null,
    "permissions": "[]",
    "pingSubnet": "0",
    "discoverSubnet": "0",
    "resolveDNS": "0",
    "DNSrecursive": "0",
    "DNSrecords": "0",
    "nameserverId": "0",
    "scanAgent": "0",
    "customer_id": null,
    "isFolder": "0",
    "isFull": "0",
    "isPool": "1",
    "tag": "2",
    "threshold": "0",
    "location": null,
    "editDate": null,
    "lastScan": null,
    "lastDiscovery": null,
    "calculation": {
      "Type": "IPv4",
      "IP address": "/",
      "Network": "198.51.100.0",
      "Broadcast": "198.51.100.255",
      "Subnet bitmask": "24",
      "Subnet netmask": "255.255.255.0",
      "Subnet wildcard": "0.0.0.255",
      "Min host IP": "198.51.100.1",
      "Max host IP": "198.51.100.254",
      "Number of hosts": "254",
      "Subnet Class": "TEST-NET-2"
    }
  },
  "time": 0.005
}

For some reason, I'm struggling to create an add-subnet example, but this is failing on sections and CIDRs, not on the "isPool" value.

JonTheNiceGuy commented 1 year ago

I've added a PR to implement this at the SDK layer.

lord-kyron commented 1 year ago

@pavel-z1

pavel-z1 commented 1 year ago

Hi @JonTheNiceGuy I've merged you PR and created the new SDk release https://github.com/pavel-z1/phpipam-sdk-go/releases/tag/v0.1.8 But this will not add automatically ispool feature to the terraform provider You need to connect updated SDK to this project and add logic for creating pool

JonTheNiceGuy commented 1 year ago

@lord-kyron is there much that needs to happen to get this new variable/value into the terraform provider?

lord-kyron commented 1 year ago

@JonTheNiceGuy I guess it will take some effort to add this support. WIll you be able to create the pull requests for adding the support here also, as @pavel-z1 suggested?

JonTheNiceGuy commented 1 year ago

Yep, I'll take a look. My go knowledge is pretty weak, so I'll have a poke around one evening and see what I can do :)

lord-kyron commented 8 months ago

@JonTheNiceGuy, Did you have some time to take a look at this?

JonTheNiceGuy commented 8 months ago

Apologies, my focus at work shifted considerably, so I didn't get time to dedicate to this. Sorry!