Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyInterfaceResultToVirtualEthCard(ctx context.Context, ethCard *vimtypes.VirtualEthernetCard, ...) error
- func CreateDefaultEthCard(ctx context.Context, result *NetworkInterfaceResult) (vimtypes.BaseVirtualDevice, error)
- func GuestOSCustomization(results NetworkInterfaceResults) ([]vimtypes.CustomizationAdapterMapping, error)
- func NCPCRName(vmName, networkName, interfaceName string, isV1A1 bool) string
- func NetOPCRName(vmName, networkName, interfaceName string, isV1A1 bool) string
- func NetPlanCustomization(result NetworkInterfaceResults) (*netplan.Network, error)
- func NormalizeNetplanMac(mac string) string
- func ResolveBackingPostPlacement(ctx context.Context, vimClient *vim25.Client, ...) (bool, error)
- func VPCCRName(vmName, networkName, interfaceName string) string
- type NetworkInterfaceIPConfig
- type NetworkInterfaceResult
- type NetworkInterfaceResults
- type NetworkInterfaceRoute
Constants ¶
const ( // VMNameLabel is the label put on a network interface CR that identifies its VM by name. VMNameLabel = pkg.VMOperatorKey + "/vm-name" )
Variables ¶
var ( // RetryTimeout is var so tests can change it to shorten tests until we get rid of the poll. RetryTimeout = 15 * time.Second )
Functions ¶
func ApplyInterfaceResultToVirtualEthCard ¶
func ApplyInterfaceResultToVirtualEthCard( ctx context.Context, ethCard *vimtypes.VirtualEthernetCard, result *NetworkInterfaceResult) error
ApplyInterfaceResultToVirtualEthCard applies the interface result from the NetOP/NCP provider to an existing Ethernet device from the class ConfigSpec.
func CreateDefaultEthCard ¶
func CreateDefaultEthCard( ctx context.Context, result *NetworkInterfaceResult) (vimtypes.BaseVirtualDevice, error)
CreateDefaultEthCard creates a default Ethernet card attached to the backing. This is used when the VM Class ConfigSpec does not have a device entry for a VM Spec network interface, so we need a new device.
func GuestOSCustomization ¶
func GuestOSCustomization(results NetworkInterfaceResults) ([]vimtypes.CustomizationAdapterMapping, error)
func NetOPCRName ¶
NetOPCRName returns the name to be used for the NetOP NetworkInterface CR.
func NetPlanCustomization ¶
func NetPlanCustomization(result NetworkInterfaceResults) (*netplan.Network, error)
func NormalizeNetplanMac ¶
NormalizeNetplanMac normalizes the mac address format to one compatible with netplan.
func ResolveBackingPostPlacement ¶
func ResolveBackingPostPlacement( ctx context.Context, vimClient *vim25.Client, clusterMoRef vimtypes.ManagedObjectReference, results *NetworkInterfaceResults) (bool, error)
ResolveBackingPostPlacement fixes up the backings where we did not know the CCR until after placement. This should be called if CreateAndWaitForNetworkInterfaces() was called with a nil clusterMoRef. Returns true if a backing was resolved, so the ConfigSpec needs to be updated.
Types ¶
type NetworkInterfaceResult ¶
type NetworkInterfaceResult struct {
IPConfigs []NetworkInterfaceIPConfig
MacAddress string
ExternalID string
NetworkID string
Backing object.NetworkReference
Device vimtypes.BaseVirtualDevice
// Fields from the InterfaceSpec used later during customization.
Name string
GuestDeviceName string
DHCP4 bool
DHCP6 bool
MTU int64
Nameservers []string
SearchDomains []string
Routes []NetworkInterfaceRoute
}
type NetworkInterfaceResults ¶
type NetworkInterfaceResults struct {
Results []NetworkInterfaceResult
}
func CreateAndWaitForNetworkInterfaces ¶
func CreateAndWaitForNetworkInterfaces( vmCtx pkgctx.VirtualMachineContext, client ctrlclient.Client, vimClient *vim25.Client, finder *find.Finder, clusterMoRef *vimtypes.ManagedObjectReference, networkSpec *vmopv1.VirtualMachineNetworkSpec) (NetworkInterfaceResults, error)
CreateAndWaitForNetworkInterfaces creates the appropriate CRs for the VM's network interfaces, and then waits for them to be reconciled by NCP (NSX-T) or NetOP (VDS).
Networking has always been kind of a pain and clunky for us, and unfortunately this code suffers gotchas and other not-so-great limitations.
- Historically, this code used wait.PollImmediate() and we continue to do so here, but eventually we should Watch() these resources. Note though, that in the very common case, the CR is reconciled before our poll timeout, so that does save us from bailing out of the Reconcile.
- NCP, NetOP and VPC CR Status inform us of the backing and IPAM info. However, for our InterfaceSpec we allow for DHCP but neither NCP nor NetOP has a way for us to mark the CR to don't do IPAM or to check DHCP is even enabled on the network. So this burns an IP, and the user must know that DHCP is actually configured.
- CR naming has mostly been working by luck, and sometimes didn't offer very good discoverability. Here, with v1a2 we now have a "name" field in our InterfaceSpec, so we use that (BMV: need to double-check that field meets k8s name requirements) A longer term option is to use GenerateName to ensure a unique name, and then client.List() and filter by the OwnerRef to find the VM's network CRs, and to annotate the CRs to help identify which VM InterfaceSpec it corresponds to. Note that for existing v1a1 VMs we may need to add legacy name support here to find their interface CRs.
- Instead of CreateOrUpdate, use CreateOrPatch to lessen the odds of blowing away any new fields.