availabilityzones

package
Version: v0.0.0-...-ae37572 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

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

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

type Hosts map[string]Services

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.

type ZoneState

type ZoneState struct {
	// Returns true if the availability zone is available
	Available bool `json:"available"`
}

ZoneState represents the current state of the availability zone.

Directories

Path Synopsis
availabilityzones unittests
availabilityzones unittests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL