aggregates

package
v0.0.0-...-1fd1e9e Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package aggregates manages information about the host aggregates in the OpenStack cloud.

Example of Create Aggregate

opts := aggregates.CreateOpts{
	Name:             "name",
	AvailabilityZone: "london",
}

aggregate, err := aggregates.Create(computeClient, opts).Extract()
if err != nil {
	panic(err)
}
fmt.Printf("%+v\n", aggregate)

Example of Show Aggregate Details

aggregateID := 42
aggregate, err := aggregates.Get(computeClient, aggregateID).Extract()
if err != nil {
	panic(err)
}
fmt.Printf("%+v\n", aggregate)

Example of Delete Aggregate

aggregateID := 32
err := aggregates.Delete(computeClient, aggregateID).ExtractErr()
if err != nil {
	panic(err)
}

Example of Update Aggregate

aggregateID := 42
opts := aggregates.UpdateOpts{
	Name:             "new_name",
	AvailabilityZone: "nova2",
}

aggregate, err := aggregates.Update(computeClient, aggregateID, opts).Extract()
if err != nil {
	panic(err)
}
fmt.Printf("%+v\n", aggregate)

Example of Retrieving list of all aggregates

allPages, err := aggregates.List(computeClient).AllPages()
if err != nil {
	panic(err)
}

allAggregates, err := aggregates.ExtractAggregates(allPages)
if err != nil {
	panic(err)
}

for _, aggregate := range allAggregates {
	fmt.Printf("%+v\n", aggregate)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List makes a request against the API to list aggregates.

Types

type Aggregate

type Aggregate struct {
	// The availability zone of the host aggregate.
	AvailabilityZone string `json:"availability_zone"`

	// A list of host ids in this aggregate.
	Hosts []string `json:"hosts"`

	// The ID of the host aggregate.
	ID int `json:"id"`

	// Metadata key and value pairs associate with the aggregate.
	Metadata map[string]string `json:"metadata"`

	// Name of the aggregate.
	Name string `json:"name"`

	// The date and time when the resource was created.
	CreatedAt time.Time `json:"-"`

	// The date and time when the resource was updated,
	// if the resource has not been updated, this field will show as null.
	UpdatedAt time.Time `json:"-"`

	// The date and time when the resource was deleted,
	// if the resource has not been deleted yet, this field will be null.
	DeletedAt time.Time `json:"-"`

	// A boolean indicates whether this aggregate is deleted or not,
	// if it has not been deleted, false will appear.
	Deleted bool `json:"deleted"`
}

Aggregate represents a host aggregate in the OpenStack cloud.

func ExtractAggregates

func ExtractAggregates(p pagination.Page) ([]Aggregate, error)

ExtractAggregates interprets a page of results as a slice of Aggregates.

func (*Aggregate) UnmarshalJSON

func (r *Aggregate) UnmarshalJSON(b []byte) error

UnmarshalJSON to override default

type AggregatesPage

type AggregatesPage struct {
	pagination.SinglePageBase
}

AggregatesPage represents a single page of all Aggregates from a List request.

func (AggregatesPage) IsEmpty

func (page AggregatesPage) IsEmpty() (bool, error)

IsEmpty determines whether or not a page of Aggregates contains any results.

type CreateOpts

type CreateOpts struct {
	// The name of the host aggregate.
	Name string `json:"name" required:"true"`

	// The availability zone of the host aggregate.
	// You should use a custom availability zone rather than
	// the default returned by the os-availability-zone API.
	// The availability zone must not include ‘:’ in its name.
	AvailabilityZone string `json:"availability_zone,omitempty"`
}

func (CreateOpts) ToAggregatesCreateMap

func (opts CreateOpts) ToAggregatesCreateMap() (map[string]interface{}, error)

type CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

func Create

func Create(client *gophercloud.ServiceClient, opts CreateOpts) (r CreateResult)

Create makes a request against the API to create an aggregate.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Aggregate, error)

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

func Delete

func Delete(client *gophercloud.ServiceClient, aggregateID int) (r DeleteResult)

Delete makes a request against the API to delete an aggregate.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

func Get

func Get(client *gophercloud.ServiceClient, aggregateID int) (r GetResult)

Get makes a request against the API to get details for an specific aggregate.

func (GetResult) Extract

func (r GetResult) Extract() (*Aggregate, error)

type UpdateOpts

type UpdateOpts struct {
	// The name of the host aggregate.
	Name string `json:"name,omitempty"`

	// The availability zone of the host aggregate.
	// You should use a custom availability zone rather than
	// the default returned by the os-availability-zone API.
	// The availability zone must not include ‘:’ in its name.
	AvailabilityZone string `json:"availability_zone,omitempty"`
}

func (UpdateOpts) ToAggregatesUpdateMap

func (opts UpdateOpts) ToAggregatesUpdateMap() (map[string]interface{}, error)

type UpdateResult

type UpdateResult struct {
	// contains filtered or unexported fields
}

func Update

func Update(client *gophercloud.ServiceClient, aggregateID int, opts UpdateOpts) (r UpdateResult)

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Aggregate, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL