diff --git a/ciao-controller/compute.go b/ciao-controller/compute.go index 2ad9c5204..c2adf3d32 100644 --- a/ciao-controller/compute.go +++ b/ciao-controller/compute.go @@ -482,6 +482,11 @@ func showServerDetails(w http.ResponseWriter, r *http.Request, context *controll return } + // OpenStack compatibility: expect active status not running for API Call + if server.Server.Status == "running" { + server.Server.Status = "active" + } + b, err := json.Marshal(server) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -906,7 +911,24 @@ func createServer(w http.ResponseWriter, r *http.Request, context *controller) { } servers.TotalServers = len(instances) - b, err := json.Marshal(servers) + // set machine ID for OpenStack compatibility + server.Server.ID = instances[0].ID + + // builtServers is define to meet OpenStack compatibility on result format and keep CIAOs + builtServers := struct { + payloads.ComputeCreateServer + payloads.ComputeServers + }{ + payloads.ComputeCreateServer{ + Server: server.Server, + }, + payloads.ComputeServers{ + TotalServers: servers.TotalServers, + Servers: servers.Servers, + }, + } + + b, err := json.Marshal(builtServers) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/payloads/compute.go b/payloads/compute.go index ec657d2f0..2a0b5cf29 100644 --- a/payloads/compute.go +++ b/payloads/compute.go @@ -197,6 +197,7 @@ func NewComputeFlavorsDetails() (flavors ComputeFlavorsDetails) { // one or more instances. type ComputeCreateServer struct { Server struct { + ID string `json:"id"` Name string `json:"name"` Image string `json:"imageRef"` Workload string `json:"flavorRef"`