Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support setting virtual_chassis on device #500

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

Ikke
Copy link
Contributor

@Ikke Ikke commented Nov 15, 2023

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:

  1. Master is a pointer with omitempty set, so you cannot send a json null value to remove it
  2. Name and Tags do not have omitempty, 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.

@Ikke Ikke force-pushed the resource-device-vc branch 3 times, most recently from 4c5112d to bd8e78e Compare November 15, 2023 10:03
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:

1. `Master` is a pointer with `omitempty` set, so you cannot send a json
   `null` value to remove it
2. `Name` and `Tags` do not have `omitempty`, 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.
@Ikke
Copy link
Contributor Author

Ikke commented Nov 17, 2023

One job is failing, but the failures are unrelated to the changes.

@fbreckle fbreckle merged commit 28d56e2 into e-breuninger:master Nov 22, 2023
11 checks passed
@Ikke Ikke deleted the resource-device-vc branch November 24, 2023 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants