My previous post on IP Address Insights I mentioned it wasn’t yet available with CLI but I was wrong!
It was there, just my Cloud Shell CLI version wasn’t the latest so didn’t have the command yet available. If you have 3.40.2 and above, the following commands are now available:
oci network ipam list-ip-inventory
oci network ipam get-resource-ip-inventory
oci network ipam get-subnet-cidr-utilization
oci network ipam get-subnet-ip-inventory
oci network ipam get-vcn-overlap
So, basically same features as you would have from Console UI. Let’s take a look on the first command which should give the full status similar as we had on IP Address Insights main page.
oci network ipam list-ip-inventory
Usage: oci network ipam list-ip-inventory [OPTIONS]
Error: Missing option(s) --region-list, --compartment-list.
So I will need to provide –region-list and –compartment-list as attributes. How I’ll do it is I need to create first two json documents for this as per documentation says:
oci network ipam list-ip-inventory --generate-param-json-input compartment-list > compartment-list.json
oci network ipam list-ip-inventory --generate-param-json-input region-list > region-list.json
That command will create two “empty” json files which I can edit accordingly, so for me the files look like this after modifying them:
tfg@server1 .oci % cat region-list.json
[
"ca-toronto-1"
]
tfg@server1 .oci % cat compartment-list.json
[
"ocid1.compartment.oc1..aaaaaaaacizywaohwmsyu4qq6q4djdq2nfbxr5iwh4l3kyxuivvr57b7gnjq",
"ocid1.compartment.oc1..aaaaaaaas62ttvslikcx6gizacdgay7xlgiqbnubarkyvzwvgdd53izt4zaq"
]
Interesting thing was that even when I had correct version in Cloud Shell, command didn’t execute successfully. I had to set CLI up on my laptop and then run the command there. Running the command now gives me full output as expected.
oci network ipam list-ip-inventory --compartment-list file://compartment-list.json --region-list file://region-list.json
{
"data": {
"compartments-per-tenant": 20,
"count": 5,
"inventory-vcn-collection": [
{
"compartment-id": "ocid1.compartment.oc1..aaaaaaaacizywaohwmsyu4qq6q4djdq2nfbxr5iwh4l3kyxuivvr57b7gnjq",
"dns-domain-name": "myanothervcn",
"inventory-subnetcollection": [
{
"compartment-id": "ocid1.compartment.oc1..aaaaaaaacizywaohwmsyu4qq6q4djdq2nfbxr5iwh4l3kyxuivvr57b7gnjq",
"dns-domain-name": "sub02221858380",
"inventory-resource-summary": [],
"inventory-subnet-cidr-collection": [
{
"ip-cidr-block": "10.0.1.0/25",
"utilization": 2.34
}
],
"region": "ca-toronto-1",
"resource-type": "Subnet",
"subnet-id": "ocid1.subnet.oc1.ca-toronto-1.aaaaaaaaqnk2iljxczfk75sjirzgpcvrrjfpew2vx2aoqbshhz76zwm7ru7a",
"subnet-name": "public subnet-my-another-vcn"
},
{
"compartment-id": "ocid1.compartment.oc1..aaaaaaaacizywaohwmsyu4qq6q4djdq2nfbxr5iwh4l3kyxuivvr57b7gnjq",
"dns-domain-name": "sub02221858381",
"inventory-resource-summary": [
{
"compartment-id": "ocid1.compartment.oc1..aaaaaaaacizywaohwmsyu4qq6q4djdq2nfbxr5iwh4l3kyxuivvr57b7gnjq",
"ip-address-collection": [
{
"dns-host-name": "server2.sub02221858381.myanothervcn.oraclevcn.com",
"ip-address": "10.0.1.168",
"vnic-id": "ocid1.vnic.oc1.ca-toronto-1.ab2g6ljrvethr4kkhbeafjkkyefnkwmljjfgbdr32xkps6yy24s5us4ltira",
"vnic-name": "server2"
}
],
"region": "ca-toronto-1",
"resource-name": "Resource1",
"resource-type": "Resource"
},
{
"compartment-id": "ocid1.compartment.oc1..aaaaaaaacizywaohwmsyu4qq6q4djdq2nfbxr5iwh4l3kyxuivvr57b7gnjq",
"ip-address-collection": [
{
"dns-host-name": "server1.sub02221858381.myanothervcn.oraclevcn.com",
"ip-address": "10.0.1.238",
"vnic-id": "ocid1.vnic.oc1.ca-toronto-1.ab2g6ljrmn3bnhjvtelkkphpnsaoxz43wnrpa7j2haqyos3ilhusnfbfspdq",
"vnic-name": "server1"
}
],
Above just extraction on the whole json output, what’s nice in it is you’ll see also the resources reserving the IPs so could create nice output from this if you need to automate some reporting or management.
IP Address Insights do support CLI commands after all! You can get output quickly to a file and then do automation based on that if needed, or maybe you want to load the data to Autonomous JSON database? That could be quickly doable as well using the Autonomous JSON Load Data feature.
This will NOT be a technical walkthrough on Oracle Database@Azure but rather my opinions and…
Recently OCI announced small but VERY useful service, IP Address Insights. Why this matters? I've…