Documentation ¶
Overview ¶
Package availabilityzones provides the ability to get lists and detailed availability zone information and to extend a server result with availability zone information.
Example of Extend server result with Availability Zone Information:
type ServerWithAZ struct { servers.Server availabilityzones.ServerAvailabilityZoneExt } var allServers []ServerWithAZ allPages, err := servers.List(client, nil).AllPages() if err != nil { panic("Unable to retrieve servers: %s", err) } err = servers.ExtractServersInto(allPages, &allServers) if err != nil { panic("Unable to extract servers: %s", err) } for _, server := range allServers { fmt.Println(server.AvailabilityZone) }
Example of Get Availability Zone Information
allPages, err := availabilityzones.List(computeClient).AllPages() if err != nil { panic(err) } availabilityZoneInfo, err := availabilityzones.ExtractAvailabilityZones(allPages) if err != nil { panic(err) } for _, zoneInfo := range availabilityZoneInfo { fmt.Printf("%+v\n", zoneInfo) }
Example of Get Detailed Availability Zone Information
allPages, err := availabilityzones.ListDetail(computeClient).AllPages() if err != nil { panic(err) } availabilityZoneInfo, err := availabilityzones.ExtractAvailabilityZones(allPages) if err != nil { panic(err) } for _, zoneInfo := range availabilityZoneInfo { fmt.Printf("%+v\n", zoneInfo) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient) pagination.Pager
List will return the existing availability zones.
func ListDetail ¶
func ListDetail(client *gophercloud.ServiceClient) pagination.Pager
ListDetail will return the existing availability zones with detailed information.
Types ¶
type AvailabilityZone ¶
type AvailabilityZone struct { Hosts Hosts `json:"hosts"` // The availability zone name ZoneName string `json:"zoneName"` ZoneState ZoneState `json:"zoneState"` }
AvailabilityZone contains all the information associated with an OpenStack AvailabilityZone.
func ExtractAvailabilityZones ¶
func ExtractAvailabilityZones(r pagination.Page) ([]AvailabilityZone, error)
ExtractAvailabilityZones returns a slice of AvailabilityZones contained in a single page of results.
type AvailabilityZonePage ¶
type AvailabilityZonePage struct {
pagination.SinglePageBase
}
type Hosts ¶
Hosts is map of hosts/nodes contained in an AvailabilityZone. Each host can have multiple services.
type ServerAvailabilityZoneExt ¶
type ServerAvailabilityZoneExt struct { // AvailabilityZone is the availabilty zone the server is in. AvailabilityZone string `json:"OS-EXT-AZ:availability_zone"` }
ServerAvailabilityZoneExt is an extension to the base Server object.
type ServiceState ¶
type ServiceState struct { Active bool `json:"active"` Available bool `json:"available"` UpdatedAt time.Time `json:"-"` }
ServiceState represents the state of a service in an AvailabilityZone.
func (*ServiceState) UnmarshalJSON ¶
func (r *ServiceState) UnmarshalJSON(b []byte) error
UnmarshalJSON to override default
type Services ¶
type Services map[string]ServiceState
Services is a map of services contained in an AvailabilityZone.