mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-18 04:10:22 +00:00
util: add helper functions for resize of encrypted volume
such as: ResizeEncryptedVolume() and LuksResize() Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
parent
572f39d656
commit
4fa05cb3a1
@ -261,6 +261,17 @@ func OpenEncryptedVolume(ctx context.Context, devicePath, mapperFile, passphrase
|
||||
return err
|
||||
}
|
||||
|
||||
// ResizeEncryptedVolume resizes encrypted volume so that it can be used by the client.
|
||||
func ResizeEncryptedVolume(ctx context.Context, mapperFile string) error {
|
||||
DebugLog(ctx, "Resizing LUKS device %s", mapperFile)
|
||||
_, stderr, err := LuksResize(mapperFile)
|
||||
if err != nil {
|
||||
ErrorLog(ctx, "failed to resize LUKS device %s: %s", mapperFile, stderr)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// CloseEncryptedVolume closes encrypted volume so it can be detached.
|
||||
func CloseEncryptedVolume(ctx context.Context, mapperFile string) error {
|
||||
DebugLog(ctx, "Closing LUKS device %s", mapperFile)
|
||||
|
@ -43,6 +43,11 @@ func LuksOpen(devicePath, mapperFile, passphrase string) (stdout, stderr []byte,
|
||||
return execCryptsetupCommand(&passphrase, "luksOpen", devicePath, mapperFile, "-d", "/dev/stdin")
|
||||
}
|
||||
|
||||
// LuksResize resizes LUKS encrypted partition.
|
||||
func LuksResize(mapperFile string) (stdout, stderr []byte, err error) {
|
||||
return execCryptsetupCommand(nil, "resize", mapperFile)
|
||||
}
|
||||
|
||||
// LuksClose removes existing mapping.
|
||||
func LuksClose(mapperFile string) (stdout, stderr []byte, err error) {
|
||||
return execCryptsetupCommand(nil, "luksClose", mapperFile)
|
||||
|
Loading…
Reference in New Issue
Block a user