Reply

Proper way to update a network

Authority
Posts: 31
6668     0

What is the proper way to update a network's EAs in IPAM?  

 

I know for a host, you have to delete and then readd it, but I've read somewhere on the forums or the documentation that networks are different in that way.  So I tried a PUT to modify it, and it failed in this way:

 

curl -k -u user:pw -H "Content-Type: application/json" -X PUT https://ipam.domain.com/wapi/v2.2/network/ZG5zLm5ldHdvcmskMTAuMTQyLjcxLjAvMjQvMA:10.142.71.0/24/default -d '[{"comment":"HPBX"}]'
{ "Error": "AdmConProtoError: Input is not an object",
"code": "Client.Ibap.Proto",
"text": "Input is not an object"

 

To prove that the network really does exist, I did a GET:

curl -k -u toolbox:tool@box  -X GET https://ipam.mgt.epbinternet.com/wapi/v2.2/network?ipv4addr=10.142.71.0/24?_return_fields=extattrs
[
    {
        "_ref": "network/ZG5zLm5ldHdvcmskMTAuMTQyLjcxLjAvMjQvMA:10.142.71.0/24/default",
        "network": "10.142.71.0/24",
        "network_view": "default"
    }
]

 

 

So I moved on to the delete/add method.  I can delete with no problem, but I can only POST if I have no EAs.

Here's where it works: 

curl -k -u user:pw -H "Content-Type: application/json" -X POST https://ipam.domain.com/wapi/v2.2/network?_return_fields=extattrs -d '{"network":"10.142.71.0/24"}'
{
"_ref": "network/ZG5zLm5ldHdvcmskMTAuMTQyLjcxLjAvMjQvMA:10.142.71.0/24/default",
"extattrs": {
"Type": {
"inheritance_source": {
"_ref": "networkcontainer/ZG5zLm5ldHdvcmtfY29udGFpbmVyJDEwLjAuMC4wLzgvMA:10.0.0.0/8/default"
},
"value": "Private"
}
}
}

 

And here's where it fails, when I add the Circuit_id EA to it, which is defined as an EA in the admin console:

curl -k -u user:pw  -H "Content-Type: application/json"  -X POST https://ipam.domain.com/wapi/v2.2/network?_return_fields=extattrs -d '[{"network": {"value": "10.142.71.0\/24"},"extattrs": {"Circuit_id": {"value": 77867}}}]'
{ "Error": "AdmConProtoError: Multiple-object requests should be submitted to the \"request\" object only",
  "code": "Client.Ibap.Proto",
  "text": "Multiple-object requests should be submitted to the \"request\" object only"
}

 

That JSON validates in the last example, but it must not be what it's looking for.  That error doesn't make any sense.  The only "multiple" is where I added the EA to the JSON data.  But if I can't directly update a network (see first section in this post) and I can only have a single value in the JSON when I add a network, how am I supposed to add EAs to a network?  It's a catch-22, so I must be missing something!

 

Thanks!

Blair

Re: Proper way to update a network

Moderator
Moderator
Posts: 87
6669     0

Here is an example that will update or add an EA on a network:

 

curl -k1 -u admin:infoblox -H "Content-Type: application/json" -X PUT https://10.60.27.4/wapi/v2.5/network/ZG5zLm5ldHdvcmskMTAuMTI4LjAuMC8yMC8w:10.128.0.0/20/default -d '{"extattrs+":{"TestEA2":{"value":"Test String"}}}'

Pay close attention to that "extaddrs+" as that is what tells the WAPI to add or update the EA value. Without the + the entire set of EAs will be replaced with the one specified.

 

See the "Extensible attributes update" section of the WAPI help for more information.

Re: Proper way to update a network

Authority
Posts: 31
6669     0

Thank you!  Now I'm hopeful that that will make updating the ipv4addr's easier too! Smiley Happy

Re: Proper way to update a network

Guru
Posts: 55
6669     0

I have a related issue.  The WAPI guide gives this example as to how to search for networks that have an EA with a particular value:

 

GET /wapi/v2.5/network?*Building:='Data Center'

That's great and all but not exactly what I need.  Suppose I have a network object: 

 

network/ZG5zLm5ldHdvcmskMTAuMjAuMTAwLjAvMjQvMA:10.20.100.0/24/default

 

I want to be able to retreive that object, and while doing so, also retrieve the values assigned to any/all extensible attributes for that network object. Now granted, for the most part,but network objects will not have many (if any) but over time, it's my intent to populate the object with valuable metadata, and update it upon occasion.  By update Imeant update one EA, not replace the whole shooting match with one new value.

 

I plan on using something like this:

ea =    { "zone":       { "value": ea_zone },
          "vrf":        { "value": ea_vrf },
          "vlan_id":    { "value": ea_vlan_id },
          "vlan_name":  { "value": ea_vlanname },
          "DHCP":       { "value": ea_dhcp },
          "usage":      { "value": ea_usage },
          "Lab Name":   { "value": ea_lab_name },
          "access_sw":  { "value": ea_switch },
          "legacy_vlan":{ "value": ea_legacy_vlan },
          "building":   { "value": ea_building },
          "tech":       { "value": ea_tech },
          "dept":       { "value": ea_dept },
          "fac_dept":   { "value": ea_fac_dept },
          "fac_owner":  { "value": ea_fac_owner },
          "floor":      { "value": ea_floor },
          "renewal_dt": { "value": ea_renewal_dt },
          "service":    { "value": ea_service },
          "site":       { "value": ea_site },
          "source":     { "value": ea_source }}

where some EAs will be mandatory going forward, but most will be optional.  In any case, I need to be able to read them in, make updates, and write them back out.

 

I've tried using 'extattrs' in the _return_fields: clause, but all I seem to get is _ref, address,/CIDR, view, and Comment.

 

Example:

{'_ref': 'network/ZG5zLm5ldHdvcmskMTAuMjAuMTAwLjAvMjQvMA:10.20.100.0/24/default', 'comment': 'R10N Core Network Services-McLean', 'network': '10.20.100.0/24', 'network_view': 'default'}
>>> 

Re: Proper way to update a network

Moderator
Moderator
Posts: 87
6669     0

This works for me to get all of the EAs assigned to the object:

 

curl -k1 -u admin:infoblox -H "Content-Type: appliction/json" -X GET https://10.60.27.4/wapi/v2.5/networkcontainer?_return_fields%2B=extattrs -d '{"network":"10.128.0.0/10"}'

Note that the %2B is URL encoding for a +. The _return_fields+=extattrs adds the EAs to the fields normally returned. If you omit the + you will just get the EAs.

Re: Proper way to update a network

[ Edited ]
Techie
Posts: 4
6669     0

I am trying to update my existing network with PUT request. First I tried for 4.4.4.0/24 and it threw an error.

 

Sending request through postman with PUT request.

 

https://infobloxsite/wapi/v2.11.1/network/ZG5z5ldHdvcmskMTAuMS4xLjAvMjQvMA:4.4.4.0/24/default/

 

Body:

 

 
{"options": [{"name": "routers",
"use_option": true,
"value": "4.4.4.1",
"vendor_class": "DHCP"}]}
 
 
Error:
 
 
{
"Error": "AdmConDataError: None (IBDataConflictError: IB.Data.Conflict:Router address 4.4.4.1 should be in the same subnet as address 10.1.1.0/24)",
"code": "Client.Ibap.Data.Conflict",
"text": "Router address 4.4.4.1 should be in the same subnet as address 10.1.1.0/24"
}
 
 
this error is for some other network that already exists. so I tried to update that network(10.1.1.0/24) and it worked with giving the same network(4.4.4.0/24) in URL. It always redirects to 10.1.1.0/24 network.
 

Sending request through postman with PUT request.

 

https://infobloxsite/wapi/v2.11.1/network/ZG5z5ldHdvcmskMTAuMS4xLjAvMjQvMA:4.4.4.0/24/default/

 

Body:

 

{"options": [{"name": "routers",
"use_option": true,
"value": "10.1.1.1",
"vendor_class": "DHCP"}]}
 
 
result:
 
"network/ZG5zLm5ldHdvcmskMTAuMS4xLjAvMjQvMA:10.1.1.0/24/default"
 
Please suggest to me what's going on here and how can I resolve this issue. I just want to update my existing networks (add dhcp_member, add router, extra attributes, etc.) through api.
 
 
Thanks,
Aditi
 

Re: Proper way to update a network

Adviser
Posts: 65
6669     0

You have probably figured this out already, but the reference id is unique to each subnet.  It can't be reused by changing the subnet info at the end.  As you can see, that subnet info is strictly informational, as the reference you used was for 10.1.1.0/24, not 4.4.4.0/24.   You need a GET call for the network to to find the '_ref' object, then PUT to the correct _ref.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin