hosts

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(c *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager

List returns a Pager which allows you to iterate over a collection of dedicated hosts resources. It accepts a ListOpts struct, which allows you to filter the returned collection for greater efficiency.

Types

type AllocateOpts

type AllocateOpts struct {
	Name          string `json:"name" required:"true"`
	Az            string `json:"availability_zone" required:"true"`
	AutoPlacement string `json:"auto_placement,omitempty"`
	HostType      string `json:"host_type" required:"true"`
	Quantity      int    `json:"quantity" required:"true"`
}

AllocateOpts contains all the values needed to allocate a new DeH.

func (AllocateOpts) ToDeHAllocateMap

func (opts AllocateOpts) ToDeHAllocateMap() (map[string]interface{}, error)

ToDeHAllocateMap builds a allocate request body from AllocateOpts.

type AllocateOptsBuilder

type AllocateOptsBuilder interface {
	ToDeHAllocateMap() (map[string]interface{}, error)
}

AllocateOptsBuilder allows extensions to add additional parameters to the Allocate request.

type AllocateResult

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

AllocateResult represents the result of a allocate operation. Call its Extract method to interpret it as a host.

func Allocate

func Allocate(c *golangsdk.ServiceClient, opts AllocateOptsBuilder) (r AllocateResult)

Allocate accepts a AllocateOpts struct and uses the values to allocate a new DeH.

func (AllocateResult) Extract

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

Extract is a function that accepts a result and extracts a host.

func (AllocateResult) ExtractHost

func (r AllocateResult) ExtractHost() (*AllocatedHosts, error)

Extract is a function that accepts a result and extracts Allocated Hosts.

type AllocatedHosts

type AllocatedHosts struct {
	AllocatedHostIds []string `json:"dedicated_host_ids"`
}

AllocatedHosts is the response structure of the allocated DeH

type DeleteResult

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

func Delete

func Delete(c *golangsdk.ServiceClient, hostid string) (r DeleteResult)

Deletes the DeH using the specified hostID.

func (DeleteResult) Extract

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

Extract is a function that accepts a result and extracts a host.

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a host.

func Get

func Get(c *golangsdk.ServiceClient, id string) (r GetResult)

Get retrieves a particular host based on its unique ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts a host.

type Host

type Host struct {
	// ID is the unique identifier for the dedicated host .
	ID string `json:"dedicated_host_id"`
	// Specifies the Dedicated Host name.
	Name string `json:"name"`
	// Specifies whether to allow a VM to be placed on this available host
	// if its Dedicated Host ID is not specified during its creation.
	AutoPlacement string `json:"auto_placement"`
	// Specifies the AZ to which the Dedicated Host belongs.
	Az string `json:"availability_zone"`
	// Specifies the tenant who owns the Dedicated Host.
	TenantId string `json:"project_id"`
	// Specifies the host status.
	State string `json:"state"`
	// Specifies the number of available vCPUs for the Dedicated Host.
	AvailableVcpus int `json:"available_vcpus"`
	// 	Specifies the size of available memory for the Dedicated Host.
	AvailableMemory int `json:"available_memory"`
	// Time at which the dedicated host has been allocated.
	AllocatedAt string `json:"allocated_at"`
	// Time at which the dedicated host has been released.
	ReleasedAt string `json:"released_at"`
	// Specifies the number of the placed VMs.
	InstanceTotal int `json:"instance_total"`
	// Specifies the VMs started on the Dedicated Host.
	InstanceUuids []string `json:"instance_uuids"`
	// Specifies the property of host.
	HostProperties HostPropertiesOpts `json:"host_properties"`
}

func ExtractHosts

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

ExtractHosts accepts a Page struct, specifically a HostPage struct, and extracts the elements into a slice of hosts structs. In other words, a generic collection is mapped into a relevant slice.

type HostPage

type HostPage struct {
	pagination.LinkedPageBase
}

HostPage is the page returned by a pager when traversing over a collection of Hosts.

func (HostPage) IsEmpty

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

IsEmpty returns true if a ListResult contains no Dedicated Hosts.

func (HostPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of hosts has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type HostPropertiesOpts

type HostPropertiesOpts struct {
	// Specifies the property of host.
	HostType           string               `json:"host_type"`
	HostTypeName       string               `json:"host_type_name"`
	Vcpus              int                  `json:"vcpus"`
	Cores              int                  `json:"cores"`
	Sockets            int                  `json:"sockets"`
	Memory             int                  `json:"memory"`
	InstanceCapacities []InstanceCapacities `json:"available_instance_capacities"`
}

type InstanceCapacities

type InstanceCapacities struct {
	// Specifies the number of supported flavors.
	Flavor string `json:"flavor"`
}

type ListOpts

type ListOpts struct {
	// Specifies Dedicated Host ID.
	ID string `q:"dedicated_host_id"`
	// Specifies the Dedicated Host name.
	Name string `q:"name"`
	// Specifes the Dedicated Host type.
	HostType string `q:"host_type"`
	// Specifes the Dedicated Host name of type.
	HostTypeName string `q:"host_type_name"`
	// Specifies flavor ID.
	Flavor string `q:"flavor"`
	// Specifies the Dedicated Host status.
	// The value can be available, fault or released.
	State string `q:"state"`
	// Specifies the AZ to which the Dedicated Host belongs.
	Az string `q:"availability_zone"`
	// Specifies the number of entries displayed on each page.
	Limit string `q:"limit"`
	// 	The value is the ID of the last record on the previous page.
	Marker string `q:"marker"`
	// Filters the response by a date and time stamp when the dedicated host last changed status.
	ChangesSince string `q:"changes-since"`
	// Specifies the UUID of the tenant in a multi-tenancy cloud.
	TenantId string `q:"tenant"`
}

ListOpts allows the filtering and sorting of paginated collections through the API.

func (ListOpts) ToHostListQuery

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

ToRegionListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add parameters to the List request.

type ListServerOpts

type ListServerOpts struct {
	// Specifies the number of entries displayed on each page.
	Limit int `q:"limit"`
	// The value is the ID of the last record on the previous page.
	// If the marker value is invalid, error code 400 will be returned.
	Marker string `q:"marker"`
	// ID uniquely identifies this server amongst all other servers,
	// including those not accessible to the current tenant.
	ID string `json:"id"`
	// Name contains the human-readable name for the server.
	Name string `json:"name"`
	// Status contains the current operational status of the server,
	// such as IN_PROGRESS or ACTIVE.
	Status string `json:"status"`
	// UserID uniquely identifies the user account owning the tenant.
	UserID string `json:"user_id"`
}

ListServerOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the server attributes you want to see returned. Marker and Limit are used for pagination.

type Server

type Server struct {
	// ID uniquely identifies this server amongst all other servers,
	// including those not accessible to the current tenant.
	ID string `json:"id"`
	// TenantID identifies the tenant owning this server resource.
	TenantID string `json:"tenant_id"`
	// UserID uniquely identifies the user account owning the tenant.
	UserID string `json:"user_id"`
	// Name contains the human-readable name for the server.
	Name string `json:"name"`
	// Updated and Created contain ISO-8601 timestamps of when the state of the
	// server last changed, and when it was created.
	Updated time.Time `json:"updated"`
	Created time.Time `json:"created"`
	// Status contains the current operational status of the server,
	// such as IN_PROGRESS or ACTIVE.
	Status string `json:"status"`
	// Image refers to a JSON object, which itself indicates the OS image used to
	// deploy the server.
	Image map[string]interface{} `json:"-"`
	// Flavor refers to a JSON object, which itself indicates the hardware
	// configuration of the deployed server.
	Flavor map[string]interface{} `json:"flavor"`
	// Addresses includes a list of all IP addresses assigned to the server,
	// keyed by pool.
	Addresses map[string]interface{} `json:"addresses"`
	// Metadata includes a list of all user-specified key-value pairs attached
	// to the server.
	Metadata map[string]string `json:"metadata"`
}

Server represents a server/instance in the OpenStack cloud.

func ExtractServers

func ExtractServers(r pagination.Page) ([]Server, error)

ExtractServers accepts a Page struct, specifically a ServerPage struct, and extracts the elements into a slice of Server structs. In other words, a generic collection is mapped into a relevant slice.

func FilterServers

func FilterServers(servers []Server, opts ListServerOpts) ([]Server, error)

func ListServer

func ListServer(c *golangsdk.ServiceClient, id string, opts ListServerOpts) ([]Server, error)

ListServer returns a Pager which allows you to iterate over a collection of dedicated hosts Server resources. It accepts a ListServerOpts struct, which allows you to filter the returned collection for greater efficiency.

type ServerPage

type ServerPage struct {
	pagination.LinkedPageBase
}

func (ServerPage) IsEmpty

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

IsEmpty returns true if a page contains no Server results.

func (ServerPage) NextPageURL

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

NextPageURL uses the response's embedded link reference to navigate to the next page of results.

type UpdateOpts

type UpdateOpts struct {
	Name          string `json:"name,omitempty"`
	AutoPlacement string `json:"auto_placement,omitempty"`
}

UpdateOpts contains all the values needed to update a DeH.

func (UpdateOpts) ToDeHUpdateMap

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

ToDeHUpdateMap builds a update request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToDeHUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

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

AllocateResult represents the result of a allocate operation. Call its Extract method to interpret it as a host.

func Update

func Update(c *golangsdk.ServiceClient, hostID string, opts UpdateOptsBuilder) (r UpdateResult)

Update accepts a UpdateOpts struct and uses the values to update a DeH.The response code from api is 204

func (UpdateResult) Extract

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

Extract is a function that accepts a result and extracts a host.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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