flavors

package
v0.0.0-...-2804b72 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package flavors provides information and interaction with the flavor API resource in the OpenStack Compute service.

A flavor is an available hardware configuration for a server. Each flavor has a unique combination of disk space, memory capacity and priority for CPU time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IDFromName

func IDFromName(client *gophercloud.ServiceClient, name string) (string, error)

IDFromName is a convienience function that returns a flavor's ID given its name.

func ListDetail

func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

ListDetail instructs OpenStack to provide a list of flavors. You may provide criteria by which List curtails its results for easier processing. See ListOpts for more details.

Types

type AccessType

type AccessType string

AccessType maps to OpenStack's Flavor.is_public field. Although the is_public field is boolean, the request options are ternary, which is why AccessType is a string. The following values are allowed:

PublicAccess (the default):  Returns public flavors and private flavors associated with that project.
PrivateAccess (admin only):  Returns private flavors, across all projects.
AllAccess (admin only):      Returns public and private flavors across all projects.

The AccessType arguement is optional, and if it is not supplied, OpenStack returns the PublicAccess flavors.

const (
	PublicAccess  AccessType = "true"
	PrivateAccess AccessType = "false"
	AllAccess     AccessType = "None"
)

type CreateOpts

type CreateOpts struct {
	Name string `json:"name" required:"true"`
	// memory size, in MBs
	RAM   int `json:"ram" required:"true"`
	VCPUs int `json:"vcpus" required:"true"`
	// disk size, in GBs
	Disk *int   `json:"disk" required:"true"`
	ID   string `json:"id,omitempty"`
	// non-zero, positive
	Swap       *int    `json:"swap,omitempty"`
	RxTxFactor float64 `json:"rxtx_factor,omitempty"`
	IsPublic   *bool   `json:"os-flavor-access:is_public,omitempty"`
	// ephemeral disk size, in GBs, non-zero, positive
	Ephemeral *int `json:"OS-FLV-EXT-DATA:ephemeral,omitempty"`
}

CreateOpts is passed to Create to create a flavor Source: https://github.com/openstack/nova/blob/stable/newton/nova/api/openstack/compute/schemas/flavor_manage.py#L20

func (*CreateOpts) ToFlavorCreateMap

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

ToFlavorCreateMap satisfies the CreateOptsBuilder interface

type CreateOptsBuilder

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

type CreateResult

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

func Create

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

Create a flavor

func (CreateResult) Extract

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

Extract provides access to the individual Flavor returned by the Get and Create functions.

type Flavor

type Flavor struct {
	// The Id field contains the flavor's unique identifier.
	// For example, this identifier will be useful when specifying which hardware configuration to use for a new server instance.
	ID string `json:"id"`
	// The Disk and RA< fields provide a measure of storage space offered by the flavor, in GB and MB, respectively.
	Disk int `json:"disk"`
	RAM  int `json:"ram"`
	// The Name field provides a human-readable moniker for the flavor.
	Name       string  `json:"name"`
	RxTxFactor float64 `json:"rxtx_factor"`
	// Swap indicates how much space is reserved for swap.
	// If not provided, this field will be set to 0.
	Swap int `json:"swap"`
	// VCPUs indicates how many (virtual) CPUs are available for this flavor.
	VCPUs int `json:"vcpus"`
	// IsPublic indicates whether the flavor is public.
	IsPublic bool `json:"is_public"`
}

Flavor records represent (virtual) hardware configurations for server resources in a region.

func ExtractFlavors

func ExtractFlavors(r pagination.Page) ([]Flavor, error)

ExtractFlavors provides access to the list of flavors in a page acquired from the List operation.

func (*Flavor) UnmarshalJSON

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

type FlavorPage

type FlavorPage struct {
	pagination.LinkedPageBase
}

FlavorPage contains a single page of the response from a List call.

func (FlavorPage) IsEmpty

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

IsEmpty determines if a page contains any results.

func (FlavorPage) NextPageURL

func (page FlavorPage) NextPageURL() (string, error)

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

type GetResult

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

GetResult temporarily holds the response from a Get call.

func Get

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

Get instructs OpenStack to provide details on a single flavor, identified by its ID. Use ExtractFlavor to convert its result into a Flavor.

func (GetResult) Extract

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

Extract provides access to the individual Flavor returned by the Get and Create functions.

type ListOpts

type ListOpts struct {

	// ChangesSince, if provided, instructs List to return only those things which have changed since the timestamp provided.
	ChangesSince string `q:"changes-since"`

	// MinDisk and MinRAM, if provided, elides flavors which do not meet your criteria.
	MinDisk int `q:"minDisk"`
	MinRAM  int `q:"minRam"`

	// Marker and Limit control paging.
	// Marker instructs List where to start listing from.
	Marker string `q:"marker"`

	// Limit instructs List to refrain from sending excessively large lists of flavors.
	Limit int `q:"limit"`

	// AccessType, if provided, instructs List which set of flavors to return. If IsPublic not provided,
	// flavors for the current project are returned.
	AccessType AccessType `q:"is_public"`
}

ListOpts helps control the results returned by the List() function. For example, a flavor with a minDisk field of 10 will not be returned if you specify MinDisk set to 20. Typically, software will use the last ID of the previous call to List to set the Marker for the current call.

func (ListOpts) ToFlavorListQuery

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

ToFlavorListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add additional parameters to the List request.

Directories

Path Synopsis
compute_flavors_v2
compute_flavors_v2

Jump to

Keyboard shortcuts

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