summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go15
-rw-r--r--resources/xml/spice.xml2
-rw-r--r--resources/xml/standard.x86.xml4
-rw-r--r--xml.go24
4 files changed, 25 insertions, 20 deletions
diff --git a/main.go b/main.go
index ce4823a..fd06cf6 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ package main
import (
"embed"
+ "fmt"
"os"
"time"
@@ -52,7 +53,19 @@ func main() {
os.Exit(0)
}
log.Info("start droplet here:", d.Hostname)
- makeStandardXml(d)
+ domcfg := makeStandardXml(d)
+
+ fmt.Printf("Virt type %s\n", domcfg.Type)
+ fmt.Printf("Virt name %s\n", domcfg.Name)
+ fmt.Printf("Virt UUID %s\n", domcfg.UUID)
+ fmt.Printf("Virt Memory %s\n", domcfg.Memory)
+
+ qcow := "/home/nfs/" + d.Hostname + ".qcow2"
+ setSimpleDisk(domcfg, qcow)
+ // setMacs(domcfg, "33:44:33:11:22:11", "worldbr")
+ setRandomMacs(domcfg)
+
+ writeoutXml(domcfg, "blahcarr")
os.Exit(0)
}
diff --git a/resources/xml/spice.xml b/resources/xml/spice.xml
index 07a27a2..651e6ac 100644
--- a/resources/xml/spice.xml
+++ b/resources/xml/spice.xml
@@ -1,6 +1,6 @@
<domain type='kvm' id='2'>
<devices>
- <graphics type='spice' port='5900' autoport='no' listen='0.0.0.0'>
+ <graphics type='spice' port='5921' autoport='no' listen='0.0.0.0' passwd='deprecatethis'>
<listen type='address' address='0.0.0.0'/>
<image compression='off'/>
</graphics>
diff --git a/resources/xml/standard.x86.xml b/resources/xml/standard.x86.xml
index 7256cbc..412d2cd 100644
--- a/resources/xml/standard.x86.xml
+++ b/resources/xml/standard.x86.xml
@@ -143,10 +143,6 @@
<address type='usb' bus='0' port='1'/>
</input>
<input type='mouse' bus='ps2'/>
- <graphics type='spice' autoport='yes'>
- <listen type='address'/>
- <image compression='off'/>
- </graphics>
<sound model='ich9'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x1b' function='0x0'/>
</sound>
diff --git a/xml.go b/xml.go
index b44040e..37cc01e 100644
--- a/xml.go
+++ b/xml.go
@@ -10,7 +10,7 @@ import (
"libvirt.org/go/libvirtxml"
)
-func makeStandardXml(d *DropletT) {
+func makeStandardXml(d *DropletT) *libvirtxml.Domain {
log.Info("create new xml file for:", d.Hostname)
domcfg := &libvirtxml.Domain{}
@@ -21,28 +21,24 @@ func makeStandardXml(d *DropletT) {
addDefaults(domcfg, "qcow")
addDefaults(domcfg, d.Hostname)
- fmt.Printf("Virt type %s\n", domcfg.Type)
- fmt.Printf("Virt name %s\n", domcfg.Name)
- fmt.Printf("Virt UUID %s\n", domcfg.UUID)
- fmt.Printf("Virt Memory %s\n", domcfg.Memory)
-
- qcow := "/home/nfs2/" + d.Hostname + ".qcow2"
- simpleDisk(domcfg, qcow)
- // setMacs(domcfg, "33:44:33:11:22:11", "worldbr")
- randomMacs(domcfg)
+ return domcfg
+}
+func writeoutXml(domcfg *libvirtxml.Domain, filename string) bool {
xmldoc, err := domcfg.Marshal()
if err != nil {
fmt.Println("can't make xml file error:\n", err)
- return
+ return false
}
- outfile := "/tmp/" + d.Hostname + ".xml"
+ outfile := "/tmp/" + filename + ".xml"
regfile, _ := os.OpenFile(outfile, os.O_RDWR|os.O_CREATE, 0666)
fmt.Fprintln(regfile, xmldoc)
log.Info("File is in", outfile)
+ regfile.Close()
+ return true
}
func setDiskFilename(domcfg *libvirtxml.Domain, filename string) {
@@ -75,7 +71,7 @@ func addDefaults(d *libvirtxml.Domain, filename string) {
}
}
-func simpleDisk(domcfg *libvirtxml.Domain, filename string) {
+func setSimpleDisk(domcfg *libvirtxml.Domain, filename string) {
// Clear out the existing disks (if any)
domcfg.Devices.Disks = nil
@@ -133,7 +129,7 @@ func setMacs(domcfg *libvirtxml.Domain, mac string, brname string) {
domcfg.Devices.Interfaces = append(domcfg.Devices.Interfaces, newNet)
}
-func randomMacs(domcfg *libvirtxml.Domain) {
+func setRandomMacs(domcfg *libvirtxml.Domain) {
for i, x := range domcfg.Devices.Interfaces {
// Create a new DomainDiskInterfaces struct
newMac := &libvirtxml.DomainInterfaceMAC{