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

Delete Switch status along with switch #591

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/metal-api/internal/datastore/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,8 @@ func (rs *RethinkStore) GetSwitchStatus(id string) (*metal.SwitchStatus, error)
func (rs *RethinkStore) SetSwitchStatus(state *metal.SwitchStatus) error {
return rs.upsertEntity(rs.switchStatusTable(), state)
}

// DeleteSwitchStatus delete SwitchStatus
func (rs *RethinkStore) DeleteSwitchStatus(status *metal.SwitchStatus) error {
return rs.deleteEntity(rs.switchStatusTable(), status)
}
12 changes: 12 additions & 0 deletions cmd/metal-api/internal/service/switch-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,18 @@ func (r *switchResource) deleteSwitch(request *restful.Request, response *restfu
return
}

status, err := r.ds.GetSwitchStatus(id)
if err != nil {
r.sendError(request, response, defaultError(err))
return
}
iljarotar marked this conversation as resolved.
Show resolved Hide resolved

err = r.ds.DeleteSwitchStatus(status)
if err != nil {
r.sendError(request, response, defaultError(err))
return
}

resp, err := r.makeSwitchResponse(s)
if err != nil {
r.sendError(request, response, defaultError(err))
Expand Down
Loading