Reply
Accepted Solution

Proper way to update a network

Authority
Posts: 31
3842     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 BRampling
Moderator
Posts: 69
3843     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
3843     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

Authority
Posts: 41
3843     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 BRampling
Moderator
Posts: 69
3843     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.

Showing results for 
Search instead for 
Do you mean 

Recommended for You

Infoblox ActiveTrust and a Deeper Dive Into your DNS Security