-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdoc.go
60 lines (45 loc) · 1.24 KB
/
doc.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
53
54
55
56
57
58
59
60
/*
aoscxgo is a golang package that allows users to connect to and configure AOS-CX switches using REST API. The minimum supported firmware version is 10.09.
To login to the switch and create a client connection:
package main
import (
"log"
"github.com/aruba/aoscxgo"
)
func main() {
sw, err := aoscxgo.Connect(
&aoscxgo.Client{
Hostname: "10.0.0.1",
Username: "admin",
Password: "admin",
},
)
if (sw.Cookie == nil) || (err != nil) {
log.Printf("Failed to login to switch: %s", err)
return
}
log.Printf("Login Success")
}
This will login to the switch and create a cookie to use for authentication in further calls. This cookie is stored within the aoscxgo.Client object that will be passed into configuration modules like so:
vlan100 := aoscxgo.Vlan{
VlanId: 100,
Name: "uplink VLAN",
Description: "uplink VLAN",
AdminState: "up",
}
// if the vlan exists use
// err = vlan100.Update(sw)
err = vlan100.Create(sw)
if err != nil {
log.Printf("Error in creating VLAN 100: %s", err)
return
}
log.Printf("VLAN Create Success")
Each API resource will have the following functions (exceptions may vary):
* Create
* Update
* Get
* GetStatus
* Delete
*/
package aoscxgo