func()

in network/endpoint.go [42:105]


func (endpoint *EndpointInfo) GetHostComputeEndpoint() *hcn.HostComputeEndpoint {
	// Check for nil on address objects.
	ipAddr := ""
	ipConfig := []hcn.IpConfig{}
	routes := []hcn.Route{}	

	if endpoint.IPAddress != nil {
		ipAddr = endpoint.IPAddress.String()
		ipConfig = append(ipConfig, hcn.IpConfig{
			IpAddress: ipAddr,
		})
	}

	if endpoint.IPAddress6.IP != nil {
		ipAddr = endpoint.IPAddress6.IP.String()
		ipConfig = append(ipConfig, hcn.IpConfig{
			IpAddress: ipAddr,
		})
	}

	macAddr := ""
	if endpoint.MacAddress != nil {
		macAddr = endpoint.MacAddress.String()
	}

	gwAddr := ""
	if endpoint.Gateway != nil {
		gwAddr = endpoint.Gateway.String()
	}

	routes = append(routes, hcn.Route{
		NextHop:           gwAddr,
		DestinationPrefix: "0.0.0.0/0",
	})

	if endpoint.Gateway6 != nil {
		gwAddr6 := endpoint.Gateway6.String()
		routes = append(routes, hcn.Route{
			NextHop:           gwAddr6,
			DestinationPrefix: "::/0",
		})
	}

	return &hcn.HostComputeEndpoint{
		Name:                 endpoint.Name,
		Id:                   endpoint.ID,
		HostComputeNetwork:   endpoint.NetworkID,
		HostComputeNamespace: endpoint.NamespaceID,
		Dns: hcn.Dns{
			Domain:     endpoint.DNS.Domain,
			Search:     endpoint.DNS.Search,
			ServerList: endpoint.DNS.Nameservers,
			Options:    endpoint.DNS.Options,
		},
		MacAddress: macAddr,
		Routes: routes,
		IpConfigurations: ipConfig,
		SchemaVersion: hcn.SchemaVersion{
			Major: 2,
			Minor: 0,
		},
		Policies: GetHostComputeEndpointPolicies(endpoint.Policies),
	}
}