Skip to content

devans10/pugo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Pure Storage REST client for Go

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.

Table of Contents

Requirements

You should have a working Go environment setup. If not check out the Go getting started guide.

Capabilities

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.

Installation

$ go get github.com/devans10/go-purestorage/flasharray

Testing

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

Documentation

FlashArray

https://godoc.org/github.com/devans10/go-purestorage/flasharray

Client

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}

Array

Get the array status

array, _ := client.Array.Get(nil)
fmt.Printf("Array Name: %s", array.ArrayName)
fmt.Printf("ID: %s", array.Id)

Volume

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
}

About

Pure Storage REST client written in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages