[OpenWisp-AP Registration] -: Device registration from backend via API/Script

79 views
Skip to first unread message

Amit Goyal

unread,
Jul 5, 2019, 6:58:50 AM7/5/19
to OpenWISP
Hi 

I have requirement of registering AP in openwisp from backend. Client is providing AP information like name , mac address etc in csv file .
We have to get all information from csv file and need to register AP using that information . 
Is there any API or script exist in openwisp where we can pass these information as arguments and register AP in openwisp.

Regards
Amit 

Amit Goyal

unread,
Jul 10, 2019, 6:07:22 AM7/10/19
to OpenWISP
Hi , Can someone help here ? 

Federico Capoano

unread,
Jul 10, 2019, 9:11:56 AM7/10/19
to OpenWISP
There's no tool already made for this use case, but you could write a script which reads the csv and for each row uses the device registration HTTP resource of openwisp-controller to register the device using the shared secret of the specific organization you want the device to register to (or have the shared secret part of the csv if you want to register devices for multiple organizations using this strategy).

This is the shell code used by the openwisp-config deamon on OpenWRT to register a device:
You can use this code as a guide for what you have to do in your script.

I hope it helps.
Federico

--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openwisp/7d5041cb-d141-46e2-b27f-23110b250a19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Amit Goyal

unread,
Jul 11, 2019, 4:48:02 AM7/11/19
to OpenWISP
Hi Federico 

Thanks for providing so details answer. Sure it will help me .

One more query -: Can we register device only with MAC address information ? If we do device registration using HTTP resource , minimum information required is UUID and KEY or Shared_Secret . 

Client does want to share shared_secret due to security reason and  UUID & Key is generated by Openwisp itself .  Is there way we can generate UUID & Key using Device Mac Address ? 

Thanks for advance ! 

Regards
Amit 

On Wednesday, July 10, 2019 at 6:41:56 PM UTC+5:30, Federico Capoano wrote:
There's no tool already made for this use case, but you could write a script which reads the csv and for each row uses the device registration HTTP resource of openwisp-controller to register the device using the shared secret of the specific organization you want the device to register to (or have the shared secret part of the csv if you want to register devices for multiple organizations using this strategy).

This is the shell code used by the openwisp-config deamon on OpenWRT to register a device:
You can use this code as a guide for what you have to do in your script.

I hope it helps.
Federico

On Wed, Jul 10, 2019 at 5:07 AM Amit Goyal <amitg...@gmail.com> wrote:
Hi , Can someone help here ? 

On Friday, July 5, 2019 at 4:28:50 PM UTC+5:30, Amit Goyal wrote:
Hi 

I have requirement of registering AP in openwisp from backend. Client is providing AP information like name , mac address etc in csv file .
We have to get all information from csv file and need to register AP using that information . 
Is there any API or script exist in openwisp where we can pass these information as arguments and register AP in openwisp.

Regards
Amit 

--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open...@googlegroups.com.

Federico Capoano

unread,
Jul 11, 2019, 8:52:11 AM7/11/19
to OpenWISP
On Thu, Jul 11, 2019 at 3:48 AM Amit Goyal <amitg...@gmail.com> wrote:
Hi Federico 

Thanks for providing so details answer. Sure it will help me .

One more query -: Can we register device only with MAC address information ? If we do device registration using HTTP resource , minimum information required is UUID and KEY or Shared_Secret . 

Client does want to share shared_secret due to security reason and  UUID & Key is generated by Openwisp itself .  Is there way we can generate UUID & Key using Device Mac Address ? 

Not at the moment, but regarding the key, when using "consistent key generation", which is enabled by default, the key is generated consistently according to the mac address and the shared secret.
It means that the key is always the same for the same device. So if the device flash is reset and it registers again it will use the same DB object.

If you want to generate your own UUID and keys, instead of using the HTTP resource you have to use the Django ORM to create Device and Config objects manually, depends on your experience with django, for someone who has some experience with Django and the django ORM, doing this is almost trivial, you just need to understand how the base models of openwisp-controller work.

Best regards
Federico

Amit Goyal

unread,
Jul 12, 2019, 3:04:55 AM7/12/19
to OpenWISP
Thanks a lot Federico for your help! I will start implementation as per your suggestion now . 

Regards
Amit
Reply all
Reply to author
Forward
Message has been deleted
0 new messages