servers

package
Version: v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2015 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package servers provides information and interaction with the server API resource in the OpenStack Compute service.

A server is a virtual machine instance in the compute system. In order for one to be provisioned, a valid flavor and image are required.

Index

Constants

View Source
const (
	SoftReboot RebootMethod = "SOFT"
	HardReboot RebootMethod = "HARD"
	OSReboot                = SoftReboot
	PowerCycle              = HardReboot
)

These constants determine how a server should be rebooted. See the Reboot() function for further details.

Variables

This section is empty.

Functions

func ExtractAddresses added in v0.3.0

func ExtractAddresses(page pagination.Page) (map[string][]Address, error)

ExtractAddresses interprets the results of a single page from a ListAddresses() call, producing a map of addresses.

func List

List makes a request against the API to list servers accessible to you.

func ListAddresses added in v0.3.0

func ListAddresses(client *gophercloud.ServiceClient, id string) pagination.Pager

ListAddresses makes a request against the API to list the servers IP addresses.

func ListAddressesByNetwork added in v0.3.0

func ListAddressesByNetwork(client *gophercloud.ServiceClient, id, network string) pagination.Pager

ListAddressesByNetwork makes a request against the API to list the servers IP addresses for the given network.

func WaitForStatus

func WaitForStatus(c *gophercloud.ServiceClient, id, status string, secs int) error

WaitForStatus will continually poll a server until it successfully transitions to a specified status. It will do this for at most the number of seconds specified.

Types

type ActionResult

type ActionResult struct {
	gophercloud.ErrResult
}

ActionResult represents the result of server action operations, like reboot

func ChangeAdminPassword

func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword string) ActionResult

ChangeAdminPassword alters the administrator or root password for a specified server.

func ConfirmResize

func ConfirmResize(client *gophercloud.ServiceClient, id string) ActionResult

ConfirmResize confirms a previous resize operation on a server. See Resize() for more details.

func Reboot

func Reboot(client *gophercloud.ServiceClient, id string, how RebootMethod) ActionResult

Reboot requests that a given server reboot. Two methods exist for rebooting a server:

HardReboot (aka PowerCycle) restarts the server instance by physically cutting power to the machine, or if a VM, terminating it at the hypervisor level. It's done. Caput. Full stop. Then, after a brief while, power is restored or the VM instance restarted.

SoftReboot (aka OSReboot) simply tells the OS to restart under its own procedures. E.g., in Linux, asking it to enter runlevel 6, or executing "sudo shutdown -r now", or by asking Windows to restart the machine.

func Resize

Resize instructs the provider to change the flavor of the server. Note that this implies rebuilding it. Unfortunately, one cannot pass rebuild parameters to the resize function. When the resize completes, the server will be in RESIZE_VERIFY state. While in this state, you can explore the use of the new server's configuration. If you like it, call ConfirmResize() to commit the resize permanently. Otherwise, call RevertResize() to restore the old configuration.

func RevertResize

func RevertResize(client *gophercloud.ServiceClient, id string) ActionResult

RevertResize cancels a previous resize operation on a server. See Resize() for more details.

type Address added in v0.3.0

type Address struct {
	Version int    `mapstructure:"version"`
	Address string `mapstructure:"addr"`
}

Address represents an IP address.

func ExtractNetworkAddresses added in v0.3.0

func ExtractNetworkAddresses(page pagination.Page) ([]Address, error)

ExtractNetworkAddresses interprets the results of a single page from a ListAddressesByNetwork() call, producing a slice of addresses.

type AddressPage added in v0.3.0

type AddressPage struct {
	pagination.SinglePageBase
}

AddressPage abstracts the raw results of making a ListAddresses() request against the API. As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the data provided through the ExtractAddresses call.

func (AddressPage) IsEmpty added in v0.3.0

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

IsEmpty returns true if an AddressPage contains no networks.

type CreateMetadatumResult

type CreateMetadatumResult struct {
	MetadatumResult
}

CreateMetadatumResult temporarily contains the response from a metadatum Create call.

func CreateMetadatum

CreateMetadatum will create or update the key-value pair with the given key for the given server ID.

type CreateOpts

type CreateOpts struct {
	// Name [required] is the name to assign to the newly launched server.
	Name string

	// ImageRef [required] is the ID or full URL to the image that contains the server's OS and initial state.
	// Optional if using the boot-from-volume extension.
	ImageRef string

	// FlavorRef [required] is the ID or full URL to the flavor that describes the server's specs.
	FlavorRef string

	// SecurityGroups [optional] lists the names of the security groups to which this server should belong.
	SecurityGroups []string

	// UserData [optional] contains configuration information or scripts to use upon launch.
	// Create will base64-encode it for you.
	UserData []byte

	// AvailabilityZone [optional] in which to launch the server.
	AvailabilityZone string

	// Networks [optional] dictates how this server will be attached to available networks.
	// By default, the server will be attached to all isolated networks for the tenant.
	Networks []Network

	// Metadata [optional] contains key-value pairs (up to 255 bytes each) to attach to the server.
	Metadata map[string]string

	// Personality [optional] includes the path and contents of a file to inject into the server at launch.
	// The maximum size of the file is 255 bytes (decoded).
	Personality []byte

	// ConfigDrive [optional] enables metadata injection through a configuration drive.
	ConfigDrive bool

	// AdminPass [optional] sets the root user password. If not set, a randomly-generated
	// password will be created and returned in the response.
	AdminPass string

	// AccessIPv4 [optional] specifies an IPv4 address for the instance.
	AccessIPv4 string

	// AccessIPv6 [optional] specifies an IPv6 address for the instance.
	AccessIPv6 string
}

CreateOpts specifies server creation parameters.

func (CreateOpts) ToServerCreateMap

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

ToServerCreateMap assembles a request body based on the contents of a CreateOpts.

type CreateOptsBuilder

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

CreateOptsBuilder describes struct types that can be accepted by the Create call. The CreateOpts struct in this package does.

type CreateResult

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

CreateResult temporarily contains the response from a Create call.

func Create

Create requests a server to be provisioned to the user in the current tenant.

func (CreateResult) Extract

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

Extract interprets any serverResult as a Server, if possible.

type DeleteMetadatumResult

type DeleteMetadatumResult struct {
	gophercloud.ErrResult
}

DeleteMetadatumResult temporarily contains the response from a metadatum Delete call.

func DeleteMetadatum

func DeleteMetadatum(client *gophercloud.ServiceClient, id, key string) DeleteMetadatumResult

DeleteMetadatum will delete the key-value pair with the given key for the given server ID.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult temporarily contains the response from a Delete call.

func Delete

func Delete(client *gophercloud.ServiceClient, id string) DeleteResult

Delete requests that a server previously provisioned be removed from your account.

type ErrArgument

type ErrArgument struct {
	Function, Argument string
	Value              interface{}
}

ErrArgument errors occur when an argument supplied to a package function fails to fall within acceptable values. For example, the Reboot() function expects the "how" parameter to be one of HardReboot or SoftReboot. These constants are (currently) strings, leading someone to wonder if they can pass other string values instead, perhaps in an effort to break the API of their provider. Reboot() returns this error in this situation.

Function identifies which function was called/which function is generating the error. Argument identifies which formal argument was responsible for producing the error. Value provides the value as it was passed into the function.

func (*ErrArgument) Error

func (e *ErrArgument) Error() string

Error yields a useful diagnostic for debugging purposes.

func (*ErrArgument) String

func (e *ErrArgument) String() string

type GetMetadataResult

type GetMetadataResult struct {
	MetadataResult
}

GetMetadataResult temporarily contains the response from a metadata Get call.

func Metadata

func Metadata(client *gophercloud.ServiceClient, id string) GetMetadataResult

Metadata requests all the metadata for the given server ID.

type GetMetadatumResult

type GetMetadatumResult struct {
	MetadatumResult
}

GetMetadatumResult temporarily contains the response from a metadatum Get call.

func Metadatum

func Metadatum(client *gophercloud.ServiceClient, id, key string) GetMetadatumResult

Metadatum requests the key-value pair with the given key for the given server ID.

type GetResult

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

GetResult temporarily contains the response from a Get call.

func Get

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

Get requests details on a single server, by ID.

func (GetResult) Extract

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

Extract interprets any serverResult as a Server, if possible.

type ListOpts

type ListOpts struct {
	// A time/date stamp for when the server last changed status.
	ChangesSince string `q:"changes-since"`

	// Name of the image in URL format.
	Image string `q:"image"`

	// Name of the flavor in URL format.
	Flavor string `q:"flavor"`

	// Name of the server as a string; can be queried with regular expressions.
	// Realize that ?name=bob returns both bob and bobb. If you need to match bob
	// only, you can use a regular expression matching the syntax of the
	// underlying database server implemented for Compute.
	Name string `q:"name"`

	// Value of the status of the server so that you can filter on "ACTIVE" for example.
	Status string `q:"status"`

	// Name of the host as a string.
	Host string `q:"host"`

	// UUID of the server at which you want to set a marker.
	Marker string `q:"marker"`

	// Integer value for the limit of values to return.
	Limit int `q:"limit"`
}

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

func (ListOpts) ToServerListQuery

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

ToServerListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type MetadataOpts

type MetadataOpts map[string]string

MetadataOpts is a map that contains key-value pairs.

func (MetadataOpts) ToMetadataResetMap

func (opts MetadataOpts) ToMetadataResetMap() (map[string]interface{}, error)

ToMetadataResetMap assembles a body for a Reset request based on the contents of a MetadataOpts.

func (MetadataOpts) ToMetadataUpdateMap

func (opts MetadataOpts) ToMetadataUpdateMap() (map[string]interface{}, error)

ToMetadataUpdateMap assembles a body for an Update request based on the contents of a MetadataOpts.

type MetadataResult

type MetadataResult struct {
	gophercloud.Result
}

MetadataResult contains the result of a call for (potentially) multiple key-value pairs.

func (MetadataResult) Extract

func (r MetadataResult) Extract() (map[string]string, error)

Extract interprets any MetadataResult as a Metadata, if possible.

type MetadatumOpts

type MetadatumOpts map[string]string

MetadatumOpts is a map of length one that contains a key-value pair.

func (MetadatumOpts) ToMetadatumCreateMap

func (opts MetadatumOpts) ToMetadatumCreateMap() (map[string]interface{}, string, error)

ToMetadatumCreateMap assembles a body for a Create request based on the contents of a MetadataumOpts.

type MetadatumOptsBuilder

type MetadatumOptsBuilder interface {
	ToMetadatumCreateMap() (map[string]interface{}, string, error)
}

MetadatumOptsBuilder allows extensions to add additional parameters to the Create request.

type MetadatumResult

type MetadatumResult struct {
	gophercloud.Result
}

MetadatumResult contains the result of a call for individual a single key-value pair.

func (MetadatumResult) Extract

func (r MetadatumResult) Extract() (map[string]string, error)

Extract interprets any MetadatumResult as a Metadatum, if possible.

type Network

type Network struct {
	// UUID of a nova-network to attach to the newly provisioned server.
	// Required unless Port is provided.
	UUID string

	// Port of a neutron network to attach to the newly provisioned server.
	// Required unless UUID is provided.
	Port string

	// FixedIP [optional] specifies a fixed IPv4 address to be used on this network.
	FixedIP string
}

Network is used within CreateOpts to control a new server's network attachments.

type NetworkAddressPage added in v0.3.0

type NetworkAddressPage struct {
	pagination.SinglePageBase
}

NetworkAddressPage abstracts the raw results of making a ListAddressesByNetwork() request against the API. As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the data provided through the ExtractAddresses call.

func (NetworkAddressPage) IsEmpty added in v0.3.0

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

IsEmpty returns true if a NetworkAddressPage contains no addresses.

type RebootMethod

type RebootMethod string

RebootMethod describes the mechanisms by which a server reboot can be requested.

type RebuildOpts

type RebuildOpts struct {
	// Required. The ID of the image you want your server to be provisioned on
	ImageID string

	// Name to set the server to
	Name string

	// Required. The server's admin password
	AdminPass string

	// AccessIPv4 [optional] provides a new IPv4 address for the instance.
	AccessIPv4 string

	// AccessIPv6 [optional] provides a new IPv6 address for the instance.
	AccessIPv6 string

	// Metadata [optional] contains key-value pairs (up to 255 bytes each) to attach to the server.
	Metadata map[string]string

	// Personality [optional] includes the path and contents of a file to inject into the server at launch.
	// The maximum size of the file is 255 bytes (decoded).
	Personality []byte
}

RebuildOpts represents the configuration options used in a server rebuild operation

func (RebuildOpts) ToServerRebuildMap

func (opts RebuildOpts) ToServerRebuildMap() (map[string]interface{}, error)

ToServerRebuildMap formats a RebuildOpts struct into a map for use in JSON

type RebuildOptsBuilder

type RebuildOptsBuilder interface {
	ToServerRebuildMap() (map[string]interface{}, error)
}

RebuildOptsBuilder is an interface that allows extensions to override the default behaviour of rebuild options

type RebuildResult

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

RebuildResult temporarily contains the response from a Rebuild call.

func Rebuild

Rebuild will reprovision the server according to the configuration options provided in the RebuildOpts struct.

func (RebuildResult) Extract

func (r RebuildResult) Extract() (*Server, error)

Extract interprets any serverResult as a Server, if possible.

type RescueOpts

type RescueOpts struct {
	// AdminPass is the desired administrative password for the instance in
	// RESCUE mode. If it's left blank, the server will generate a password.
	AdminPass string
}

RescueOpts represents the configuration options used to control a Rescue option.

func (RescueOpts) ToServerRescueMap

func (opts RescueOpts) ToServerRescueMap() (map[string]interface{}, error)

ToServerRescueMap formats a RescueOpts as a map that can be used as a JSON request body for the Rescue request.

type RescueOptsBuilder

type RescueOptsBuilder interface {
	ToServerRescueMap() (map[string]interface{}, error)
}

RescueOptsBuilder is an interface that allows extensions to override the default structure of a Rescue request.

type RescueResult

type RescueResult struct {
	ActionResult
}

RescueResult represents the result of a server rescue operation

func Rescue

Rescue instructs the provider to place the server into RESCUE mode.

func (RescueResult) Extract

func (r RescueResult) Extract() (string, error)

Extract interprets any RescueResult as an AdminPass, if possible.

type ResetMetadataOptsBuilder

type ResetMetadataOptsBuilder interface {
	ToMetadataResetMap() (map[string]interface{}, error)
}

ResetMetadataOptsBuilder allows extensions to add additional parameters to the Reset request.

type ResetMetadataResult

type ResetMetadataResult struct {
	MetadataResult
}

ResetMetadataResult temporarily contains the response from a metadata Reset call.

func ResetMetadata

ResetMetadata will create multiple new key-value pairs for the given server ID. Note: Using this operation will erase any already-existing metadata and create the new metadata provided. To keep any already-existing metadata, use the UpdateMetadatas or UpdateMetadata function.

type ResizeOpts

type ResizeOpts struct {
	// FlavorRef is the ID of the flavor you wish your server to become.
	FlavorRef string
}

ResizeOpts represents the configuration options used to control a Resize operation.

func (ResizeOpts) ToServerResizeMap

func (opts ResizeOpts) ToServerResizeMap() (map[string]interface{}, error)

ToServerResizeMap formats a ResizeOpts as a map that can be used as a JSON request body for the Resize request.

type ResizeOptsBuilder

type ResizeOptsBuilder interface {
	ToServerResizeMap() (map[string]interface{}, error)
}

ResizeOptsBuilder is an interface that allows extensions to override the default structure of a Resize request.

type Server

type Server struct {
	// ID uniquely identifies this server amongst all other servers, including those not accessible to the current tenant.
	ID string

	// TenantID identifies the tenant owning this server resource.
	TenantID string `mapstructure:"tenant_id"`

	// UserID uniquely identifies the user account owning the tenant.
	UserID string `mapstructure:"user_id"`

	// Name contains the human-readable name for the server.
	Name string

	// Updated and Created contain ISO-8601 timestamps of when the state of the server last changed, and when it was created.
	Updated string
	Created string

	HostID string

	// Status contains the current operational status of the server, such as IN_PROGRESS or ACTIVE.
	Status string

	// Progress ranges from 0..100.
	// A request made against the server completes only once Progress reaches 100.
	Progress int

	// AccessIPv4 and AccessIPv6 contain the IP addresses of the server, suitable for remote access for administration.
	AccessIPv4, AccessIPv6 string

	// Image refers to a JSON object, which itself indicates the OS image used to deploy the server.
	Image map[string]interface{}

	// Flavor refers to a JSON object, which itself indicates the hardware configuration of the deployed server.
	Flavor map[string]interface{}

	// Addresses includes a list of all IP addresses assigned to the server, keyed by pool.
	Addresses map[string]interface{}

	// Metadata includes a list of all user-specified key-value pairs attached to the server.
	Metadata map[string]interface{}

	// Links includes HTTP references to the itself, useful for passing along to other APIs that might want a server reference.
	Links []interface{}

	// KeyName indicates which public key was injected into the server on launch.
	KeyName string `json:"key_name" mapstructure:"key_name"`

	// AdminPass will generally be empty ("").  However, it will contain the administrative password chosen when provisioning a new server without a set AdminPass setting in the first place.
	// Note that this is the ONLY time this field will be valid.
	AdminPass string `json:"adminPass" mapstructure:"adminPass"`

	// SecurityGroups includes the security groups that this instance has applied to it
	SecurityGroups []map[string]interface{} `json:"security_groups" mapstructure:"security_groups"`
}

Server exposes only the standard OpenStack fields corresponding to a given server on the user's account.

func ExtractServers

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

ExtractServers interprets the results of a single page from a List() call, producing a slice of Server entities.

type ServerPage

type ServerPage struct {
	pagination.LinkedPageBase
}

ServerPage abstracts the raw results of making a List() request against the API. As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the data provided through the ExtractServers call.

func (ServerPage) IsEmpty

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

IsEmpty returns true if a page contains no Server results.

func (ServerPage) NextPageURL

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

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

type UpdateMetadataOptsBuilder

type UpdateMetadataOptsBuilder interface {
	ToMetadataUpdateMap() (map[string]interface{}, error)
}

UpdateMetadataOptsBuilder allows extensions to add additional parameters to the Create request.

type UpdateMetadataResult

type UpdateMetadataResult struct {
	MetadataResult
}

UpdateMetadataResult temporarily contains the response from a metadata Update call.

func UpdateMetadata

UpdateMetadata updates (or creates) all the metadata specified by opts for the given server ID. This operation does not affect already-existing metadata that is not specified by opts.

type UpdateOpts

type UpdateOpts struct {
	// Name [optional] changes the displayed name of the server.
	// The server host name will *not* change.
	// Server names are not constrained to be unique, even within the same tenant.
	Name string

	// AccessIPv4 [optional] provides a new IPv4 address for the instance.
	AccessIPv4 string

	// AccessIPv6 [optional] provides a new IPv6 address for the instance.
	AccessIPv6 string
}

UpdateOpts specifies the base attributes that may be updated on an existing server.

func (UpdateOpts) ToServerUpdateMap

func (opts UpdateOpts) ToServerUpdateMap() map[string]interface{}

ToServerUpdateMap formats an UpdateOpts structure into a request body.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToServerUpdateMap() map[string]interface{}
}

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

type UpdateResult

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

UpdateResult temporarily contains the response from an Update call.

func Update

Update requests that various attributes of the indicated server be changed.

func (UpdateResult) Extract

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

Extract interprets any serverResult as a Server, if possible.

Jump to

Keyboard shortcuts

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