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

POST to /api/ipam/prefixes/{pk}/available-ips/ API returns a /32 address rather than prefix's netmask #2222

Closed
pm17788 opened this issue Jul 6, 2018 · 1 comment
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@pm17788
Copy link

pm17788 commented Jul 6, 2018

Issue type

[ ] Feature request
[x] Bug report
[ ] Documentation
[ ] Housekeeping

Environment

  • Python version: 3.5.4
  • NetBox version: 2.3.4

Description

Given the following prefix definition:

{
  "id": 481,
  "family": 4,
  "prefix": "172.16.240.0/27",
  "site": {
    "id": 5,
    "url": "https://netbox/api/dcim/sites/5/",
    "name": "TEST_SITE",
    "slug": "TEST_SITE"
  },
  "vrf": null,
  "tenant": null,
  "vlan": null,
  "status": {
    "label": "Active",
    "value": 1
  },
  "role": {
    "id": 1,
    "url": "https://netbox/api/ipam/roles/1/",
    "name": "Production",
    "slug": "production"
  },
  "is_pool": false,
  "description": "pm17788 Testing POC. Prefix 1",
  "custom_fields": {
    "prefix_gateway": "172.16.0.10",
    "bond0": true
  },
  "created": "2018-03-13",
  "last_updated": "2018-06-22T11:58:02.105686Z"
}

Additionally, a device interface exists:

{
  "id": 6574731,
  "device": {
    "id": 370881,
    "url": "https://netbox/api/dcim/devices/370881/",
    "name": "server-0CC47ABB77FD",
    "display_name": "server-0CC47ABB77FD"
  },
  "name": "eth0",
  "form_factor": {
    "label": "1000BASE-T (1GE)",
    "value": 1000
  },
  "enabled": true,
  "lag": null,
  "mtu": 0,
  "mac_address": "0C:C4:7A:BB:77:FD",
  "mgmt_only": false,
  "description": "Interface 'eth0' on host 'server-0CC47ABB77FD'",
  "is_connected": false,
  "interface_connection": null,
  "circuit_termination": null,
  "mode": null,
  "untagged_vlan": null,
  "tagged_vlans": []
}

During the POST to https://netbox/api/ipam/prefixes/481/available-ips/ of the following JSON, the result returns the ip of /32 rather than the (expected) prefix's /27

{
  "prefix": 481,
  "interface": 6574731,
  "status": 2,
  "description": "Reserving IP on INT 6574731, DEV 370881"
}
{
  "id": 868650,
  "address": "172.16.240.2/32",
  "vrf": null,
  "tenant": null,
  "status": 2,
  "role": null,
  "interface": 6574731,
  "description": "Reserving IP on INT 6574731, DEV 370881",
  "nat_inside": null,
  "created": "2018-07-06",
  "last_updated": "2018-07-06T18:40:03.133753Z"
}
@pm17788
Copy link
Author

pm17788 commented Jul 9, 2018

Curiously, doing a GET to the same API endpoint returns IPs with the correct net mask:

[
  {
    "family": 4,
    "address": "172.16.240.2/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.3/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.4/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.5/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.6/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.7/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.8/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.9/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.10/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.11/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.12/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.13/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.14/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.15/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.16/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.17/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.18/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.19/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.20/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.21/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.22/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.23/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.24/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.25/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.26/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.27/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.28/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.29/27",
    "vrf": null
  },
  {
    "family": 4,
    "address": "172.16.240.30/27",
    "vrf": null
  }
]

@pm17788 pm17788 changed the title POST to /api/ipam/prefixes/{pk}/available-ips/ API returns a /32 address rather than prefix's subnet POST to /api/ipam/prefixes/{pk}/available-ips/ API returns a /32 address rather than prefix's netmask Jul 17, 2018
@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation labels Jul 18, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants