network

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNetworkPolicySetting

func CreateNetworkPolicySetting(networkAdapterName string) hcn.NetworkPolicy

CreateNetworkPolicySetting builds a NetAdapterNameNetworkPolicySetting.

func GetHostComputeEndpointPolicies

func GetHostComputeEndpointPolicies(policies []Policy) []hcn.EndpointPolicy

GetHostComputeEndpointPolicies converts CNI Policy objects into HCN Policy objects.

func GetHostComputeNetworkPolicies

func GetHostComputeNetworkPolicies(policies []Policy) []hcn.NetworkPolicy

GetHostComputeNetworkPolicies converts CNI Policy objects into HCN Policy objects.

func GetHostComputeSubnetPolicies

func GetHostComputeSubnetPolicies(policies []Policy) []json.RawMessage

GetHostComputeSubnetPolicies converts CNI Policy objects into HCN Policy objects.

func GetNetAdapterNameNetworkPolicySetting

func GetNetAdapterNameNetworkPolicySetting(hcnPolicies []hcn.NetworkPolicy) string

GetNetAdapterNameNetworkPolicySetting searches for NetAdapterNameNetworkPolicySetting among HCN Policy objects.

func GetPortEnumValue added in v0.3.0

func GetPortEnumValue(protocol string) (uint32, error)

Types

type CNIPolicyType

type CNIPolicyType string
const (
	NetworkPolicy     CNIPolicyType = "NetworkPolicy"
	EndpointPolicy    CNIPolicyType = "EndpointPolicy"
	OutBoundNatPolicy CNIPolicyType = "OutBoundNatPolicy"
)

type DNSInfo

type DNSInfo struct {
	Nameservers []string
	Domain      string
	Search      []string
	Options     []string
}

type EndpointInfo

type EndpointInfo struct {
	ID          string
	Name        string
	NetworkID   string
	NamespaceID string
	IPAddress   net.IP
	IP4Mask     net.IPMask // Used when dual stack is enabled
	IPAddress6  net.IPNet
	MacAddress  net.HardwareAddr
	Gateway     net.IP
	Gateway6    net.IP
	Routes      []RouteInfo
	Policies    []Policy
	Subnet      net.IPNet
	DNS         DNSInfo
	ContainerID string
	DualStack   bool
}

EndpointInfo contains read-only information about an endpoint. Datastore for NetworkInfo. Store this if required

func GetEndpointInfoFromHostComputeEndpoint

func GetEndpointInfoFromHostComputeEndpoint(hcnEndpoint *hcn.HostComputeEndpoint, withIpv6 bool) *EndpointInfo

GetEndpointInfoFromHostComputeEndpoint converts HostComputeEndpoint to CNI EndpointInfo.

func (*EndpointInfo) GetHostComputeEndpoint

func (endpoint *EndpointInfo) GetHostComputeEndpoint() *hcn.HostComputeEndpoint

GetHostComputeEndpoint converts EndpointInfo to HostComputeEndpoint format.

type Manager

type Manager interface {
	Initialize(config *common.PluginConfig) error
	Uninitialize()
	// Network
	CreateNetwork(config *NetworkInfo) (*NetworkInfo, error)
	DeleteNetwork(networkID string) error
	GetNetwork(networkID string) (*NetworkInfo, error)
	GetNetworkByName(networkName string) (*NetworkInfo, error)
	// Endpoint
	CreateEndpoint(networkID string, epInfo *EndpointInfo, namespaceID string) (*EndpointInfo, error)
	DeleteEndpoint(endpointID string) error
	GetEndpoint(endpointID string, withIpv6 bool) (*EndpointInfo, error)
	GetEndpointByName(endpointName string, withIpv6 bool) (*EndpointInfo, error)
}

Manager API.

func NewManager

func NewManager() (Manager, error)

NewManager creates a new networkManager.

type NetworkInfo

type NetworkInfo struct {
	ID            string
	Name          string
	Type          NetworkType
	InterfaceName string
	Subnets       []SubnetInfo
	DNS           DNSInfo
	Policies      []Policy
}

Datastore for NetworkInfo.

func GetNetworkInfoFromHostComputeNetwork

func GetNetworkInfoFromHostComputeNetwork(hcnNetwork *hcn.HostComputeNetwork) *NetworkInfo

GetNetworkInfoFromHostComputeNetwork converts HCN Network to NetworkInfo

func (*NetworkInfo) GetHostComputeNetworkConfig

func (info *NetworkInfo) GetHostComputeNetworkConfig() *hcn.HostComputeNetwork

GetHostComputeNetworkConfig converts NetworkInfo to HCN format.

type NetworkType

type NetworkType string
const (
	NAT         NetworkType = "NAT"
	Overlay     NetworkType = "Overlay"
	Transparent NetworkType = "Transparent"
	L2Tunnel    NetworkType = "L2Tunnel"
	L2Bridge    NetworkType = "L2Bridge"
)

type Policy

type Policy struct {
	Type CNIPolicyType
	Data json.RawMessage
}

func GetEndpointPoliciesFromHostComputePolicies

func GetEndpointPoliciesFromHostComputePolicies(hcnPolicies []hcn.EndpointPolicy) []Policy

GetEndpointPoliciesFromHostComputePolicies converts HCN Endpoint policy into CNI Policy objects.

func GetLoopbackDSRPolicy added in v0.3.0

func GetLoopbackDSRPolicy(ip *net.IP) (Policy, error)

GetLoopbackDSRPolicy creates a policy to support loopback direct server return.

func GetNetworkPoliciesFromHostComputeNetworkPolicies

func GetNetworkPoliciesFromHostComputeNetworkPolicies(hcnPolicies []hcn.NetworkPolicy) []Policy

GetNetworkPoliciesFromHostComputeNetworkPolicies converts HCN NetworkPolicy into CNI Policy objects.

func GetPortMappingPolicy

func GetPortMappingPolicy(externalPort int, internalPort int, protocol string, hostIp string, flags uint32) (Policy, error)

GetPortMappingPolicy creates an HCN PortMappingPolicy and stores it in CNI Policy.

func GetSubnetPoliciesFromHostComputeSubnetPolicies

func GetSubnetPoliciesFromHostComputeSubnetPolicies(hcnPolicies []json.RawMessage) []Policy

GetSubnetPoliciesFromHostComputeSubnetPolicies converts HCN SubnetPolicy into CNI Policy objects.

type RouteInfo

type RouteInfo struct {
	Destination net.IPNet
	Gateway     net.IP
}

RouteInfo contains information about an IP route.

type SubnetInfo

type SubnetInfo struct {
	AddressPrefix  net.IPNet
	GatewayAddress net.IP
	Policies       []Policy
}

Datastore for SubnetInfo.

func GetSubnetInfoFromHostComputeSubnet

func GetSubnetInfoFromHostComputeSubnet(hcnSubnet *hcn.Subnet) SubnetInfo

GetSubnetInfoFromHostComputeSubnet converts HCN Subnet to SubnetInfo.

func (*SubnetInfo) GetHostComputeSubnetConfig

func (subnet *SubnetInfo) GetHostComputeSubnetConfig() *hcn.Subnet

GetHostComputeSubnetConfig converts SubnetInfo into an HCN format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL