-
Notifications
You must be signed in to change notification settings - Fork 2
/
config_vxlan.go
46 lines (38 loc) · 1.07 KB
/
config_vxlan.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
package vmmanager6
import (
"fmt"
"encoding/json"
)
type VxLANipnets struct {
Id int `json:"id"`
Name string `json:"name"`
Gateway string `json:"gateway"`
}
type ConfigNewVxLAN struct {
Name string `json:"name"`
Account int `json:"account"`
Clusters []int `json:"clusters"`
Comment string `json:"comment"`
Ips []VxLANipnets `json:"ipnets"`
}
type ConfigVxLAN struct {
Id int `json:"id"`
Name string `json:"name"`
Account ConfigAccount `json:"account"`
Comment string `json:"comment"`
Ips []VxLANipnets `json:"ipnets"`
Ippool int `json:"ippool"`
}
func (config ConfigNewVxLAN) CreateVxLAN(client *Client) (vmid string, err error) {
vmid, err = client.AccountAddVxLAN(config)
if err != nil {
return "", fmt.Errorf("error creating VxLAN: %v (params: %v)", err, config)
}
return
}
func NewConfigVxLANFromApi(id string, client *Client) (config *ConfigVxLAN, err error) {
api_config, err := client.GetVxLANInfo(id)
j, err := json.Marshal(api_config)
err = json.Unmarshal(j, &config)
return
}