API Examples

Reply
Highlighted
Accepted Solution

Looking for a WAPI API to do upgrade of members and Grid.

lramamur
Techie
Posts: 2
3003     0

Hi All,

 

I am new to WAPI API's. When i had a look at the documentation, i could not find out any API that does :

 

1. Backing up of configuration files

2. Restoring back the backed up configuration files

3. Upgrade of Grid and members.

 

Please let me know if we have the support.

 

In Perl API's, i see there are some API's related to upgrade. But i found the installation of perl and related modules hard and it gave me errors, so id didn't proceed further.

 

Please help.

 

Thanks,

Lakshmi

Re: Looking for a WAPI API to do upgrade of members and Grid.

Adviser
Posts: 56
3004     0

Hi,

 

You can use the following list of WAPI calls. These are a sample set. Please change the credentials and IP address according to yout environment.

 

Export a database backup

Initiate backup:
curl -k -u admin:Infoblox -H 'content-type: application/json' -X POST "https://127.0.0.1/wapi/v2.9/fileop?_function=getgriddata" -d '{"type": "BACKUP"}'

Sample output:
{"token": "eJydUE1PwzAMvfuPjMvaplvWjdtQmYSENmlD4mi1STos2iQkGdr+PQ4SnDhxSOT4fcR+Sjl/w2DO\nwJdyNqZwUckF8ALuFNnB9aO7Fs6afNLNmwhtlzo8mgF8DQqxv9CYyCKCJpXAL+BO+yWcZubqKdww\n0WRm4CXshKxkI+W6XhWyqZayhniaXcLI6Ir5byn5eF+WoqkLpoiiLnMLNfFoCQcaDZIrg/lA0vP2\n8Lp/PmzbuagqUWqeqe+iKfrune2a7EyaqzUb/6VgaJNJWci1qJhXRt68O5syTf7fXwvxY4vGKqfJ\nnnO3Zv+Hp30uF7+EyekcjchptduXLR4fd/ktIaajF6ucpGgYHMiMOmJyqNzku/CtWsM+b9l3Hsn6\nS8JPEyI5m7ENY33xBbQAllA=\n",
 "url": "https://127.0.0.1/http_direct_file_io/req_id-DOWNLOAD-1001/database.bak"
}

Download the backup:
curl -k -u admin:Infoblox -H 'content-type: application/force-download' "https://127.0.0.1/http_direct_file_io/req_id-DOWNLOAD-1001/database.bak" -o "database.bak"

Remove the stored file using the token:
curl -k -u admin:Infoblox -H 'content-type: application/json' -X POST "https://127.0.0.1/wapi/v2.9/fileop?_function=downloadcomplete" -d '{"token" : "eJydUE1PwzAMvfuPjMvaplvWjdtQmYSENmlD4mi1STos2iQkGdr+PQ4SnDhxSOT4fcR+Sjl/w2DO\nwJdyNqZwUckF8ALuFNnB9aO7Fs6afNLNmwhtlzo8mgF8DQqxv9CYyCKCJpXAL+BO+yWcZubqKdww\n0WRm4CXshKxkI+W6XhWyqZayhniaXcLI6Ir5byn5eF+WoqkLpoiiLnMLNfFoCQcaDZIrg/lA0vP2\n8Lp/PmzbuagqUWqeqe+iKfrune2a7EyaqzUb/6VgaJNJWci1qJhXRt68O5syTf7fXwvxY4vGKqfJ\nnnO3Zv+Hp30uF7+EyekcjchptduXLR4fd/ktIaajF6ucpGgYHMiMOmJyqNzku/CtWsM+b9l3Hsn6\nS8JPEyI5m7ENY33xBbQAllA=\n"}'

Restore database:

Initiate file upload:
curl -k -u admin:Infoblox -H 'content-type:application/json' -X POST "https://127.0.0.1/wapi/v2.9/fileop?_function=uploadinit"

Sample output:
{"token": "eJydUMFOwzAMvftHymVt09Fu5TY0JiGhgTY4W22SDkttYpIUbX9PMgQXbhwS2X7PL3lPSssXdPoE\n8ZLW+OBmGawDFnAjyQy2H+05t0anEy6sPWy70OFBD8AVSMR+pjGQQQRFMgAv4UbxLRwzfWZyFww0\n6Qy4hp2oy3pVN1XT5GXZtmIF/pjNboxoE/nvIbC/KwqxqvKqyUVeFWmEiuLXAg40aiRbOP2BpBZv\nL0/Pm+1ClKUoaGLrvhlR6ypLKlbrqPqXHoE2UVT0EWtRRlbho+nupIsw8f9eFeJHE7WRVpE5pWkV\nxe8f96lc/hImq64rKaXt5nWDh4dd6mvw4cCiSQnGdI7ZQHpUHoNFaSfu3HVrDftksO8YyfAc8FM7\nT9YkrI1Yn38Bt1KUqw==\n",
 "url": "https://172.26.1.2/http_direct_file_io/req_id-UPLOAD-1001/import_file"
}

Upload the database backup file:
curl -k -u admin:Infoblox -H 'content-type:multipart-formdata' "https://127.0.0.1/http_direct_file_io/req_id-UPLOAD-1001/import_file" -F file=@database.bak

Restore the database:
curl -k -u admin:Infoblox -H 'content-type:application/json' -X POST "https://127.0.0.1/wapi/v2.9/fileop?_function=restoredatabase" -d '{"mode":"NORMAL","token":"eJydUMFOwzAMvftHymVt09Fu5TY0JiGhgTY4W22SDkttYpIUbX9PMgQXbhwS2X7PL3lPSssXdPoE\n8ZLW+OBmGawDFnAjyQy2H+05t0anEy6sPWy70OFBD8AVSMR+pjGQQQRFMgAv4UbxLRwzfWZyFww0\n6Qy4hp2oy3pVN1XT5GXZtmIF/pjNboxoE/nvIbC/KwqxqvKqyUVeFWmEiuLXAg40aiRbOP2BpBZv\nL0/Pm+1ClKUoaGLrvhlR6ypLKlbrqPqXHoE2UVT0EWtRRlbho+nupIsw8f9eFeJHE7WRVpE5pWkV\nxe8f96lc/hImq64rKaXt5nWDh4dd6mvw4cCiSQnGdI7ZQHpUHoNFaSfu3HVrDftksO8YyfAc8FM7\nT9YkrI1Yn38Bt1KUqw==\n"}'

Upgrade a member:

Get the grid reference:
curl -k -u admin:Infoblox -X GET "https://127.0.0.1/wapi/v2.9/grid"

Sample output:
{"result": 
  [{"_ref": "grid/b25lLmNsdXN0ZXIkMA:Infoblox"}]}

Upgrade a member:
curl -k -u admin:Infoblox -H 'content-type: application/json' -X POST "https://127.0.0.1/wapi/v2.9/grid/b25lLmNsdXN0ZXIkMA:Infoblox?_function=member_upgrade" -d '{"member": "infoblox.localdomain"}'

Hope you find this helpful,

Krishna

Re: Looking for a WAPI API to do upgrade of members and Grid.

lramamur
Techie
Posts: 2
3004     0

Thanks a lot kirshna.

We will try it out and get back.

BTW, all these API's are not documented ? Or i missed something.

 

 

Thanks once again.

Lakshmi

Re: Looking for a WAPI API to do upgrade of members and Grid.

Adviser
Posts: 56
3004     0

Hi Lakshmi,

 

All the functions are listed in the API documentation, but not with the examples.

 

However there is a reference guide which lists examples for various use cases: https://www.infoblox.com/wp-content/uploads/infoblox-deployment-infoblox-rest-api.pdf

 

Thanks,

Krishna

Re: Looking for a WAPI API to do upgrade of members and Grid.

Ramachary
Techie
Posts: 6
3004     0

Under Restore database:

 

I have used the below mentioned command for - Upload the database backup file:

curl -k -u admin:Infoblox -H 'content-type:multipart-formdata' "https://127.0.0.1/http_direct_file_io/req_id-UPLOAD-1001/import_file" -F file=@database.bak

 but that dis not get through....

 

I gives a response as:

[root@localhost CSPC]#
[root@localhost CSPC]# curl -k -u lramamur:Cisco123 -H 'content-type:multipart-formdata' "https://172.25.121.82/http_direct_file_io/req_id-UPLOAD-1001/import_file" -F file=@database.bak
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
</body></html>
[root@localhost CSPC]#

 

Please help.

 

Thanks, Ramachary.

Re: Looking for a WAPI API to do upgrade of members and Grid.

Adviser
Posts: 56
3004     0

Hi,

 

Please check the IP address and user credentials you aare passing.

 

Regards,

Krishna

Re: Looking for a WAPI API to do upgrade of members and Grid.

Ramachary
Techie
Posts: 6
3004     0

Now I am faced with the following issue:

 

My Infoblox shows:
ib_lab_a > show upgrade_history
[2018/03/27 16:24:12] Upgraded to: 8.1.8-365387
[2018/11/16 11:46:09] Upgraded to: 8.2.4-366880
[2018/11/16 12:09:05] Reverted to: 8.1.8-365387
[2018/11/20 06:20:47] Upgraded to: 8.2.4-366880
[2018/11/27 04:09:02] Reverted to: 8.1.8-365387
[2018/11/27 05:27:48] Upgraded to: 8.2.4-366880
[2018/11/27 06:00:43] Reverted to: 8.1.8-365387


[root@localhost CSPC]# curl -k -u lramamur:Cisco123 -X GET "https://172.25.121.82/wapi/v2.6/grid"
[
{
"_ref": "grid/b25lLmNsdXN0ZXIkMA:IB_A"
}
][root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]# curl -k -u lramamur:Cisco123 -H 'content-type: application/json' -X POST "https://172.25.121.82/wapi/v2.6/grid/b25lLmNsdXN0ZXIkMA:IB_A?_function=member_upgrade" -d '{"member": "ib_lab_b.localdomain.com"}'
{ "Error": "AdmConDataError: None (IBDataError: IB.Data:You must pause the upgrade before upgrading a member.)",
"code": "Client.Ibap.Data",
"text": "You must pause the upgrade before upgrading a member."
}[root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]#

I have not configured: Activate Upgrade Schedule.... but still I am prompted with the above message: "You must pause the upgrade before upgrading a member"

 

How to resolve this issue, Pl.. help..

Thanks, Ramachary

Re: Looking for a WAPI API to do upgrade of members and Grid.

Adviser
Posts: 56
3004     0

Hi,

 

You can check if there are any upgrades in progress using the upgradestatus object, like below:

curl -k -u admin:Infoblox -X GET "https://grid-master/wapi/v2.9/upgradestatus?type=GRID"

Sample output:
[
    {
        "_ref": "upgradestatus/Li51cGdyYWRlc3RhdHVzJHVwZ3JhZGVfc3RhdHVz:Infoblox",
        "element_status": "WORKING",
        "grid_state": "DEFAULT",
        "group_state": "GROUP_NONE",
        "ha_status": "NOT_CONFIGURED",
        "message": "",
        "steps_completed": 0,
        "steps_total": 0,
        "type": "GRID",
        "upgrade_state": "NONE",
        "upgrade_test_status": "NONE"
    }
]

Also, if you want to do a grid-wide upgrade, you can use the upgrade function.

 

Snippet from the WAPI Documentation:

This function provides control over the Grid upgrade. The upgrade process normally is as follows: 
1) Upload the
upgrade file using the set_upgrade_file function call in object fileop 
2) call this function with ‘action’ set to ‘UPLOAD’,
this will prepare the uploaded file for deployment 
3) call this function with ‘action’ set to ‘DISTRIBUTION_START’
which will start the Grid distribution process. 
4) call this function with ‘action’ set to ‘UPGRADE’ which will restart
the appliances with the new NIOS version.
This function does not support multiple object matches when called as part of an atomic insertion operation.

Translating the steps to WAPI commands (please change the necessary values as per your environment):

Step 1: Upload the upgrade file

Initiate file upload:
curl -k -u admin:Infoblox -H 'content-type:application/json' -X POST "https://grid-master/wapi/v2.9/fileop?_function=uploadinit"

Sample output:
{"token": "eJydUMFOwzAMvftHymVt09Fu5TY0JiGhgTY4W22SDkttYpIUbX9PMgQXbhwS2X7PL3lPSssXdPoE\n8ZLW+OBmGawDFnAjyQy2H+05t0anEy6sPWy70OFBD8AVSMR+pjGQQQRFMgAv4UbxLRwzfWZyFww0\n6Qy4hp2oy3pVN1XT5GXZtmIF/pjNboxoE/nvIbC/KwqxqvKqyUVeFWmEiuLXAg40aiRbOP2BpBZv\nL0/Pm+1ClKUoaGLrvhlR6ypLKlbrqPqXHoE2UVT0EWtRRlbho+nupIsw8f9eFeJHE7WRVpE5pWkV\nxe8f96lc/hImq64rKaXt5nWDh4dd6mvw4cCiSQnGdI7ZQHpUHoNFaSfu3HVrDftksO8YyfAc8FM7\nT9YkrI1Yn38Bt1KUqw==\n",
 "url": "https://172.26.1.2/http_direct_file_io/req_id-UPLOAD-1001/import_file"
}

Upload the upgrade file:
curl -k -u admin:Infoblox -H 'content-type:multipart-formdata' "https://grid-master/http_direct_file_io/req_id-UPLOAD-1001/import_file" -F file=@upgrade-file.bin

Set it as the upgrade file:
curl -k -u admin:Infoblox -H 'content-type:application/json' -X POST "https://grid-master/wapi/v2.9/fileop?_function=set_upgrade_file" -d '{"token":"eJydUMFOwzAMvftHymVt09Fu5TY0JiGhgTY4W22SDkttYpIUbX9PMgQXbhwS2X7PL3lPSssXdPoE\n8ZLW+OBmGawDFnAjyQy2H+05t0anEy6sPWy70OFBD8AVSMR+pjGQQQRFMgAv4UbxLRwzfWZyFww0\n6Qy4hp2oy3pVN1XT5GXZtmIF/pjNboxoE/nvIbC/KwqxqvKqyUVeFWmEiuLXAg40aiRbOP2BpBZv\nL0/Pm+1ClKUoaGLrvhlR6ypLKlbrqPqXHoE2UVT0EWtRRlbho+nupIsw8f9eFeJHE7WRVpE5pWkV\nxe8f96lc/hImq64rKaXt5nWDh4dd6mvw4cCiSQnGdI7ZQHpUHoNFaSfu3HVrDftksO8YyfAc8FM7\nT9YkrI1Yn38Bt1KUqw==\n"}'

Step 2: Call the upgrade function to "UPLOAD" the file

curl -k -u admin:Infoblox -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.9/grid/b25lLmNsdXN0ZXIkMA:Infoblox?_function=upgrade" -d '{"action": "UPLOAD"}'

Step 3: Call the upgrade function to start the distribution process

curl -k -u admin:Infoblox -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.9/grid/b25lLmNsdXN0ZXIkMA:Infoblox?_function=upgrade" -d '{"action": "DISTRIBUTION_START"}'

Step 4: Step 3: Call the upgrade function to start the upgrade

curl -k -u admin:Infoblox -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.9/grid/b25lLmNsdXN0ZXIkMA:Infoblox?_function=upgrade" -d '{"action": "UPGRADE"}'

Re: Looking for a WAPI API to do upgrade of members and Grid.

Ramachary
Techie
Posts: 6
3004     0

Hi Krishna,

 

In Step 2: Call the upgrade function to "UPLOAD" the file,   it is throwing the message as follows:

 

"text": "Invalid upgrade file : Invalid NIOS software image uploaded, try again with a valid NIOS software image."

 

The Screen capture is given below:

==========================

 

curl -k -u lramamur:Cisco123 -X GET "https://172.25.121.82/wapi/v2.6/grid"
[
{
"_ref": "grid/b25lLmNsdXN0ZXIkMA:IB_A"
}
]

 

 

 

 

[root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]# curl -k -u lramamur:Cisco123 -H 'content-type:application/json' -X POST "https://172.25.121.82/wapi/v2.6/fileop?_function=uploadinit"
{
"token": "eJydUEFOwzAQvPsj7aVJ7CRNyq2oVEJCBbVwXiW2U1ZKbGM7qP096yK4cONga3ZnduxZKa27gtdn\nRpe0JkQ/y2g9c5wtJZrB9qO9ZNbodOLV6cB2XezgqAfmBJMA/YxjRAPAFMrIXMmWylXstNAXh/4K\nESe9YK5me15XZVU0VdVmhahbwcJpMfuRyDXJ32N04S7PeSMyUWdc8KwVeeqCQvpchAFHDWhzrz8A\n1ert5el5u1vxoihznJz13wqya5IzKkItGf+VE7FJEkVJCPOCVHmg2N1Z53Fy/3uV8x9P0EZaheac\nuoLM7x8PCZa/gsmq20ja0277uoXjwz7VNQvx6Pg67ZA3RA6oRxUgWpB2cp2/TbXskAL2nQM0bo7w\nqX1AaxK3Ia7PvgCT0pUP\n",
"url": "https://172.25.121.82/http_direct_file_io/req_id-UPLOAD-1003/import_file"
}[root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]# curl -k -u lramamur:Cisco123 -H 'content-type:multipart-formdata' "https://172.25.121.82/http_direct_file_io/req_id-UPLOAD-1003/import_file" -F file=@nios-8.2.4-366880-2018-02-09-04-06-41_x86_64.bin
[root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]# curl -k -u lramamur:Cisco123 -H 'content-type:application/json' -X POST "https://172.25.121.82/wapi/v2.6/fileop?_function=set_upgrade_file" -d '{"token": "eJydUEFOwzAQvPsj7aVJ7CRNyq2oVEJCBbVwXiW2U1ZKbGM7qP096yK4cONga3ZnduxZKa27gtdn\nRpe0JkQ/y2g9c5wtJZrB9qO9ZNbodOLV6cB2XezgqAfmBJMA/YxjRAPAFMrIXMmWylXstNAXh/4K\nESe9YK5me15XZVU0VdVmhahbwcJpMfuRyDXJ32N04S7PeSMyUWdc8KwVeeqCQvpchAFHDWhzrz8A\n1ert5el5u1vxoihznJz13wqya5IzKkItGf+VE7FJEkVJCPOCVHmg2N1Z53Fy/3uV8x9P0EZaheac\nuoLM7x8PCZa/gsmq20ja0277uoXjwz7VNQvx6Pg67ZA3RA6oRxUgWpB2cp2/TbXskAL2nQM0bo7w\nqX1AaxK3Ia7PvgCT0pUP\n"}'
{}[root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]# curl -k -u lramamur:Cisco123 -H 'content-type: application/json' -X POST "https://172.25.121.82/wapi/v2.6/grid/b25lLmNsdXN0ZXIkMA:Infoblox?_function=upgrade" -d '{"action": "UPLOAD"}'
{ "Error": "AdmConDataError: None (IBDataError: IB.Data:Invalid upgrade file : Invalid NIOS software image uploaded, try again with a valid NIOS software image.)",
"code": "Client.Ibap.Data",
"text": "Invalid upgrade file : Invalid NIOS software image uploaded, try again with a valid NIOS software image."
}[root@localhost CSPC]#
[root@localhost CSPC]#
[root@localhost CSPC]#

 

 

Request help, in the matter please.

 

Thanks, Ramachary.

Re: Looking for a WAPI API to do upgrade of members and Grid.

Adviser
Posts: 56
3004     0

Hi,

 

Have you tried upgrading with the same file from the GUI?

 

Regards,

Krishna

Re: Looking for a WAPI API to do upgrade of members and Grid.

Ramachary
Techie
Posts: 6
3004     0

Hi Krishna

 

Thanks fot your response...

 

I have Observed the following, during Image Upgrade:

 

If the image file is uploaded manually through GUI, then the further two steps:

 

>> Call the upgrade function to start the distribution process... and

>> Call the upgrade function to start the upgrade,

 

given thru curl commands......goes through fine without any issues (the upgradation progress can be monitored on GUI now).... and then the device goes for reboot, and comes up with the new Image. 

 

Thanks,
Ramachary.

Showing results for 
Search instead for 
Do you mean 

Recommended for You