func NetworkConfigFromInterfaceInfo(interfaceInfos network.InterfaceInfos) []NetworkConfig {
	result := make([]NetworkConfig, len(interfaceInfos))
	for i, v := range interfaceInfos {
		var dnsServers []string
		for _, nameserver := range v.DNSServers {
			dnsServers = append(dnsServers, nameserver.Value)
		}

		var routes []NetworkRoute
		if len(v.Routes) != 0 {
			routes = make([]NetworkRoute, len(v.Routes))
			for j, route := range v.Routes {
				routes[j] = NetworkRoute{
					DestinationCIDR: route.DestinationCIDR,
					GatewayIP:       route.GatewayIP,
					Metric:          route.Metric,
				}
			}
		}

		result[i] = NetworkConfig{
			DeviceIndex:         v.DeviceIndex,
			MACAddress:          network.NormalizeMACAddress(v.MACAddress),
			ConfigType:          string(v.ConfigType),
			MTU:                 v.MTU,
			ProviderId:          string(v.ProviderId),
			ProviderNetworkId:   string(v.ProviderNetworkId),
			ProviderSubnetId:    string(v.ProviderSubnetId),
			ProviderSpaceId:     string(v.ProviderSpaceId),
			ProviderVLANId:      string(v.ProviderVLANId),
			ProviderAddressId:   string(v.ProviderAddressId),
			VLANTag:             v.VLANTag,
			InterfaceName:       v.InterfaceName,
			ParentInterfaceName: v.ParentInterfaceName,
			InterfaceType:       string(v.InterfaceType),
			Disabled:            v.Disabled,
			NoAutoStart:         v.NoAutoStart,
			Addresses:           FromProviderAddresses(v.Addresses...),
			ShadowAddresses:     FromProviderAddresses(v.ShadowAddresses...),
			DNSServers:          dnsServers,
			DNSSearchDomains:    v.DNSSearchDomains,
			GatewayAddress:      v.GatewayAddress.Value,
			Routes:              routes,
			IsDefaultGateway:    v.IsDefaultGateway,
			VirtualPortType:     string(v.VirtualPortType),
			NetworkOrigin:       NetworkOrigin(v.Origin),

			// TODO (manadart 2021-03-24): Retained for compatibility.
			// Delete CIDR and Address for Juju 3/4.
			CIDR:    v.PrimaryAddress().CIDR,
			Address: v.PrimaryAddress().Value,
		}
	}
	return result
}
// NetworkConfigFromInterfaceInfo converts a slice of network.InterfaceInfo into
// the equivalent NetworkConfig slice.
NetworkConfigFromInterfaceInfo converts a slice of network.InterfaceInfo into
the equivalent NetworkConfig slice.
// NetworkConfigFromInterfaceInfo converts a slice of network . InterfaceInfo into // the equivalent NetworkConfig slice .
func NetworkConfigFromInterfaceInfo(interfaceInfos network.InterfaceInfos) []NetworkConfig {
	result := make([]NetworkConfig, len(interfaceInfos))
	for i, v := range interfaceInfos {
		var dnsServers []string
		for _, nameserver := range v.DNSServers {
			dnsServers = append(dnsServers, nameserver.Value)
		}
		var routes []NetworkRoute
		if len(v.Routes) != 0 {
			routes = make([]NetworkRoute, len(v.Routes))
			for j, route := range v.Routes {
				routes[j] = NetworkRoute{
					DestinationCIDR: route.DestinationCIDR,
					GatewayIP:       route.GatewayIP,
					Metric:          route.Metric,
				}
			}
		}
		result[i] = NetworkConfig{
			DeviceIndex:         v.DeviceIndex,
			MACAddress:          network.NormalizeMACAddress(v.MACAddress),
			ConfigType:          string(v.ConfigType),
			MTU:                 v.MTU,
			ProviderId:          string(v.ProviderId),
			ProviderNetworkId:   string(v.ProviderNetworkId),
			ProviderSubnetId:    string(v.ProviderSubnetId),
			ProviderSpaceId:     string(v.ProviderSpaceId),
			ProviderVLANId:      string(v.ProviderVLANId),
			ProviderAddressId:   string(v.ProviderAddressId),
			VLANTag:             v.VLANTag,
			InterfaceName:       v.InterfaceName,
			ParentInterfaceName: v.ParentInterfaceName,
			InterfaceType:       string(v.InterfaceType),
			Disabled:            v.Disabled,
			NoAutoStart:         v.NoAutoStart,
			Addresses:           FromProviderAddresses(v.Addresses...),
			ShadowAddresses:     FromProviderAddresses(v.ShadowAddresses...),
			DNSServers:          dnsServers,
			DNSSearchDomains:    v.DNSSearchDomains,
			GatewayAddress:      v.GatewayAddress.Value,
			Routes:              routes,
			IsDefaultGateway:    v.IsDefaultGateway,
			VirtualPortType:     string(v.VirtualPortType),
			NetworkOrigin:       NetworkOrigin(v.Origin),
			CIDR:    v.PrimaryAddress().CIDR,
			Address: v.PrimaryAddress().Value,
		}
	}
	return result
}
func NetworkConfigFromInterfaceInfo ( interfaceInfos network . InterfaceInfos ) [ ] NetworkConfig { result := make ( [ ] NetworkConfig , len ( interfaceInfos ) ) for i , v := range interfaceInfos { var dnsServers [ ] string for _ , nameserver := range v . DNSServers { dnsServers = append ( dnsServers , nameserver . Value ) } var routes [ ] NetworkRoute if len ( v . Routes ) != 0 { routes = make ( [ ] NetworkRoute , len ( v . Routes ) ) for j , route := range v . Routes { routes [ j ] = NetworkRoute { DestinationCIDR : route . DestinationCIDR , GatewayIP : route . GatewayIP , Metric : route . Metric , } } } result [ i ] = NetworkConfig { DeviceIndex : v . DeviceIndex , MACAddress : network . NormalizeMACAddress ( v . MACAddress ) , ConfigType : string ( v . ConfigType ) , MTU : v . MTU , ProviderId : string ( v . ProviderId ) , ProviderNetworkId : string ( v . ProviderNetworkId ) , ProviderSubnetId : string ( v . ProviderSubnetId ) , ProviderSpaceId : string ( v . ProviderSpaceId ) , ProviderVLANId : string ( v . ProviderVLANId ) , ProviderAddressId : string ( v . ProviderAddressId ) , VLANTag : v . VLANTag , InterfaceName : v . InterfaceName , ParentInterfaceName : v . ParentInterfaceName , InterfaceType : string ( v . InterfaceType ) , Disabled : v . Disabled , NoAutoStart : v . NoAutoStart , Addresses : FromProviderAddresses ( v . Addresses ... ) , ShadowAddresses : FromProviderAddresses ( v . ShadowAddresses ... ) , DNSServers : dnsServers , DNSSearchDomains : v . DNSSearchDomains , GatewayAddress : v . GatewayAddress . Value , Routes : routes , IsDefaultGateway : v . IsDefaultGateway , VirtualPortType : string ( v . VirtualPortType ) , NetworkOrigin : NetworkOrigin ( v . Origin ) , CIDR : v . PrimaryAddress ( ) . CIDR , Address : v . PrimaryAddress ( ) . Value , } } return result }
NetworkConfigFromInterfaceInfo converts a slice of network.InterfaceInfo into
the equivalent NetworkConfig slice.
NetworkConfigFromInterfaceInfo converts a slice of network . InterfaceInfo into the equivalent NetworkConfig slice .
// TODO (manadart 2021-03-24): Retained for compatibility. // Delete CIDR and Address for Juju 3/4.