This library is designed to provide a simple interface for issuing commands to a Pure Storage FlashArray 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 program.
You should have a working Go environment setup. If not check out the Go getting started guide.
The FlashArray library contains all functionality provided by version 1.16 of the Purity//FA REST API.
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.
The pure1 library contains all functionality provided by version 1.0 of the Pure1 REST API.
$ go get github.com/devans10/pugo/flasharray
$ go get github.com/devans10/pugo/pure1
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
The Pure1 tests require a connection to Pure1. They will require environment variables set for PURE1_APPID
and PURE1_PRIVATEKEY
https://godoc.org/github.com/devans10/pugo/flasharray
Create a client to connect to the FlashArray
import (
"fmt"
"github.com/devans10/pugo/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
}
https://godoc.org/github.com/devans10/pugo/pure1
The Pure1 REST API authentication requires a public and private certificate. A certificate can be created using openssl:
$ openssl genrsa -aes256 -out private.pem 2048
From that cert, you can create a public cert:
$ openssl rsa -in private.pem -outform PEM -pubout -out public.pem
Next, you will need to create a API registration on the Pure1 Manage site. You will need to be an administrator to complete this.
- Login to https://pure1.purestorage.com
- Go to Administration -> API Registration
- Click "+ Register Application"
- Give your application a name, and paste the contents of the public.pem created above.
- the "Application ID" that is generated will be used to authenticate the client.
To create a client connection, the Application ID, byte slice of the private key contents and the rest version need to be passed. In the example below, I have exported the contents of the private.pem and the Application ID to envrionment variables.
Create a client to connect to Pure1
import (
"fmt"
"os"
"github.com/devans10/pugo/pure1"
)
appID := os.Getenv("PURE1_APPID")
privateKey := []byte(os.Getenv("PURE1_PRIVATEKEY"))
restVersion := ""
client := pure1.NewClient(appID, privateKey, restVersion)
Get a list of FlashArray and FlashBlade objects
array, _ := client.Array.GetArray(nil)
fmt.Println("ID: ", array.ID)
fmt.Println("Name: ", array.Name)
fmt.Println("Model: ", array.Model)
fmt.Println("OS: ", array.OS)
fmt.Println("Version: ", array.Version)
fmt.Println("AsOf: ", array.AsOf)
PuGo and its developer(s) are not affiliated with or sponsored by Pure Storage. The statements and opinions on this site are those of the developer(s) and do not necessarily represent those of Pure Storage. Pure Storage and the Pure Storage trademarks listed at https://www.purestorage.com/pure-folio/showcase.html?type=pdf&path=/content/dam/pdf/en/legal/external-trademark-list.pdf are trademarks of Pure Storage, Inc.