network

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NsxtNetworkType = "nsx-t"
	VdsNetworkType  = "vsphere-distributed"
)

Variables

View Source
var ErrNamedNetworkProviderNotSupported = fmt.Errorf("named network provider is not supported in production")

ErrNamedNetworkProviderNotSupported is returned if the named network provider is used in production deployments of VM Operator.

Functions

func NormalizeNetplanMac

func NormalizeNetplanMac(mac string) string

NormalizeNetplanMac normalizes the mac address format to one compatible with netplan.

func ToCidrNotation

func ToCidrNotation(ip string, mask string) string

ToCidrNotation takes ip and mask as ip addresses and returns a cidr notation. It Assumes ipv4.

Types

type IPConfig

type IPConfig struct {
	// IP setting.
	IP string
	// IPFamily specifies the IP family (IPv4 vs IPv6) the IP belongs to.
	IPFamily IPFamily
	// Gateway setting.
	Gateway string
	// SubnetMask setting.
	SubnetMask string
}

IPConfig represents an IP configuration.

type IPFamily

type IPFamily string

IPFamily represents the IP Family (IPv4 or IPv6). This type is used to express the family of an IP expressed by a type (i.e. service.Spec.IPFamily) NOTE: Copied from k8s.io/api/core/v1" because VM Operator is using old version.

const (
	// IPv4Protocol indicates that this IP is IPv4 protocol.
	IPv4Protocol IPFamily = "IPv4"
	// IPv6Protocol indicates that this IP is IPv6 protocol.
	IPv6Protocol IPFamily = "IPv6"
)

type InterfaceInfo

type InterfaceInfo struct {
	Device          vimtypes.BaseVirtualDevice
	Customization   *vimtypes.CustomizationAdapterMapping
	IPConfiguration IPConfig
	NetplanEthernet NetplanEthernet
}

type InterfaceInfoList

type InterfaceInfoList []InterfaceInfo

func (InterfaceInfoList) GetIPConfigs

func (l InterfaceInfoList) GetIPConfigs() []IPConfig

func (InterfaceInfoList) GetInterfaceCustomizations

func (l InterfaceInfoList) GetInterfaceCustomizations() []vimtypes.CustomizationAdapterMapping

func (InterfaceInfoList) GetNetplan

func (l InterfaceInfoList) GetNetplan(
	currentEthCards object.VirtualDeviceList,
	dnsServers, searchSuffixes []string) Netplan

func (InterfaceInfoList) GetVirtualDeviceList

func (l InterfaceInfoList) GetVirtualDeviceList() object.VirtualDeviceList

type Netplan

type Netplan struct {
	Version   int                        `yaml:"version,omitempty"`
	Ethernets map[string]NetplanEthernet `yaml:"ethernets,omitempty"`
}

Netplan representation described in https://via.vmw.com/cloud-init-netplan

type NetplanEthernet

type NetplanEthernet struct {
	Match       NetplanEthernetMatch      `yaml:"match,omitempty"`
	SetName     string                    `yaml:"set-name,omitempty"`
	Dhcp4       bool                      `yaml:"dhcp4,omitempty"`
	Addresses   []string                  `yaml:"addresses,omitempty"`
	Gateway4    string                    `yaml:"gateway4,omitempty"`
	Nameservers NetplanEthernetNameserver `yaml:"nameservers,omitempty"`
}

type NetplanEthernetMatch

type NetplanEthernetMatch struct {
	MacAddress string `yaml:"macaddress,omitempty"`
}

type NetplanEthernetNameserver

type NetplanEthernetNameserver struct {
	Addresses []string `yaml:"addresses,omitempty"`
	Search    []string `yaml:"search,omitempty"`
}

type Provider

type Provider interface {
	// EnsureNetworkInterface returns the NetworkInterfaceInfo for the vif.
	EnsureNetworkInterface(vmCtx context.VirtualMachineContext, vif *v1alpha1.VirtualMachineNetworkInterface) (*InterfaceInfo, error)
}

Provider sets up network for different type of network.

func NewProvider

func NewProvider(
	k8sClient ctrlruntime.Client,
	vimClient *vim25.Client,
	finder *find.Finder,
	cluster *object.ClusterComputeResource) Provider

Jump to

Keyboard shortcuts

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