- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2021 02:13 AM
Hi,
How to get all subnets within an IPv4 network container, with REST API ?
Regards,
Aurelien
Solved! Go to Solution.
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2021 05:29 AM
Hi Aurelien,
You can filter the networks by their container like below:
API Call: https://<grid_ip>/wapi/v2.10/network?network_container=10.0.0.0/16&_return_fields%2B=network_container Sample Output: [ { "_ref": "network/ZG5zLm5ldHdvcmskMTAuMC4xMC4wLzI0LzA:10.0.10.0/24/Company%201", "comment": "Lab", "network": "10.0.10.0/24", "network_container": "10.0.0.0/16", "network_view": "Company 1" }, { "_ref": "network/ZG5zLm5ldHdvcmskMTAuMC4xLjAvMjQvMA:10.0.1.0/24/Company%201", "network": "10.0.1.0/24", "network_container": "10.0.0.0/16", "network_view": "Company 1" } ]
Hope this is helpful,
Krishna
Re: How to get all subnets within an IPv4 network container ?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2021 03:54 AM - edited 02-26-2021 01:31 AM
How to Get A Docker Container IP Address - Explained with Examples and run an application in a loosely isolated environment called a container.
mypennmedicine
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2021 08:52 AM
Thanks Krishna.
Is there a way to get comment field of an IPv4 network container ?
Re: How to get all subnets within an IPv4 network container ?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2021 10:20 PM - edited 02-14-2021 10:21 PM
Hi,
You can add it to the list of _return_fields like below:
For network: https://<grid_ip>/wapi/v2.10/network?network_container=10.0.0.0/16&_return_fields%2B=network_container,comment For network container: https://<grid_ip>/wapi/v2.10/networkcontainer?_return_fields%2B=comment
Regards,
Krishna Vasudevan
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2021 02:51 PM
Are you able to return the network container's comments within the output for all networks?
https://<grid>/wapi/v2.10/network?network_container=10.0.0.0/8&_return_fields%2B=network_container
plus something...
And get output like this?
[{
"_ref": "network/ZG5z...jgvMA:10.10.10.0/24/default",
"comment": "Example network comment",
"network": "10.10.10.0/24",
"network_container": "10.0.0.0/8",
"network_container:comment": "Example container comment",
"network_view": "default"
}]
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2021 07:27 AM
Hi,
I'm not clear regarding your question.
This is the output I get:
[ { "_ref": "network/ZG5zLm5ldHdvcmskMTAuMC4xMC4wLzI0LzA:10.0.10.0/24/Company%201", "comment": "Lab", "network": "10.0.10.0/24", "network_container": "10.0.0.0/16", "network_view": "Company 1" }, { "_ref": "network/ZG5zLm5ldHdvcmskMTAuMC4xLjAvMjQvMA:10.0.1.0/24/Company%201", "network": "10.0.1.0/24", "network_container": "10.0.0.0/16", "network_view": "Company 1" } ]
The comment field is returned by default if there is a comment added to the network/container.
Regards,
Krishna Vasudevan
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2021 10:20 PM
How to query to multiple network container and create a next_available_network using powershell?
please help out this much helpful for me
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2021 10:32 PM
Hi,
Here you go:
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Authorization", "Basic YWRtaW46aW5mb2Jsb3g=") $headers.Add("Content-Type", "application/json") $body = "{`n `"network`":`"func:nextavailablenetwork:192.168.0.0/16,27`"`n}" $response = Invoke-RestMethod 'https://grid-master.lab.com/wapi/v2.12/network' -Method 'POST' -Headers $headers -Body $body $response | ConvertTo-Json
You can modify the fields highlighted in bold. 192.168.0.0/16 is the network container. 27 is the CIDR of the new network you want to create.
Regards,
Krishna
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2021 06:30 AM
how to check network_container exists, if not create a network container and create network subnet into it using powershell with REST API?
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2021 11:48 AM
You have to develop the logic in your code, and then make separate API calls for each step.
Search for the network container, and count the number of results. If the number of results is zero, then the container does not exist and should be created.
10.0.0.0/8 exists in this grid:
curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.10/request' -H "Content-Type: application/json" -d \ '[ { "method":"GET", "object":"networkcontainer", "data": { "network": "10.0.0.0/8" } } ]' returns: [ [ { "_ref": "networkcontainer/ZG5zLm5ldHdvcmtfY29udGFpbmVyJDEwLjAuMC4wLzgvMA:10.0.0.0/8/default", "network": "10.0.0.0/8", "network_view": "default" } ] ]%
But 10.0.0.0/12 does not:
curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.10/request' -H "Content-Type: application/json" -d \ '[ { "method":"GET", "object":"networkcontainer", "data": { "network": "10.0.0.0/12" } } ]' returns an empty set: [ [] ]
Subnets can be created directly, or by using a next_available_network function within the network container.
Create the next available network inside a network container: (using the 10.0.0.0/8 from the first example)
curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.10/request' -H "Content-Type: application/json" -d \ '[ { "method":"POST", "object": "network", "enable_substitution": true, "data": { "network": "func:nextavailablenetwork:networkcontainer/ZG5zLm5ldHdvcmtfY29udGFpbmVyJDEwLjAuMC4wLzgvMA:10.0.0.0/8/default,24", "comment": "Created by Next Available Network" } } ]' returns a reference to the network that was created: [ "network/ZG5zLm5ldHdvcmskMTAuMC4yLjAvMjQvMA:10.0.2.0/24/default" ]
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2021 11:43 PM
can you please make the above code into powershell ?
please help me to solve this
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2021 11:39 PM
I have used this below code.. it showing an error like 400 bad request
$pwd = ConvertTo-SecureString "password" -AsPlainText -Force $creds = New-Object Management.Automation.PSCredential ("admin", $pwd) -ErrorAction stop $network_data = @{ network="func:nextavailablenetwork:$network_container,default,$cidr"; comment="PS-TESTAPI"; network_view="default" } $body = $network_data | ConvertTo-Json $new_network_discovery_url = "https://xx.xx.xxx.xx/wapi/v2.9.7/network" Invoke-RestMethod -Uri $new_network_discovery_url -Method POST -Body $body -Credential $creds -ContentType 'application/json' -UseBasicParsing
Below is the error i am getting
Invoke-RestMethod : The remote server returned an error: (400) Bad Request. At C:\Users\Desktop\Untitled4.ps1:52 char:1 + Invoke-RestMethod -Uri $new_network_discovery_url -Method POST -Body ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Please help me to solve this issue..
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2021 03:58 AM
Hi,
The below powershell code works for me:
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Authorization", "Basic auth") $headers.Add("Content-Type", "application/json") $body = "{ `n `"network`":`"func:nextavailablenetwork:10.0.0.0/8,default,24`", `n `"network_view`":`"default`", `n `"comment`":`"Test`" `n}" $response = Invoke-RestMethod 'https://grid-master/wapi/v2.7/network' -Method 'POST' -Headers $headers -Body $body $response | ConvertTo-Json
Regards,
Krishna
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2021 05:54 AM
how to check if particular network container is already utilizing 100% using REST API in powershell?
Re: How to get all subnets within an IPv4 network container ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2021 06:39 AM
The comment is for the network object and I also want the comment for the network container object.