THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

Need Help:Creating Extensible attribute using API

Authority
Posts: 29
12922     0

Hi Team,

 

I want to know is it possible to create new extensible attribute using WAPI?? If yes, please let me know the way. 

 

I didnt find any in the Infoblox API documentation.

Re: Need Help:Creating Extensible attribute using API

Moderator
Moderator
Posts: 317
12922     0

There are a few examples in the archives, here are a few more.

 

This lists the set of EAs defined on the grid:

 

 

curl -k1 -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.8/extensibleattributedef?_return_fields=name,type,list_values'

 

 

This creates a new EA "City".  of type STRING:

 

 

curl -k1 -u admin:infoblox -X POST 'https://10.9.16.6/wapi/v2.8/extensibleattributedef' -H "Content-Type: application/json" -d \
'{
  "name":"City",
  "type":"STRING"
}'

 

 

This creates a new EA "State". of type ENUM (enumerated list), with the value of every U.S. state:

 

 

curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.8/extensibleattributedef' -H "Content-Type: application/json" -d \
'{
  "name":"State",
  "type":"ENUM",
  "list_values":[
    {"value":"AL"},
    {"value":"AK"},
    {"value":"AZ"},
    {"value":"AR"},
    {"value":"CA"},
    {"value":"CO"},
    {"value":"CT"},
    {"value":"DE"},
    {"value":"DC"},
    {"value":"FL"},
    {"value":"GA"},
    {"value":"HI"},
    {"value":"ID"},
    {"value":"IL"},
    {"value":"IN"},
    {"value":"IA"},
    {"value":"KS"},
    {"value":"KY"},
    {"value":"LA"},
    {"value":"ME"},
    {"value":"MD"},
    {"value":"MA"},
    {"value":"MI"},
    {"value":"MN"},
    {"value":"MS"},
    {"value":"MO"},
    {"value":"MT"},
    {"value":"NE"},
    {"value":"NV"},
    {"value":"NH"},
    {"value":"NJ"},
    {"value":"NM"},
    {"value":"NY"},
    {"value":"NC"},
    {"value":"ND"},
    {"value":"OH"},
    {"value":"OK"},
    {"value":"OR"},
    {"value":"PA"},
    {"value":"RI"},
    {"value":"SC"},
    {"value":"SD"},
    {"value":"TN"},
    {"value":"TX"},
    {"value":"UT"},
    {"value":"VT"},
    {"value":"VA"},
    {"value":"WA"},
    {"value":"WV"},
    {"value":"WI"},
    {"value":"WY"}
  ]
}'

 

 

 

Re: Need Help:Creating Extensible attribute using API

Authority
Posts: 29
12923     0

Thanks Richard.

 

I was successful in creating a new extensible attribute with the below API request

 

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://172.40.165.192/wapi/v2.4/extensibleattributedef?_return_fields%2B=name,type&_return_as_objec..." -d '{"name": "Comments","type": "STRING"}'

 

but the problem is that the above API request creates extensible attribute "comments" for every network view that i have.

 

When I try to put reference for desired network ( in my case testing network view, see bwlow), it throws error

 

"_ref": "network/ZG5zLm5ldHdvcmskMTAuMTAuMC4wLzI0LzI:10.10.0.0/24/Testing",
"network": "10.10.0.0/24",
"network_view": "Testing"

 

API request: 

 

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://172.40.165.192/wapi/v2.4/network/ZG5zLm5ldHdvcmskMTAuMTAuMC4wLzI0LzI:10.10.0.0/24/Testing/ex..." -d '{"name": "Comments","type": "STRING"}'

 

Error:

 

{ "Error": "AdmConProtoError: Unknown argument/field: 'name'",
"code": "Client.Ibap.Proto",
"text": "Unknown argument/field: 'name'"
}

 

I just want to create the extensible attribute for one network view. can you help me in correcting my API request??

Re: Need Help:Creating Extensible attribute using API

Moderator
Moderator
Posts: 317
12923     0

When you create a new Extensible Attribute it is available for all objects.  (networks, zones, network views, etc.)

 

Did you want to add or change the extensible attribute value for the network view?

 

Also, there are regular attributes, "name" and "comment" for network views, you don't need extensible attributes for those.

 

 

Re: Need Help:Creating Extensible attribute using API

Adviser
Posts: 181
12923     0

Hi,

 

My understanding that you are trying to assign a value to the Extensible Attribute for your network.

 

You can do so using the following API

curl -k -u admin:Infoblox -H 'content-type: application/json' -X PUT "https://172.40.165.192/wapi/v2.4/network/ZG5zLm5ldHdvcmskMTAuMTAuMC4wLzI0LzI:10.10.0.0/24/Testing?_return_fields%2B=extattrs&_return_as_object=1" -d '{"extattrs":{"Comments": {"value": "Test"}}}'

Hope this helps,

Krishna

Re: Need Help:Creating Extensible attribute using API

Authority
Posts: 29
12923     0

Thanks Richard and Kvasudevan,

 

What I understood is that if i create a new extensible attribute, it will be created for all the network view. I cant create for one single network view.

 

The problem that I am facing is how to use the netwok view when i want to add a record to only one network view.

 

For example: In the below request, I want to add a record with hostname ="ABC" and ip=10.10.0..1 in network view=default.Testing

 

API request:

 

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://172.20.165.192/wapi/v2.4/record:host?_return_fields%2B=name,network_view&_return_as_object=1" -d '{"name":"ABC","ipv4addrs": [{"ipv4addr":"10.10.0.1","configure_for_dhcp":false}],"view":"default.Testing"}'

 

Error: 

but i get the error: "code": "Client.Ibap.Proto",
"text": "Unknown argument/field: 'configue_for_dhcp'"
}

 

Can you help me in fixing this error?

Re: Need Help:Creating Extensible attribute using API

Adviser
Posts: 181
12923     0

Hi,

 

From the error message, it looks like you have made a typo: configue_for_dhcp. It should be configure_for_dhcp.

 

Regards,

Krishna Vasudevan

Re: Need Help:Creating Extensible attribute using API

New Member
Posts: 1
12923     0

Is there a way to add more values to the existing extensible attribute using wapi?

Re: Need Help:Creating Extensible attribute using API

Moderator
Moderator
Posts: 317
12923     0

Yes.  You need to read the existing values into an array, add in the new value or values, and then write back the whole array.

Re: Need Help:Creating Extensible attribute using API

Adviser
Posts: 181
12923     0

Hi,

 

If you need to add additonal extensible attributes to an object using WAPI, you can do so by using extattrs+ option available like below:

Sample code (Assuming you already have an EA set called Building=HQ):
curl -k -u admin:infoblox -H 'content-type: application/json' -X PUT "https://grid-master/wapi/v2.11/record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5pbmZvLndhcGk:wapi.info.com/default?_return_fields%2B=extattrs&_return_as_object=1" -d '{"extattrs+":{"Site": {"value": "East"}}}'

Sample Output:
{"result": 
  {"_ref": "record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5pbmZvLndhcGk:wapi.info.com/default",
   "extattrs": 
    {"Site": {"value": "East"},
     "Building": {"value": "HQ"}
    },
   "ipv4addrs": 
    [{"_ref": "record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuY29tLmluZm8ud2FwaS4xMC4wLjAuMy4:10.0.0.3/wapi.info.com/default",
     "configure_for_dhcp": false,
     "host": "wapi.info.com",
     "ipv4addr": "10.0.0.3"
  }],
  "name": "wapi.info.com",
  "view": "default"
}}

However, if you need to add additional values to an existing EA, then you would need to do what MRichard suggests: read and save the existing values in an array, add the new value and insert it back using WAPI.

Re: Need Help:Creating Extensible attribute using API

New Member
Posts: 2
12923     0

Hi,

 

Need to assistant!

 

Now when I have an Extra attribute value created, how do I attach this to network object?

And also if I want to modiy inhetitance state to 'inhereted' on same API request.

 

Thanks in advance

Patric 

Re: Need Help:Creating Extensible attribute using API

Techie
Posts: 9
12923     0

Do you have an example of how to over-wright an existing Extensible Attribute array?

Re: Need Help:Creating Extensible attribute using API

Moderator
Moderator
Posts: 317
12923     0

Yes it is possible,  please see the first question & answer in this thread for examples.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You