client

package
v1.15.22 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// DefaultTimeout default timeout duration for CNS Client.
	DefaultTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound tests if the provided error is of type CNSClientError and then further tests if the error code is of type UnknowContainerID

func IsUnsupportedAPI

func IsUnsupportedAPI(err error) bool

IsUnsupportedAPI tests if the provided error is of type CNSClientError and then further tests if the error code is of type UnsupportedAPI

Types

type CNSClientError

type CNSClientError struct {
	Code types.ResponseCode
	Err  error
}

CNSClientError records an error and relevant code

func (*CNSClientError) Error

func (e *CNSClientError) Error() string

type Client

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

Client specifies a client to connect to Ipam Plugin.

func New

func New(baseURL string, requestTimeout time.Duration) (*Client, error)

New returns a new CNS client configured with the passed URL and timeout.

func (*Client) CreateHostNCApipaEndpoint

func (c *Client) CreateHostNCApipaEndpoint(ctx context.Context, networkContainerID string) (string, error)

CreateHostNCApipaEndpoint creates an endpoint in APIPA network for host container connectivity.

func (*Client) CreateNetworkContainer

func (c *Client) CreateNetworkContainer(ctx context.Context, cncr cns.CreateNetworkContainerRequest) error

CreateNetworkContainer will create the provided network container, or update an existing one if one already exists.

func (*Client) DeleteHostNCApipaEndpoint

func (c *Client) DeleteHostNCApipaEndpoint(ctx context.Context, networkContainerID string) error

DeleteHostNCApipaEndpoint deletes the endpoint in APIPA network created for host container connectivity.

func (*Client) DeleteNetworkContainer

func (c *Client) DeleteNetworkContainer(ctx context.Context, ncID string) error

DeleteNetworkContainer destroys the requested network container matching the provided ID.

func (*Client) GetAllNCsFromCns

func (c *Client) GetAllNCsFromCns(ctx context.Context) (cns.GetAllNetworkContainersResponse, error)

func (*Client) GetAllNetworkContainers

func (c *Client) GetAllNetworkContainers(ctx context.Context, orchestratorContext []byte) ([]cns.GetNetworkContainerResponse, error)

GetAllNetworkContainers Request to get network container configs.

func (*Client) GetEndpoint added in v1.5.17

func (c *Client) GetEndpoint(ctx context.Context, endpointID string) (*cns.GetEndpointResponse, error)

GetEndpoint calls the EndpointHandlerAPI in CNS to retrieve the state of a given EndpointID

func (*Client) GetHTTPServiceData

func (c *Client) GetHTTPServiceData(ctx context.Context) (*cns.GetHTTPServiceDataResponse, error)

GetHTTPServiceData gets all public in-memory struct details for debugging purpose

func (*Client) GetHomeAz

func (c *Client) GetHomeAz(ctx context.Context) (*cns.GetHomeAzResponse, error)

GetHomeAz gets home AZ of host

func (*Client) GetIPAddressesMatchingStates

func (c *Client) GetIPAddressesMatchingStates(ctx context.Context, stateFilter ...types.IPState) ([]cns.IPConfigurationStatus, error)

GetIPAddressesMatchingStates takes a variadic number of string parameters, to get all IP Addresses matching a number of states usage GetIPAddressesWithStates(ctx, types.Available...)

func (*Client) GetNetworkContainer

func (c *Client) GetNetworkContainer(ctx context.Context, orchestratorContext []byte) (*cns.GetNetworkContainerResponse, error)

GetNetworkContainer Request to get network container config.

func (*Client) GetPodOrchestratorContext

func (c *Client) GetPodOrchestratorContext(ctx context.Context) (map[string][]string, error)

GetPodOrchestratorContext calls GetPodIpOrchestratorContext API on CNS

func (*Client) NMAgentSupportedAPIs

func (c *Client) NMAgentSupportedAPIs(ctx context.Context) (*cns.NmAgentSupportedApisResponse, error)

NMAgentSupportedAPIs returns the supported API names from NMAgent. This can be used, for example, to detect whether the node is capable for GRE allocations.

func (*Client) NumOfCPUCores

func (c *Client) NumOfCPUCores(ctx context.Context) (*cns.NumOfCPUCoresResponse, error)

NumOfCPUCores returns the number of CPU cores available on the host that CNS is running on.

func (*Client) PostAllNetworkContainers

func (c *Client) PostAllNetworkContainers(ctx context.Context, createNcRequest cns.PostNetworkContainersRequest) error

func (*Client) PublishNetworkContainer

func (c *Client) PublishNetworkContainer(ctx context.Context, pncr cns.PublishNetworkContainerRequest) error

PublishNetworkContainer publishes the provided network container via the NMAgent resident on the node where CNS is running. This effectively proxies the publication through CNS which can be useful for avoiding throttling issues from Wireserver.

func (*Client) ReleaseIPAddress

func (c *Client) ReleaseIPAddress(ctx context.Context, ipconfig cns.IPConfigRequest) error

ReleaseIPAddress calls releaseIPAddress on CNS, ipaddress ex: (10.0.0.1)

func (*Client) ReleaseIPs

func (c *Client) ReleaseIPs(ctx context.Context, ipconfig cns.IPConfigsRequest) error

ReleaseIPs calls releaseIPs on which releases the IPs on the pod

func (*Client) RequestIPAddress

func (c *Client) RequestIPAddress(ctx context.Context, ipconfig cns.IPConfigRequest) (*cns.IPConfigResponse, error)

RequestIPAddress calls the requestIPAddress in CNS

func (*Client) RequestIPs

func (c *Client) RequestIPs(ctx context.Context, ipconfig cns.IPConfigsRequest) (*cns.IPConfigsResponse, error)

RequestIPs calls the RequestIPConfigs in CNS

func (*Client) SetOrchestratorType

func (c *Client) SetOrchestratorType(ctx context.Context, sotr cns.SetOrchestratorTypeRequest) error

SetOrchestratorType sets the orchestrator type for a given node

func (*Client) UnpublishNC

func (c *Client) UnpublishNC(ctx context.Context, uncr cns.UnpublishNetworkContainerRequest) error

UnpublishNC unpublishes the network container via the NMAgent running alongside the CNS service. This is useful to avoid throttling issues imposed by Wireserver.

func (*Client) UpdateEndpoint added in v1.5.17

func (c *Client) UpdateEndpoint(ctx context.Context, endpointID, hnsID, vethName string) (*cns.Response, error)

UpdateEndpoint calls the EndpointHandlerAPI in CNS to update the state of a given EndpointID with either HNSEndpointID or HostVethName

type ConnectionFailureErr

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

func (*ConnectionFailureErr) Error

func (e *ConnectionFailureErr) Error() string

type FailedHTTPRequest

type FailedHTTPRequest struct {
	Code int
}

FailedHTTPRequest describes an HTTP request to CNS that has returned a non-200 status code.

func (*FailedHTTPRequest) Error

func (f *FailedHTTPRequest) Error() string

Jump to

Keyboard shortcuts

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