-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (39 loc) · 1001 Bytes
/
main.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
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
)
func main() {
u := new(url.URL)
u.Scheme = "http"
u.Host = "mrstn-nso.cisco.com:8080"
u.User = url.UserPassword("admin", "admin")
var netClient = &http.Client{
Timeout: time.Second * 20,
}
device := "mrstn-5501-1.cisco.com"
//req, err := fullConfig(u, device")
//req, err := interfaceConfig(u, device)
//req, err := routerConfig(u, device)
//req, err := syncFrom(u, device)
//config, err := generateStatic("191.0.0.0/8", "10.87.89.1")
config, err := generateStatic("2001:425::/32", "2001:420:2cff:1204::1")
checkErr(err)
req, err := setRouterConfig(u, device, "static", config)
checkErr(err)
resp, err := netClient.Do(req)
checkErr(err)
defer resp.Body.Close()
// Read JSON data
/* data := new(Router)
err = decodeJSON(data, resp.Body)
checkErr(err)
fmt.Printf("%v\n", data)
*/
contents, err := ioutil.ReadAll(resp.Body)
checkErr(err)
fmt.Printf("%s\n", string(contents))
}