GithubHelp home page GithubHelp logo

classicvalues / go-libzfs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ubuntu/go-libzfs

1.0 1.0 0.0 130 KB

go language link to libzfs C library

License: BSD 3-Clause "New" or "Revised" License

Go 75.70% C 24.30%

go-libzfs's Introduction

Introduction

go-libzfs currently implements basic manipulation of ZFS pools and data sets. Plan is to add more in further development, improve documentation with more examples, and add more tests. go-libzfs use libzfs C library and does not wrap OpenZFS CLI tools. Goal is to let easy using and manipulating OpenZFS form with in go, and tries to map libzfs C library in to go style package respecting golang common practice.

Note

This golang package is only used and tested on Linux.

  • Version tagged as v0.1 is latest used and compatible with ZFS On Linux version 0.6.5.x
  • Version tagged as v0.2 is latest used and compatible with ZFS On Linux version 0.7.x

GoDoc

Main features

  • Creating, destroying, importing and exporting pools.
  • Reading and modifying pool properties.
  • Creating, destroying and renaming of filesystem datasets and volumes.
  • Creating, destroying and rollback of snapshots.
  • Cloning datasets and volumes.
  • Reading and modifying dataset and volume properties.
  • Send and receive snapshot streams

Requirements:

  • OpenZFS on Linux and libzfs with development headers installed.
  • Developed using go1.9

Installing

go get github.com/bicomsystems/go-libzfs

Testing

# On command line shell run
cd $GOPATH/src/github.com/bicomsystems/go-libzfs
go test

Usage example

// Create map to represent ZFS dataset properties. This is equivalent to
// list of properties you can get from ZFS CLI tool, and some more
// internally used by libzfs.
props := make(map[ZFSProp]Property)

// I choose to create (block) volume 1GiB in size. Size is just ZFS dataset
// property and this is done as map of strings. So, You have to either
// specify size as base 10 number in string, or use strconv package or
// similar to convert in to string (base 10) from numeric type.
strSize := "1073741824"

props[DatasetPropVolsize] = Property{Value: strSize}
// In addition I explicitly choose some more properties to be set.
props[DatasetPropVolblocksize] = Property{Value: "4096"}
props[DatasetPropReservation] = Property{Value: strSize}

// Lets create desired volume
d, err := DatasetCreate("TESTPOOL/VOLUME1", DatasetTypeVolume, props)
if err != nil {
	println(err.Error())
	return
}
// Dataset have to be closed for memory cleanup
defer d.Close()

println("Created zfs volume TESTPOOL/VOLUME1")

Special thanks to

  • Bicom Systems for supporting this little project and that way making it possible.
  • OpenZFS as the main ZFS software collective.

go-libzfs's People

Contributors

aslmvc avatar atykhyy avatar classicvalues avatar didrocks avatar fkasumovic avatar mend-bolt-for-github[bot] avatar ncabatoff avatar prometherion avatar steigr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.