Reply

Set "unusual" DHCP options

SJohansen
Techie
Posts: 7
9700     0

I am having trouble setting "unusual" DHCP options via the API. Neither my own script nor ibcli manages it. My only option now is importing via CSV, but I really want to do this via API or ibcli.

Running this gets me:

$ ./add-option.pl <username> <password> 4199
Connecting to Infoblox Grid...Session created successfully
Get Grid DHCP object found at least 1 matching entry
DHCP option object created successfully

Found <subnet>
Modify Grid DHCP object failed: 1012Smiley Surprisedption DHCP.option-150 is undefined. at ./add-option.pl line 66.

And when attempting the same in ibcli:

<username>@<infoblox> > configure network modify <subnet> addoption 150=1.2.3.4
  Error : API returned : Option DHCP.option-150 is undefined. (1012)

Any ideas?

Re: Set "unusual" DHCP

Authority
Posts: 37
9700     0

Hi,

I've also created a script that changes option 150. But on our grid option 150 is already defined on the grid level. So no new option is created.

Could you add some troubleshooting by putting a 'print Dumper(@options);' right after pushing $myoption to the existing option-array?

Re: Set "unusual" DHCP

SJohansen
Techie
Posts: 7
9700     0

Result:

$ ./add-option.pl <user> <pass> 4199
Connecting to Infoblox Grid...Session created successfully
Get Grid DHCP object found at least 1 matching entry
DHCP option object lease-time created successfully

Found <subnet>
$VAR1 = bless( {
  'ipv4addrs' => [
    '<ip>'
  ],
  'num' => '3',
  'value' => '<ip>',
  'name' => 'routers',
  'vendor_class' => 'DHCP',
  'type' => 'routers'
}, 'Infoblox:Smiley Very HappyHCP:Smiley Surprisedption' );
$VAR2 = bless( {
  'num' => 150,
  'value' => '1.2.3.4'
}, 'Infoblox:Smiley Very HappyHCP:Smiley Surprisedption' );
Modify Grid DHCP object failed: 1012Smiley Surprisedption DHCP.option-150 is undefined. at ./add-option.pl line 68.

 

Now, if I do a CSV export, I get OPTION-150 as a column as it has already been defined on several subnets as an DHCP option either via the GUI or via CSV imports... but it still won't let me do it via the API.

Any hints?

Re: Set "unusual" DHCP

Authority
Posts: 37
9700     0

I noticed the following in the API doc about the num() method :

Note that specifying "num" without "name" is supported only for predefined options and custom options with names that haven't been modified.

Which kinda contradicts the note in the new() method :

Note that in a future NIOS version 'num' will become mandatory and 'name' will become optional.

I've also tested the creation of option-150 and could only modify the network object when "name" was specified. It does not work when "num" is used without "name".

EDIT : just noticed that on our grid the name defined for option 150 was added manually after the grid was installed. (before I got my hands on it :-p)

 

Re: Set "unusual" DHCP

SJohansen
Techie
Posts: 7
9700     0

Didn't make a dent...

<snip>

$VAR2 = bless( {
  'num' => 150,
  'value' => '1.2.3.4',
  'name' => 'option-150'
}, 'Infoblox:Smiley Very HappyHCP:Smiley Surprisedption' );
Modify Grid DHCP object failed: 1012Smiley Surprisedption DHCP.option-150 is undefined. at ./add-option.pl line 69.

Re: Set "unusual" DHCP

Authority
Posts: 37
9700     0

Could you check the result of the attached code?

I'm guessing that the option definition is either missing or uses a different name.

If the option is not defined the array will be empty and no name will be output.

If the option is defined the name will be output and it'll probably differ from 'option-150' which I used in the example.

 

 

Re: Set "unusual" DHCP

SJohansen
Techie
Posts: 7
9700     0

Results below... Now, I tried using the first of these, and it actually worked... The second and third definitions did NOT work.

Re: Set "unusual" DHCP

Authority
Posts: 37
9700     0

the part of your code that creates the option should look like this :

Edit : seems you're fast on the responses :-)

Re: Set "unusual" DHCP

SJohansen
Techie
Posts: 7
9700     0

Here is the script with a few modifications and incorporated the code you suggested. Thank you for your help.

Edit: It will still fail with completely "unknown" options, but at least all options available in the GUI are now possible to manipulate via the API.

Re: Set "unusual" DHCP

Authority
Posts: 37
9700     0

If you want to incorporate some code to add the missing definitions instead of 'die ("option $option is not defined");'.

From the API doc :

I am facing the same issue.

RDias
Techie
Posts: 1
9700     0
Hi Stig, I am facing the same issue you had. Can you share your script with me... I wasn't able to see your code. Thanks! Roberto
Highlighted

Have you defined the option

Guru
Posts: 60
9700     0

Have you defined the option parameters under DHCP > Options Spaces > DHCP?

my option 150 is as follows-

Name: option-150

Code: 150

Type: array of ip-address

Showing results for 
Search instead for 
Do you mean 

Recommended for You