more migrations done

This commit is contained in:
Matthew Stobbs 2024-03-20 15:45:25 -06:00
parent 3862e3d4e9
commit 99fcb2b360

View File

@ -176,10 +176,10 @@ func (h *Host) memoryInfo() {
log.Println(err)
}
h.NodeMemory = &NodeMemoryInfo{
Total: mi.Total,
Free: mi.Free,
Total: mi.Total,
Free: mi.Free,
Buffers: mi.Buffers,
Cached: mi.Cached,
Cached: mi.Cached,
}
h.SysInfo, err = h.conn.GetSysinfo(0)
@ -303,58 +303,46 @@ func (h *Host) getDomainInfo() {
log.Println(err)
}
if len(doms) > 0 {
h.VMList = make([]VMInfo, len(doms))
h.VMList = make([]*libvirtxml.Domain, len(doms))
for i, d := range doms {
// Just going to log errors here, and free the dom after getting what we can
if h.VMList[i].Name, err = d.GetName(); err != nil {
log.Println(err)
}
if h.VMList[i].UUID, err = d.GetUUID(); err != nil {
log.Println(err)
}
if h.VMList[i].ID, err = d.GetID(); err != nil {
log.Println(err)
}
if h.VMList[i].XML, err = d.GetXMLDesc(0); err != nil {
log.Println(err)
}
vmXML := &libvirtxml.Domain{}
if err = vmXML.Unmarshal(h.VMList[i].XML); err != nil {
log.Println(err)
}
h.VMList[i].VCPUs = vmXML.VCPU.Value
h.VMList[i].Memory = vmXML.CurrentMemory.Value
if h.VMList[i].Active, err = d.IsActive(); err != nil {
log.Println(err)
}
func() {
defer d.Free()
rawxml, err := d.GetXMLDesc(0)
if err != nil {
log.Printf("error getting domain XML: %s", err)
}
h.VMList[i] = &libvirtxml.Domain{}
if err = h.VMList[i].Unmarshal(rawxml); err != nil {
log.Printf("error parsing domain XML: %s", err)
}
}()
d.Free()
}
}
}
func (h *Host) getIfaceInfo() {
// getIfaceInfo
ifaces, err := h.conn.ListInterfaces()
ifaces, err := h.conn.ListAllInterfaces(0)
if err != nil {
log.Println(err)
}
if len(ifaces) > 0 {
h.NetIfFList = make([]NetIfInfo, len(ifaces))
h.NetIfFList = make([]*libvirtxml.Interface, len(ifaces))
for i, ni := range ifaces {
h.NetIfFList[i].Name = ni
iface, err := h.conn.LookupInterfaceByName(ni)
if err != nil {
log.Println(err)
}
if h.NetIfFList[i].MacAddr, err = iface.GetMACString(); err != nil {
log.Println(err)
}
if h.NetIfFList[i].XML, err = iface.GetXMLDesc(0); err != nil {
log.Println(err)
}
iface.Free()
func() {
defer ni.Free()
rawxml, err := ni.GetXMLDesc(0)
if err != nil {
log.Printf("error getting interface XML: %s")
return
}
h.NetIfFList[i] = &libvirtxml.Interface{}
if err = h.NetIfFList[i].Unmarshal(rawxml); err != nil {
log.Printf("error parsing interface XML: %s")
return
}
}()
}
}
}