Skip to content

Commit

Permalink
deletedomain quickfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrizhu committed Mar 6, 2024
1 parent 59f85f1 commit 56be8c2
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions internal/server/routes/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,41 @@ func GetDomain(w http.ResponseWriter, r *http.Request) {
}

func DeleteDomain(w http.ResponseWriter, r *http.Request) {
domain, err := getDomain(r)
if err != nil {
eUtil.WriteError(w, r, err, http.StatusNotFound, "Invalid domain ID or can't be found")
return
domidStr := chi.URLParam(r, "domain")
domid, _ := uuid.Parse(domidStr)
resp := map[string]interface{}{
"domain": domid,
}
if err := eUtil.WriteResponse(resp, w, http.StatusOK); err != nil {
eUtil.WriteError(w, r, err, http.StatusInternalServerError, "Failed to marshall/send response")
}

for _, disk := range domain.Storages {
if err := HV.DeleteDiskFile(disk.Path); err != nil {
eUtil.WriteError(w, r, err, http.StatusInternalServerError, "Failed to delete disk")
/*
domain, err := getDomain(r)
if err != nil {
eUtil.WriteError(w, r, err, http.StatusNotFound, "Invalid domain ID or can't be found")
return
}
}
if err := HV.DestroyVM(domain); err != nil {
eUtil.WriteError(w, r, err, http.StatusInternalServerError, "Failed to destroy domain")
return
}
for _, disk := range domain.Storages {
if err := HV.DeleteDiskFile(disk.Path); err != nil {
eUtil.WriteError(w, r, err, http.StatusInternalServerError, "Failed to delete disk")
return
}
}
if err := HV.UndefineVM(domain); err != nil {
eUtil.WriteError(w, r, err, http.StatusInternalServerError, "Failed to undefine domain")
return
}
if err := HV.DestroyVM(domain); err != nil {
eUtil.WriteError(w, r, err, http.StatusInternalServerError, "Failed to destroy domain")
return
}
if err := eUtil.WriteResponse(domain, w, http.StatusOK); err != nil {
eUtil.WriteError(w, r, err, http.StatusInternalServerError, "Failed to marshall/send response")
}
if err := HV.UndefineVM(domain); err != nil {
eUtil.WriteError(w, r, err, http.StatusInternalServerError, "Failed to undefine domain")
return
}
if err := eUtil.WriteResponse(domain, w, http.StatusOK); err != nil {
eUtil.WriteError(w, r, err, http.StatusInternalServerError, "Failed to marshall/send response")
}
*/
}

0 comments on commit 56be8c2

Please sign in to comment.