forked from hpe-storage/nimble-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
volume.go
52 lines (46 loc) · 1.46 KB
/
volume.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2020 Hewlett Packard Enterprise Development LP
package main
import (
"fmt"
"github.com/hpe-storage/nimble-golang-sdk/pkg/client/v1/nimbleos"
"github.com/hpe-storage/nimble-golang-sdk/pkg/param"
"github.com/hpe-storage/nimble-golang-sdk/pkg/service"
)
func main() {
groupService, err := service.NewNsGroupService("1.1.1.1", "xxx", "xxx", "v1", false)
if err != nil {
fmt.Printf("NewGroupService(): Unable to connect to group, err: %v", err.Error())
return
}
// set debug
groupService.SetDebug()
defer groupService.LogoutService()
// get volume service instance
volSvc := groupService.GetVolumeService()
// Initialize volume attributes
var sizeField int64 = 5120
descriptionField := "This volume was created as part of a unit test"
var limitIopsField int64 = 256
var limitMbpsField int64 = 1
// set volume attributes
newVolume := &nimbleos.Volume{
Name: param.NewString("TestDemo1"),
Size: &sizeField,
Description: &descriptionField,
ThinlyProvisioned: param.NewBool(true),
Online: param.NewBool(true),
LimitIops: &limitIopsField,
LimitMbps: &limitMbpsField,
MultiInitiator: param.NewBool(true),
AgentType: nimbleos.NsAgentTypeNone,
}
// create volume
volume, err := volSvc.CreateVolume(newVolume)
if err != nil {
fmt.Printf("Failed to create volume, err ", err)
return
}
fmt.Println(volume)
// delete volume, cleanup
volSvc.DeleteVolume(*volume.ID)
}