hosts

package
v0.0.0-...-cd80d89 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package hosts and retrieves hosts in the OpenStack masakari Service.

Example to List Hosts

createdQuery := &hosts.List{}

listOpts := hosts.ListOpts{}

allPages, err := hosts.List(client, listOpts).AllPages()
if err != nil {
	panic(err)
}

allHosts, err := hosts.ExtractHosts(allPages)
if err != nil {
	panic(err)
}

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

Example to Get a Host

host, err := hosts.Get(client, segmentID, hostID).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%v\n", host)

Example to Create a Host

createOpts := hosts.CreateOpts{
}

host, err := hosts.Create(client, createOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Println(host.Name)

Example to Delete a Secrets

err := hosts.Delete(client, segmentID, hostID).ExtractErr()
if err != nil {
	panic(err)
}

Example to Update of a Host in segment

opts := hosts.UpdateOpts{
	Key:   "foo",
	Value: "bar",
}

r, err := hosts.Update(client, segmentID, hostID, opts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%v\n", r)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List retrieves a list of hosts in segment.

Types

type CreateOpts

type CreateOpts struct {
	// Type of host.
	Type string `json:"type" required:"true"`

	// Name The host name.
	Name string `json:"name" required:"true"`

	// ControlAttributes Attributes to control host.
	ControlAttributes string `json:"control_attributes" required:"true"`

	// Reserved A boolean indicates whether this host is reserved or not, if it is not reserved, false will appear.
	Reserved bool `json:"reserved,omitempty"`

	// OnMaintenance A boolean indicates whether this host is on maintenance or not, if it is not on maintenance mode,
	// false will appear.
	OnMaintenance bool `json:"on_maintenance,omitempty"`
}

CreateOpts provides options used to add a host to segment.

func (CreateOpts) ToContainerCreateMap

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

ToContainerCreateMap formats a CreateOpts into a create request.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToContainerCreateMap() (map[string]interface{}, error)
}

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 host.

func Create

func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder, segmentID string) (r CreateResult)

Create creates a host in segment.

func (CreateResult) Extract

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

Extract interprets any commonResult as a Host.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the response from a Delete operation. Call its ExtractErr to determine if the request succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, segmentID, hostID string) (r DeleteResult)

Delete deletes a host in segment.

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 host.

func Get

func Get(client *gophercloud.ServiceClient, segmentID, hostID string) (r GetResult)

Get retrieves details of a host in segment.

func (GetResult) Extract

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

Extract interprets any commonResult as a Host.

type Host

type Host struct {
	// Name is the name of the host.
	Name string `json:"name"`

	// UUID The UUID of the host.
	UUID string `json:"uuid"`

	// FailoverSegmentID The UUID of the segment.
	FailoverSegmentID string

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

	// OnMaintenance A boolean indicates whether this host is on maintenance or not, if it is not on maintenance mode,
	// false will appear.
	OnMaintenance bool `json:"on_maintenance"`

	// Reserved A boolean indicates whether this host is reserved or not, if it is not reserved, false will appear.
	Reserved bool `json:"reserved"`

	// CreatedAt The date and time stamp when the host was created.
	CreatedAt string `json:"created_at"`

	// UpdatedAt The date and time stamp when the host was updated.
	UpdatedAt string `json:"updated_at"`

	// ControlAttributes Attributes to control host.
	ControlAttributes string `json:"control_attributes"`

	// FailoverSegment A segment object.
	FailoverSegment segments.FailoverSegment `json:"failover_segment"`

	// Type of host.
	Type string `json:"type"`

	// ID of host.
	ID int `json:"id"`
}

Host represents a host list in masakari service.

func ExtractHosts

func ExtractHosts(r pagination.Page) ([]Host, error)

ExtractHosts returns a slice of Hosts in a single page of results.

type HostsPage

type HostsPage struct {
	pagination.LinkedPageBase
}

HostsPage is a single page of container results.

func (HostsPage) IsEmpty

func (r HostsPage) IsEmpty() (bool, error)

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

func (HostsPage) NextPageURL

func (r HostsPage) NextPageURL() (string, error)

NextPageURL extracts the "next" link from the links section of the result.

type ListOpts

type ListOpts struct {
	// Limit is the amount of containers to retrieve.
	Limit int `q:"limit"`

	// Marker The ID of the last-seen item. Use the limit parameter to make an initial limited request and use the
	// ID of the last-seen item from the response as the marker parameter value in a subsequent limited request.
	Marker string `q:"marker"`

	// OnMaintenance Filter the host list result by on_maintenance.
	OnMaintenance bool `q:"on_maintenance"`

	// Reserved Filter the host list result by reserved flag.
	Reserved bool `q:"reserved"`

	// SortDir Sort direction. A valid value is asc (ascending) or desc (descending). Default is desc.
	// You can specify multiple pairs of sort key and sort direction query parameters. If you omit the sort direction in
	// a pair, the API uses the natural sorting direction of the direction of the segment sort_key attribute.
	SortDir string `q:"sort_dir"`

	// SortKey Sorts by a hosts attribute. Default attribute is created_at. You can specify multiple pairs of sort key
	// and sort direction query parameters. If you omit the sort direction in a pair, the API uses the natural sorting
	// direction of the segment sort_key attribute. The sort keys are limited to:
	// created_at, type, name, updated_at, uuid, reserved, on_maintenance
	SortKey string `q:"sort_key"`

	// Status Filter the host list result by status.
	Type bool `q:"type"`
}

ListOpts provides options to filter the List results.

func (ListOpts) ToContainerListQuery

func (opts ListOpts) ToContainerListQuery() (string, error)

ToContainerListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToContainerListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request

type UpdateOpts

type UpdateOpts struct {
	// Type Type of host.
	Type string `json:"type" required:"true"`

	// Name The host name.
	Name string `json:"name" required:"true"`

	// ControlAttributes Attributes to control host.
	ControlAttributes string `json:"control_attributes" required:"true"`

	// Reserved A boolean indicates whether this host is reserved or not, if it is not reserved, false will appear.
	Reserved bool `json:"reserved,omitempty"`

	// OnMaintenance A boolean indicates whether this host is on maintenance or not, if it is not on maintenance mode,
	// false will appear.
	OnMaintenance bool `json:"on_maintenance,omitempty"`
}

UpdateOpts provides options used to update a host to segment.

func (UpdateOpts) ToUpdateRequest

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

ToUpdateRequest formats a UpdateOpts into an update request.

type UpdateResult

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

UpdateResult is the response from a Create operation. Call its Extract method to interpret it as a host.

func Update

func Update(client *gophercloud.ServiceClient, segmentID, hostID string, opts UpdateOpts) (r UpdateResult)

Update will update a host in segment.

func (UpdateResult) Extract

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

Extract interprets any commonResult as a Host.

Jump to

Keyboard shortcuts

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