netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.23k stars 2.59k forks source link

Add Platform Version as child model to Platform #3593

Closed ReK42 closed 5 years ago

ReK42 commented 5 years ago

Environment

Proposed Functionality

Add a child model to Platform named Platform Version. Devices could then select either the platform in general or a specific version of it. If the version-specific fields, such as NAPALM driver and arguments, are null they should inherit the values on the base platform, otherwise they should override them.

Use Case

Platforms can include major version changes that significantly affect functionality and feature set, or even the NAPALM driver required to access them (e.g. Cisco NX-OS prior to version 6.1 requires using nxos_ssh instead of nxos).

This would also add the ability to track major version changes and use that to aid in lifecycle management. This should not extend into minor version tracking and patch targeting, as that is very vendor-specific and can be accomplished through other means, such as an OS version field on the device.

For example, virtual machines could have the following platforms:

Database Changes

Add a new model, PlatformVersion, with a foreign key to Platform.

External Dependencies

None

Grokzen commented 5 years ago

would all current platform relations have to be migrated to the new PlatformVersion object instances? And would all current relations that is in the code point to this new object? I dont know if you would really point to the old Platform any longer then since if you have to choose between Platform and PlatformVersion it would make the code much more messier. Alternative solution might be to make Platform model a Tree model then you can make any tree relation that you want and you still keep the Platform model and dont have to change any code that enables us to point to a Platform object.

ReK42 commented 5 years ago

You're right, it would be easier to have devices link to a single model rather than two possible ones, but since this is a simple one-level hierarchy you could do that by simply creating a hidden PlatformVersion instance with the same properties as the Platform.

jeremystretch commented 5 years ago

This has been raised before and the solution is to simply include the version number in the platform name. So instead of having a hierarchy with CentOS and Windows Server at its root, you would have a flat list:

This should be acceptable as the total number of major versions is likely to be relatively low. And if you need to track specific versions down to the minor/patch level, a custom field is probably more efficient anyway.

ReK42 commented 5 years ago

The intention behind having the hierarchy is so that entries can still be aggregated and displayed together despite being separate major versions. That way a user could go to /dcim/devices/?platform=cisco-ios and see both IOS 12 and IOS 15 devices, for example.

jeremystretch commented 5 years ago

This can be done by combining filters:

GET /api/dcim/devices/?platform=cisco-ios-12&platform=cisco-ios-15