Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakobmoellerdev/lvm2go
lvm2go implements a Go API for the lvm2 command line tools.
https://github.com/jakobmoellerdev/lvm2go
golang lvm lvm-volumes lvm2
Last synced: about 1 month ago
JSON representation
lvm2go implements a Go API for the lvm2 command line tools.
- Host: GitHub
- URL: https://github.com/jakobmoellerdev/lvm2go
- Owner: jakobmoellerdev
- License: apache-2.0
- Created: 2024-06-14T14:31:27.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-09-16T20:15:19.000Z (4 months ago)
- Last Synced: 2024-09-17T01:45:22.355Z (4 months ago)
- Topics: golang, lvm, lvm-volumes, lvm2
- Language: Go
- Homepage:
- Size: 263 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# lvm2go (Alpha)
[![Go Reference](https://pkg.go.dev/badge/github.com/jakobmoellerdev/lvm2go.svg)](https://pkg.go.dev/github.com/jakobmoellerdev/lvm2go)
[![Test](https://github.com/jakobmoellerdev/lvm2go/actions/workflows/test.yaml/badge.svg)](https://github.com/jakobmoellerdev/lvm2go/actions/workflows/test.yaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/jakobmoellerdev/lvm2go)](https://goreportcard.com/report/github.com/jakobmoellerdev/lvm2go)
[![License](https://img.shields.io/github/license/jakobmoellerdev/lvm2go)](https://github.com/jakobmoellerdev/lvm2go)Package lvm2go implements a Go API for the lvm2 command line tools.
_This project is in Alpha stage and should not be used in production installations. Not all commands have been properly implemented and tested._
The API is designed to be simple and easy to use, while still providing
access to the full functionality of the LVM2 command line tools.Compared to a simple command line wrapper, lvm2go provides a more structured
way to interact with lvm2, and allows for more complex interactions while safeguarding typing
and allowing for fine-grained control over the input of various usually problematic parameters,
such as sizes (and their conversion), validation of input parameters, and caching of data.A simple usage example is shown below:
```go
package mainimport (
"context"
"errors"
"log/slog"
"os". "github.com/jakobmoellerdev/lvm2go"
)func main() {
if os.Geteuid() != 0 {
panic("panicking because lvm2 requires root privileges for most operations.")
}
if err := run(); err != nil {
slog.Error(err.Error())
os.Exit(1)
}
}func run() (err error) {
ctx := context.Background()
lvm := NewClient()
vgName := VolumeGroupName("test")
lvName := LogicalVolumeName("test")
deviceSize := MustParseSize("1G")
lvSize := MustParseSize("100M")var losetup LoopbackDevice
if losetup, err = NewLoopbackDevice(deviceSize); err != nil {
return
}
defer func() {
err = errors.Join(err, losetup.Close())
}()if err = lvm.VGCreate(ctx, vgName, PhysicalVolumesFrom(losetup.Device())); err != nil {
return
}
defer func() {
err = errors.Join(err, lvm.VGRemove(ctx, vgName))
}()if err = lvm.LVCreate(ctx, vgName, lvName, lvSize); err != nil {
return
}
defer func() {
err = errors.Join(err, lvm.LVRemove(ctx, vgName, lvName))
}()return
}
```## Implemented commands by tested feature set
This set of commands is implemented and tested to some extent. The tested feature set is described in the table below.
| Command | State | E2E Testing | Special Use Cases |
|------------|-------|-------------|-------------------|
| lvcreate | Alpha | Basic | Thin |
| lvremove | Alpha | Basic | Thin |
| lvextend | Alpha | Basic | Extents & Sizes |
| lvchange | Alpha | Basic | (De-)Activation |
| lvrename | Alpha | Basic | |
| lvs | Alpha | Basic | |
| vgcreate | Alpha | Basic | |
| vgremove | Alpha | Basic | |
| vgextend | Alpha | Basic | |
| vgreduce | Alpha | Basic | |
| vgchange | Alpha | Basic | |
| vgrename | Alpha | Basic | |
| vgs | Alpha | Basic | |
| pvs | Alpha | Basic | |
| pvcreate | Alpha | Basic | |
| pvchange | Alpha | Basic | |
| pvremove | Alpha | Basic | |
| pvmove | Alpha | Basic | |
| lvmdevices | Alpha | Basic | |
| version | Alpha | Basic | |