From 53ca297153763781428d67f44250b185916f7e75 Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Thu, 30 May 2024 10:38:48 -0400 Subject: [PATCH] Drop DiskWiper and toy usage in StorageControllerAction This isn't a very useful interface/api and I intend for Wiper to be easier to use. The DiskWipe in StorageControllerAction was mostly serving as an example but we already have multiple in examples/, so we can drop this usage too. --- actions/interface.go | 6 ------ actions/storage_controller.go | 30 ------------------------------ examples/diskwipe/main.go | 27 --------------------------- 3 files changed, 63 deletions(-) delete mode 100644 examples/diskwipe/main.go diff --git a/actions/interface.go b/actions/interface.go index 84928693a..0f3736980 100644 --- a/actions/interface.go +++ b/actions/interface.go @@ -6,7 +6,6 @@ import ( "github.com/bmc-toolbox/common" "github.com/metal-toolbox/ironlib/model" "github.com/metal-toolbox/ironlib/utils" - "github.com/sirupsen/logrus" ) // DeviceManager interface is returned to the caller when calling ironlib.New() @@ -200,8 +199,3 @@ type VirtualDiskManager interface { VirtualDiskDestroyer VirtualDisks(ctx context.Context) ([]*utils.MvcliDevice, error) } - -// DiskWiper defines an interface to override disk data -type DiskWiper interface { - WipeDisk(ctx context.Context, log *logrus.Logger, logicalName string) error -} diff --git a/actions/storage_controller.go b/actions/storage_controller.go index c747d5024..9fc2146cc 100644 --- a/actions/storage_controller.go +++ b/actions/storage_controller.go @@ -76,33 +76,3 @@ func (s *StorageControllerAction) GetControllerUtility(vendorName, modelName str return nil, errors.Wrap(ErrVirtualDiskManagerUtilNotIdentified, "vendor: "+vendorName+" model: "+modelName) } - -// GetWipeUtility returns the wipe utility based on the disk wipping features -func (s *StorageControllerAction) GetWipeUtility(logicalName string) (DiskWiper, error) { - s.Logger.Tracef("%s | Detecting wipe utility", logicalName) - // TODO: use disk wipping features to return the best wipe utility, currently only one available - - return utils.NewFillZeroCmd(s.trace), nil -} - -func (s *StorageControllerAction) WipeDisk(ctx context.Context, log *logrus.Logger, logicalName string) error { - util, err := s.GetWipeUtility(logicalName) - if err != nil { - return err - } - - // Watermark disk - // Before wiping the disk, we apply watermarks to later verify successful deletion - check, err := utils.ApplyWatermarks(logicalName) - if err != nil { - return err - } - - // Wipe the disk - err = util.WipeDisk(ctx, log, logicalName) - if err != nil { - return err - } - - return check() -} diff --git a/examples/diskwipe/main.go b/examples/diskwipe/main.go deleted file mode 100644 index 44f0f735e..000000000 --- a/examples/diskwipe/main.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "context" - "time" - - "github.com/metal-toolbox/ironlib/actions" - "github.com/sirupsen/logrus" -) - -// This example invokes ironlib and wipes the disk /dev/sdZZZ with a timeout of 1 day - -func main() { - logger := logrus.New() - logger.Formatter = new(logrus.JSONFormatter) - logger.SetLevel(logrus.TraceLevel) - - sca := actions.NewStorageControllerAction(logger) - ctx, cancel := context.WithTimeout(context.Background(), 86400*time.Second) - defer cancel() - - err := sca.WipeDisk(ctx, logger, "/dev/sdZZZ") - if err != nil { - logger.Fatal(err) - } - logger.Println("Wiped successfully!") -}