Ok, so based on the feedback of both Oliver and Aaron here's how I think we can implement this.
*New field in django-netjsonconfig* We should add a dedicated field in django-netjsonconfig with a generic name which can be used for any type of hardware ID. Since it's generic, we should be flexible in defining this field, but we know for sure it's going to be a unique alphanumeric string with a generous length, the database field can be NULL (and if an empty string is supplied it should be converted to None to avoid triggering the unique DB constraint error). The field may or may not be required depending on a configuration (django setting), which makes it not required by default, which maintains backward compatibility. The human readable label and the help text of the field should be configurable, by default we could use something like "Serial number", but it can be modified to use a different term depending on the context where it is used. In my opinion this feature should be deactivated by by default and shown only when a specific setting is turned on. When the feature is enabled, the following things should happen: - it should be possible to search devices in the admin by their serial number - it should be shown in the device list, probably as first field from the left - it should be shown and be editable in the add device page, shown right before or right after the name field - it should be shown and (probably) readonly in change device page, shown right before or right after the name field - the controller view which allows registration of new devices should save this value if it finds it in the HTTP POST data *openwisp-controller* OpenWISP controller will just need the migration to add the new field, the logic is shipped in django-netjsonconfig. *openwisp-config* We should add a new configuration option called "serial_number" or "serial_number_script", which is a path to a script which if exists will be used to retrieve the serial number, which will then be sent to ow2 during registration. We could add another boolean config option like "serial_number_key" which if true uses the serial number to generate the device key. The default value of this config option could be true if "serial_number_script" is defined and exists, false otherwise. It would basically mean the key is generated from the serial number by default when this feature is used, but it can be turned off if needed. What do you think? Federico On Mon, Oct 1, 2018 at 7:57 AM Oliver Kraitschy <[email protected]> wrote: > On Sun, Sep 30, 2018 at 01:28:27PM +0200, Federico Capoano wrote: > > > That is really great news, I will make sure to help you in this process. > > You're already at it - thank you for your help all the time :-) > > > My understanding is that in your case you would like to show the serial > number > > in the UI instead of the hostname, is this understanding correct? If not > could > > you explain what your specific goal is? > > Yes, the serial number should be used as the unique name for the device in > the UI and it should also be possible to search for a specific device by > serial number. > > > In chat you mentioned that you needed the key to be generated from the > serial > > number, right? > > Yes, it would make sense and be logical because in our case the serial > number is the unique device identifier. The downside is that for devices > which are created manually with django-netjsonconfig, the key is not > generated from the mac address (or from the serial number). > > > I think we should add a new field dedicated to store some sort of > hardware ID. > > The reason is that other use cases have come up needing the same thing, > I'm > > talking specifically about the device EUI in LoRa / IoT. > > Yes, or generally speaking, some user-definable field which can be filled > by a script on the client side. > > > Before focusing too much on technical details, could you explain what > your need > > is regarding this serial number? For example: > > > > Our hardware has a unique serial number which we use for identification > and > > internal purposes, we would like to: > > > > • see this serial number as prominent identification in the admin > > • be able to search devices in the admin by their serial number > > • have the device automatically register its serial number without the > need > > of manual intervention > > • have the key field of the device generated from this serial number > because > > we consider it more reliable and secure than doing so with the mac > address > > Yes, all of this :-) The serial number is assigned when the device is > built and is used throughout the whole process - in provisioning, in all > communication with our customers and also internally. > > And I think this is also what Aaron meant and would like to have. > > > Greetings, > Oliver > > -- > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
