mock

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetAlloc

type NetAlloc struct {
	// contains filtered or unexported fields
}

NetAlloc is a mock version of the netplugin, suitable for unit testing.

func NewMockNetAlloc

func NewMockNetAlloc() *NetAlloc

NewMockNetAlloc is a constructor for mock netalloc plugin.

func (*NetAlloc) Allocate

func (p *NetAlloc) Allocate(network, ifaceName, address, gw string)

Allocate simulates allocation of an IP address.

func (*NetAlloc) CorrelateRetrievedIPs

func (p *NetAlloc) CorrelateRetrievedIPs(expAddrsOrRefs []string, retrievedAddrs []string,
	ifaceName string, addrForm netalloc.IPAddressForm) (correlated []string)

CorrelateRetrievedIPs is not implemented here.

func (*NetAlloc) CreateAddressAllocRef

func (p *NetAlloc) CreateAddressAllocRef(network, iface string, getGW bool) string

CreateAddressAllocRef creates reference to an allocated IP address.

func (*NetAlloc) Deallocate

func (p *NetAlloc) Deallocate(network, ifaceName string)

Deallocate simulates de-allocation of an IP address.

func (*NetAlloc) GetAddressAllocDep

func (p *NetAlloc) GetAddressAllocDep(addrOrAllocRef, ifaceName, depLabelPrefix string) (
	dep kvs.Dependency, hasAllocDep bool)

GetAddressAllocDep is not implemented here.

func (*NetAlloc) GetOrParseIPAddress

func (p *NetAlloc) GetOrParseIPAddress(addrOrAllocRef string, ifaceName string,
	addrForm netalloc.IPAddressForm) (addr *net.IPNet, err error)

GetOrParseIPAddress tries to get allocated interface (or GW) IP address referenced by <addrOrAllocRef> in the requested form. But if the string contains/ an actual IP address instead of a reference, the address is parsed using methods from the net package and returned in the requested form. For ADDR_ONLY address form, the returned <addr> will have the mask unset and the IP address should be accessed as <addr>.IP

func (*NetAlloc) ParseAddressAllocRef

func (p *NetAlloc) ParseAddressAllocRef(addrAllocRef, expIface string) (
	network, iface string, isGW, isRef bool, err error)

ParseAddressAllocRef parses reference to an allocated IP address.

func (*NetAlloc) ValidateIPAddress

func (p *NetAlloc) ValidateIPAddress(addrOrAllocRef, ifaceName, fieldName string, gwCheck plugin.GwValidityCheck) error

ValidateIPAddress checks validity of address reference or, if <addrOrAllocRef> already contains an actual IP address, it tries to parse it.

Jump to

Keyboard shortcuts

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