common

package
v1.5.37 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 24 Imported by: 19

Documentation

Index

Constants

View Source
const (
	// Operating environment.
	OptEnvironment             = "environment"
	OptEnvironmentAlias        = "e"
	OptEnvironmentAzure        = "azure"
	OptEnvironmentMAS          = "mas"
	OptEnvironmentFileIpam     = "fileIpam"
	OptEnvironmentIPv6NodeIpam = "ipv6NodeIpam"

	// API server URL.
	OptAPIServerURL      = "api-url"
	OptAPIServerURLAlias = "u"
	OptCnsURL            = "cns-url"
	OptCnsURLAlias       = "c"
	OptCnsPort           = "cns-port"
	OptCnsPortAlias      = "p"

	// Logging level.
	OptLogLevel      = "log-level"
	OptLogLevelAlias = "l"
	OptLogLevelInfo  = "info"
	OptLogLevelDebug = "debug"
	OptLogLevelError = "error"

	// Logging target.
	OptLogTarget       = "log-target"
	OptLogTargetAlias  = "t"
	OptLogTargetSyslog = "syslog"
	OptLogTargetStderr = "stderr"
	OptLogTargetFile   = "logfile"
	OptLogStdout       = "stdout"
	OptLogMultiWrite   = "stdoutfile"

	// Logging location
	OptLogLocation      = "log-location"
	OptLogLocationAlias = "o"

	// IPAM query URL.
	OptIpamQueryUrl      = "ipam-query-url"
	OptIpamQueryUrlAlias = "q"

	// IPAM query interval.
	OptIpamQueryInterval      = "ipam-query-interval"
	OptIpamQueryIntervalAlias = "i"

	// Start CNM
	OptStartAzureCNM      = "start-azure-cnm"
	OptStartAzureCNMAlias = "startcnm"

	// Interval to send reports to host
	OptReportToHostInterval      = "report-interval"
	OptReportToHostIntervalAlias = "hostinterval"

	// Periodic Interval Time
	OptIntervalTime        = "interval"
	OptIntervalTimeAlias   = "it"
	OptDefaultIntervalTime = "defaultinterval"

	// Version.
	OptVersion      = "version"
	OptVersionAlias = "v"

	// Help.
	OptHelp      = "help"
	OptHelpAlias = "h"

	// CNI binary location
	OptNetPluginPath      = "net-plugin-path"
	OptNetPluginPathAlias = "np"

	// CNI binary location
	OptNetPluginConfigFile      = "net-plugin-config-file"
	OptNetPluginConfigFileAlias = "npconfig"

	// Telemetry config Location
	OptTelemetryConfigDir      = "telemetry-config-file"
	OptTelemetryConfigDirAlias = "d"

	// Create ext Hns network
	OptCreateDefaultExtNetworkType      = "create-defaultextnetwork-type"
	OptCreateDefaultExtNetworkTypeAlias = "defaultextnetworktype"

	// Disable Telemetry
	OptTelemetry      = "telemetry"
	OptTelemetryAlias = "dt"

	// Enable CNS to program SNAT iptables rules
	OptProgramSNATIPTables = "program-snat-iptables"

	// Enable Telemetry service
	OptTelemetryService      = "telemetry-service"
	OptTelemetryServiceAlias = "ts"

	// HTTP connection timeout
	OptHttpConnectionTimeout      = "http-connection-timeout"
	OptHttpConnectionTimeoutAlias = "httpcontimeout"

	// HTTP response header timeout
	OptHttpResponseHeaderTimeout      = "http-response-header-timeout"
	OptHttpResponseHeaderTimeoutAlias = "httprespheadertimeout"

	// Enable CNS to manage endpoint state
	OptManageEndpointState = "manage-endpoint-state"

	// Store file location
	OptStoreFileLocation      = "store-file-path"
	OptStoreFileLocationAlias = "storefilepath"

	// Private Endpoint
	OptPrivateEndpoint      = "private-endpoint"
	OptPrivateEndpointAlias = "pe"

	// Infrastructure Network
	OptInfrastructureNetworkID      = "infra-vnet"
	OptInfrastructureNetworkIDAlias = "iv"

	// Node ID/Name
	OptNodeID      = "node-id"
	OptNodeIDAlias = "n"

	// Managed mode
	OptManaged      = "managed"
	OptManagedAlias = "m"

	// Client mode, cmd
	OptDebugCmd      = "debugcmd"
	OptDebugCmdAlias = "cmd"

	// Client mode, args for cmd
	OptDebugArg      = "debugarg"
	OptDebugArgAlias = "darg"

	// CNS config path
	OptCNSConfigPath      = "config-path"
	OptCNSConfigPathAlias = "cp"

	// OptCNIConflistFilepath
	OptCNIConflistFilepath = "cni-conflist-filepath"
	// OptCNIConflistFilepathAlias TODO: a "shorthand" is required for the acn args package but this isn't helpful
	OptCNIConflistFilepathAlias = "cniconflist"

	// OptCNIConflistFilepath
	OptCNIConflistScenario = "cni-conflist-scenario"
	// OptCNIConflistScenarioAlias "shorthand" for the cni conflist scenairo, see above
	OptCNIConflistScenarioAlias = "cniconflistscenario"
)

Command line options.

View Source
const (
	RegisterNodeURLFmt              = "%s/networks/%s/node/%s%s"
	SyncNodeNetworkContainersURLFmt = "%s/networks/%s/node/%s/networkcontainers%s"
	FiveSeconds                     = 5 * time.Second
	JsonContent                     = "application/json; charset=UTF-8"
	ContentType                     = "Content-Type"
)

Variables

This section is empty.

Functions

func Decode added in v1.5.29

func Decode(w http.ResponseWriter, r *http.Request, request interface{}) error

Decode receives and decodes JSON payload to a request.

func Encode added in v1.5.29

func Encode(w http.ResponseWriter, response interface{}) error

Encode encodes and sends a response as JSON payload.

func GetArg

func GetArg(name string) interface{}

GetArg returns the parsed value of the given argument.

func GetAzureCloud

func GetAzureCloud(url string) (string, error)

func GetExecutableDirectory

func GetExecutableDirectory() (string, error)

func GetHttpClient

func GetHttpClient() *http.Client

GetHttpClient returns the singleton httpClient object

func GetInterfaceSubnetWithSpecificIP

func GetInterfaceSubnetWithSpecificIP(ipAddr string) *net.IPNet

func InitHttpClient

func InitHttpClient(
	connectionTimeoutSec int,
	responseHeaderTimeoutSec int) *http.Client

InitHttpClient initializes the httpClient object

func IpToInt

func IpToInt(ip net.IP) uint32

func LogNetworkInterfaces

func LogNetworkInterfaces()

LogNetworkInterfaces logs the host's network interfaces in the default namespace.

func ParseArgs

func ParseArgs(args *ArgumentList, usage func())

ParseArgs parses and validates command line arguments based on rules in the given ArgumentList.

func PostCtx

func PostCtx(ctx context.Context, cl *http.Client, url, contentType string, body io.Reader) (*http.Response, error)

func SaveHostMetadata

func SaveHostMetadata(metadata Metadata, fileName string) error

SaveHostMetadata - save metadata got from wireserver to json file

func StartProcess

func StartProcess(path string, args []string) error

Types

type Argument

type Argument struct {
	Name         string
	Shorthand    string
	Description  string
	Type         string
	DefaultValue interface{}
	Value        interface{}
	ValueMap     map[string]interface{}
	// contains filtered or unexported fields
}

Argument represents a command line argument.

type ArgumentList

type ArgumentList []*Argument

ArgumentList represents a set of command line arguments.

type IOShim

type IOShim struct {
	Exec utilexec.Interface
}

func NewIOShim

func NewIOShim() *IOShim

func NewMockIOShim

func NewMockIOShim(calls []testutils.TestCmd) *IOShim

func (*IOShim) VerifyCalls

func (ioshim *IOShim) VerifyCalls(t *testing.T, calls []testutils.TestCmd)

VerifyCalls is used for Unit Testing with a mock ioshim. It asserts that the number of calls made is equal to the number given to the mock ioshim.

type IpamApi

type IpamApi interface{}

IPAM internal interface.

type Listener

type Listener struct {
	URL *url.URL
	// contains filtered or unexported fields
}

Listener represents an HTTP listener.

func NewListener

func NewListener(u *url.URL) (*Listener, error)

NewListener creates a new Listener.

func (*Listener) AddEndpoint

func (l *Listener) AddEndpoint(endpoint string)

AddEndpoint registers a protocol endpoint.

func (*Listener) AddHandler

func (l *Listener) AddHandler(path string, handler http.HandlerFunc)

AddHandler registers a protocol handler.

func (*Listener) GetEndpoints

func (l *Listener) GetEndpoints() []string

GetEndpoints returns the list of registered protocol endpoints.

func (*Listener) GetMux

func (l *Listener) GetMux() *http.ServeMux

GetMux returns the HTTP mux for the listener.

func (*Listener) Start

func (l *Listener) Start(errChan chan<- error) error

Start creates the listener socket and starts the HTTP server.

func (*Listener) StartTLS

func (l *Listener) StartTLS(errChan chan<- error, tlsConfig *tls.Config, address string) error

StartTLS creates the listener socket and starts the HTTPS server.

func (*Listener) Stop

func (l *Listener) Stop()

Stop stops listening for requests.

type Metadata

type Metadata struct {
	Location             string `json:"location"`
	VMName               string `json:"name"`
	Offer                string `json:"offer"`
	OsType               string `json:"osType"`
	PlacementGroupID     string `json:"placementGroupId"`
	PlatformFaultDomain  string `json:"platformFaultDomain"`
	PlatformUpdateDomain string `json:"platformUpdateDomain"`
	Publisher            string `json:"publisher"`
	ResourceGroupName    string `json:"resourceGroupName"`
	Sku                  string `json:"sku"`
	SubscriptionID       string `json:"subscriptionId"`
	Tags                 string `json:"tags"`
	OSVersion            string `json:"version"`
	VMID                 string `json:"vmId"`
	VMSize               string `json:"vmSize"`
	KernelVersion        string
}

Metadata retrieved from wireserver

func GetHostMetadata

func GetHostMetadata(fileName string) (Metadata, error)

GetHostMetadata - retrieve VM metadata from wireserver

type NamedLock

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

NamedLock holds a mutex and a map of locks. Mutex is used to get exclusive lock on the map while initializing the lock in the map.

func InitNamedLock

func InitNamedLock() *NamedLock

InitNamedLock initializes the named lock struct

func (*NamedLock) LockAcquire

func (namedLock *NamedLock) LockAcquire(lockName string)

LockAcquire acquires the lock with specified name

func (*NamedLock) LockRelease

func (namedLock *NamedLock) LockRelease(lockName string)

LockRelease releases the lock with specified name

type NetApi

type NetApi interface {
	AddExternalInterface(ifName string, subnet string) error
}

Network internal interface.

type Plugin

type Plugin struct {
	Name      string
	Version   string
	Options   map[string]interface{}
	ErrChan   chan error
	Store     store.KeyValueStore
	Stateless bool
}

Plugin is the parent class that implements behavior common to all plugins.

func NewPlugin

func NewPlugin(name, version string) (*Plugin, error)

NewPlugin creates a new Plugin object.

func (*Plugin) GetOption

func (plugin *Plugin) GetOption(key string) interface{}

GetOption gets the option value for the given key.

func (*Plugin) Initialize

func (plugin *Plugin) Initialize(config *PluginConfig) error

Initialize initializes the plugin.

func (*Plugin) SetOption

func (plugin *Plugin) SetOption(key string, value interface{})

SetOption sets the option value for the given key.

func (*Plugin) Uninitialize

func (plugin *Plugin) Uninitialize()

Uninitialize cleans up the plugin.

type PluginApi

type PluginApi interface {
	Start(*PluginConfig) error
	Stop()
	GetOption(string) interface{}
	SetOption(string, interface{})
}

Plugin base interface.

type PluginConfig

type PluginConfig struct {
	Version   string
	NetApi    NetApi  // nolint
	IpamApi   IpamApi // nolint
	Listener  *Listener
	ErrChan   chan error
	Store     store.KeyValueStore
	Stateless bool
}

Plugin common configuration.

type XmlDocument

type XmlDocument struct {
	XMLName   xml.Name `xml:"Interfaces"`
	Interface []struct {
		XMLName    xml.Name `xml:"Interface"`
		MacAddress string   `xml:"MacAddress,attr"`
		IsPrimary  bool     `xml:"IsPrimary,attr"`

		IPSubnet []struct {
			XMLName xml.Name `xml:"IPSubnet"`
			Prefix  string   `xml:"Prefix,attr"`

			IPAddress []struct {
				XMLName   xml.Name `xml:"IPAddress"`
				Address   string   `xml:"Address,attr"`
				IsPrimary bool     `xml:"IsPrimary,attr"`
			}
		}
	}
}

XmlDocument - Azure host agent XML document format.

Jump to

Keyboard shortcuts

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