hcn

package
v0.0.0-...-2393a11 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package hcn is a shim for the Host Compute Networking (HCN) service, which manages networking for Windows Server containers and Hyper-V containers. Previous to RS5, HCN was referred to as Host Networking Service (HNS).

Package hcn is a shim for the Host Compute Networking (HCN) service, which manages networking for Windows Server containers and Hyper-V containers. Previous to RS5, HCN was referred to as Host Networking Service (HNS).

Index

Constants

View Source
const (
	// Allow traffic
	ActionTypeAllow ActionType = "Allow"
	// Block traffic
	ActionTypeBlock ActionType = "Block"

	// In is traffic coming to the Endpoint
	DirectionTypeIn DirectionType = "In"
	// Out is traffic leaving the Endpoint
	DirectionTypeOut DirectionType = "Out"

	// Host creates WFP (Windows Firewall) rules
	RuleTypeHost RuleType = "Host"
	// Switch creates VFP (Virtual Filter Platform) rules
	RuleTypeSwitch RuleType = "Switch"
)

Variables

View Source
var (
	// HNSVersion1803 added ACL functionality.
	HNSVersion1803 = VersionRanges{VersionRange{MinVersion: Version{Major: 7, Minor: 2}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
	// V2ApiSupport allows the use of V2 Api calls and V2 Schema.
	V2ApiSupport = VersionRanges{VersionRange{MinVersion: Version{Major: 9, Minor: 2}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
	// Remote Subnet allows for Remote Subnet policies on Overlay networks
	RemoteSubnetVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 9, Minor: 2}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
	// A Host Route policy allows for local container to local host communication Overlay networks
	HostRouteVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 9, Minor: 2}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
	// HNS 9.3 through 10.0 (not included), and 10.2+ allows for Direct Server Return for loadbalancing
	DSRVersion = VersionRanges{
		VersionRange{MinVersion: Version{Major: 9, Minor: 3}, MaxVersion: Version{Major: 9, Minor: math.MaxInt32}},
		VersionRange{MinVersion: Version{Major: 10, Minor: 2}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}},
	}
	// HNS 9.3 through 10.0 (not included) and, 10.4+ provide support for configuring endpoints with /32 prefixes
	Slash32EndpointPrefixesVersion = VersionRanges{
		VersionRange{MinVersion: Version{Major: 9, Minor: 3}, MaxVersion: Version{Major: 9, Minor: math.MaxInt32}},
		VersionRange{MinVersion: Version{Major: 10, Minor: 4}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}},
	}
	// HNS 9.3 through 10.0 (not included) and, 10.4+ allow for HNS ACL Policies to support protocol 252 for VXLAN
	AclSupportForProtocol252Version = VersionRanges{
		VersionRange{MinVersion: Version{Major: 11, Minor: 0}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}},
	}
	// HNS 12.0 allows for session affinity for loadbalancing
	SessionAffinityVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 12, Minor: 0}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
	// HNS 10.5 through 11 (not included) and 12.0+ supports Ipv6 dual stack.
	IPv6DualStackVersion = VersionRanges{
		VersionRange{MinVersion: Version{Major: 10, Minor: 5}, MaxVersion: Version{Major: 10, Minor: math.MaxInt32}},
		VersionRange{MinVersion: Version{Major: 12, Minor: 0}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}},
	}
	// HNS 13.0 allows for Set Policy support
	SetPolicyVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 13, Minor: 0}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
	// HNS 10.3 allows for VXLAN ports
	VxlanPortVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 10, Minor: 3}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}

	//HNS 9.5 through 10.0(not included), 10.5 through 11.0(not included), 11.11 through 12.0(not included), 12.1 through 13.0(not included), 13.1+ allows for Network L4Proxy Policy support
	L4ProxyPolicyVersion = VersionRanges{
		VersionRange{MinVersion: Version{Major: 9, Minor: 5}, MaxVersion: Version{Major: 9, Minor: math.MaxInt32}},
		VersionRange{MinVersion: Version{Major: 10, Minor: 5}, MaxVersion: Version{Major: 10, Minor: math.MaxInt32}},
		VersionRange{MinVersion: Version{Major: 11, Minor: 11}, MaxVersion: Version{Major: 11, Minor: math.MaxInt32}},
		VersionRange{MinVersion: Version{Major: 12, Minor: 1}, MaxVersion: Version{Major: 12, Minor: math.MaxInt32}},
		VersionRange{MinVersion: Version{Major: 13, Minor: 1}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}},
	}

	//HNS 13.2 allows for L4WfpProxy Policy support
	L4WfpProxyPolicyVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 13, Minor: 2}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
)

Functions

func AclSupportForProtocol252Supported

func AclSupportForProtocol252Supported() error

AclSupportForProtocol252Supported returns an error if the HCN version does not support HNS ACL Policies to support protocol 252 for VXLAN.

func AddNamespaceEndpoint

func AddNamespaceEndpoint(namespaceId string, endpointId string) error

AddNamespaceEndpoint adds an endpoint to a Namespace.

func CheckErrorWithCode

func CheckErrorWithCode(err error, code ErrorCode) bool

func DSRSupported

func DSRSupported() error

DSRSupported returns an error if the HCN version does not support Direct Server Return.

func GetNamespaceContainerIds

func GetNamespaceContainerIds(namespaceId string) ([]string, error)

GetNamespaceContainerIds returns the containers of the Namespace specified by Id.

func GetNamespaceEndpointIds

func GetNamespaceEndpointIds(namespaceId string) ([]string, error)

GetNamespaceEndpointIds returns the endpoints of the Namespace specified by Id.

func HostRouteSupported

func HostRouteSupported() error

HostRouteSupported returns an error if the HCN version does not support Host Route policies.

func IPv6DualStackSupported

func IPv6DualStackSupported() error

IPv6DualStackSupported returns an error if the HCN version does not support IPv6DualStack.

func IsElementNotFoundError

func IsElementNotFoundError(err error) bool

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns a boolean indicating whether the error was caused by a resource not being found.

func IsPortAlreadyExistsError

func IsPortAlreadyExistsError(err error) bool

func L4WfpProxyPolicySupported

func L4WfpProxyPolicySupported() error

L4WfpProxySupported returns an error if the HCN verison does not support L4WfpProxy

func L4proxyPolicySupported

func L4proxyPolicySupported() error

L4proxySupported returns an error if the HCN verison does not support L4Proxy

func ModifyEndpointSettings

func ModifyEndpointSettings(endpointId string, request *ModifyEndpointSettingRequest) error

ModifyEndpointSettings updates the Port/Policy of an Endpoint.

func ModifyNamespaceSettings

func ModifyNamespaceSettings(namespaceId string, request *ModifyNamespaceSettingRequest) error

ModifyNamespaceSettings updates the Endpoints/Containers of a Namespace.

func RemoteSubnetSupported

func RemoteSubnetSupported() error

RemoteSubnetSupported returns an error if the HCN version does not support Remote Subnet policies.

func RemoveNamespaceEndpoint

func RemoveNamespaceEndpoint(namespaceId string, endpointId string) error

RemoveNamespaceEndpoint removes an endpoint from a Namespace.

func SessionAffinitySupported

func SessionAffinitySupported() error

SessionAffinitySupported returns an error if the HCN version does not support Session Affinity.

func SetPolicySupported

func SetPolicySupported() error

SetPolicySupported returns an error if the HCN version does not support SetPolicy.

func Slash32EndpointPrefixesSupported

func Slash32EndpointPrefixesSupported() error

Slash32EndpointPrefixesSupported returns an error if the HCN version does not support configuring endpoints with /32 prefixes.

func V2ApiSupported

func V2ApiSupported() error

V2ApiSupported returns an error if the HCN version does not support the V2 Apis.

func VxlanPortSupported

func VxlanPortSupported() error

VxlanPortSupported returns an error if the HCN version does not support configuring the VXLAN TCP port.

Types

type AclFeatures

type AclFeatures struct {
	AclAddressLists       bool `json:"AclAddressLists"`
	AclNoHostRulePriority bool `json:"AclHostRulePriority"`
	AclPortRanges         bool `json:"AclPortRanges"`
	AclRuleId             bool `json:"AclRuleId"`
}

AclFeatures are the supported ACL possibilities.

type AclPolicySetting

type AclPolicySetting struct {
	Protocols       string        `json:",omitempty"` // EX: 6 (TCP), 17 (UDP), 1 (ICMPv4), 58 (ICMPv6), 2 (IGMP)
	Action          ActionType    `json:","`
	Direction       DirectionType `json:","`
	LocalAddresses  string        `json:",omitempty"`
	RemoteAddresses string        `json:",omitempty"`
	LocalPorts      string        `json:",omitempty"`
	RemotePorts     string        `json:",omitempty"`
	RuleType        RuleType      `json:",omitempty"`
	Priority        uint16        `json:",omitempty"`
}

AclPolicySetting creates firewall rules on an endpoint

type ActionType

type ActionType string

ActionType associated with ACLs. Value is either Allow or Block.

type ApiSupport

type ApiSupport struct {
	V1 bool `json:"V1"`
	V2 bool `json:"V2"`
}

ApiSupport lists the supported API versions.

type AutomaticDNSNetworkPolicySetting

type AutomaticDNSNetworkPolicySetting struct {
	Enable bool `json:",omitempty"`
}

AutomaticDNSNetworkPolicySetting enables/disables automatic DNS on a network.

type DirectionType

type DirectionType string

DirectionType associated with ACLs. Value is either In or Out.

type Dns

type Dns struct {
	Domain     string   `json:",omitempty"`
	Search     []string `json:",omitempty"`
	ServerList []string `json:",omitempty"`
	Options    []string `json:",omitempty"`
}

Dns (Domain Name System is associated with a network.

type DrMacAddressNetworkPolicySetting

type DrMacAddressNetworkPolicySetting struct {
	Address string `json:",omitempty"`
}

DrMacAddressNetworkPolicySetting sets the DR MAC for a network.

type EncapOverheadEndpointPolicySetting

type EncapOverheadEndpointPolicySetting struct {
	Overhead uint16 `json:",omitempty"`
}

EncapOverheadEndpointPolicySetting sets the encap overhead for an endpoint.

type EndpointFlags

type EndpointFlags uint32

EndpointFlags are special settings on an endpoint.

var (
	// EndpointFlagsNone is the default.
	EndpointFlagsNone EndpointFlags
	// EndpointFlagsRemoteEndpoint means that an endpoint is on another host.
	EndpointFlagsRemoteEndpoint EndpointFlags = 1
)

type EndpointNotFoundError

type EndpointNotFoundError struct {
	EndpointName string
	EndpointID   string
}

EndpointNotFoundError results from a failed seach for an endpoint by Id or Name

func (EndpointNotFoundError) Error

func (e EndpointNotFoundError) Error() string

type EndpointPolicy

type EndpointPolicy struct {
	Type     EndpointPolicyType `json:""`
	Settings json.RawMessage    `json:",omitempty"`
}

EndpointPolicy is a collection of Policy settings for an Endpoint.

type EndpointPolicyType

type EndpointPolicyType string

EndpointPolicyType are the potential Policies that apply to Endpoints.

const (
	PortMapping   EndpointPolicyType = "PortMapping"
	ACL           EndpointPolicyType = "ACL"
	QOS           EndpointPolicyType = "QOS"
	L2Driver      EndpointPolicyType = "L2Driver"
	OutBoundNAT   EndpointPolicyType = "OutBoundNAT"
	SDNRoute      EndpointPolicyType = "SDNRoute"
	L4Proxy       EndpointPolicyType = "L4Proxy"
	L4WFPPROXY    EndpointPolicyType = "L4WFPPROXY"
	PortName      EndpointPolicyType = "PortName"
	EncapOverhead EndpointPolicyType = "EncapOverhead"
	// Endpoint and Network have InterfaceConstraint and ProviderAddress
	NetworkProviderAddress     EndpointPolicyType = "ProviderAddress"
	NetworkInterfaceConstraint EndpointPolicyType = "InterfaceConstraint"
)

EndpointPolicyType const

type EndpointResourceType

type EndpointResourceType string

EndpointResourceType are the two different Endpoint settings resources.

var (
	// EndpointResourceTypePolicy is for Endpoint Policies. Ex: ACL, NAT
	EndpointResourceTypePolicy EndpointResourceType = "Policy"
	// EndpointResourceTypePort is for Endpoint Port settings.
	EndpointResourceTypePort EndpointResourceType = "Port"
)

type ErrorCode

type ErrorCode uint32
const (
	ERROR_NOT_FOUND                     = 0x490
	HCN_E_PORT_ALREADY_EXISTS ErrorCode = 0x803b0013
)

For common errors, define the error as it is in windows, so we can quickly determine it later

type FiveTuple

type FiveTuple struct {
	Protocols       string `json:",omitempty"`
	LocalAddresses  string `json:",omitempty"`
	RemoteAddresses string `json:",omitempty"`
	LocalPorts      string `json:",omitempty"`
	RemotePorts     string `json:",omitempty"`
	Priority        uint16 `json:",omitempty"`
}

FiveTuple is nested in L4ProxyPolicySetting for WFP support.

type Globals

type Globals struct {
	Version Version `json:"Version"`
}

Globals are all global properties of the HCN Service.

func GetGlobals

func GetGlobals() (*Globals, error)

GetGlobals returns the global properties of the HCN Service.

type HcnError

type HcnError struct {
	*hcserror.HcsError
	// contains filtered or unexported fields
}

func (*HcnError) Error

func (e *HcnError) Error() string

type HostComputeEndpoint

type HostComputeEndpoint struct {
	Id                   string           `json:"ID,omitempty"`
	Name                 string           `json:",omitempty"`
	HostComputeNetwork   string           `json:",omitempty"` // GUID
	HostComputeNamespace string           `json:",omitempty"` // GUID
	Policies             []EndpointPolicy `json:",omitempty"`
	IpConfigurations     []IpConfig       `json:",omitempty"`
	Dns                  Dns              `json:",omitempty"`
	Routes               []Route          `json:",omitempty"`
	MacAddress           string           `json:",omitempty"`
	Flags                EndpointFlags    `json:",omitempty"`
	SchemaVersion        SchemaVersion    `json:",omitempty"`
}

HostComputeEndpoint represents a network endpoint

func GetEndpointByID

func GetEndpointByID(endpointId string) (*HostComputeEndpoint, error)

GetEndpointByID returns an endpoint specified by Id

func GetEndpointByName

func GetEndpointByName(endpointName string) (*HostComputeEndpoint, error)

GetEndpointByName returns an endpoint specified by Name

func ListEndpoints

func ListEndpoints() ([]HostComputeEndpoint, error)

ListEndpoints makes a call to list all available endpoints.

func ListEndpointsOfNetwork

func ListEndpointsOfNetwork(networkId string) ([]HostComputeEndpoint, error)

ListEndpointsOfNetwork queries the list of endpoints on a network.

func ListEndpointsQuery

func ListEndpointsQuery(query HostComputeQuery) ([]HostComputeEndpoint, error)

ListEndpointsQuery makes a call to query the list of available endpoints.

func (*HostComputeEndpoint) ApplyPolicy

func (endpoint *HostComputeEndpoint) ApplyPolicy(requestType RequestType, endpointPolicy PolicyEndpointRequest) error

ApplyPolicy applies a Policy (ex: ACL) on the Endpoint.

func (*HostComputeEndpoint) Create

func (endpoint *HostComputeEndpoint) Create() (*HostComputeEndpoint, error)

Create Endpoint.

func (*HostComputeEndpoint) Delete

func (endpoint *HostComputeEndpoint) Delete() error

Delete Endpoint.

func (*HostComputeEndpoint) NamespaceAttach

func (endpoint *HostComputeEndpoint) NamespaceAttach(namespaceId string) error

NamespaceAttach modifies a Namespace to add an endpoint.

func (*HostComputeEndpoint) NamespaceDetach

func (endpoint *HostComputeEndpoint) NamespaceDetach(namespaceId string) error

NamespaceDetach modifies a Namespace to remove an endpoint.

type HostComputeLoadBalancer

type HostComputeLoadBalancer struct {
	Id                   string                    `json:"ID,omitempty"`
	HostComputeEndpoints []string                  `json:",omitempty"`
	SourceVIP            string                    `json:",omitempty"`
	FrontendVIPs         []string                  `json:",omitempty"`
	PortMappings         []LoadBalancerPortMapping `json:",omitempty"`
	SchemaVersion        SchemaVersion             `json:",omitempty"`
	Flags                LoadBalancerFlags         `json:",omitempty"` // 0: None, 1: EnableDirectServerReturn
}

HostComputeLoadBalancer represents software load balancer.

func AddLoadBalancer

func AddLoadBalancer(endpoints []HostComputeEndpoint, flags LoadBalancerFlags, portMappingFlags LoadBalancerPortMappingFlags, sourceVIP string, frontendVIPs []string, protocol uint16, internalPort uint16, externalPort uint16) (*HostComputeLoadBalancer, error)

AddLoadBalancer for the specified endpoints

func GetLoadBalancerByID

func GetLoadBalancerByID(loadBalancerId string) (*HostComputeLoadBalancer, error)

GetLoadBalancerByID returns the LoadBalancer specified by Id.

func ListLoadBalancers

func ListLoadBalancers() ([]HostComputeLoadBalancer, error)

ListLoadBalancers makes a call to list all available loadBalancers.

func ListLoadBalancersQuery

func ListLoadBalancersQuery(query HostComputeQuery) ([]HostComputeLoadBalancer, error)

ListLoadBalancersQuery makes a call to query the list of available loadBalancers.

func (*HostComputeLoadBalancer) AddEndpoint

func (loadBalancer *HostComputeLoadBalancer) AddEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error)

AddEndpoint add an endpoint to a LoadBalancer

func (*HostComputeLoadBalancer) Create

func (loadBalancer *HostComputeLoadBalancer) Create() (*HostComputeLoadBalancer, error)

Create LoadBalancer.

func (*HostComputeLoadBalancer) Delete

func (loadBalancer *HostComputeLoadBalancer) Delete() error

Delete LoadBalancer.

func (*HostComputeLoadBalancer) RemoveEndpoint

func (loadBalancer *HostComputeLoadBalancer) RemoveEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error)

RemoveEndpoint removes an endpoint from a LoadBalancer

type HostComputeNamespace

type HostComputeNamespace struct {
	Id            string              `json:"ID,omitempty"`
	NamespaceId   uint32              `json:",omitempty"`
	Type          NamespaceType       `json:",omitempty"` // Host, HostDefault, Guest, GuestDefault
	Resources     []NamespaceResource `json:",omitempty"`
	SchemaVersion SchemaVersion       `json:",omitempty"`
}

HostComputeNamespace represents a namespace (AKA compartment) in

func GetNamespaceByID

func GetNamespaceByID(namespaceId string) (*HostComputeNamespace, error)

GetNamespaceByID returns the Namespace specified by Id.

func ListNamespaces

func ListNamespaces() ([]HostComputeNamespace, error)

ListNamespaces makes a call to list all available namespaces.

func ListNamespacesQuery

func ListNamespacesQuery(query HostComputeQuery) ([]HostComputeNamespace, error)

ListNamespacesQuery makes a call to query the list of available namespaces.

func NewNamespace

func NewNamespace(nsType NamespaceType) *HostComputeNamespace

NewNamespace creates a new Namespace object

func (*HostComputeNamespace) Create

func (namespace *HostComputeNamespace) Create() (*HostComputeNamespace, error)

Create Namespace.

func (*HostComputeNamespace) Delete

func (namespace *HostComputeNamespace) Delete() error

Delete Namespace.

func (*HostComputeNamespace) Sync

func (namespace *HostComputeNamespace) Sync() error

Sync Namespace endpoints with the appropriate sandbox container holding the network namespace open. If no sandbox container is found for this namespace this method is determined to be a success and will not return an error in this case. If the sandbox container is found and a sync is initiated any failures will be returned via this method.

This call initiates a sync between endpoints and the matching UtilityVM hosting those endpoints. It is safe to call for any `NamespaceType` but `NamespaceTypeGuest` is the only case when a sync will actually occur. For `NamespaceTypeHost` the process container will be automatically synchronized when the the endpoint is added via `AddNamespaceEndpoint`.

Note: This method sync's both additions and removals of endpoints from a `NamespaceTypeGuest` namespace.

type HostComputeNetwork

type HostComputeNetwork struct {
	Id            string          `json:"ID,omitempty"`
	Name          string          `json:",omitempty"`
	Type          NetworkType     `json:",omitempty"`
	Policies      []NetworkPolicy `json:",omitempty"`
	MacPool       MacPool         `json:",omitempty"`
	Dns           Dns             `json:",omitempty"`
	Ipams         []Ipam          `json:",omitempty"`
	Flags         NetworkFlags    `json:",omitempty"` // 0: None
	SchemaVersion SchemaVersion   `json:",omitempty"`
}

HostComputeNetwork represents a network

func GetNetworkByID

func GetNetworkByID(networkID string) (*HostComputeNetwork, error)

GetNetworkByID returns the network specified by Id.

func GetNetworkByName

func GetNetworkByName(networkName string) (*HostComputeNetwork, error)

GetNetworkByName returns the network specified by Name.

func ListNetworks

func ListNetworks() ([]HostComputeNetwork, error)

ListNetworks makes a call to list all available networks.

func ListNetworksQuery

func ListNetworksQuery(query HostComputeQuery) ([]HostComputeNetwork, error)

ListNetworksQuery makes a call to query the list of available networks.

func (*HostComputeNetwork) AddPolicy

func (network *HostComputeNetwork) AddPolicy(networkPolicy PolicyNetworkRequest) error

AddPolicy applies a Policy (ex: RemoteSubnet) on the Network.

func (*HostComputeNetwork) Create

func (network *HostComputeNetwork) Create() (*HostComputeNetwork, error)

Create Network.

func (*HostComputeNetwork) CreateEndpoint

func (network *HostComputeNetwork) CreateEndpoint(endpoint *HostComputeEndpoint) (*HostComputeEndpoint, error)

CreateEndpoint creates an endpoint on the Network.

func (*HostComputeNetwork) CreateRemoteEndpoint

func (network *HostComputeNetwork) CreateRemoteEndpoint(endpoint *HostComputeEndpoint) (*HostComputeEndpoint, error)

CreateRemoteEndpoint creates a remote endpoint on the Network.

func (*HostComputeNetwork) Delete

func (network *HostComputeNetwork) Delete() error

Delete Network.

func (*HostComputeNetwork) ModifyNetworkSettings

func (network *HostComputeNetwork) ModifyNetworkSettings(request *ModifyNetworkSettingRequest) error

ModifyNetworkSettings updates the Policy for a network.

func (*HostComputeNetwork) RemovePolicy

func (network *HostComputeNetwork) RemovePolicy(networkPolicy PolicyNetworkRequest) error

RemovePolicy removes a Policy (ex: RemoteSubnet) from the Network.

type HostComputeQuery

type HostComputeQuery struct {
	SchemaVersion SchemaVersion         `json:""`
	Flags         HostComputeQueryFlags `json:",omitempty"`
	Filter        string                `json:",omitempty"`
}

HostComputeQuery is the format for HCN queries.

type HostComputeQueryFlags

type HostComputeQueryFlags uint32

HostComputeQueryFlags are passed in to a HostComputeQuery to determine which properties of an object are returned.

var (
	// HostComputeQueryFlagsNone returns an object with the standard properties.
	HostComputeQueryFlagsNone HostComputeQueryFlags
	// HostComputeQueryFlagsDetailed returns an object with all properties.
	HostComputeQueryFlagsDetailed HostComputeQueryFlags = 1
)

type HostComputeRoute

type HostComputeRoute struct {
	ID                   string                  `json:"ID,omitempty"`
	HostComputeEndpoints []string                `json:",omitempty"`
	Setting              []SDNRoutePolicySetting `json:",omitempty"`
	SchemaVersion        SchemaVersion           `json:",omitempty"`
}

HostComputeRoute represents SDN routes.

func AddRoute

func AddRoute(endpoints []HostComputeEndpoint, destinationPrefix string, nextHop string, needEncapsulation bool) (*HostComputeRoute, error)

AddRoute for the specified endpoints and SDN Route setting

func GetRouteByID

func GetRouteByID(routeID string) (*HostComputeRoute, error)

GetRouteByID returns the route specified by Id.

func ListRoutes

func ListRoutes() ([]HostComputeRoute, error)

ListRoutes makes a call to list all available routes.

func ListRoutesQuery

func ListRoutesQuery(query HostComputeQuery) ([]HostComputeRoute, error)

ListRoutesQuery makes a call to query the list of available routes.

func (*HostComputeRoute) AddEndpoint

func (route *HostComputeRoute) AddEndpoint(endpoint *HostComputeEndpoint) (*HostComputeRoute, error)

AddEndpoint add an endpoint to a route Since HCNRoute doesn't implement modify functionality, add operation is essentially delete and add

func (*HostComputeRoute) Create

func (route *HostComputeRoute) Create() (*HostComputeRoute, error)

Create Route.

func (*HostComputeRoute) Delete

func (route *HostComputeRoute) Delete() error

Delete Route.

func (*HostComputeRoute) RemoveEndpoint

func (route *HostComputeRoute) RemoveEndpoint(endpoint *HostComputeEndpoint) (*HostComputeRoute, error)

RemoveEndpoint removes an endpoint from a route Since HCNRoute doesn't implement modify functionality, remove operation is essentially delete and add

type InterfaceConstraintPolicySetting

type InterfaceConstraintPolicySetting struct {
	InterfaceGuid        string `json:",omitempty"`
	InterfaceLuid        uint64 `json:",omitempty"`
	InterfaceIndex       uint32 `json:",omitempty"`
	InterfaceMediaType   uint32 `json:",omitempty"`
	InterfaceAlias       string `json:",omitempty"`
	InterfaceDescription string `json:",omitempty"`
}

InterfaceConstraintPolicySetting limits an Endpoint or Network to a specific Nic.

type IpConfig

type IpConfig struct {
	IpAddress    string `json:",omitempty"`
	PrefixLength uint8  `json:",omitempty"`
}

IpConfig is assoicated with an endpoint

type Ipam

type Ipam struct {
	Type    string   `json:",omitempty"` // Ex: Static, DHCP
	Subnets []Subnet `json:",omitempty"`
}

Ipam (Internet Protocol Addres Management) is assoicated with a network and represents the address space(s) of a network.

type L4ProxyPolicySetting

type L4ProxyPolicySetting struct {
	IP          string       `json:",omitempty"`
	Port        string       `json:",omitempty"`
	Protocol    ProtocolType `json:",omitempty"`
	Exceptions  []string     `json:",omitempty"`
	Destination string
	OutboundNAT bool `json:",omitempty"`
}

L4ProxyPolicySetting applies proxy policy on network/endpoint

type L4WfpProxyPolicySetting

type L4WfpProxyPolicySetting struct {
	InboundProxyPort  string    `json:",omitempty"`
	OutboundProxyPort string    `json:",omitempty"`
	FilterTuple       FiveTuple `json:",omitempty"`
	UserSID           string    `json:",omitempty"`
}

L4WfpProxyPolicySetting sets Layer-4 Proxy on an endpoint.

type LoadBalancerDistribution

type LoadBalancerDistribution uint32

LoadBalancerDistribution specifies how the loadbalancer distributes traffic.

var (
	// LoadBalancerDistributionNone is the default and loadbalances each connection to the same pod.
	LoadBalancerDistributionNone LoadBalancerDistribution
	// LoadBalancerDistributionSourceIPProtocol loadbalances all traffic of the same protocol from a client IP to the same pod.
	LoadBalancerDistributionSourceIPProtocol LoadBalancerDistribution = 1
	// LoadBalancerDistributionSourceIP loadbalances all traffic from a client IP to the same pod.
	LoadBalancerDistributionSourceIP LoadBalancerDistribution = 2
)

type LoadBalancerFlags

type LoadBalancerFlags uint32

LoadBalancerFlags modify settings for a loadbalancer.

var (
	// LoadBalancerFlagsNone is the default.
	LoadBalancerFlagsNone LoadBalancerFlags = 0
	// LoadBalancerFlagsDSR enables Direct Server Return (DSR)
	LoadBalancerFlagsDSR LoadBalancerFlags = 1
)

type LoadBalancerNotFoundError

type LoadBalancerNotFoundError struct {
	LoadBalancerId string
}

LoadBalancerNotFoundError results from a failed seach for a loadbalancer by Id

func (LoadBalancerNotFoundError) Error

type LoadBalancerPortMapping

type LoadBalancerPortMapping struct {
	Protocol         uint32                       `json:",omitempty"` // EX: TCP = 6, UDP = 17
	InternalPort     uint16                       `json:",omitempty"`
	ExternalPort     uint16                       `json:",omitempty"`
	DistributionType LoadBalancerDistribution     `json:",omitempty"` // EX: Distribute per connection = 0, distribute traffic of the same protocol per client IP = 1, distribute per client IP = 2
	Flags            LoadBalancerPortMappingFlags `json:",omitempty"`
}

LoadBalancerPortMapping is associated with HostComputeLoadBalancer

type LoadBalancerPortMappingFlags

type LoadBalancerPortMappingFlags uint32

LoadBalancerPortMappingFlags are special settings on a loadbalancer.

var (
	// LoadBalancerPortMappingFlagsNone is the default.
	LoadBalancerPortMappingFlagsNone LoadBalancerPortMappingFlags
	// LoadBalancerPortMappingFlagsILB enables internal loadbalancing.
	LoadBalancerPortMappingFlagsILB LoadBalancerPortMappingFlags = 1
	// LoadBalancerPortMappingFlagsLocalRoutedVIP enables VIP access from the host.
	LoadBalancerPortMappingFlagsLocalRoutedVIP LoadBalancerPortMappingFlags = 2
	// LoadBalancerPortMappingFlagsUseMux enables DSR for NodePort access of VIP.
	LoadBalancerPortMappingFlagsUseMux LoadBalancerPortMappingFlags = 4
	// LoadBalancerPortMappingFlagsPreserveDIP delivers packets with destination IP as the VIP.
	LoadBalancerPortMappingFlagsPreserveDIP LoadBalancerPortMappingFlags = 8
)

type MacPool

type MacPool struct {
	Ranges []MacRange `json:",omitempty"`
}

MacPool is assoicated with a network and represents pool of MacRanges.

type MacRange

type MacRange struct {
	StartMacAddress string `json:",omitempty"`
	EndMacAddress   string `json:",omitempty"`
}

MacRange is associated with MacPool and respresents the start and end addresses.

type ModifyEndpointSettingRequest

type ModifyEndpointSettingRequest struct {
	ResourceType EndpointResourceType `json:",omitempty"` // Policy, Port
	RequestType  RequestType          `json:",omitempty"` // Add, Remove, Update, Refresh
	Settings     json.RawMessage      `json:",omitempty"`
}

ModifyEndpointSettingRequest is the structure used to send request to modify an endpoint. Used to update policy/port on an endpoint.

type ModifyNamespaceSettingRequest

type ModifyNamespaceSettingRequest struct {
	ResourceType NamespaceResourceType `json:",omitempty"` // Container, Endpoint
	RequestType  RequestType           `json:",omitempty"` // Add, Remove, Update, Refresh
	Settings     json.RawMessage       `json:",omitempty"`
}

ModifyNamespaceSettingRequest is the structure used to send request to modify a namespace. Used to Add/Remove an endpoints and containers to/from a namespace.

type ModifyNetworkSettingRequest

type ModifyNetworkSettingRequest struct {
	ResourceType NetworkResourceType `json:",omitempty"` // Policy, DNS, Extension
	RequestType  RequestType         `json:",omitempty"` // Add, Remove, Update, Refresh
	Settings     json.RawMessage     `json:",omitempty"`
}

ModifyNetworkSettingRequest is the structure used to send request to modify an network. Used to update DNS/extension/policy on an network.

type NamespaceNotFoundError

type NamespaceNotFoundError struct {
	NamespaceID string
}

NamespaceNotFoundError results from a failed seach for a namsepace by Id

func (NamespaceNotFoundError) Error

func (e NamespaceNotFoundError) Error() string

type NamespaceResource

type NamespaceResource struct {
	Type NamespaceResourceType `json:","` // Container, Endpoint
	Data json.RawMessage       `json:","`
}

NamespaceResource is associated with a namespace

type NamespaceResourceContainer

type NamespaceResourceContainer struct {
	Id string `json:"ID,"`
}

NamespaceResourceContainer represents a Container attached to a Namespace.

type NamespaceResourceEndpoint

type NamespaceResourceEndpoint struct {
	Id string `json:"ID,"`
}

NamespaceResourceEndpoint represents an Endpoint attached to a Namespace.

type NamespaceResourceType

type NamespaceResourceType string

NamespaceResourceType determines whether the Namespace resource is a Container or Endpoint.

var (
	// NamespaceResourceTypeContainer are contianers associated with a Namespace.
	NamespaceResourceTypeContainer NamespaceResourceType = "Container"
	// NamespaceResourceTypeEndpoint are endpoints associated with a Namespace.
	NamespaceResourceTypeEndpoint NamespaceResourceType = "Endpoint"
)

type NamespaceType

type NamespaceType string

NamespaceType determines whether the Namespace is for a Host or Guest

var (
	// NamespaceTypeHost are host namespaces.
	NamespaceTypeHost NamespaceType = "Host"
	// NamespaceTypeHostDefault are host namespaces in the default compartment.
	NamespaceTypeHostDefault NamespaceType = "HostDefault"
	// NamespaceTypeGuest are guest namespaces.
	NamespaceTypeGuest NamespaceType = "Guest"
	// NamespaceTypeGuestDefault are guest namespaces in the default compartment.
	NamespaceTypeGuestDefault NamespaceType = "GuestDefault"
)

type NatFlags

type NatFlags uint32

NatFlags are flags for portmappings.

type NetAdapterNameNetworkPolicySetting

type NetAdapterNameNetworkPolicySetting struct {
	NetworkAdapterName string `json:",omitempty"`
}

NetAdapterNameNetworkPolicySetting sets network adapter of a network.

type NetworkFlags

type NetworkFlags uint32

NetworkFlags are various network flags.

const (
	None                NetworkFlags = 0
	EnableNonPersistent NetworkFlags = 8
)

NetworkFlags const

type NetworkNotFoundError

type NetworkNotFoundError struct {
	NetworkName string
	NetworkID   string
}

NetworkNotFoundError results from a failed seach for a network by Id or Name

func (NetworkNotFoundError) Error

func (e NetworkNotFoundError) Error() string

type NetworkPolicy

type NetworkPolicy struct {
	Type     NetworkPolicyType `json:""`
	Settings json.RawMessage   `json:",omitempty"`
}

NetworkPolicy is a collection of Policy settings for a Network.

type NetworkPolicyType

type NetworkPolicyType string

NetworkPolicyType are the potential Policies that apply to Networks.

const (
	SourceMacAddress    NetworkPolicyType = "SourceMacAddress"
	NetAdapterName      NetworkPolicyType = "NetAdapterName"
	VSwitchExtension    NetworkPolicyType = "VSwitchExtension"
	DrMacAddress        NetworkPolicyType = "DrMacAddress"
	AutomaticDNS        NetworkPolicyType = "AutomaticDNS"
	InterfaceConstraint NetworkPolicyType = "InterfaceConstraint"
	ProviderAddress     NetworkPolicyType = "ProviderAddress"
	RemoteSubnetRoute   NetworkPolicyType = "RemoteSubnetRoute"
	VxlanPort           NetworkPolicyType = "VxlanPort"
	HostRoute           NetworkPolicyType = "HostRoute"
	SetPolicy           NetworkPolicyType = "SetPolicy"
	NetworkL4Proxy      NetworkPolicyType = "L4Proxy"
)

NetworkPolicyType const

type NetworkResourceType

type NetworkResourceType string

NetworkResourceType are the 3 different Network settings resources.

var (
	// NetworkResourceTypePolicy is for Network's policies. Ex: RemoteSubnet
	NetworkResourceTypePolicy NetworkResourceType = "Policy"
	// NetworkResourceTypeDNS is for Network's DNS settings.
	NetworkResourceTypeDNS NetworkResourceType = "DNS"
	// NetworkResourceTypeExtension is for Network's extension settings.
	NetworkResourceTypeExtension NetworkResourceType = "Extension"
)

type NetworkType

type NetworkType string

NetworkType are various networks.

const (
	NAT         NetworkType = "NAT"
	Transparent NetworkType = "Transparent"
	L2Bridge    NetworkType = "L2Bridge"
	L2Tunnel    NetworkType = "L2Tunnel"
	ICS         NetworkType = "ICS"
	Private     NetworkType = "Private"
	Overlay     NetworkType = "Overlay"
)

NetworkType const

type OutboundNatPolicySetting

type OutboundNatPolicySetting struct {
	VirtualIP    string   `json:",omitempty"`
	Exceptions   []string `json:",omitempty"`
	Destinations []string `json:",omitempty"`
}

OutboundNatPolicySetting sets outbound Network Address Translation on an Endpoint.

type PolicyEndpointRequest

type PolicyEndpointRequest struct {
	Policies []EndpointPolicy `json:",omitempty"`
}

type PolicyNetworkRequest

type PolicyNetworkRequest struct {
	Policies []NetworkPolicy `json:",omitempty"`
}

type PortMappingPolicySetting

type PortMappingPolicySetting struct {
	Protocol     uint32   `json:",omitempty"` // EX: TCP = 6, UDP = 17
	InternalPort uint16   `json:",omitempty"`
	ExternalPort uint16   `json:",omitempty"`
	VIP          string   `json:",omitempty"`
	Flags        NatFlags `json:",omitempty"`
}

PortMappingPolicySetting defines Port Mapping (NAT)

type PortnameEndpointPolicySetting

type PortnameEndpointPolicySetting struct {
	Name string `json:",omitempty"`
}

PortnameEndpointPolicySetting sets the port name for an endpoint.

type ProtocolType

type ProtocolType uint32

ProtocolType associated with L4ProxyPolicy

const (
	ProtocolTypeUnknown ProtocolType = 0
	ProtocolTypeICMPv4  ProtocolType = 1
	ProtocolTypeIGMP    ProtocolType = 2
	ProtocolTypeTCP     ProtocolType = 6
	ProtocolTypeUDP     ProtocolType = 17
	ProtocolTypeICMPv6  ProtocolType = 58
)

type ProviderAddressEndpointPolicySetting

type ProviderAddressEndpointPolicySetting struct {
	ProviderAddress string `json:",omitempty"`
}

ProviderAddressEndpointPolicySetting sets the PA for an endpoint.

type QosPolicySetting

type QosPolicySetting struct {
	MaximumOutgoingBandwidthInBytes uint64
}

QosPolicySetting sets Quality of Service bandwidth caps on an Endpoint.

type RemoteSubnetRoutePolicySetting

type RemoteSubnetRoutePolicySetting struct {
	DestinationPrefix           string
	IsolationId                 uint16
	ProviderAddress             string
	DistributedRouterMacAddress string
}

RemoteSubnetRoutePolicySetting creates remote subnet route rules on a network

type RequestType

type RequestType string

RequestType are the different operations performed to settings. Used to update the settings of Endpoint/Namespace objects.

var (
	// RequestTypeAdd adds the provided settings object.
	RequestTypeAdd RequestType = "Add"
	// RequestTypeRemove removes the provided settings object.
	RequestTypeRemove RequestType = "Remove"
	// RequestTypeUpdate replaces settings with the ones provided.
	RequestTypeUpdate RequestType = "Update"
	// RequestTypeRefresh refreshes the settings provided.
	RequestTypeRefresh RequestType = "Refresh"
)

type Route

type Route struct {
	NextHop           string `json:",omitempty"`
	DestinationPrefix string `json:",omitempty"`
	Metric            uint16 `json:",omitempty"`
}

Route is assoicated with a subnet.

type RouteNotFoundError

type RouteNotFoundError struct {
	RouteId string
}

RouteNotFoundError results from a failed seach for a route by Id

func (RouteNotFoundError) Error

func (e RouteNotFoundError) Error() string

type RuleType

type RuleType string

RuleType associated with ACLs. Value is either Host (WFP) or Switch (VFP).

type SDNRoutePolicySetting

type SDNRoutePolicySetting struct {
	DestinationPrefix string `json:",omitempty"`
	NextHop           string `json:",omitempty"`
	NeedEncap         bool   `json:",omitempty"`
}

SDNRoutePolicySetting sets SDN Route on an Endpoint.

type SchemaVersion

type SchemaVersion = Version // hcnglobals.go

SchemaVersion for HCN Objects/Queries.

func V2SchemaVersion

func V2SchemaVersion() SchemaVersion

type SetPolicySetting

type SetPolicySetting struct {
	Id     string
	Name   string
	Type   SetPolicyType
	Values string
}

SetPolicySetting creates IPSets on network

type SetPolicyType

type SetPolicyType string

SetPolicyTypes associated with SetPolicy. Value is IPSET.

const (
	SetPolicyTypeIpSet SetPolicyType = "IPSET"
)

type SourceMacAddressNetworkPolicySetting

type SourceMacAddressNetworkPolicySetting struct {
	SourceMacAddress string `json:",omitempty"`
}

SourceMacAddressNetworkPolicySetting sets source MAC for a network.

type Subnet

type Subnet struct {
	IpAddressPrefix string            `json:",omitempty"`
	Policies        []json.RawMessage `json:",omitempty"`
	Routes          []Route           `json:",omitempty"`
}

Subnet is assoicated with a Ipam.

type SubnetPolicy

type SubnetPolicy struct {
	Type     SubnetPolicyType `json:""`
	Settings json.RawMessage  `json:",omitempty"`
}

SubnetPolicy is a collection of Policy settings for a Subnet.

type SubnetPolicyType

type SubnetPolicyType string

SubnetPolicyType are the potential Policies that apply to Subnets.

const (
	VLAN SubnetPolicyType = "VLAN"
	VSID SubnetPolicyType = "VSID"
)

SubnetPolicyType const

type SupportedFeatures

type SupportedFeatures struct {
	Acl                      AclFeatures `json:"ACL"`
	Api                      ApiSupport  `json:"API"`
	RemoteSubnet             bool        `json:"RemoteSubnet"`
	HostRoute                bool        `json:"HostRoute"`
	DSR                      bool        `json:"DSR"`
	Slash32EndpointPrefixes  bool        `json:"Slash32EndpointPrefixes"`
	AclSupportForProtocol252 bool        `json:"AclSupportForProtocol252"`
	SessionAffinity          bool        `json:"SessionAffinity"`
	IPv6DualStack            bool        `json:"IPv6DualStack"`
	SetPolicy                bool        `json:"SetPolicy"`
	VxlanPort                bool        `json:"VxlanPort"`
	L4Proxy                  bool        `json:"L4Proxy"`    // network policy that applies VFP rules to all endpoints on the network to redirect traffic
	L4WfpProxy               bool        `json:"L4WfpProxy"` // endpoint policy that applies WFP filters to redirect traffic to/from that endpoint
}

SupportedFeatures are the features provided by the Service.

func GetSupportedFeatures

func GetSupportedFeatures() SupportedFeatures

GetSupportedFeatures returns the features supported by the Service.

type VSwitchExtensionNetworkPolicySetting

type VSwitchExtensionNetworkPolicySetting struct {
	ExtensionID string `json:",omitempty"`
	Enable      bool   `json:",omitempty"`
}

VSwitchExtensionNetworkPolicySetting enables/disabled VSwitch extensions for a network.

type Version

type Version struct {
	Major int `json:"Major"`
	Minor int `json:"Minor"`
}

Version is the HCN Service version.

type VersionRange

type VersionRange struct {
	MinVersion Version
	MaxVersion Version
}

type VersionRanges

type VersionRanges []VersionRange

type VlanPolicySetting

type VlanPolicySetting struct {
	IsolationId uint32 `json:","`
}

VlanPolicySetting isolates a subnet with VLAN tagging.

type VsidPolicySetting

type VsidPolicySetting struct {
	IsolationId uint32 `json:","`
}

VsidPolicySetting isolates a subnet with VSID tagging.

type VxlanPortPolicySetting

type VxlanPortPolicySetting struct {
	Port uint16
}

VxlanPortPolicySetting allows configuring the VXLAN TCP port

Jump to

Keyboard shortcuts

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