forked from gophercloud/gophercloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
microversions.go
32 lines (26 loc) · 949 Bytes
/
microversions.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
package servergroups
import "github.com/phouverneyuff/gophercloud"
// ExtractPolicy will extract the policy attribute.
// This requires the client to be set to microversion 2.64 or later.
func ExtractPolicy(r gophercloud.Result) (string, error) {
var s struct {
Policy string `json:"policy"`
}
err := r.ExtractIntoStructPtr(&s, "server_group")
return s.Policy, err
}
// ExtractRules will extract the rules attribute.
// This requires the client to be set to microversion 2.64 or later.
func ExtractRules(r gophercloud.Result) (Rules, error) {
var s struct {
Rules Rules `json:"rules"`
}
err := r.ExtractIntoStructPtr(&s, "server_group")
return s.Rules, err
}
// Rules represents set of rules for a policy.
type Rules struct {
// MaxServerPerHost specifies how many servers can reside on a single compute host.
// It can be used only with the "anti-affinity" policy.
MaxServerPerHost int `json:"max_server_per_host,omitempty"`
}