more migrations done
This commit is contained in:
parent
3862e3d4e9
commit
99fcb2b360
@ -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)
|
||||
func() {
|
||||
defer d.Free()
|
||||
rawxml, err := d.GetXMLDesc(0)
|
||||
if err != nil {
|
||||
log.Printf("error getting domain XML: %s", 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)
|
||||
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)
|
||||
func() {
|
||||
defer ni.Free()
|
||||
rawxml, err := ni.GetXMLDesc(0)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Printf("error getting interface XML: %s")
|
||||
return
|
||||
}
|
||||
if h.NetIfFList[i].MacAddr, err = iface.GetMACString(); err != nil {
|
||||
log.Println(err)
|
||||
h.NetIfFList[i] = &libvirtxml.Interface{}
|
||||
if err = h.NetIfFList[i].Unmarshal(rawxml); err != nil {
|
||||
log.Printf("error parsing interface XML: %s")
|
||||
return
|
||||
}
|
||||
if h.NetIfFList[i].XML, err = iface.GetXMLDesc(0); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
iface.Free()
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user