{"modulePath":"github.com/emnify/vpp-agent","version":"v1.4.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package nsplugin\n\n## Constants\n\n```go\nconst (\n\t// NewMicroservice event type\n\tNewMicroservice = \"new-ms\"\n\t// TerminatedMicroservice event type\n\tTerminatedMicroservice = \"term-ms\"\n)\n```\nMicroservice event types\n\n```go\nconst (\n\n\t// Namespace types\n\tPidRefNs          = 0\n\tMicroserviceRefNs = 1\n\tNamedNs           = 2\n\tFileRefNs         = 3\n)\n```\nNamespace-related constants\n\n## Types\n\n```go\ntype Microservice struct {\n\tLabel string\n\tPid   int\n\tId    string\n}\n```\nMicroservice is used to store PID and ID of the container running a given microservice.\n\n```go\ntype MicroserviceCtx struct {\n\t// contains filtered or unexported fields\n}\n```\nMicroserviceCtx contains all data required to handle microservice changes\n\n```go\ntype MicroserviceEvent struct {\n\t*Microservice\n\tEventType string\n}\n```\nMicroserviceEvent contains microservice object and event type\n\n```go\ntype Namespace struct {\n\tType         int32\n\tPid          uint32\n\tMicroservice string\n\tName         string\n\tFilePath     string\n}\n```\nNamespace is a generic representation of typed namespace (interface, arp, etc...)\n\n```go\nfunc (ns *Namespace) CompareNamespaces(nsToCompare *Namespace) int\n```\nCompareNamespaces is a comparison function for \"Namespace\" type.\n\n```go\nfunc (ns *Namespace) GenericNsToString() string\n```\nGenericNsToString returns a string representation of a namespace suitable for logging purposes.\n\n```go\nfunc (ns *Namespace) GenericToIfaceNs() (*intf.LinuxInterfaces_Interface_Namespace, error)\n```\nGenericToIfaceNs converts generic namespace to interface-type namespace\n\n```go\ntype NamespaceMgmtCtx struct {\n\t// contains filtered or unexported fields\n}\n```\nNamespaceMgmtCtx represents context of an ongoing management of Linux namespaces. The same context should not be used concurrently.\n\n```go\nfunc NewNamespaceMgmtCtx() *NamespaceMgmtCtx\n```\nNewNamespaceMgmtCtx creates and returns a new context for management of Linux namespaces.\n\n```go\ntype NsHandler struct {\n\tLog logging.Logger\n\t// contains filtered or unexported fields\n}\n```\nNsHandler is a plugin to handle namespaces and microservices for other linux plugins (ifplugin, l3plugin ...). It does not follow the standard concept of CRUD, but provides a set of methods other plugins can use to manage namespaces\n\n```go\nfunc (plugin *NsHandler) ArpNsToGeneric(ns *l3.LinuxStaticArpEntries_ArpEntry_Namespace) *Namespace\n```\nArpNsToGeneric converts arp-type namespace to generic type namespace. Such an object can be used to call common namespace-related methods\n\n```go\nfunc (plugin *NsHandler) Close() error\n```\nClose pre-configured namespace\n\n```go\nfunc (plugin *NsHandler) GenericToArpNs(ns *Namespace) (*l3.LinuxStaticArpEntries_ArpEntry_Namespace, error)\n```\nGenericToArpNs converts generic namespace to arp-type namespace\n\n```go\nfunc (plugin *NsHandler) GenericToRouteNs(ns *Namespace) (*l3.LinuxStaticRoutes_Route_Namespace, error)\n```\nGenericToRouteNs converts generic namespace to arp-type namespace\n\n```go\nfunc (plugin *NsHandler) GetConfigNamespace() *intf.LinuxInterfaces_Interface_Namespace\n```\nGetConfigNamespace return configuration namespace object\n\n```go\nfunc (plugin *NsHandler) HandleMicroservices(ctx *MicroserviceCtx)\n```\nHandleMicroservices handles microservice changes\n\n```go\nfunc (plugin *NsHandler) IfNsToGeneric(ns *intf.LinuxInterfaces_Interface_Namespace) *Namespace\n```\nIfNsToGeneric converts interface-type namespace to generic type namespace. Such an object can be used to call common namespace-related methods\n\n```go\nfunc (plugin *NsHandler) IfaceNsToString(namespace *intf.LinuxInterfaces_Interface_Namespace) string\n```\nIfaceNsToString returns a string representation of a namespace suitable for logging purposes.\n\n```go\nfunc (plugin *NsHandler) Init(msChan chan *MicroserviceCtx, ifNotif chan *MicroserviceEvent) error\n```\nInit namespace handler caches and create config namespace\n\n```go\nfunc (plugin *NsHandler) IsNamespaceAvailable(ns *intf.LinuxInterfaces_Interface_Namespace) bool\n```\nIsNamespaceAvailable returns true if the destination namespace is available.\n\n```go\nfunc (plugin *NsHandler) RouteNsToGeneric(ns *l3.LinuxStaticRoutes_Route_Namespace) *Namespace\n```\nRouteNsToGeneric converts route-type namespace to generic type namespace. Such an object can be used to call common namespace-related methods\n\n```go\nfunc (plugin *NsHandler) SetInterfaceNamespace(ctx *NamespaceMgmtCtx, ifName string, namespace *intf.LinuxInterfaces_Interface_Namespace,\n\tlog logging.Logger, stopwatch *measure.Stopwatch) error\n```\nSetInterfaceNamespace moves a given Linux interface into a specified namespace.\n\n```go\nfunc (plugin *NsHandler) SwitchNamespace(ns *Namespace, ctx *NamespaceMgmtCtx, log logging.Logger) (revert func(), err error)\n```\nSwitchNamespace switches the network namespace of the current thread. Caller should eventually call the returned \"revert\" function in order to get back to the original network namespace (for example using \"defer revert()\").\n\n```go\nfunc (plugin *NsHandler) SwitchToNamespace(nsMgmtCtx *NamespaceMgmtCtx, ns *intf.LinuxInterfaces_Interface_Namespace) (revert func(), err error)\n```\nswitchToNamespace switches the network namespace of the current thread.\n\n","path":"github.com/emnify/vpp-agent/plugins/linuxplugin/nsplugin","name":"nsplugin","synopsis":"","isRedistributable":true}
