github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/lib/net/configurator/api.go (about) 1 package configurator 2 3 import ( 4 "io" 5 "net" 6 7 "github.com/Cloud-Foundations/Dominator/lib/log" 8 fm_proto "github.com/Cloud-Foundations/Dominator/proto/fleetmanager" 9 hyper_proto "github.com/Cloud-Foundations/Dominator/proto/hypervisor" 10 ) 11 12 type bondedInterfaceType struct { 13 name string // "bond0.VlanId" interface name. 14 ipAddr net.IP 15 subnet *hyper_proto.Subnet 16 } 17 18 type bridgeOnlyInterfaceType struct { 19 netInterface net.Interface 20 subnetId string 21 } 22 23 type normalInterfaceType struct { 24 ipAddr net.IP 25 netInterface net.Interface 26 subnet *hyper_proto.Subnet 27 } 28 29 type NetworkConfig struct { 30 bondedInterfaces []bondedInterfaceType 31 bridges []uint 32 bridgeOnlyInterfaces []bridgeOnlyInterfaceType 33 DefaultSubnet *hyper_proto.Subnet 34 normalInterfaces []normalInterfaceType 35 bondSlaves []string 36 vlanRawDevice string 37 } 38 39 func FindMatchingSubnet(subnets []*hyper_proto.Subnet, 40 ipAddr net.IP) *hyper_proto.Subnet { 41 return findMatchingSubnet(subnets, ipAddr) 42 } 43 44 func GetNetworkEntries( 45 info fm_proto.GetMachineInfoResponse) []fm_proto.NetworkEntry { 46 return getNetworkEntries(info) 47 } 48 49 func Compute(machineInfo fm_proto.GetMachineInfoResponse, 50 interfaces map[string]net.Interface, 51 logger log.DebugLogger) (*NetworkConfig, error) { 52 return compute(machineInfo, interfaces, logger) 53 } 54 55 func (netconf *NetworkConfig) PrintDebian(writer io.Writer) error { 56 return netconf.printDebian(writer) 57 } 58 59 func (netconf *NetworkConfig) Update(rootDir string, 60 logger log.DebugLogger) (bool, error) { 61 return netconf.update(rootDir, logger) 62 } 63 64 func (netconf *NetworkConfig) UpdateDebian(rootDir string) (bool, error) { 65 return netconf.updateDebian(rootDir) 66 } 67 68 func (netconf *NetworkConfig) WriteDebian(rootDir string) error { 69 return netconf.writeDebian(rootDir) 70 } 71 72 func PrintResolvConf(writer io.Writer, subnet *hyper_proto.Subnet) error { 73 return printResolvConf(writer, subnet) 74 } 75 76 func UpdateResolvConf(rootDir string, 77 subnet *hyper_proto.Subnet) (bool, error) { 78 return updateResolvConf(rootDir, subnet) 79 } 80 81 func WriteResolvConf(rootDir string, subnet *hyper_proto.Subnet) error { 82 return writeResolvConf(rootDir, subnet) 83 }