36 lines
809 B
Go
36 lines
809 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
// attempts to create a new virtual machine
|
|
|
|
func importDomain(w http.ResponseWriter, r *http.Request) (string, error) {
|
|
name := r.URL.Query().Get("domainName")
|
|
if name == "" {
|
|
result := "start failed. name is blank " + r.URL.Path
|
|
log.Warn(result)
|
|
fmt.Fprintln(w, result)
|
|
return "", errors.New(result)
|
|
}
|
|
log.Warn("name is", name)
|
|
fmt.Fprintln(w, "name is", name)
|
|
|
|
d := me.cluster.FindDropletByName(name)
|
|
if d == nil {
|
|
result := "libvirt domain " + name + " could not be found on any hypervisor"
|
|
log.Info(result)
|
|
fmt.Fprintln(w, result)
|
|
return result, errors.New(result)
|
|
}
|
|
result := "libvirt domain " + name + " found on " + d.Current.Hypervisor
|
|
log.Info(result)
|
|
fmt.Fprintln(w, result)
|
|
return result, nil
|
|
}
|