Skip to content

Commit

Permalink
added configuration checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Jun 17, 2023
1 parent 8f1236b commit 9579670
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/manual/kinds/srl.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ Additional configurations that containerlab adds on top of the factory config:
* enabling gNMI/JSON-RPC
* creating tls server certificate

A configuration checkpoint named `clab-initial` is generated by containerlab once default and user-provided configs are applied. The checkpoint may be used to quickly revert configuration changes made by a user to a state that was present after the node was started.

#### User defined startup config

It is possible to make SR Linux nodes boot up with a user-defined config instead of a built-in one. With a [`startup-config`](../nodes.md#startup-config) property of the node/kind a user sets the path to the local config file that will be used as a startup config.
Expand Down
26 changes: 25 additions & 1 deletion nodes/srl/srl.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,11 @@ func (s *srl) PostDeploy(ctx context.Context, params *nodes.PostDeployParams) er
return err
}

return s.addOverlayCLIConfig(ctx)
if err := s.addOverlayCLIConfig(ctx); err != nil {
return err
}

return s.generateCheckpoint(ctx)
}

func (s *srl) SaveConfig(ctx context.Context) error {
Expand Down Expand Up @@ -570,6 +574,26 @@ func (s *srl) addOverlayCLIConfig(ctx context.Context) error {
return nil
}

func (s *srl) generateCheckpoint(ctx context.Context) error {
cmd, err := exec.NewExecCmdFromString(`bash -c 'sr_cli /tools system configuration generate-checkpoint name clab-initial comment \"set by containerlab\"'`)
if err != nil {
return err
}

execResult, err := s.RunExec(ctx, cmd)
if err != nil {
return err
}

if len(execResult.GetStdErrString()) != 0 {
return fmt.Errorf("%w:%s", nodes.ErrCommandExecError, execResult.GetStdErrString())
}

log.Debugf("node %s. stdout: %s, stderr: %s", s.Cfg.ShortName, execResult.GetStdOutString(), execResult.GetStdErrString())

return nil
}

// populateHosts adds container hostnames for other nodes of a lab to SR Linux /etc/hosts file
// to mitigate the fact that srlinux uses non default netns for management and thus
// can't leverage docker DNS service.
Expand Down

0 comments on commit 9579670

Please sign in to comment.