summaryrefslogtreecommitdiff
path: root/importDomain.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-31 15:43:25 -0500
committerJeff Carr <[email protected]>2024-10-31 15:43:25 -0500
commitb28ae96cd4c2801968ed883814b83357b77ed144 (patch)
tree5caa74ff9dd503fde31829b66d54164ddc0dbc42 /importDomain.go
parentb4ef8b76b1a92ef4da9fc0892c59a00f6f63a130 (diff)
ready for import local domain request to hypervisors
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'importDomain.go')
-rw-r--r--importDomain.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/importDomain.go b/importDomain.go
new file mode 100644
index 0000000..59c6398
--- /dev/null
+++ b/importDomain.go
@@ -0,0 +1,35 @@
+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
+}