diff --git a/xml.go b/xml.go index dbfd17d..75e95b2 100644 --- a/xml.go +++ b/xml.go @@ -25,26 +25,32 @@ func makeStandardXml(d *DropletT) { 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) + // domcfg.Memory = 3333 - fmt.Printf("Virt Devices %s\n", domcfg.Devices.Disks) + // 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("") + // 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 + /* + 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) } - - // 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() @@ -62,6 +68,21 @@ func makeStandardXml(d *DropletT) { log.Info("File is in", outfile) } +func setDiskFilename(domcfg *libvirtxml.Domain, filename string) { + for i, x := range domcfg.Devices.Disks { + // Create a new DomainDiskSourceFile struct + newSource := &libvirtxml.DomainDiskSourceFile{ + File: filename, // 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) + } +} + func addDefaults(d *libvirtxml.Domain, filename string) { fullname := "resources/xml/" + filename + ".xml" pfile, err := resources.ReadFile(fullname) @@ -102,3 +123,17 @@ func simpleDisk(domcfg *libvirtxml.Domain, filename string) { // Add the new disk to the domain configuration domcfg.Devices.Disks = append(domcfg.Devices.Disks, newDisk) } + +func showMacs(domcfg *libvirtxml.Domain) []string { + var macs []string + // Iterate over the network interfaces and print the MAC addresses + for _, iface := range domcfg.Devices.Interfaces { + if iface.MAC != nil { + fmt.Printf("Interface: %s, MAC Address: %s\n", iface.Target.Dev, iface.MAC.Address) + macs = append(macs, iface.MAC.Address) + } else { + fmt.Printf("Interface: %s, MAC Address: not available\n", iface.Target.Dev) + } + } + return macs +}