GoUnity is a Go project that provides a client for managing Dell EMC Unity storage.
Under development. Please contribute and follow the guideline.
- Query instances of:
- Storage Pool
- LUN
- Snapshot
- Host
- Filesystem
- Nas Server
- NFS Share
- Create/Delete LUNs
- Create/Delete Filesystems
- Create/Delete NFS Shares
- Attach/Detach Hosts to LUNs
- Create/Attach/Detach/Copy Snapshots
go get github.com/murray-liang/gounityunity, err := gounity.NewUnity(
"UnityMgmtIP", "username", "password", true,
)
if err != nil {
panic(err)
}// List all the pools
pools, err := unity.GetPools()
// Get the pool by ID
pool, err := unity.GetPoolById("Pool_1")// Create a 3GB LUN named `lunName` on `pool`
lun, err := pool.CreateLun("lunName", 3)host, err := unity.GetHostById("Host_1")hluNum, err := host.Attach(lun)*_test.go files of this package contains lots of detailed examples.
Optional parameters are supported for forward compatibility.
fs, err := pool.CreateFilesystem(
nas, "fs-name", 3,
// `SupportedProtocol` is optional.
gounity.SupportedProtocolsOpt(gounity.FSSupportedProtocolNFS),
)HTTP requests and responses are traced with logs by enabling GOUNITY_TRACEHTTP.
- Set environment variable
GOUNITY_TRACEHTTP.$ export GOUNITY_TRACEHTTP=true - In your codes, enable
Debuglog level oflogrus.logrus.SetLevel(logrus.DebugLevel) // Your codes continue here ......
If you have any questions or find any issues, please post Github Issues.
- Create a branch from the latest
developbranch:git checkout -b <branch_name>. - Push code changes to your branch. Please make sure your changes be covered by unittest.
- Push your branch to the remote.
- Publish a pull request from your branch to
developbranch. - Merge the pull request after passing the review. Recommend using
Squash and Mergeand deleting your branch after merging.
- Fork this repo as your own one.
- Push code changes to your repo. Please make sure your changes be covered by unittest.
- Publish a pull request from your repo to
developbranch of this repo. - Wait for merging the pull request.
*_gen.go source files are generated by go generate. The templates and source files can be found under cmd/modelgen. You are not supposed to edit the *_gen.go files but the templates.
Once you modify the templates, run go generate, then all *_gen.go files update.
Test cases in integration_test.go require a real Unity. go test won't run the cases there.
The below commands would help out.
# The integration tests would fail depending on the resources on Unity.
# Modify the cases accordingly before running.
# Command to test `CreateLun` on a real Unity.
$ go test -tags=integration -v -run TestE2ECreateLun \
-args -mgmtIp='10.245.101.39' -username=admin -password=*****
# Command to run all integration tests on a real Unity.
$ go test -tags=integration -v \
-args -mgmtIp='10.245.101.39' -username=admin -password=*****