f-74: api: disques additionnels xvdX sur la cible SCSI de même rang, sdX refusé, migration des clés disk/sdX #74
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
9b5b4a6e62
commit
1e9f436648
7 changed files with 187 additions and 27 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
dispatcher "git.g3e.fr/syonad/two/internal/dispatcher/agent"
|
||||
|
|
@ -12,6 +13,8 @@ import (
|
|||
"git.g3e.fr/syonad/two/pkg/db/kv"
|
||||
)
|
||||
|
||||
var diskDev = regexp.MustCompile(`^(vda|xvd[a-z])$`)
|
||||
|
||||
func (s *Server) VmsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
switch r.Method {
|
||||
|
|
@ -88,6 +91,11 @@ func (s *Server) startVM(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
disks := make([]dispatcher.VMDisk, len(req.Storage))
|
||||
for i, s := range req.Storage {
|
||||
if !diskDev.MatchString(s.Dev) {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
json.NewEncoder(w).Encode(ErrorResponse{Error: fmt.Sprintf("storage %d: dev %q must be vda (root disk) or xvd[a-z]", i, s.Dev)})
|
||||
return
|
||||
}
|
||||
disks[i] = dispatcher.VMDisk{Path: s.Path, Dev: s.Dev}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue