-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cae95ef
commit f57eb60
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/hawkv6/clab-telemetry-linker/pkg/command" | ||
"github.com/hawkv6/clab-telemetry-linker/pkg/config" | ||
"github.com/hawkv6/clab-telemetry-linker/pkg/helpers" | ||
"github.com/hawkv6/clab-telemetry-linker/pkg/impairments" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var deleteCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete impairments on a containerlab interface", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err, defaultConfig := config.NewDefaultConfig() | ||
if err != nil { | ||
log.Fatalf("Error creating config: %v\n", err) | ||
} | ||
helper := helpers.NewDefaultHelper() | ||
command := command.NewDefaultSetCommand(Node, Interface, defaultConfig.GetValue(helper.GetDefaultClabNameKey())) | ||
manager := impairments.NewDefaultSetter(defaultConfig, Node, Interface, helper, command) | ||
// Delete is setting all values to 0 | ||
handleError(manager.SetDelay(0), manager, "Error setting delay") | ||
handleError(manager.SetJitter(0), manager, "Error setting jitter") | ||
handleError(manager.SetLoss(0), manager, "Error setting loss") | ||
handleError(manager.SetRate(0), manager, "Error setting rate") | ||
handleError(manager.ApplyImpairments(), manager, "Error applying impairments") | ||
handleError(manager.WriteConfig(), manager, "Error writing config") | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(deleteCmd) | ||
deleteCmd.Flags().StringVarP(&Node, "node", "n", "", "node to delete the impairments from ") | ||
deleteCmd.Flags().StringVarP(&Interface, "interface", "i", "", "interface to delete the impairments from") | ||
markRequiredFlags(deleteCmd, []string{"node", "interface"}) | ||
} |