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

Are there any way to check the availability of a certain CIDR range via using API #166

Closed
trandangtri opened this issue Sep 6, 2023 · 13 comments · Fixed by #181
Closed
Assignees
Labels
enhancement New feature or request

Comments

@trandangtri
Copy link

Let say I wanna allocate a subnet from within a certain CIDR range, from my administration application, via using API request. I just wanna make sure this CIDR range is available and not overlapped with others.

At this moment, can I do that with API request, to IPAM engine?

@DCMattyG DCMattyG self-assigned this Sep 6, 2023
@DCMattyG DCMattyG added the enhancement New feature or request label Sep 6, 2023
@DCMattyG
Copy link
Contributor

DCMattyG commented Sep 6, 2023

Hi @trandangtri, this is an excellent use case!

Just to be clear, we're talking about checking if a CIDR is in use withing a specific Space/Block, correct?

Whould an API like this make sense:
/api/spaces/ExampleSpace/blocks/ExampleBlock/cidrCheck

Or perhaps this might fit better under the Tools section:
/api/tools/cidrCheck

What are your thoughts here?

@trandangtri
Copy link
Author

trandangtri commented Sep 7, 2023

Hi @DCMattyG

Thanks for your response. Meant, we didn't support this function at this moment yet?
In that case, would you please recommend some way to work around? Highly appreciated

@DCMattyG
Copy link
Contributor

Hey @trandangtri, there's not workaround within the product today, but perhaps you could do some calculations using something like the netaddr library in Python. Not sure what environment you're using here.

I can get this feature added in fairly quickly. I'm finishing up some major updates this week, so I can likely have this done by the end of this month. Did you have a preference on how this API should be presented (from my comment above)?

@trandangtri
Copy link
Author

Hi @DCMattyG . That sounds great, thanks for support.

In general speaking, I prefer option #2, where I don't need to specify Space and Block as required. If I want to, I could do that with arguments.

/api/tools/cidrCheck

Regards

@DCMattyG
Copy link
Contributor

I'm on it @trandangtri!

I'll begin working on this right away 👍

@DCMattyG
Copy link
Contributor

Good afternoon @trandangtri, I wanted to run this by you...

Given an input CIDR of something like "10.1.0.0/16", would a response like the following make sense:

[
  {
    "name": "Test-vNET",
    "id": "/subscriptions/13599e70-8675-4012-ba4d-7508a8b9fd1e/resourceGroups/RG-TESTING/providers/Microsoft.Network/virtualNetworks/Test-vNET",
    "resource_group": "rg-testing",
    "subscription_id": "13599e70-8675-4012-ba4d-7508a8b9fd1e",
    "tenant_id": "9a885645-7e98-4479-8ae3-4118e0c13594",
    "prefixes": [
      "10.1.0.0/24"
    ],
    "containers": []
  },
  {
    "name": "Services-vNET",
    "id": "/subscriptions/57ff49dd-d5b5-48cb-b920-c5f0593c7f5b/resourceGroups/RG-SERVICES/providers/Microsoft.Network/virtualNetworks/Services-vNET",
    "resource_group": "rg-services",
    "subscription_id": "57ff49dd-d5b5-48cb-b920-c5f0593c7f5b",
    "tenant_id": "9a885645-7e98-4479-8ae3-4118e0c13594",
    "prefixes": [
      "10.1.0.0/16"
    ],
    "containers": [
      "/spaces/TestSpace/blocks/TestBlock"
    ]
  },
  {
    "name": "Marketing-vNET",
    "id": "/subscriptions/4bf4a48d-aa55-4c03-b575-fb612f52a218/resourceGroups/RG-MARKETING/providers/Microsoft.Network/virtualNetworks/Marketing-vNET",
    "resource_group": "rg-marketing",
    "subscription_id": "4bf4a48d-aa55-4c03-b575-fb612f52a218",
    "tenant_id": "9a885645-7e98-4479-8ae3-4118e0c13594",
    "prefixes": [
      "10.1.0.0/16"
    ],
    "containers": []
  }
] 

You can see here it would show you all overlapping vNET's, and call out the ones that are container within existing Spaces/Blocks if such an association exists.

Is this what you are looking for?

@trandangtri
Copy link
Author

Such wonderful. Although my initialized thought is to check the availability of a certain CIDR range, but in case we are able to dive deeper into the existing ranges like your response example, I would love to have a distinct container info:

[
  {
    "name": "Services-vNET",
    "id": "/subscriptions/57ff49dd-d5b5-48cb-b920-c5f0593c7f5b/resourceGroups/RG-SERVICES/providers/Microsoft.Network/virtualNetworks/Services-vNET",
    "resource_group": "rg-services",
    "subscription_id": "57ff49dd-d5b5-48cb-b920-c5f0593c7f5b",
    "tenant_id": "9a885645-7e98-4479-8ae3-4118e0c13594",
    "prefixes": [
      "10.1.0.0/16"
    ],
    "containers": [
      {
        "space": "TestSpace",
        "block": "TestBlock"
      }
    ]
  }
]

Then, I don't need to work on string parsing anymore, if I need to retrieve further information. Just my 2 cents

@DCMattyG
Copy link
Contributor

DCMattyG commented Oct 8, 2023

Hi @trandangtri, I've implemented this new API in the latest code changes from PR #181. Please restart your IPAM App Service to pull down the latest containers for testing.

image

Here's the details from the API Docs page:

image

Please give it a test and let me know if it meets all of your expectations. Thanks so much!

@DCMattyG DCMattyG linked a pull request Oct 8, 2023 that will close this issue
@DCMattyG
Copy link
Contributor

Good morning @trandangtri, just wanted to check-in with you on this item. Please let me know once you've had a chance to test everything out and have verified that the new API (above) meets your requirements.

Much appreciated!

@trandangtri
Copy link
Author

Hi @DCMattyG

That’s fantastic! I will try to manage my time to work on this, and keep you posted
Highly appreciated your quick response.

Regards

@DCMattyG
Copy link
Contributor

Hi @trandangtri, I know it's been a while but I wanted to see if you've had a chance to test out this functionality and are satisfied with the implementation.

Let me know when you can, thanks so much!

@DCMattyG
Copy link
Contributor

Good afternoon @trandangtri, I'm circling back one last time before closing out this issue. Have you been able to test everything out, and if so is everything looking good or perhaps is there anything we need to tweak about this solution?

Appreciate the feedback!

@DCMattyG
Copy link
Contributor

Hey there @trandangtri, as this item has been addressed for quite some time now, I'm going to close this issue for the time being. If for any reason you aren't satisfied with the provided fix, please feel free to either re-open this issue or file a new one, and I'll make sure we get everything working as you expected.

Thanks for the contribution, and know we're always here if there's anything else you ever need. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants