Documentation ¶
Index ¶
- Constants
- type Microservice
- type MicroserviceCtx
- type MicroserviceEvent
- type Namespace
- type NamespaceMgmtCtx
- type NsHandler
- func (plugin *NsHandler) ArpNsToGeneric(ns *l3.LinuxStaticArpEntries_ArpEntry_Namespace) *Namespace
- func (plugin *NsHandler) Close() error
- func (plugin *NsHandler) GenericToArpNs(ns *Namespace) (*l3.LinuxStaticArpEntries_ArpEntry_Namespace, error)
- func (plugin *NsHandler) GenericToRouteNs(ns *Namespace) (*l3.LinuxStaticRoutes_Route_Namespace, error)
- func (plugin *NsHandler) GetConfigNamespace() *intf.LinuxInterfaces_Interface_Namespace
- func (plugin *NsHandler) HandleMicroservices(ctx *MicroserviceCtx)
- func (plugin *NsHandler) IfNsToGeneric(ns *intf.LinuxInterfaces_Interface_Namespace) *Namespace
- func (plugin *NsHandler) IfaceNsToString(namespace *intf.LinuxInterfaces_Interface_Namespace) string
- func (plugin *NsHandler) Init(msChan chan *MicroserviceCtx, ifNotif chan *MicroserviceEvent) error
- func (plugin *NsHandler) IsNamespaceAvailable(ns *intf.LinuxInterfaces_Interface_Namespace) bool
- func (plugin *NsHandler) RouteNsToGeneric(ns *l3.LinuxStaticRoutes_Route_Namespace) *Namespace
- func (plugin *NsHandler) SetInterfaceNamespace(ctx *NamespaceMgmtCtx, ifName string, ...) error
- func (plugin *NsHandler) SwitchNamespace(ns *Namespace, ctx *NamespaceMgmtCtx, log logging.Logger) (revert func(), err error)
- func (plugin *NsHandler) SwitchToNamespace(nsMgmtCtx *NamespaceMgmtCtx, ns *intf.LinuxInterfaces_Interface_Namespace) (revert func(), err error)
Constants ¶
const ( // NewMicroservice event type NewMicroservice = "new-ms" // TerminatedMicroservice event type TerminatedMicroservice = "term-ms" )
Microservice event types
const ( // Namespace types PidRefNs = 0 MicroserviceRefNs = 1 NamedNs = 2 FileRefNs = 3 )
Namespace-related constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Microservice ¶
Microservice is used to store PID and ID of the container running a given microservice.
type MicroserviceCtx ¶
type MicroserviceCtx struct {
// contains filtered or unexported fields
}
MicroserviceCtx contains all data required to handle microservice changes
type MicroserviceEvent ¶
type MicroserviceEvent struct { *Microservice EventType string }
MicroserviceEvent contains microservice object and event type
type Namespace ¶
Namespace is a generic representation of typed namespace (interface, arp, etc...)
func (*Namespace) CompareNamespaces ¶
CompareNamespaces is a comparison function for "Namespace" type.
func (*Namespace) GenericNsToString ¶
GenericNsToString returns a string representation of a namespace suitable for logging purposes.
func (*Namespace) GenericToIfaceNs ¶
func (ns *Namespace) GenericToIfaceNs() (*intf.LinuxInterfaces_Interface_Namespace, error)
GenericToIfaceNs converts generic namespace to interface-type namespace
type NamespaceMgmtCtx ¶
type NamespaceMgmtCtx struct {
// contains filtered or unexported fields
}
NamespaceMgmtCtx represents context of an ongoing management of Linux namespaces. The same context should not be used concurrently.
func NewNamespaceMgmtCtx ¶
func NewNamespaceMgmtCtx() *NamespaceMgmtCtx
NewNamespaceMgmtCtx creates and returns a new context for management of Linux namespaces.
type NsHandler ¶
NsHandler 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
func (*NsHandler) ArpNsToGeneric ¶
func (plugin *NsHandler) ArpNsToGeneric(ns *l3.LinuxStaticArpEntries_ArpEntry_Namespace) *Namespace
ArpNsToGeneric converts arp-type namespace to generic type namespace. Such an object can be used to call common namespace-related methods
func (*NsHandler) GenericToArpNs ¶
func (plugin *NsHandler) GenericToArpNs(ns *Namespace) (*l3.LinuxStaticArpEntries_ArpEntry_Namespace, error)
GenericToArpNs converts generic namespace to arp-type namespace
func (*NsHandler) GenericToRouteNs ¶
func (plugin *NsHandler) GenericToRouteNs(ns *Namespace) (*l3.LinuxStaticRoutes_Route_Namespace, error)
GenericToRouteNs converts generic namespace to arp-type namespace
func (*NsHandler) GetConfigNamespace ¶
func (plugin *NsHandler) GetConfigNamespace() *intf.LinuxInterfaces_Interface_Namespace
GetConfigNamespace return configuration namespace object
func (*NsHandler) HandleMicroservices ¶
func (plugin *NsHandler) HandleMicroservices(ctx *MicroserviceCtx)
HandleMicroservices handles microservice changes
func (*NsHandler) IfNsToGeneric ¶
func (plugin *NsHandler) IfNsToGeneric(ns *intf.LinuxInterfaces_Interface_Namespace) *Namespace
IfNsToGeneric converts interface-type namespace to generic type namespace. Such an object can be used to call common namespace-related methods
func (*NsHandler) IfaceNsToString ¶
func (plugin *NsHandler) IfaceNsToString(namespace *intf.LinuxInterfaces_Interface_Namespace) string
IfaceNsToString returns a string representation of a namespace suitable for logging purposes.
func (*NsHandler) Init ¶
func (plugin *NsHandler) Init(msChan chan *MicroserviceCtx, ifNotif chan *MicroserviceEvent) error
Init namespace handler caches and create config namespace
func (*NsHandler) IsNamespaceAvailable ¶
func (plugin *NsHandler) IsNamespaceAvailable(ns *intf.LinuxInterfaces_Interface_Namespace) bool
IsNamespaceAvailable returns true if the destination namespace is available.
func (*NsHandler) RouteNsToGeneric ¶
func (plugin *NsHandler) RouteNsToGeneric(ns *l3.LinuxStaticRoutes_Route_Namespace) *Namespace
RouteNsToGeneric converts route-type namespace to generic type namespace. Such an object can be used to call common namespace-related methods
func (*NsHandler) SetInterfaceNamespace ¶
func (plugin *NsHandler) SetInterfaceNamespace(ctx *NamespaceMgmtCtx, ifName string, namespace *intf.LinuxInterfaces_Interface_Namespace, log logging.Logger, stopwatch *measure.Stopwatch) error
SetInterfaceNamespace moves a given Linux interface into a specified namespace.
func (*NsHandler) SwitchNamespace ¶
func (plugin *NsHandler) SwitchNamespace(ns *Namespace, ctx *NamespaceMgmtCtx, log logging.Logger) (revert func(), err error)
SwitchNamespace 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()").
func (*NsHandler) SwitchToNamespace ¶
func (plugin *NsHandler) SwitchToNamespace(nsMgmtCtx *NamespaceMgmtCtx, ns *intf.LinuxInterfaces_Interface_Namespace) (revert func(), err error)
switchToNamespace switches the network namespace of the current thread.