VOL-3504 changes to support force delete
Change-Id: I40a3018d530f966b2e3723618eedfd50e4bbd5f6
diff --git a/internal/pkg/commands/devices.go b/internal/pkg/commands/devices.go
index 2f0d8a8..d41b9ac 100644
--- a/internal/pkg/commands/devices.go
+++ b/internal/pkg/commands/devices.go
@@ -66,7 +66,8 @@
type ValueFlag string
type DeviceDelete struct {
- Args struct {
+ Force bool `long:"force" description:"Delete device forcefully"`
+ Args struct {
Ids []DeviceId `positional-arg-name:"DEVICE_ID" required:"yes"`
} `positional-args:"yes"`
}
@@ -537,15 +538,18 @@
defer conn.Close()
client := voltha.NewVolthaServiceClient(conn)
-
var lastErr error
for _, i := range options.Args.Ids {
ctx, cancel := context.WithTimeout(context.Background(), GlobalConfig.Grpc.Timeout)
defer cancel()
id := voltha.ID{Id: string(i)}
+ if options.Force {
+ _, err = client.ForceDeleteDevice(ctx, &id)
+ } else {
+ _, err = client.DeleteDevice(ctx, &id)
+ }
- _, err := client.DeleteDevice(ctx, &id)
if err != nil {
Error.Printf("Error while deleting '%s': %s\n", i, err)
lastErr = err