metal-stack / metal-api

API to manage and control plane resources like machines, switches, operating system images, machine sizes, networks, IP addresses and more
GNU Affero General Public License v3.0
126 stars 9 forks source link

allow the API to toggle switch ports #506

Closed ulrichSchreiner closed 2 months ago

ulrichSchreiner commented 4 months ago

This API enables the user to toggle a port of a switch. The endpoint is /switch/{id}/port and the post body contains

type SwitchPortToggleRequest struct {
    NicName string           `json:"nic" description:"the nic of the switch you want to change"`
    Status  SwitchPortStatus `json:"status" description:"sets the port status" enum:"UP|DOWN"`
}

When this endpoint is invoked, the system stores the status as the new desired state (if it differs from the current state). The switch uses metal-core to regularly fetch the switch state. If it finds a desired state which differs from the current state, it will change the switch configuration to reflect this state and send a notification to /switch/{id}/notify and report the new state. If the new state is equal to the desired state, metal-api will store this new state and remove the desired state from the persistence layer.

Dependencies:

majst01 commented 3 months ago

We should run the small integration test suite with this deployed in test, then merge