more mac and filename stats
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
bdb262e9a0
commit
789a5ada40
60
xml.go
60
xml.go
|
@ -28,29 +28,8 @@ func makeStandardXml(d *DropletT) {
|
||||||
|
|
||||||
qcow := "/home/nfs2/" + d.Hostname + ".qcow2"
|
qcow := "/home/nfs2/" + d.Hostname + ".qcow2"
|
||||||
simpleDisk(domcfg, qcow)
|
simpleDisk(domcfg, qcow)
|
||||||
|
// setMacs(domcfg, "33:44:33:11:22:11", "worldbr")
|
||||||
// domcfg.Memory = 3333
|
randomMacs(domcfg)
|
||||||
// fmt.Printf("Virt Devices %s\n", domcfg.Devices.Disks)
|
|
||||||
// log.Spew(domcfg.Devices)
|
|
||||||
// fmt.Printf("Virt Devices %s\n", domcfg.DiskDriver)
|
|
||||||
// log.Info("DISKS")
|
|
||||||
// log.Info("DISKS")
|
|
||||||
// log.Info("")
|
|
||||||
// structure DomainDeviceList shows what can be done as a range
|
|
||||||
/*
|
|
||||||
for i, x := range domcfg.Devices.Disks {
|
|
||||||
// Create a new DomainDiskSourceFile struct
|
|
||||||
newSource := &libvirtxml.DomainDiskSourceFile{
|
|
||||||
File: "mynew.qcow2", // Set the file name here
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign it to the disk's source
|
|
||||||
domcfg.Devices.Disks[i].Source.File = newSource
|
|
||||||
|
|
||||||
// fmt.Printf("Disk Source %s\n", name)
|
|
||||||
fmt.Printf("Disk Device %s\n", x.Source.File)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
xmldoc, err := domcfg.Marshal()
|
xmldoc, err := domcfg.Marshal()
|
||||||
|
|
||||||
|
@ -59,8 +38,6 @@ func makeStandardXml(d *DropletT) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Printf("Virt type %s\n", xmldoc)
|
|
||||||
|
|
||||||
outfile := "/tmp/" + d.Hostname + ".xml"
|
outfile := "/tmp/" + d.Hostname + ".xml"
|
||||||
regfile, _ := os.OpenFile(outfile, os.O_RDWR|os.O_CREATE, 0666)
|
regfile, _ := os.OpenFile(outfile, os.O_RDWR|os.O_CREATE, 0666)
|
||||||
fmt.Fprintln(regfile, xmldoc)
|
fmt.Fprintln(regfile, xmldoc)
|
||||||
|
@ -137,3 +114,36 @@ func showMacs(domcfg *libvirtxml.Domain) []string {
|
||||||
}
|
}
|
||||||
return macs
|
return macs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setMacs(domcfg *libvirtxml.Domain, mac string, brname string) {
|
||||||
|
// Clear out the existing disks (if any)
|
||||||
|
domcfg.Devices.Interfaces = nil
|
||||||
|
|
||||||
|
// Define a new disk with "mynew.qcow2"
|
||||||
|
newNet := libvirtxml.DomainInterface{
|
||||||
|
MAC: &libvirtxml.DomainInterfaceMAC{
|
||||||
|
Address: mac,
|
||||||
|
},
|
||||||
|
Target: &libvirtxml.DomainInterfaceTarget{
|
||||||
|
Dev: brname,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the new disk to the domain configuration
|
||||||
|
domcfg.Devices.Interfaces = append(domcfg.Devices.Interfaces, newNet)
|
||||||
|
}
|
||||||
|
|
||||||
|
func randomMacs(domcfg *libvirtxml.Domain) {
|
||||||
|
for i, x := range domcfg.Devices.Interfaces {
|
||||||
|
// Create a new DomainDiskInterfaces struct
|
||||||
|
newMac := &libvirtxml.DomainInterfaceMAC{
|
||||||
|
Address: "aa:bb:cc:dd:ee:ff", // make sure this is unique
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign it to the disk's source
|
||||||
|
domcfg.Devices.Interfaces[i].MAC = newMac
|
||||||
|
|
||||||
|
// fmt.Printf("Disk Source %s\n", name)
|
||||||
|
fmt.Printf("mac addr %s\n", x.MAC)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue