aggregates

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 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)
}

Example of Add Host

aggregateID := 22
opts := aggregates.AddHostOpts{
	Host: "newhost-cmp1",
}

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

Example of Remove Host

aggregateID := 22
opts := aggregates.RemoveHostOpts{
	Host: "newhost-cmp1",
}

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

Example of Create or Update Metadata

aggregateID := 22
opts := aggregates.SetMetadata{
	Metadata: map[string]string{"key": "value"},
}

aggregate, err := aggregates.SetMetadata(computeClient, aggregateID, opts).Extract()
if err != nil {
	panic(err)
}
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 ActionResult

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

func AddHost

func AddHost(client *gophercloud.ServiceClient, aggregateID int, opts AddHostOpts) (r ActionResult)

AddHost makes a request against the API to add host to a specific aggregate.

func RemoveHost

func RemoveHost(client *gophercloud.ServiceClient, aggregateID int, opts RemoveHostOpts) (r ActionResult)

RemoveHost makes a request against the API to remove host from a specific aggregate.

func SetMetadata

func SetMetadata(client *gophercloud.ServiceClient, aggregateID int, opts SetMetadataOpts) (r ActionResult)

SetMetadata makes a request against the API to set metadata to a specific aggregate.

func (ActionResult) Extract

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

type AddHostOpts

type AddHostOpts struct {
	// The name of the host.
	Host string `json:"host" required:"true"`
}

func (AddHostOpts) ToAggregatesAddHostMap

func (opts AddHostOpts) ToAggregatesAddHostMap() (map[string]interface{}, error)

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 a specific aggregate.

func (GetResult) Extract

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

type RemoveHostOpts

type RemoveHostOpts struct {
	// The name of the host.
	Host string `json:"host" required:"true"`
}

func (RemoveHostOpts) ToAggregatesRemoveHostMap

func (opts RemoveHostOpts) ToAggregatesRemoveHostMap() (map[string]interface{}, error)

type SetMetadataOpts

type SetMetadataOpts struct {
	Metadata map[string]interface{} `json:"metadata" required:"true"`
}

func (SetMetadataOpts) ToSetMetadataMap

func (opts SetMetadataOpts) ToSetMetadataMap() (map[string]interface{}, 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)

Update makes a request against the API to update a specific aggregate.

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