Reply

Editing/changing a fixed address with curl

Authority
Posts: 15
955     0

I want to edit an *existing* fixed address and add a dhcp option.

I'm using this json for the creation:

{
  "name": "testhostname",
  "ipv4addr": "10.0.0.1",
  "mac":"00:11:22:33:44:55",
  "match_client":"MAC_ADDRESS",
  "options":[
  { "name": "host-name",
    "num": 12,
    "value": "testhostname",
    "vendor_class": "DHCP"}]
}

And it works with this curl call:

curl -u <user>:<password> -H 'Content-Type: application/json' -X POST https://infoblox/wapi/v2.0/fixedaddress -d @add_dhcp_hostname.json

 

But when I have created a fixed address without this option and want to later add the host-name option, I get an error:

 

{ "Error": "AdmConDataError: None (IBDataConflictError: IB.Data.Conflict:MAC address 00:11:22:33:44:55 is used in two fixed addresses 10.0.0.1 and 10.0.0.1, which are in the same network 10.0.0.0/24.)",
"code": "Client.Ibap.Data.Conflict",
"text": "MAC address 00:11:22:33:44:55 is used in two fixed addresses 10.0.0.1 and 10.0.0.1, which are in the same network 10.0.0.0/24."

 

It looks like this is the wrong way to edit/change a fixed address ... even though I want to add a previously not existing option in an existing fixed address.

What is the right way to do it?

Re: Editing/changing a fixed address with curl

MRichard Community Manager
Community Manager
Posts: 101
956     0

When you create or search for an object (including fixed addrs) one of the returned fields is the _ref.  This is the object reference.

 

To make changes to an existing object, use a PUT call against the reference, and give it the fields that are changing.

 

Something like this perhaps, with the complete list of options in the JSON file:

 

curl -u <user>:<password> -H 'Content-Type: application/json' -X PUT https://infoblox/wapi/v2.0/fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTAzLjMuMzMuMC4u:10.0.0.1/default -d @add_dhcp_hostname.json

Note that the DHCP options field is an array.  It cannot be modified in-place, when you update it you need to send the entire array of DHCP options.  So you may need to use a script to read the array, add new option/value pairs, adn then write the array.

 

Re: Editing/changing a fixed address with curl

Authority
Posts: 15
956     0

Thanks.

Do you have an example? A simple one on how to get the _ref for a fixed address?

Initially I wanted to do all this with Ansible, but the nios_fixed_address module has a bug (see my other post).

 

Re: Editing/changing a fixed address with curl

MRichard Community Manager
Community Manager
Posts: 101
956     0

A simple get will give you the list of all fixed addresses, including the _ref:

 

curl -k -u admin:infoblox -X GET https://192.168.1.2/wapi/v2.3/fixedaddress

You can also search for a specific one:

 

curl -k -u admin:infoblox -X GET https://192.168.1.2/wai/v2.3/fixedaddress?ipv4addr=192.168.1.26

returns:

 

[
    {
        "_ref": "fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuOS4xNi4yNi4wLi4:192.168.1.26/default",
        "ipv4addr": "192.168.1.26",
        "network_view": "default"
    }
]

Re: Editing/changing a fixed address with curl

Authority
Posts: 15
956     0

Cool. One step closer. Thanks! I try to implement that.

I found that I need to add return_fields when I want to get more info than default.

I also want to get bootfile and nextserver. But adding those to returnfields, doesn't return anything.

Any hint on those?

 

Re: Editing/changing a fixed address with curl

Posts: 1
956     0

Thanks for this information. It is useful

Re: Editing/changing a fixed address with curl

MRichard Community Manager
Community Manager
Posts: 101
956     0

Are you sure bootfile and nextserver are configured directly on the fixedaddress?  They might be configured on the network or the grid instead, and inherited.

Re: Editing/changing a fixed address with curl

[ Edited ]
Authority
Posts: 15
956     0

Ehm, yes and no. I want to have a default nextserver but have the ability to override the default for each address, e.g. have the default bootserver Windows and be able to also boot from a Redhat Satellite or other OS install environment.

 

Following your answer, I suspect, that inherited entries are not displayed when I query a fixed address, correct?

Is there a way to show all effective settings for a certain entity, including the inherited? DHCP options also seem to be subject of inheritance, which makes things pretty hard... I mean, there can be more levels of inhertiance, one can't expect to follow the crumbs back to the initial configuration.

 

Is there a "better" best practice to boot different next servers than what we do?

 

Re: Editing/changing a fixed address with curl

MRichard Community Manager
Community Manager
Posts: 101
956     0

You are correct, the inherited values are not displayed, as they don't belong to this object but instead to the parent object.

 

There is an "_inheritance" flag however I haven't found it to work consistently.   It's giving me the lease time but not any other options inherited from the network.

 

curl -k -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.3/fixedaddress' \
-d 'network=192.168.1.0/24' \
-d '_return_fields=options,bootfile,bootserver,nextserver' \
-d '_inheritance=true'

Re: Editing/changing a fixed address with curl

Authority
Posts: 15
956     0

I don't get your example to work. It works without -d '_inheritance=true' and displays all addresses with the requested options, but with the inheritance part I get

{ "Error": "AdmConProtoError: Unknown argument: _inheritance=true", 
  "code": "Client.Ibap.Proto", 
  "text": "Unknown argument: _inheritance=true"

 

Any idea?

I checked the May2019 API guide and I could not find any example that uses _inheritance. But there are other inheritance options... maybe a typo?

 

Speaking about consistency: When this is not the way it should work intentionaly, will you ask you collegues to fix this?

 

Re: Editing/changing a fixed address with curl

MRichard Community Manager
Community Manager
Posts: 101
956     0

Can I ask what version of NIOS you're running?  It looks like the _inheritance flag was introduced with NIOS 8.4 so it may not be available to you.

 

I'd recommend opening a support case, and discuss it with your account team, that's the best way to have it tracked.

Re: Editing/changing a fixed address with curl

Authority
Posts: 15
956     0

It's 8.4.3 (from the browser window title). Not sure whether or not this is the real one.

I'm not the admin... I'm just a user.

 

Is there a way to find out without having admin permission?

 

Re: Editing/changing a fixed address with curl

MRichard Community Manager
Community Manager
Posts: 101
956     0

The browser tab title should be accuerate.  You can also get the current version by asking about the grid upgrade stautus, via API:

 

curl -k1 -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.8/upgradestatus?type=GRID&_return_fields=current_version_summary'

Re: Editing/changing a fixed address with curl

[ Edited ]
Authority
Posts: 15
956     0

This one is working fine.

It really is "current_version_summary": "8.4.3-383835".

 

It looks like there are no api elements like nextserver or bootfile. The gui is misleading here.

bootfile and nextserver are DHCP options and need to be requested with "options". Then it's option 66 (tftp-server-name) and 67 (bootfile-name).

It looks like one needs to check whether or not this option is actually used or inherited. According to the API reference then use_bootfile or use_nextboot are set to true for "set directly". When it's false, then the value is inherited from a higher level.

The API reference reads like this:

Somefields are associated with a corresponding boolean flag value that has the prefix use_. For example, ttlis associated with the flag use_ttl. In an object, the value of this field will only take effect when its use flag is true.Otherwise, the value will be inherited from a higher level setting.

 

I understand this like there would *always* be a value, but when the use_* value is true, it's set directly, and when it's false, it's inherited. But this is not the case. It seems that the use_* values are necessary for writing those values, but don't have an effect on reading them.

 

I still have no clue how to get the value when it's inherited from higher levels.

 

And I still can't find the _inheritance option in the api reference (https://www.infoblox.com/wp-content/uploads/infoblox-deployment-infoblox-rest-api.pdf)

 

Re: Editing/changing a fixed address with curl

MRichard Community Manager
Community Manager
Posts: 101
956     0

In the GUI, the bootfile, nextserver & bootserver fields (Boot File, Next Server, Boot Server, respectively) are in the BOOTP/PXE tab, and are only used by BOOTP and PXE clients.


DHCP clients will use the DHCP options 67 & 68 as you noted.

 

The appliance's online documentation for 8.4 does mention the "_inheritance" flag.  I usually use that documentaion instead as I find it to be more complete.  However as I mentioed before it doesn't seem to be fully implemented so I don't think it will suit your needs.

 

I'd recommend reaching out to your Infoblox account team if you think the current capabilites don't match your needs.

Showing results for 
Search instead for 
Do you mean 

Recommended for You