// GetAllowedNICs responsible for fetching Network ports satisfying user configuration func GetAllowedNICs(data *xmlinput.XMLInputData, hidriver deployer.HostinfoDriver) (host.NICList, error) { allowedNics := host.NewNICList() priorityNics := host.NewNICList() physicalNics := host.NewNICList() nics, err := hidriver.NICs() if err != nil { return nil, utils.FormatError(err) } for _, nic := range nics { if deniedNIC(nic, &data.HostNics) { continue } // if counfiguration exists, treat physical ports if nic.Type == host.NicTypePhys || nic.Type == host.NicTypePhysVF { if data.HostNics.Allowed != nil { for _, anic := range data.HostNics.Allowed { if (anic.Model == "" && strings.Contains(nic.Vendor, anic.Vendor)) || nic.Model == anic.Model { if anic.Priority { priorityNics.Add(nic) } else { physicalNics.Add(nic) } } } } } else { // allow all ports in case configuration is empty or the port is not physical allowedNics.Add(nic) } } // if found ports with priority append them if priorityNics.Length() > 0 { allowedNics.AppendList(priorityNics) } else { allowedNics.AppendList(physicalNics) } return allowedNics, nil }