Documentation ¶
Overview ¶
Package servergroups provides the ability to manage server groups.
Example to List Server Groups
allpages, err := servergroups.List(ecsClient).AllPages() if err != nil { panic(err) } allServerGroups, err := servergroups.ExtractServerGroups(allPages) if err != nil { panic(err) } for _, sg := range allServerGroups { fmt.Printf("%#v\n", sg) }
Example to Create a Server Group
createOpts := servergroups.CreateOpts{ Name: "my_sg", Policies: []string{"anti-affinity"}, } sg, err := servergroups.Create(ecsClient, createOpts).Extract() if err != nil { panic(err) }
Example to Delete a Server Group
sgID := "7a6f29ad-e34d-4368-951a-58a08f11cfb7" err := servergroups.Delete(ecsClient, sgID).ExtractErr() if err != nil { panic(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *golangsdk.ServiceClient) pagination.Pager
List returns a Pager that allows you to iterate over a collection of ServerGroups.
Types ¶
type CreateOpts ¶
type CreateOpts struct { // Name is the name of the server group Name string `json:"name" required:"true"` // Policies are the server group policies Policies []string `json:"policies" required:"true"` }
CreateOpts specifies Server Group creation parameters.
func (CreateOpts) ToServerGroupCreateMap ¶
func (opts CreateOpts) ToServerGroupCreateMap() (map[string]interface{}, error)
ToServerGroupCreateMap constructs a request body from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult is the response from a Create operation. Call its Extract method to interpret it as a ServerGroup.
func Create ¶
func Create(client *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create requests the creation of a new Server Group.
func (CreateResult) Extract ¶
func (r CreateResult) Extract() (*ServerGroup, error)
Extract is a method that attempts to interpret any Server Group resource response as a ServerGroup struct.
type DeleteResult ¶
type DeleteResult struct {
golangsdk.ErrResult
}
DeleteResult is the response from a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.
func Delete ¶
func Delete(client *golangsdk.ServiceClient, id string) (r DeleteResult)
Delete requests the deletion of a previously allocated ServerGroup.
type FaultDomainInfo ¶
type FaultDomainInfo struct {
Names []string `json:"fault_domain_names"`
}
FaultDomainInfo represents the response of `fault_domain`
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the response from a Get operation. Call its Extract method to interpret it as a ServerGroup.
func (GetResult) Extract ¶
func (r GetResult) Extract() (*ServerGroup, error)
Extract is a method that attempts to interpret any Server Group resource response as a ServerGroup struct.
type MemberOpts ¶
type MemberOpts struct {
InstanceID string `json:"instance_uuid" required:"true"`
}
func (MemberOpts) ToServerGroupUpdateMemberMap ¶
func (opts MemberOpts) ToServerGroupUpdateMemberMap(optsType string) (map[string]interface{}, error)
type MemberOptsBuilder ¶
type MemberResult ¶
type MemberResult struct {
golangsdk.ErrResult
}
MemberResult is the response from a Member update operation. Call its ExtractErr method to determine if the call succeeded or failed.
func UpdateMember ¶
func UpdateMember(client *golangsdk.ServiceClient, opts MemberOptsBuilder, optsType, id string) (r MemberResult)
UpdateMember is used to add and delete members from Server Group. (params)optsType: The opts type is title of block in request body. Add options is "add_memebr" and remove options is "remove_member".
type ServerGroup ¶
type ServerGroup struct { // ID is the unique ID of the Server Group. ID string `json:"id"` // Name is the common name of the server group. Name string `json:"name"` // Polices are the group policies. // // Normally a single policy is applied: // // "affinity" will place all servers within the server group on the // same compute node. // // "anti-affinity" will place servers within the server group on different // compute nodes. Policies []string `json:"policies"` // Members are the members of the server group. Members []string `json:"members"` // FaultDomain is valid when policy is "fault_domain" FaultDomain FaultDomainInfo `json:"fault_domain"` // Metadata includes a list of all user-specified key-value pairs attached // to the Server Group. Metadata map[string]interface{} }
A ServerGroup creates a policy for instance placement in the cloud.
func ExtractServerGroups ¶
func ExtractServerGroups(r pagination.Page) ([]ServerGroup, error)
ExtractServerGroups interprets a page of results as a slice of ServerGroups.
type ServerGroupPage ¶
type ServerGroupPage struct {
pagination.SinglePageBase
}
ServerGroupPage stores a single page of all ServerGroups results from a List call.
func (ServerGroupPage) IsEmpty ¶
func (page ServerGroupPage) IsEmpty() (bool, error)
IsEmpty determines whether or not a ServerGroupsPage is empty.