feat: support setting virtual_chassis on device #500
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows a device to be marked as part of a virtual chassis, it's position, priority, and whether it's the master or not.
Setting the master is done on the device itself to avoid circular dependencies (the device needing to know the virtual cluster and the cluster needing to know a device to set as master).
Updating the master device of a virtual chassis is ideally done with a PATCH request where only the id and the master are provided, but
WritableVirtualChassis
struct does handle that properly:Master
is a pointer withomitempty
set, so you cannot send a jsonnull
value to remove itName
andTags
do not haveomitempty
, so you always have to provide values for them (otherwise the API complains)So for now, the entire virtual chassis is retrieved and updated with PUT instead.
A device that is marked as a master on a virtual chassis cannot be deleted, so before we can remove such a device, we remove it as a master from the virtual chassis (a chassis does not need to have a master), after which it can be properly removed.