Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/wim/master' into containerd
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Vahlenkamp committed Jun 11, 2021
2 parents 3884a9f + 7a08664 commit 9d02826
Show file tree
Hide file tree
Showing 78 changed files with 440 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
filters: |
code:
- 'clab/**'
- 'runtime/**'
- 'cmd/**'
- 'tests/**'
- '.github/workflows/cicd.yml'
Expand Down
4 changes: 4 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2020 Nokia
# Licensed under the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause

project_name: containerlab
builds:
- env:
Expand Down
4 changes: 1 addition & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
BSD 3-Clause License
Copyright (c) 2021 Nokia. All rights reserved.

Copyright (c) 2021, SRL Labs
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
4 changes: 4 additions & 0 deletions clab/ceos.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/cert.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
8 changes: 7 additions & 1 deletion clab/clab.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down Expand Up @@ -84,7 +88,9 @@ func WithGracefulShutdown(gracefulShutdown bool) ClabOption {
// NewContainerLab function defines a new container lab
func NewContainerLab(opts ...ClabOption) *CLab {
c := &CLab{
Config: new(Config),
Config: &Config{
Mgmt: new(types.MgmtNet),
},
TopoFile: new(TopoFile),
m: new(sync.RWMutex),
Nodes: make(map[string]*types.Node),
Expand Down
29 changes: 24 additions & 5 deletions clab/config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down Expand Up @@ -81,10 +85,10 @@ var srlTypes = map[string]string{

// Config defines lab configuration as it is provided in the YAML file
type Config struct {
Name string `json:"name,omitempty"`
Mgmt types.MgmtNet `json:"mgmt,omitempty"`
Topology Topology `json:"topology,omitempty"`
ConfigPath string `yaml:"config_path,omitempty"`
Name string `json:"name,omitempty"`
Mgmt *types.MgmtNet `json:"mgmt,omitempty"`
Topology Topology `json:"topology,omitempty"`
ConfigPath string `yaml:"config_path,omitempty"`
}

// Topology represents a lab topology
Expand Down Expand Up @@ -584,6 +588,10 @@ func (c *CLab) CheckTopologyDefinition(ctx context.Context) error {
if err := c.VerifyImages(ctx); err != nil {
return err
}
if err := c.VerifyImages(ctx); err != nil { // skipcq: RVV-B0005
return err
}

return nil
}

Expand Down Expand Up @@ -648,6 +656,7 @@ func (c *CLab) VerifyImages(ctx context.Context) error {
}

// VerifyContainersUniqueness ensures that nodes defined in the topology do not have names of the existing containers
// additionally it checks that the lab name is unique and no containers are currently running with the same lab name label
func (c *CLab) VerifyContainersUniqueness(ctx context.Context) error {
nctx, cancel := context.WithTimeout(ctx, c.timeout)
defer cancel()
Expand All @@ -672,6 +681,16 @@ func (c *CLab) VerifyContainersUniqueness(ctx context.Context) error {
if len(dups) != 0 {
return fmt.Errorf("containers %q already exist. Add '--reconfigure' flag to the deploy command to first remove the containers and then deploy the lab", dups)
}

// check that none of the existing containers has a label that matches
// the lab name of a currently deploying lab
// this ensures lab uniqueness
for _, cnt := range containers {
if cnt.Labels["containerlab"] == c.Config.Name {
return fmt.Errorf("the '%s' lab has already been deployed. Destroy the lab before deploying a lab with the same name", c.Config.Name)
}
}

return err
}

Expand Down Expand Up @@ -845,7 +864,7 @@ func (c *CLab) CheckResources() error {
}
freeMemG := sysMemory("free") / 1024 / 1024 / 1024
if freeMemG < 1 {
log.Warnf("it appears that container host has low memory available: ~%dGi. This might lead to runtimer errors. Consider freeing up more memory.", freeMemG)
log.Warnf("it appears that container host has low memory available: ~%dGi. This might lead to runtime errors. Consider freeing up more memory.", freeMemG)
}
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions clab/config_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/crpd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/file.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/graph.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/inventory.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/inventory_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/mysocketio.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/mysocketio_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/netlink.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/ovs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/sonic.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import "github.com/srl-labs/containerlab/types"
Expand Down
4 changes: 4 additions & 0 deletions clab/srl.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/tc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/vr-csr.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/vr-ros.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/vr-sros.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/vr-veos.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/vr-vmx.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/vr-xrv.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/vr-xrv9k.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions clab/vxlan.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package clab

import (
Expand Down
4 changes: 4 additions & 0 deletions cmd/completion.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand Down
4 changes: 4 additions & 0 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand Down
4 changes: 4 additions & 0 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand Down
4 changes: 4 additions & 0 deletions cmd/disableTxOffload.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand Down
4 changes: 4 additions & 0 deletions cmd/exec.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand Down
6 changes: 6 additions & 0 deletions cmd/generate.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand All @@ -11,6 +15,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/srl-labs/containerlab/clab"
"github.com/srl-labs/containerlab/types"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -129,6 +134,7 @@ func generateTopologyConfig(name, network, ipv4range, ipv6range string, images m
numStages := len(nodes)
config := &clab.Config{
Name: name,
Mgmt: new(types.MgmtNet),
Topology: clab.Topology{
Kinds: make(map[string]clab.NodeConfig),
Nodes: make(map[string]clab.NodeConfig),
Expand Down
4 changes: 4 additions & 0 deletions cmd/generate_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand Down
4 changes: 4 additions & 0 deletions cmd/graph.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand Down
4 changes: 4 additions & 0 deletions cmd/inspect.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand Down
4 changes: 4 additions & 0 deletions cmd/mysocketio.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package cmd

import (
Expand Down
Loading

0 comments on commit 9d02826

Please sign in to comment.