Example #1
0
// Returns info related to the host's NICs
func (hi *HostinfoDriver) NICs() (host.NICList, error) {
	if hi.nics != nil {
		return hi.nics, nil
	}

	var err error
	hi.nics, err = hi.c.NICInfo()
	if err != nil {
		return nil, err
	}

	out, err := hi.c.Run("virsh net-list |awk '!/-----/ && !/Name/ && !/^$/{print $1}'")
	if err != nil {
		return nil, err
	}
	for _, net := range strings.Split(out, "\n") {
		if net != "" {
			n := new(host.NIC)
			n.Name = net
			n.NUMANode = -1
			n.PCIAddr = "N/A"
			n.Type = host.NicTypeVirtualNetwork
			n.Desc = "Virtual network"
			hi.nics.Add(n)
		}
	}
	return hi.nics, nil
}
Example #2
0
func createTestListSingleNUMA() []NICList {
	phys1n1 := new(host.NIC)
	phys1n1.Desc = "test NIC #1"
	phys1n1.Driver = "e1000e"
	phys1n1.Name = "eth0"
	phys1n1.PCIAddr = "0000:00:16.1"
	phys1n1.NUMANode = 0
	phys1n1.Type = host.NicTypePhys
	phys1n1.Vendor = "Intel Corporation"
	phys1n1.Model = "82579LM Gigabit Network Connection"

	phys2n1 := new(host.NIC)
	phys2n1.Desc = "test NIC #2"
	phys2n1.Driver = "e1000e"
	phys2n1.Name = "eth1"
	phys2n1.PCIAddr = "0000:00:16.2"
	phys2n1.NUMANode = 0
	phys2n1.Type = host.NicTypePhys
	phys2n1.Vendor = "Intel Corporation"
	phys2n1.Model = "82579LM Gigabit Network Connection"

	phys3n1 := new(host.NIC)
	phys3n1.Desc = "test NIC #3"
	phys3n1.Driver = "e1000e"
	phys3n1.Name = "eth2"
	phys3n1.PCIAddr = "0000:00:16.3"
	phys3n1.NUMANode = 0
	phys3n1.Type = host.NicTypePhys
	phys3n1.Vendor = "Intel Corporation"
	phys3n1.Model = "82579LM Gigabit Network Connection"

	phys1n2 := new(host.NIC)
	phys1n2.Desc = "test NIC #4"
	phys1n2.Driver = "e1000e"
	phys1n2.Name = "eth3"
	phys1n2.PCIAddr = "0000:00:17.1"
	phys1n2.NUMANode = 0
	phys1n2.Type = host.NicTypePhys
	phys1n2.Vendor = "Intel Corporation"
	phys1n2.Model = "82579LM Gigabit Network Connection"

	phys2n2 := new(host.NIC)
	phys2n2.Desc = "test NIC #5"
	phys2n2.Driver = "e1000e"
	phys2n2.Name = "eth4"
	phys2n2.PCIAddr = "0000:00:17.2"
	phys2n2.NUMANode = 0
	phys2n2.Type = host.NicTypePhys
	phys2n2.Vendor = "Intel Corporation"
	phys2n2.Model = "82579LM Gigabit Network Connection"

	phys3n2 := new(host.NIC)
	phys3n2.Desc = "test NIC #6"
	phys3n2.Driver = "e1000e"
	phys3n2.Name = "eth5"
	phys3n2.PCIAddr = "0000:00:17.3"
	phys3n2.NUMANode = 0
	phys3n2.Type = host.NicTypePhys
	phys3n2.Vendor = "Intel Corporation"
	phys3n2.Model = "82579LM Gigabit Network Connection"

	gn1 := NewNIC()
	gn1.HostNIC = phys1n1
	gn1.Network = "net1"
	gn1.PCIAddr = &PCI{"0000", "00", "01", "0"}

	gn2 := NewNIC()
	gn2.HostNIC = phys2n1
	gn2.Network = "net1"
	gn2.PCIAddr = &PCI{"0000", "00", "01", "1"}

	gn3 := NewNIC()
	gn3.HostNIC = phys3n1
	gn3.Network = "net1"
	gn3.PCIAddr = &PCI{"0000", "00", "02", "0"}

	gn4 := NewNIC()
	gn4.HostNIC = phys1n2
	gn4.Network = "net2"
	gn4.PCIAddr = &PCI{"0000", "00", "01", "0"}

	gn5 := NewNIC()
	gn5.HostNIC = phys2n2
	gn5.Network = "net2"
	gn5.PCIAddr = &PCI{"0000", "00", "01", "1"}

	gn6 := NewNIC()
	gn6.HostNIC = phys3n2
	gn6.Network = "net1"
	gn6.PCIAddr = &PCI{"0000", "00", "02", "0"}

	list1 := NewNICList()
	list1.Add(gn1)
	list1.Add(gn2)
	list1.Add(gn3)

	list2 := NewNICList()
	list2.Add(gn4)
	list2.Add(gn5)
	list2.Add(gn6)
	return []NICList{list1, list2}
}