-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig_pool.go
More file actions
40 lines (35 loc) · 1001 Bytes
/
Copy pathconfig_pool.go
File metadata and controls
40 lines (35 loc) · 1001 Bytes
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
package vmmanager6
import (
"fmt"
"encoding/json"
)
type ConfigPoolRanges struct {
Range string `json:"name"`
Id int `json:"id"`
}
type ConfigNewPool struct {
Name string `json:"name"`
Note string `json:"note"`
Ranges []string `json: "ipnets"`
Cluster int `json:"cluster"`
}
type ConfigPool struct {
Id string `json:"id"`
Name string `json:"name"`
Note string `json:"note"`
Ranges []ConfigPoolRanges `json:"ipnets"`
}
func (config ConfigNewPool) CreatePool(client *Client) (vmid string, err error) {
vmid, err = client.CreatePool(config)
if err != nil {
return "", fmt.Errorf("error creating Pool: %v (params: %v)", err, config)
}
return
}
func NewConfigPoolFromApi(id string, client *Client) (config *ConfigPool, err error) {
var poolConfig map[string]interface{}
poolConfig, err = client.GetPoolInfo(id)
j, err := json.Marshal(poolConfig)
err = json.Unmarshal(j, &config)
return
}