This package aim to simplify interations with LVM while using Go. To do that we use lvmdbusd and the dbus package.
On ubuntu and debian you can install lvmdbusd
:
$ apt install lvm2-dbusd
Then you're ready to go and use lvmclient :
myVolumeGroup, err := lvm.GetVolumeGroup(ctx, &lvmclient.GetVolumeGroupParams{Name: "my_volume_group"})
if err != nil {
return nil, err
}
log.Printf("%+v", myVolumeGroup)
Actually the client does not support many operations but I'll add them while working with LVM :
type Client interface {
GetVolumeGroup(ctx context.Context, params *GetVolumeGroupParams) (*VolumeGroup, error)
GetVolumeGroups(ctx context.Context) ([]*VolumeGroup, error)
GetLogicalVolumes(ctx context.Context, params *GetVolumeGroupParams) ([]*LogicalVolume, error)
GetLogicalVolume(ctx context.Context, params *GetLogicalVolumeParams) (*LogicalVolume, error)
ToggleLogicalVolume(ctx context.Context, params *GetLogicalVolumeParams, state bool) (bool, error)
CreateLogicalVolume(ctx context.Context, params *CreateLogicalVolumeParams) (*LogicalVolume, error)
RemoveLogicalVolume(ctx context.Context, params *GetLogicalVolumeParams) error
}
If you found any bugs or you want to implement a missing new functions, don't hesitate to do a PR.