Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ func deployCmd(o *Options) (*cobra.Command, error) { //nolint: funlen
"lab owner name (only for users in clab_admins group)",
)

c.Flags().StringVar(
&o.Deploy.RestoreAll,
"restore-all",
"",
"restore all nodes that have snapshots in this directory (default: ./snapshots)",
)
// Allow flag without value to default to ./snapshots
c.Flags().Lookup("restore-all").NoOptDefVal = "./snapshots"

c.Flags().StringArrayVar(
&o.Deploy.RestoreNodeSnapshots,
"restore",
nil,
"restore specific node from snapshot file (format: node=path/to/snapshot.tar). "+
"Can be specified multiple times. Overrides --restore-all for specified nodes.",
)

return c, nil
}

Expand Down Expand Up @@ -157,7 +174,9 @@ func deployFn(cobraCmd *cobra.Command, o *Options) error {
SetReconfigure(o.Deploy.Reconfigure).
SetGraph(o.Deploy.GenerateGraph).
SetSkipPostDeploy(o.Deploy.SkipPostDeploy).
SetSkipLabDirFileACLs(o.Deploy.SkipLabDirectoryFileACLs)
SetSkipLabDirFileACLs(o.Deploy.SkipLabDirectoryFileACLs).
SetRestoreAll(o.Deploy.RestoreAll).
SetRestoreNodeSnapshots(o.Deploy.RestoreNodeSnapshots)

containers, err := c.Deploy(cobraCmd.Context(), deploymentOptions)
if err != nil {
Expand Down
16 changes: 16 additions & 0 deletions cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ func GetOptions() *Options {
SrcPort: 0,
DeletionPrefix: "vx-",
},
ToolsSnapshot: &ToolsSnapshotOptions{
OutputDir: "./snapshots",
Format: "table",
Timeout: 5 * time.Minute,
MaxConcurrent: 0,
},
Version: &VersionOptions{
Short: false,
JSON: false,
Expand Down Expand Up @@ -129,6 +135,7 @@ type Options struct {
ToolsSSHX *ToolsSSHXOptions
ToolsVeth *ToolsVethOptions
ToolsVxlan *ToolsVxlanOptions
ToolsSnapshot *ToolsSnapshotOptions
Version *VersionOptions
}

Expand Down Expand Up @@ -276,6 +283,8 @@ type DeployOptions struct {
SkipLabDirectoryFileACLs bool
ExportTemplate string
LabOwner string
RestoreAll string
RestoreNodeSnapshots []string
}

func (o *DeployOptions) toClabOptions() []clabcore.ClabOption {
Expand Down Expand Up @@ -443,6 +452,13 @@ type ToolsVxlanOptions struct {
DeletionPrefix string
}

type ToolsSnapshotOptions struct {
OutputDir string
Format string
Timeout time.Duration
MaxConcurrent int
}

type VersionOptions struct {
Short bool
JSON bool
Expand Down
1 change: 1 addition & 0 deletions cmd/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func toolsSubcommandRegisterFuncs() []func(*Options) (*cobra.Command, error) {
disableTxOffloadCmd,
gottyCmd,
netemCmd,
snapshotCmd,
sshxCmd,
vethCmd,
vxlanCmd,
Expand Down
Loading