This library is designed to provide a simple interface for issuing commands to a Pure Storage Flash Array using a REST API. It communicates with the array using the golang http library, and returns the data into types defined within the library.
This is not designed to be a standalone program. It is just meant to provide functions and communication within another progrom.
You should have a working Go environment setup. If not check out the Go getting started guide.
Currently, the library contains all functionality provided by version 1.16 of the REST API for Volumes, Hosts, Host Groups, and Protection Groups. Additional functionality will be added as I get time.
Note that different versions of the REST API offer different functionality, and some operations may be unusable except on certain versions of the REST API. For example, functionality relating to FlashRecover and protection groups (pgroups) requires the use of REST API version 1.2, which is supported only by Purity versions 4.0 and later.
$ go get github.com/devans10/go-purestorage/flasharray
Run unit tests
$ make test
To Run Acceptance tests
$ make testacc
These tests require a connection to a Pure FlashArray. They will require environment variables are set for PURE_TARGET
and PURE_APITOKEN
or PURE_USERNAME
and PURE_PASSWORD
https://godoc.org/github.com/devans10/go-purestorage/flasharray
Create a client to connect to the FlashArray
import (
"fmt"
"github.com/devans10/go-purestorage/flasharray"
)
client := flasharray.Client{Target: "flasharray.example.com", Username: "pureuser", Password: "password", APIToken: nil, RestVersion: nil, UserAgent: nil, RequestKwargs: nil}
Get the array status
array, _ := client.Array.Get(nil)
fmt.Printf("Array Name: %s", array.ArrayName)
fmt.Printf("ID: %s", array.Id)
Create a new volume
volume, _ := client.Volumes.CreateVolume("testvol", 1024000000)
fmt.Printf("Name: %s, Size: %d", volume.Name, volume.Size)
Clone a volume
volume, _ = client.Volumes.CopyVolume("testclone", "testvol")
fmt.Printf("Name: %s, Source: %d", volume.Name, volume.Source)
Get a volume
volume, _ = client.Volumes.GetVolume("testclone", nil)
fmt.Printf("Name: %s, Size: %d", volume.Name, volume.Size)
Create a snapshot
snapshot, _ := client.Volumes.CreateSnapshot("testvolume", "test")
List Volumes
for _, vol := range client.Volumes.ListVolumes(nil) {
fmt.Printf("Volume Name: %s", vol.Name
}