-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclient_test.go
More file actions
172 lines (138 loc) · 3.28 KB
/
client_test.go
File metadata and controls
172 lines (138 loc) · 3.28 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package ontap
import (
"fmt"
"os"
"strconv"
"testing"
"time"
)
var url string
var user string
var pw string
func init() {
user = os.Getenv("NETAPP_UID")
pw = os.Getenv("NETAPP_PW")
url = os.Getenv("NETAPP_URL")
if user == "" || pw == "" || url == "" {
fmt.Println("Env must be set")
os.Exit(1)
}
}
func TestClient(t *testing.T) {
client := NewClient(url, user, pw, true, 10*time.Second)
client.Debug = false
ver, err := client.GetSystemVersion()
if err != nil {
t.Error(err)
}
if ver == "" {
t.Error("GetSystemVersion returned empty string")
}
}
func TestLun(t *testing.T) {
client := NewClient(url, user, pw, true, 10*time.Second)
client.Debug = false
_, err := client.GetLunInfo(10)
if err != nil {
t.Error(err)
}
/*
for _, re := range res {
fmt.Printf("Name: %s, Space: %t\n", re.Volume, re.IsSpaceAllocEnabled)
}
*/
}
func TestVolume(t *testing.T) {
client := NewClient(url, user, pw, true, 10*time.Second)
client.Debug = true
res, err := client.GetVolumeInfo(25)
if err != nil {
t.Error(err)
}
for _, re := range res {
fmt.Printf("Name: %s, Space: %s %s %s\n", re.Name, re.InodeTotal, re.InodeUsed, re.InodePercent)
}
}
/*
func TestFC(t *testing.T) {
client := NewClient(url, user, pw, true)
client.Debug = true
data, err := client.GetFCConfig()
if err != nil {
t.Error(err)
}
if data == nil {
t.Error(err)
}
data2, err := client.GetFCPAdapter()
if err != nil {
t.Error(err)
}
if data2 == nil {
t.Error(err)
}
fmt.Println(data2[0].StatusAdmin)
}
*/
/*
func TestPFD(t *testing.T){
client := NewClient(url, user, pw, true)
pf, err := client.GetPerfObject()
if err != nil {
t.Error(err)
}
for _, value := range pf {
if strings.Contains(value.Name, "aggr"){
fmt.Printf("%s\n%s\n\n",value.Name, value.Description)
}
}
}
*/
/*
func TestPFD(t *testing.T) {
client := NewClient(url, user, pw, true)
pf, err := client.GetPerfCounters("aggregate")
if err != nil {
t.Error(err)
}
for _, value := range pf {
fmt.Printf("%s\n%s\n%s\n\n", value.Name, value.Desc, value.Unit)
}
}
*/
func TestVolInf(t *testing.T) {
client := NewClient(url, user, pw, true, 10*time.Second)
client.Debug = false
vl, err := client.GetVolumeInfo(4)
if err != nil {
t.Error(err)
}
for _, value := range vl {
fmt.Printf("Name: %s\n", value.Name)
fmt.Printf("Aggregate: %s\n", value.Aggr)
fmt.Printf("Dedup: %s\n", value.DeduplicationPercentageSpaceSaved)
fmt.Printf("Comp: %s\n", value.CompressionPercentageSpaceSaved)
fmt.Printf("P space saved: %s\n", value.TotalPercentageSpaceSaved)
i, _ := strconv.Atoi(value.TotalSpaceSaved)
fmt.Printf("Space saved: %d GB\n", i/1024/1024/1024)
fmt.Println()
}
}
func TestAggrInf(t *testing.T) {
client := NewClient(url, user, pw, true, 10*time.Second)
client.Debug = false
vl, err := client.GetAggrInfo(4)
if err != nil {
t.Error(err)
}
for _, value := range vl {
fmt.Printf("Name: %s\n", value.Name)
fmt.Printf("P space saved: %s\n", value.SisSpaceSavedPercent)
i, _ := strconv.Atoi(value.SisSpaceSaved)
fmt.Printf("Space saved: %d GB\n", i/1024/1024/1024)
fmt.Printf("CP space saved: %s\n", value.DataCompactionSpaceSavedPercent)
j, _ := strconv.Atoi(value.DataCompactionSpaceSaved)
fmt.Printf("Compacting Space saved: %d GB\n", j/1024/1024/1024)
fmt.Println()
}
}