apis

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const TypeOfBridgeNetwork = "L2Bridge"
View Source
const TypeOfTransparentNetwork = "Transparent"
View Source
const TypeOfTunnelNetwork = "L2Tunnel"

Variables

This section is empty.

Functions

func AddBridgeHCNNetwork

func AddBridgeHCNNetwork(ctx context.Context, i *Network) (err error)

AddBridgeHCNNetwork parses the given Network to a target HNS v2(HCN api) bridge network object, and brings it up.

func AddBridgeHNSNetwork

func AddBridgeHNSNetwork(ctx context.Context, i *Network) (err error)

AddBridgeHNSNetwork parses the given Network to a target HNS v1 bridge network object, and brings it up.

func AddHCNEndpoint

func AddHCNEndpoint(ctx context.Context, i *Endpoint, netns, networkID string, decorates ...HCNEndpointDecorator) error

AddHCNEndpoint parses the given Endpoint to a target HNS v2(HCN api) endpoint object, and adds it to given netns, or returns error.

func AddHCNHostEndpoint

func AddHCNHostEndpoint(ctx context.Context, i *Endpoint, netns, networkID string, decorates ...HCNEndpointDecorator) error

AddHCNHostEndpoint parses the given Endpoint to a target HNS v2(HCN api) endpoint object, and adds it to given nets, or returns error.

func AddHCNNetwork

func AddHCNNetwork(ctx context.Context, i *Network, decorates ...HCNNetworkDecorator) error

AddHCNNetwork parses the given Network to a target HNS v2(HCN api) network object, and brings it up.

func AddHNSEndpoint

func AddHNSEndpoint(ctx context.Context, i *Endpoint, netns, networkID, containerID string, decorates ...HNSEndpointDecorator) error

AddHNSEndpoint parses the given Endpoint to a target HNS v1 endpoint object, and adds it to given netns, or returns error.

func AddHNSHostEndpoint

func AddHNSHostEndpoint(ctx context.Context, i *Endpoint, netns, networkID, containerID string, decorates ...HNSEndpointDecorator) error

AddHNSHostEndpoint parses the given Endpoint to a target HNS v1 endpoint object, and adds it to given netns, or returns error.

func AddHNSNetwork

func AddHNSNetwork(ctx context.Context, i *Network, decorates ...HNSNetworkDecorator) error

AddHNSNetwork parses the given Network to a target HNS v1 network object, and brings it up.

func AddTransparentHCNNetwork

func AddTransparentHCNNetwork(ctx context.Context, i *Network) (err error)

AddTransparentHCNNetwork parses the given Network to a target HNS v2(HCN api) transparent network object, and brings it up.

func AddTransparentHNSNetwork

func AddTransparentHNSNetwork(ctx context.Context, i *Network) (err error)

AddTransparentHNSNetwork parses the given Network to a target HNS v1 transparent network object, and brings it up.

func AddTunnelHCNNetwork

func AddTunnelHCNNetwork(ctx context.Context, i *Network) (err error)

AddTunnelHCNNetwork parses the given Network to a target HNS v2(HCN api) bridge network object, and brings it up.

func AddTunnelHNSNetwork

func AddTunnelHNSNetwork(ctx context.Context, i *Network) (err error)

AddTunnelHNSNetwork parses the given Network to a target HNS v1 bridge network object, and brings it up.

func DeleteHCNEndpoint

func DeleteHCNEndpoint(ctx context.Context, i *Endpoint, netns string) (string, error)

DeleteHCNEndpoint deletes the target HNS v2(HCN api) endpoint object related to the given Endpoint, and returns the related HNS v2(HCN api) network ID.

func DeleteHCNNetwork

func DeleteHCNNetwork(ctx context.Context, i *Network) error

DeleteHCNNetwork deletes the target HNS v2(HCN api) network object related to the given Network.

func DeleteHCNNetworkIfEmpty

func DeleteHCNNetworkIfEmpty(ctx context.Context, i *Network) error

DeleteHCNNetworkIfEmpty deletes the target HNS v2(HCN api) network object related to the given Network if no attaching endpoints.

func DeleteHNSEndpoint

func DeleteHNSEndpoint(ctx context.Context, i *Endpoint, netns, containerID string) (string, error)

DeleteHNSEndpoint deletes the target HNS v1 endpoint object related to the given Endpoint, and returns the related HNS v1 network ID.

func DeleteHNSNetwork

func DeleteHNSNetwork(ctx context.Context, i *Network) error

DeleteHNSNetwork deletes the target HNS v1 network object related to the given Network.

func DeleteHNSNetworkIfEmpty

func DeleteHNSNetworkIfEmpty(ctx context.Context, i *Network) error

DeleteHNSNetworkIfEmpty deletes the target HNS v1 network object related to the given Network if no attaching endpoints.

func FromCommaList

func FromCommaList(s string) []string

func GetDefaultBridgeNetworkGateway

func GetDefaultBridgeNetworkGateway(subnet *net.IPNet) net.IP

GetDefaultBridgeNetworkGateway returns the default gateway address of the given bridge subnet.

func GetDefaultNetworkGateway

func GetDefaultNetworkGateway(subnet *net.IPNet) net.IP

GetDefaultNetworkGateway returns the default gateway address of the given subnet.

func GetHCNEndpointAvailableProtocolEnum

func GetHCNEndpointAvailableProtocolEnum(p string) (uint32, error)

func GetHCNHostDefaultNamespace

func GetHCNHostDefaultNamespace() (*hcn.HostComputeNamespace, error)

func GetHCNNetworkByName

func GetHCNNetworkByName(ctx context.Context, name string) (*hcn.HostComputeNetwork, error)

GetHCNNetworkByName returns the HNS v2(HCN api) network object by the given name.

func GetHCNNetworkIDByName

func GetHCNNetworkIDByName(ctx context.Context, name string) (string, error)

GetHCNNetworkIDByName returns the HNS v2(HCN api) network ID by the given name.

func GetHNSEndpointSandboxContainerID

func GetHNSEndpointSandboxContainerID(netns string, containerID string) string

func GetHNSNetworkByName

func GetHNSNetworkByName(ctx context.Context, name string) (*hcsshim.HNSNetwork, error)

GetHNSNetworkByName returns the HNS v1 network obj by the given name.

func GetHNSNetworkIDByName

func GetHNSNetworkIDByName(ctx context.Context, name string) (string, error)

GetHNSNetworkIDByName returns the HNS v1 network ID with given name.

func IsDsrSupported

func IsDsrSupported() bool

func IsHCNEndpointCorrupted

func IsHCNEndpointCorrupted(ep *hcn.HostComputeEndpoint, network string, addr net.IP) bool

func IsHCNNetworkCorrupted

func IsHCNNetworkCorrupted(nw *hcn.HostComputeNetwork, nwAdapterName string, nwAdapterMac string, nwType string, nwSubnet net.IPNet) bool

func IsHCNSupported

func IsHCNSupported(netns string) bool

func IsHNSEndpointCorrupted

func IsHNSEndpointCorrupted(ep *hcsshim.HNSEndpoint, network string, addr net.IP) bool

func IsHNSEndpointSandbox

func IsHNSEndpointSandbox(netns string) bool

func IsHNSNetworkCorrupted

func IsHNSNetworkCorrupted(nw *hcsshim.HNSNetwork, nwAdapterName string, nwAdapterMac string, nwType string, nwSubnet net.IPNet) bool

func ParseHCNNetworkManagementIP

func ParseHCNNetworkManagementIP(nw *hcn.HostComputeNetwork) net.IP

func ParseHNSNetworkManagementIP

func ParseHNSNetworkManagementIP(nw *hcsshim.HNSNetwork) net.IP

func ToCommaList

func ToCommaList(elems []string) string

Types

type APIVersion

type APIVersion string
const (
	HNS    APIVersion = "v1"
	HNS_V2 APIVersion = "v2"
	HCN               = HNS_V2
)

type Endpoint

type Endpoint struct {
	// Name specifies the name of the endpoint.
	Name string

	// Address specifies the IP address of the endpoint, included IP mask.
	Address net.IPNet

	// MAC specifies the MAC address of the endpoint,
	// it's optional.
	MAC string

	// DNS specifies the DNS configuration of the endpoint.
	DNS types.DNS

	// MTU specifies the size of MTU in network,
	// it's optional, default is `1500`.
	MTU int

	// Gateway specifies the IP address of the next hop for the endpoint.
	Gateway net.IP

	// ID specifies the id of the endpoint,
	// it's observed at creation.
	ID string
}

Endpoint describes the information of an HNS v1/v2(HCN api) endpoint object.

func (*Endpoint) Format

func (ep *Endpoint) Format(networkID string, version APIVersion) string

type HCNEndpointDecorator

type HCNEndpointDecorator func(*hcn.HostComputeEndpoint) error

HCNEndpointDecorator is a function to decorate the given HNS v2(HCN api) endpoint object before creating.

func ApplyHCNEndpointEncapsulatedRoutePolicy

func ApplyHCNEndpointEncapsulatedRoutePolicy(destinationIPNets ...*net.IPNet) HCNEndpointDecorator

ApplyHCNEndpointEncapsulatedRoutePolicy applies the destination encapsulated route policy to the creating HNS v2(HCN api) endpoint object.

func ApplyHCNEndpointLoopbackDsrPolicy

func ApplyHCNEndpointLoopbackDsrPolicy() HCNEndpointDecorator

ApplyHCNEndpointLoopbackDsrPolicy applies the loopback DSR policy to the creating HNS v2(HCN api) endpoint object.

func ApplyHCNEndpointOutboundNatPolicy

func ApplyHCNEndpointOutboundNatPolicy(exceptionIPNets ...*net.IPNet) HCNEndpointDecorator

ApplyHCNEndpointOutboundNatPolicy applies the outbound NAT policy to the creating HNS v2(HCN api) endpoint object.

func ApplyHCNEndpointPortMappingPolicy

func ApplyHCNEndpointPortMappingPolicy(protocol string, containerPort int, hostPort int, hostIP string) HCNEndpointDecorator

ApplyHCNEndpointPortMappingPolicy applies the port mapping policy to the creating HNS v2(HCN api) endpoint object.

type HCNNetworkDecorator

type HCNNetworkDecorator func(*hcn.HostComputeNetwork) error

HCNNetworkDecorator is a function to decorate the given HNS v2(HCN api) network object before creating.

type HNSEndpointDecorator

type HNSEndpointDecorator func(*hcsshim.HNSEndpoint) error

HNSEndpointDecorator is a function to decorate the given HNS v1 endpoint object before creating.

func ApplyHNSEndpointEncapsulatedRoutePolicy

func ApplyHNSEndpointEncapsulatedRoutePolicy(destinationIPNets ...*net.IPNet) HNSEndpointDecorator

ApplyHNSEndpointEncapsulatedRoutePolicy applies the destination encapsulated route policy to the creating HNS v1 endpoint object.

func ApplyHNSEndpointLoopbackDsrPolicy

func ApplyHNSEndpointLoopbackDsrPolicy() HNSEndpointDecorator

ApplyHNSEndpointLoopbackDsrPolicy applies the loopback DSR policy to the creating HNS v1 endpoint object.

func ApplyHNSEndpointOutboundNatPolicy

func ApplyHNSEndpointOutboundNatPolicy(exceptionIPNets ...*net.IPNet) HNSEndpointDecorator

ApplyHNSEndpointOutboundNatPolicy applies the outbound NAT policy to the creating HNS v1 endpoint object.

func ApplyHNSEndpointPortMappingPolicy

func ApplyHNSEndpointPortMappingPolicy(protocol string, containerPort int, hostPort int, hostIP string) HNSEndpointDecorator

ApplyHNSEndpointPortMappingPolicy applies the port mapping policy to the creating HNS v1 endpoint object.

type HNSNetworkDecorator

type HNSNetworkDecorator func(*hcsshim.HNSNetwork) error

HNSNetworkDecorator is a function to decorate the given HNS v1 network object before creating.

type Network

type Network struct {
	// Type specifies the type of the network.
	Type string

	// Name specifies the name of the network.
	Name string

	// AdapterName specifies the physical adapter name of the network.
	AdapterName string

	// AdapterMAC specifies the physical adapter MAC of the network.
	AdapterMAC string

	// Subnet specifies the allocated IP range of the network.
	Subnet net.IPNet

	// DNS specifies the DNS configuration of the network.
	DNS types.DNS

	// MTU specifies the size of MTU in network,
	// it's optional, default is `1500`.
	MTU int

	// Gateway specifies the IP address of the next hop for the network,
	// it's optional, default is the first index IP of the subnet.
	Gateway net.IP

	// ID specifies the id of the network,
	// it's observed at creation.
	ID string
	// contains filtered or unexported fields
}

func (*Network) Format

func (nw *Network) Format(version APIVersion) string

Jump to

Keyboard shortcuts

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