Documentation
¶
Overview ¶
internal/clab/converters.go
internal/clab/service.go
internal/clab/utils.go
Index ¶
- Variables
- func ContainerInterfacesToNodeInterfaceInfo(ci *clabtypes.ContainerInterfaces) models.NodeInterfaceInfo
- func ContainerToClabContainerInfo(c clabruntime.GenericContainer) models.ClabContainerInfo
- func ContainersInterfacesToInspectOutput(cis []*clabtypes.ContainerInterfaces) models.ClabInspectInterfacesOutput
- func ContainersToClabInspectOutput(containers []clabruntime.GenericContainer) models.ClabInspectOutput
- func ExecCollectionToExecResponse(ec *clabexec.ExecCollection) models.ExecResponse
- func FilterContainersByLab(containers []clabruntime.GenericContainer, labName string) []clabruntime.GenericContainer
- func FilterContainersByOwner(containers []clabruntime.GenericContainer, owner string) []clabruntime.GenericContainer
- func FindContainerByName(containers []clabruntime.GenericContainer, name string) *clabruntime.GenericContainer
- func GetContainerLabName(c *clabruntime.GenericContainer) string
- func GetContainerName(c *clabruntime.GenericContainer) string
- func GetContainerNodeName(c *clabruntime.GenericContainer) string
- func GetContainerOwner(c *clabruntime.GenericContainer) string
- func GetContainerTopoPath(c *clabruntime.GenericContainer) string
- func GroupContainersByLab(containers []clabruntime.GenericContainer) map[string][]clabruntime.GenericContainer
- func SanitizePath(relativePath string) (string, error)
- type CACreateOptions
- type CertSignOptions
- type CloneTopologySourceOptions
- type CloneTopologySourceResult
- type ContainerlabToolRunOptions
- type DeployOptions
- type DestroyOptions
- type DisableTxOffloadOptions
- type DrawioGenerateOptions
- type DrawioGenerateResult
- type ExecOptions
- type FcliRunOptions
- type GenerateTopologyOptions
- type InspectOptions
- type InterfacesOptions
- type ListOptions
- type NetemSetOptions
- type NodeLifecycleAction
- type NodeLifecycleOptions
- type RuntimeImageSummary
- type SaveOptions
- type Service
- func (s *Service) CloneTopologySource(opts CloneTopologySourceOptions) (*CloneTopologySourceResult, error)
- func (s *Service) CreateCA(ctx context.Context, opts CACreateOptions) (*clabcert.Certificate, error)
- func (s *Service) CreateVeth(ctx context.Context, opts VethCreateOptions) error
- func (s *Service) CreateVxlan(ctx context.Context, opts VxlanCreateOptions) error
- func (s *Service) DeleteVxlan(ctx context.Context, prefix string) ([]string, error)
- func (s *Service) Deploy(ctx context.Context, opts DeployOptions) ([]clabruntime.GenericContainer, error)
- func (s *Service) Destroy(ctx context.Context, opts DestroyOptions) error
- func (s *Service) DisableTxOffload(ctx context.Context, opts DisableTxOffloadOptions) error
- func (s *Service) Exec(ctx context.Context, opts ExecOptions) (*clabexec.ExecCollection, error)
- func (s *Service) GenerateDrawioFile(ctx context.Context, opts DrawioGenerateOptions) (DrawioGenerateResult, error)
- func (s *Service) GenerateTopology(ctx context.Context, opts GenerateTopologyOptions) ([]byte, error)
- func (s *Service) ListContainerInterfaces(ctx context.Context, container *clabruntime.GenericContainer) (*clabtypes.ContainerInterfaces, error)
- func (s *Service) ListContainers(ctx context.Context, opts ListOptions) ([]clabruntime.GenericContainer, error)
- func (s *Service) ListContainersInterfaces(ctx context.Context, containers []clabruntime.GenericContainer) ([]*clabtypes.ContainerInterfaces, error)
- func (s *Service) ListRuntimeImages(ctx context.Context) ([]RuntimeImageSummary, error)
- func (s *Service) PullRuntimeImage(ctx context.Context, image string) (string, error)
- func (s *Service) RemoveRuntimeImage(ctx context.Context, reference string, force bool) (string, error)
- func (s *Service) ResetNetem(ctx context.Context, containerName, iface string) error
- func (s *Service) RunContainerlabTool(ctx context.Context, opts ContainerlabToolRunOptions) (string, error)
- func (s *Service) RunFcliCommand(ctx context.Context, opts FcliRunOptions) (string, error)
- func (s *Service) RunLabLifecycleAction(ctx context.Context, opts NodeLifecycleOptions) error
- func (s *Service) RunNodeLifecycleAction(ctx context.Context, opts NodeLifecycleOptions) error
- func (s *Service) SaveConfig(ctx context.Context, opts SaveOptions) error
- func (s *Service) SetNetem(ctx context.Context, opts NetemSetOptions) error
- func (s *Service) ShowNetem(ctx context.Context, containerName string) ([]clabtypes.ImpairmentData, error)
- func (s *Service) SignCert(ctx context.Context, opts CertSignOptions) (*clabcert.Certificate, error)
- type TierDefinition
- type VethCreateOptions
- type VxlanCreateOptions
Constants ¶
This section is empty.
Variables ¶
var ErrNetemInterfaceNotFound = errors.New("netem interface not found")
Functions ¶
func ContainerInterfacesToNodeInterfaceInfo ¶ added in v0.2.0
func ContainerInterfacesToNodeInterfaceInfo(ci *clabtypes.ContainerInterfaces) models.NodeInterfaceInfo
ContainerInterfacesToNodeInterfaceInfo converts containerlab interfaces to API format.
func ContainerToClabContainerInfo ¶ added in v0.2.0
func ContainerToClabContainerInfo(c clabruntime.GenericContainer) models.ClabContainerInfo
ContainerToClabContainerInfo converts a containerlab GenericContainer to API ClabContainerInfo.
func ContainersInterfacesToInspectOutput ¶ added in v0.2.0
func ContainersInterfacesToInspectOutput(cis []*clabtypes.ContainerInterfaces) models.ClabInspectInterfacesOutput
ContainersInterfacesToInspectOutput converts a slice of container interfaces to API format.
func ContainersToClabInspectOutput ¶ added in v0.2.0
func ContainersToClabInspectOutput(containers []clabruntime.GenericContainer) models.ClabInspectOutput
ContainersToClabInspectOutput converts a slice of containers to the API inspect output format.
func ExecCollectionToExecResponse ¶ added in v0.2.0
func ExecCollectionToExecResponse(ec *clabexec.ExecCollection) models.ExecResponse
ExecCollectionToExecResponse converts containerlab exec results to API format.
func FilterContainersByLab ¶ added in v0.2.0
func FilterContainersByLab(containers []clabruntime.GenericContainer, labName string) []clabruntime.GenericContainer
FilterContainersByLab filters containers by lab name.
func FilterContainersByOwner ¶ added in v0.2.0
func FilterContainersByOwner(containers []clabruntime.GenericContainer, owner string) []clabruntime.GenericContainer
FilterContainersByOwner filters containers by owner.
func FindContainerByName ¶ added in v0.2.0
func FindContainerByName(containers []clabruntime.GenericContainer, name string) *clabruntime.GenericContainer
FindContainerByName finds a container by its name in a slice.
func GetContainerLabName ¶ added in v0.2.0
func GetContainerLabName(c *clabruntime.GenericContainer) string
GetContainerLabName extracts the lab name from a container's labels.
func GetContainerName ¶ added in v0.2.0
func GetContainerName(c *clabruntime.GenericContainer) string
GetContainerName safely extracts the container name from a GenericContainer.
func GetContainerNodeName ¶ added in v0.3.0
func GetContainerNodeName(c *clabruntime.GenericContainer) string
GetContainerNodeName extracts the topology node name from a container's labels.
func GetContainerOwner ¶ added in v0.2.0
func GetContainerOwner(c *clabruntime.GenericContainer) string
GetContainerOwner extracts the owner from a container's labels.
func GetContainerTopoPath ¶ added in v0.2.0
func GetContainerTopoPath(c *clabruntime.GenericContainer) string
GetContainerTopoPath extracts the topology path from a container's labels.
func GroupContainersByLab ¶ added in v0.2.0
func GroupContainersByLab(containers []clabruntime.GenericContainer) map[string][]clabruntime.GenericContainer
GroupContainersByLab groups containers by their lab name.
func SanitizePath ¶
SanitizePath prevents path traversal. Returns the cleaned path if valid, otherwise an error.
Types ¶
type CACreateOptions ¶ added in v0.2.0
type CACreateOptions struct {
Name string
Expiry time.Duration
CommonName string
Country string
Locality string
Organization string
OrgUnit string
KeySize int
OutputPath string
}
CACreateOptions contains options for creating a CA.
type CertSignOptions ¶ added in v0.2.0
type CertSignOptions struct {
Name string
Hosts []string
CommonName string
Country string
Locality string
Organization string
OrgUnit string
KeySize int
CACertPath string
CAKeyPath string
OutputPath string
}
CertSignOptions contains options for signing a certificate.
type CloneTopologySourceOptions ¶ added in v0.3.0
type CloneTopologySourceResult ¶ added in v0.3.0
type ContainerlabToolRunOptions ¶ added in v0.3.0
type ContainerlabToolRunOptions struct {
Args []string
}
type DeployOptions ¶ added in v0.2.0
type DeployOptions struct {
TopoPath string
Username string
Reconfigure bool
MaxWorkers uint
ExportTemplate string
NodeFilter []string
SkipPostDeploy bool
SkipLabDirACLs bool
}
DeployOptions contains options for deploying a lab.
type DestroyOptions ¶ added in v0.2.0
type DestroyOptions struct {
LabName string
TopoPath string
Username string
Graceful bool
GracefulTimeout time.Duration
Cleanup bool
KeepMgmtNet bool
NodeFilter []string
MaxWorkers uint
}
DestroyOptions contains options for destroying a lab.
type DisableTxOffloadOptions ¶ added in v0.2.0
DisableTxOffloadOptions contains options for disabling TX offload.
type DrawioGenerateOptions ¶ added in v0.3.0
type DrawioGenerateResult ¶ added in v0.3.0
type ExecOptions ¶ added in v0.2.0
type ExecOptions struct {
TopoPath string
LabName string
ContainerName string
NodeName string
Commands []string
Username string
}
ExecOptions contains options for executing commands.
type FcliRunOptions ¶ added in v0.3.0
type GenerateTopologyOptions ¶ added in v0.2.0
type GenerateTopologyOptions struct {
Name string
Tiers []TierDefinition
DefaultKind string
Images map[string]string
Licenses map[string]string
NodePrefix string
GroupPrefix string
ManagementNetwork string
IPv4Subnet string
IPv6Subnet string
}
GenerateTopologyOptions contains options for generating a topology.
type InspectOptions ¶ added in v0.2.0
InspectOptions contains options for inspecting labs.
type InterfacesOptions ¶ added in v0.2.0
InterfacesOptions contains options for listing interfaces.
type ListOptions ¶ added in v0.2.0
ListOptions contains options for listing labs/containers.
type NetemSetOptions ¶ added in v0.2.0
type NetemSetOptions struct {
ContainerName string
Interface string
Delay time.Duration
Jitter time.Duration
Loss float64
Rate uint64 // kbit/s
Corruption float64
}
NetemSetOptions contains options for setting link impairments using netem.
type NodeLifecycleAction ¶ added in v0.3.0
type NodeLifecycleAction string
const ( NodeLifecycleActionStart NodeLifecycleAction = "start" NodeLifecycleActionStop NodeLifecycleAction = "stop" NodeLifecycleActionRestart NodeLifecycleAction = "restart" NodeLifecycleActionPause NodeLifecycleAction = "pause" NodeLifecycleActionUnpause NodeLifecycleAction = "unpause" )
type NodeLifecycleOptions ¶ added in v0.3.0
type RuntimeImageSummary ¶ added in v0.3.0
type SaveOptions ¶ added in v0.2.0
SaveOptions contains options for saving lab configuration.
type Service ¶ added in v0.2.0
type Service struct{}
Service provides an interface to containerlab operations using the library directly.
func NewService ¶ added in v0.2.0
func NewService() *Service
NewService creates a new containerlab service.
func (*Service) CloneTopologySource ¶ added in v0.3.0
func (s *Service) CloneTopologySource(opts CloneTopologySourceOptions) (*CloneTopologySourceResult, error)
CloneTopologySource clones a supported topology source URL and resolves the topology file path.
func (*Service) CreateCA ¶ added in v0.2.0
func (s *Service) CreateCA(ctx context.Context, opts CACreateOptions) (*clabcert.Certificate, error)
CreateCA creates a new Certificate Authority.
func (*Service) CreateVeth ¶ added in v0.2.0
func (s *Service) CreateVeth(ctx context.Context, opts VethCreateOptions) error
CreateVeth creates a veth pair between two endpoints.
func (*Service) CreateVxlan ¶ added in v0.2.0
func (s *Service) CreateVxlan(ctx context.Context, opts VxlanCreateOptions) error
CreateVxlan creates a VxLAN tunnel.
func (*Service) DeleteVxlan ¶ added in v0.2.0
DeleteVxlan deletes VxLAN tunnels matching a prefix.
func (*Service) Deploy ¶ added in v0.2.0
func (s *Service) Deploy(ctx context.Context, opts DeployOptions) ([]clabruntime.GenericContainer, error)
Deploy deploys a lab using the containerlab library.
func (*Service) Destroy ¶ added in v0.2.0
func (s *Service) Destroy(ctx context.Context, opts DestroyOptions) error
Destroy destroys a lab using the containerlab library.
func (*Service) DisableTxOffload ¶ added in v0.2.0
func (s *Service) DisableTxOffload(ctx context.Context, opts DisableTxOffloadOptions) error
DisableTxOffload disables TX checksum offload on a container's interface.
func (*Service) Exec ¶ added in v0.2.0
func (s *Service) Exec(ctx context.Context, opts ExecOptions) (*clabexec.ExecCollection, error)
Exec executes commands on containers.
func (*Service) GenerateDrawioFile ¶ added in v0.3.0
func (s *Service) GenerateDrawioFile(ctx context.Context, opts DrawioGenerateOptions) (DrawioGenerateResult, error)
func (*Service) GenerateTopology ¶ added in v0.2.0
func (s *Service) GenerateTopology(ctx context.Context, opts GenerateTopologyOptions) ([]byte, error)
GenerateTopology generates a topology YAML.
func (*Service) ListContainerInterfaces ¶ added in v0.2.0
func (s *Service) ListContainerInterfaces(ctx context.Context, container *clabruntime.GenericContainer) (*clabtypes.ContainerInterfaces, error)
ListContainerInterfaces lists interfaces for a specific container.
func (*Service) ListContainers ¶ added in v0.2.0
func (s *Service) ListContainers(ctx context.Context, opts ListOptions) ([]clabruntime.GenericContainer, error)
ListContainers lists containers matching the given options.
func (*Service) ListContainersInterfaces ¶ added in v0.2.0
func (s *Service) ListContainersInterfaces(ctx context.Context, containers []clabruntime.GenericContainer) ([]*clabtypes.ContainerInterfaces, error)
ListContainersInterfaces lists interfaces for multiple containers.
func (*Service) ListRuntimeImages ¶ added in v0.3.0
func (s *Service) ListRuntimeImages(ctx context.Context) ([]RuntimeImageSummary, error)
func (*Service) PullRuntimeImage ¶ added in v0.3.0
func (*Service) RemoveRuntimeImage ¶ added in v0.3.0
func (*Service) ResetNetem ¶ added in v0.2.0
ResetNetem removes netem impairments from a specific interface in a container's network namespace.
func (*Service) RunContainerlabTool ¶ added in v0.3.0
func (*Service) RunFcliCommand ¶ added in v0.3.0
func (*Service) RunLabLifecycleAction ¶ added in v0.3.0
func (s *Service) RunLabLifecycleAction(ctx context.Context, opts NodeLifecycleOptions) error
func (*Service) RunNodeLifecycleAction ¶ added in v0.3.0
func (s *Service) RunNodeLifecycleAction(ctx context.Context, opts NodeLifecycleOptions) error
func (*Service) SaveConfig ¶ added in v0.2.0
func (s *Service) SaveConfig(ctx context.Context, opts SaveOptions) error
SaveConfig saves the configuration of lab nodes.
func (*Service) SetNetem ¶ added in v0.2.0
func (s *Service) SetNetem(ctx context.Context, opts NetemSetOptions) error
SetNetem applies netem impairments to a specific interface in a container's network namespace.
func (*Service) ShowNetem ¶ added in v0.2.0
func (s *Service) ShowNetem(ctx context.Context, containerName string) ([]clabtypes.ImpairmentData, error)
ShowNetem returns the current netem impairments for interfaces that have netem qdisc set.
func (*Service) SignCert ¶ added in v0.2.0
func (s *Service) SignCert(ctx context.Context, opts CertSignOptions) (*clabcert.Certificate, error)
SignCert signs a certificate with a CA.
type TierDefinition ¶ added in v0.2.0
TierDefinition defines a tier in the topology.
type VethCreateOptions ¶ added in v0.2.0
VethCreateOptions contains options for creating a veth pair.