forked from openshift/lvm-operator
-
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.
Signed-off-by: Suleyman Akbas <[email protected]>
- Loading branch information
1 parent
d147fcb
commit 7391494
Showing
12 changed files
with
122 additions
and
24 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
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
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
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
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
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
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
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
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
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
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
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,44 @@ | ||
package wipefs | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/openshift/lvm-operator/pkg/internal/exec" | ||
) | ||
|
||
const ( | ||
wipefsCmd = "/usr/sbin/wipefs" | ||
dmsetupCmd = "/usr/sbin/dmsetup" | ||
) | ||
|
||
// Wipe wipes the device only if force delete flag is set | ||
func Wipe(exec exec.Executor, deviceName string) error { | ||
if len(deviceName) == 0 { | ||
return fmt.Errorf("failed to wipe the device. Device name is empty") | ||
} | ||
|
||
args := []string{"--all", "--force"} | ||
args = append(args, deviceName) | ||
_, err := exec.ExecuteCommandWithOutputAsHost(wipefsCmd, args...) | ||
if err != nil { | ||
return fmt.Errorf("failed to wipe the device %q. %v", deviceName, err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// RemoveMapperReference removes the device's reference from the device-mapper | ||
func RemoveMapperReference(exec exec.Executor, deviceName string) error { | ||
if len(deviceName) == 0 { | ||
return fmt.Errorf("failed to remove device-mapper reference. Device name is empty") | ||
} | ||
|
||
args := []string{"remove"} | ||
args = append(args, deviceName) | ||
_, err := exec.ExecuteCommandWithOutputAsHost(dmsetupCmd, args...) | ||
if err != nil { | ||
return fmt.Errorf("failed to remove the reference from device-mapper %q. %v", deviceName, err) | ||
} | ||
|
||
return nil | ||
} |