servers

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 11 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.

Example to List Servers

listOpts := servers.ListOpts{
	AllTenants: true,
}

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

allServers, err := servers.ExtractServers(allPages)
if err != nil {
	panic(err)
}

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

Example to Create a Server

createOpts := servers.CreateOpts{
	Name:      "server_name",
	ImageRef:  "image-uuid",
	FlavorRef: "flavor-uuid",
}

server, err := servers.Create(computeClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Server

serverID := "d9072956-1560-487c-97f2-18bdf65ec749"
err := servers.Delete(computeClient, serverID).ExtractErr()
if err != nil {
	panic(err)
}

Example to Force Delete a Server

serverID := "d9072956-1560-487c-97f2-18bdf65ec749"
err := servers.ForceDelete(computeClient, serverID).ExtractErr()
if err != nil {
	panic(err)
}

Example to Reboot a Server

rebootOpts := servers.RebootOpts{
	Type: servers.SoftReboot,
}

serverID := "d9072956-1560-487c-97f2-18bdf65ec749"

err := servers.Reboot(computeClient, serverID, rebootOpts).ExtractErr()
if err != nil {
	panic(err)
}

Example to Rebuild a Server

rebuildOpts := servers.RebuildOpts{
	Name:    "new_name",
	ImageID: "image-uuid",
}

serverID := "d9072956-1560-487c-97f2-18bdf65ec749"

server, err := servers.Rebuilt(computeClient, serverID, rebuildOpts).Extract()
if err != nil {
	panic(err)
}

Example to Resize a Server

resizeOpts := servers.ResizeOpts{
	FlavorRef: "flavor-uuid",
}

serverID := "d9072956-1560-487c-97f2-18bdf65ec749"

err := servers.Resize(computeClient, serverID, resizeOpts).ExtractErr()
if err != nil {
	panic(err)
}

err = servers.ConfirmResize(computeClient, serverID).ExtractErr()
if err != nil {
	panic(err)
}

Example to Snapshot a Server

snapshotOpts := servers.CreateImageOpts{
	Name: "snapshot_name",
}

serverID := "d9072956-1560-487c-97f2-18bdf65ec749"

image, err := servers.CreateImage(computeClient, serverID, snapshotOpts).ExtractImageID()
if err != nil {
	panic(err)
}

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

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

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

func ExtractServersInto

func ExtractServersInto(r pagination.Page, v interface{}) error

func IDFromName

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

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

func List

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

func ListAddresses

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

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

func ListAddressesByNetwork

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. Call its ExtractErr method to determine if the action succeeded or failed.

func ChangeAdminPassword

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

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

func ConfirmResize

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

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

func ForceDelete

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

ForceDelete forces the deletion of a server.

func Reboot

func Reboot(client *gophercloud.ServiceClient, id string, opts RebootOptsBuilder) (r ActionResult)

Reboot requests that a given server reboot.

Two methods exist for rebooting a server:

HardReboot (aka PowerCycle) starts 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 rtored or the VM instance restarted.

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

func Resize

func Resize(client *gophercloud.ServiceClient, id string, opts ResizeOptsBuilder) (r ActionResult)

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 VERIFY_RESIZE 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) (r ActionResult)

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

type Address

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

Address represents an IP address.

func ExtractNetworkAddresses

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

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

type AddressPage

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

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

IsEmpty returns true if an AddressPage contains no networks.

type CreateImageOpts

type CreateImageOpts struct {
	// Name of the image/snapshot.
	Name string `json:"name" required:"true"`

	// Metadata contains key-value pairs (up to 255 bytes each) to attach to
	// the created image.
	Metadata map[string]string `json:"metadata,omitempty"`
}

CreateImageOpts provides options to pass to the CreateImage request.

func (CreateImageOpts) ToServerCreateImageMap

func (opts CreateImageOpts) ToServerCreateImageMap() (map[string]interface{}, error)

ToServerCreateImageMap formats a CreateImageOpts structure into a request body.

type CreateImageOptsBuilder

type CreateImageOptsBuilder interface {
	ToServerCreateImageMap() (map[string]interface{}, error)
}

CreateImageOptsBuilder allows extensions to add additional parameters to the CreateImage request.

type CreateImageResult

type CreateImageResult struct {
	gophercloud.Result
}

CreateImageResult is the response from a CreateImage operation. Call its ExtractImageID method to retrieve the ID of the newly created image.

func CreateImage

func CreateImage(client *gophercloud.ServiceClient, id string, opts CreateImageOptsBuilder) (r CreateImageResult)

CreateImage makes a request against the nova API to schedule an image to be created of the server

func (CreateImageResult) ExtractImageID

func (r CreateImageResult) ExtractImageID() (string, error)

ExtractImageID gets the ID of the newly created server image from the header.

type CreateMetadatumResult

type CreateMetadatumResult struct {
	MetadatumResult
}

CreateMetadatumResult contains the result of a Create operation. Call its Extract method to interpret it as a map[string]interface.

func CreateMetadatum

func CreateMetadatum(client *gophercloud.ServiceClient, id string, opts MetadatumOptsBuilder) (r CreateMetadatumResult)

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

type CreateOpts

type CreateOpts struct {
	//secret for logging in server
	KeyName string `json:"-"`

	//the maxum of servers created
	MaxCount int `json:"-"`

	//the minum of servers created
	MinCount int `json:"-"`

	// Name is the name to assign to the newly launched server.
	Name string `json:"name" required:"true"`
	// ImageRef [optional; required if ImageName is not provided] is the ID or
	// full URL to the image that contains the server's OS and initial state.
	// Also optional if using the boot-from-volume extension.
	ImageRef string `json:"imageRef,omitempty"`

	// ImageName [optional; required if ImageRef is not provided] is the name of
	// the image that contains the server's OS and initial state.
	// Also optional if using the boot-from-volume extension.
	ImageName string `json:"-"`

	// FlavorRef [optional; required if FlavorName is not provided] is the ID or
	// full URL to the flavor that describes the server's specs.
	FlavorRef string `json:"flavorRef"`

	// FlavorName [optional; required if FlavorRef is not provided] is the name of
	// the flavor that describes the server's specs.
	FlavorName string `json:"-"`

	// SecurityGroups lists the names of the security groups to which this server
	// should belong.
	SecurityGroups []string `json:"-"`

	// UserData contains configuration information or scripts to use upon launch.
	// Create will base64-encode it for you, if it isn't already.
	UserData []byte `json:"-"`

	// AvailabilityZone in which to launch the server.
	AvailabilityZone string `json:"availability_zone,omitempty"`

	// Networks 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 `json:"networks" required:"true"`

	// Metadata contains key-value pairs (up to 255 bytes each) to attach to the
	// server.
	Metadata map[string]string `json:"metadata,omitempty"`

	// Personality includes files to inject into the server at launch.
	// Create will base64-encode file contents for you.
	Personality Personality `json:"personality,omitempty"`

	// ConfigDrive enables metadata injection through a configuration drive.
	ConfigDrive *bool `json:"config_drive,omitempty"`

	// AdminPass sets the root user password. If not set, a randomly-generated
	// password will be created and returned in the response.
	AdminPass string `json:"adminPass,omitempty"`

	// AccessIPv4 specifies an IPv4 address for the instance.
	AccessIPv4 string `json:"accessIPv4,omitempty"`

	// AccessIPv6 pecifies an IPv6 address for the instance.
	AccessIPv6 string `json:"accessIPv6,omitempty"`

	// ServiceClient will allow calls to be made to retrieve an image or
	// flavor ID by name.
	ServiceClient *gophercloud.ServiceClient `json:"-"`

	//DCF
	DiskConfig string `json:"OS-DCF:diskConfig,omitempty"`

	// whether support return server reservation_id .
	ReturnReservationID *bool `json:"return_reservation_id,omitempty"`
}

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

func Create

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

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.

func (CreateResult) ExtractInto

func (r CreateResult) ExtractInto(v interface{}) error

type DeleteMetadatumResult

type DeleteMetadatumResult struct {
	gophercloud.ErrResult
}

DeleteMetadatumResult contains the result of a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.

func DeleteMetadatum

func DeleteMetadatum(client *gophercloud.ServiceClient, id, key string) (r 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 is the response from a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.

func Delete

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

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

type Events added in v1.0.21

type Events struct {
	FinishTime string `json:"finish_time"`
	StartTime  string `json:"start_time"`
	Traceback  string `json:"traceback"`
	Event      string `json:"event"`
	Result     string `json:"result"`
}

type Fault

type Fault struct {
	Code    int       `json:"code"`
	Created time.Time `json:"created"`
	Details string    `json:"details"`
	Message string    `json:"message"`
}

type File

type File struct {
	// Path of the file.
	Path string

	// Contents of the file. Maximum content size is 255 bytes.
	Contents []byte
}

File is used within CreateOpts and RebuildOpts to inject a file into the server at launch. File implements the json.Marshaler interface, so when a Create or Rebuild operation is requested, json.Marshal will call File's MarshalJSON method.

func (*File) MarshalJSON

func (f *File) MarshalJSON() ([]byte, error)

MarshalJSON marshals the escaped file, base64 encoding the contents.

type GetConsoleLogResult added in v1.0.21

type GetConsoleLogResult struct {
	MetadataResult
}

func GetConsoleLog added in v1.0.21

func GetConsoleLog(client *gophercloud.ServiceClient, id string, length string) (r GetConsoleLogResult)

func (GetConsoleLogResult) Extract added in v1.0.21

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

type GetMetadataResult

type GetMetadataResult struct {
	MetadataResult
}

GetMetadataResult contains the result of a Get operation. Call its Extract method to interpret it as a map[string]interface.

func Metadata

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

Metadata requests all the metadata for the given server ID.

type GetMetadatumResult

type GetMetadatumResult struct {
	MetadatumResult
}

GetMetadatumResult contains the result of a Get operation. Call its Extract method to interpret it as a map[string]interface.

func Metadatum

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

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

type GetPasswordResult

type GetPasswordResult struct {
	gophercloud.Result
}

GetPasswordResult represent the result of a get os-server-password operation. Call its ExtractPassword method to retrieve the password.

func GetPassword

func GetPassword(client *gophercloud.ServiceClient, serverId string) (r GetPasswordResult)

GetPassword makes a request against the nova API to get the encrypted administrative password.

func (GetPasswordResult) ExtractPassword

func (r GetPasswordResult) ExtractPassword(privateKey *rsa.PrivateKey) (string, error)

ExtractPassword gets the encrypted password. If privateKey != nil the password is decrypted with the private key. If privateKey == nil the encrypted password is returned and can be decrypted with:

echo '<pwd>' | base64 -D | openssl rsautl -decrypt -inkey <private_key>

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

func Get

func Get(client *gophercloud.ServiceClient, id string) (r 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.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

type InstanceAction added in v1.0.21

type InstanceAction struct {
	InstanceUUID string   `json:"instance_uuid"`
	UserID       string   `json:"user_id"`
	StartTime    string   `json:"start_time"`
	RequestID    string   `json:"request_id"`
	Action       string   `json:"action"`
	Message      string   `json:"message"`
	ProjectID    string   `json:"project_id"`
	Events       []Events `json:"events"`
}

type InstanceActionResult added in v1.0.21

type InstanceActionResult struct {
	gophercloud.Result
}

func GetInstanceActions added in v1.0.21

func GetInstanceActions(client *gophercloud.ServiceClient, serverID string, RequestID string) (r InstanceActionResult)

func ListInstanceActions added in v1.0.21

func ListInstanceActions(client *gophercloud.ServiceClient, serverID string) (r InstanceActionResult)

func (InstanceActionResult) ExtractInstanceActionsListResult added in v1.0.21

func (r InstanceActionResult) ExtractInstanceActionsListResult() (*[]InstanceActions, error)

func (InstanceActionResult) ExtractInstanceActionsResult added in v1.0.21

func (r InstanceActionResult) ExtractInstanceActionsResult() (*InstanceAction, error)

type InstanceActions added in v1.0.21

type InstanceActions struct {
	InstanceUUID string `json:"instance_uuid"`
	UserID       string `json:"user_id"`
	StartTime    string `json:"start_time"`
	RequestID    string `json:"request_id"`
	Action       string `json:"action"`
	Message      string `json:"message"`
	ProjectID    string `json:"project_id"`
	UpdatedAt    string `json:"updated_at"`
}

type ListOpts

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

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

	// Flavor is the 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"`

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

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

	// Limit is an integer value for the limit of values to return.
	Limit int `q:"limit"`

	//When you create an elastic cloud server in batches, you can specify the returned ID to query the elastic cloud server created in batches.
	ReservationId string `q:"reservation_id"`

	//The query results are sorted by elastic cloud server attributes. The default sort order is create_at reverse order.
	SortKey string `q:"sort_key"`

	//Query the cloud server that does not contain this value in the tag field.
	NoTags string `q:"not-tags"`
}

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. Call its Extract method to interpret it as a map[string]interface.

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

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

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

IsEmpty returns true if a NetworkAddressPage contains no addresses.

type Personality

type Personality []*File

Personality is an array of files that are injected into the server at launch.

type RebootMethod

type RebootMethod string

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

type RebootOpts

type RebootOpts struct {
	// Type is the type of reboot to perform on the server.
	Type RebootMethod `json:"type" required:"true"`
}

RebootOpts provides options to the reboot request.

func (*RebootOpts) ToServerRebootMap

func (opts *RebootOpts) ToServerRebootMap() (map[string]interface{}, error)

ToServerRebootMap builds a body for the reboot request.

type RebootOptsBuilder

type RebootOptsBuilder interface {
	ToServerRebootMap() (map[string]interface{}, error)
}

RebootOptsBuilder allows extensions to add additional parameters to the reboot request.

type RebuildOpts

type RebuildOpts struct {
	// AdminPass is the server's admin password
	AdminPass string `json:"adminPass,omitempty"`

	// ImageID is the ID of the image you want your server to be provisioned on.
	ImageID string `json:"imageRef"`

	// ImageName is readable name of an image.
	ImageName string `json:"-"`

	// Name to set the server to
	Name string `json:"name,omitempty"`

	// AccessIPv4 [optional] provides a new IPv4 address for the instance.
	AccessIPv4 string `json:"accessIPv4,omitempty"`

	// AccessIPv6 [optional] provides a new IPv6 address for the instance.
	AccessIPv6 string `json:"accessIPv6,omitempty"`

	// Metadata [optional] contains key-value pairs (up to 255 bytes each)
	// to attach to the server.
	Metadata map[string]string `json:"metadata,omitempty"`

	// Personality [optional] includes files to inject into the server at launch.
	// Rebuild will base64-encode file contents for you.
	Personality Personality `json:"personality,omitempty"`

	// ServiceClient will allow calls to be made to retrieve an image or
	// flavor ID by name.
	ServiceClient *gophercloud.ServiceClient `json:"-"`
}

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 allows extensions to provide additional parameters to the rebuild request.

type RebuildResult

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

RebuildResult is the response from a Rebuild operation. Call its Extract method to interpret it as a Server.

func Rebuild

func Rebuild(client *gophercloud.ServiceClient, id string, opts RebuildOptsBuilder) (r RebuildResult)

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.

func (RebuildResult) ExtractInto

func (r RebuildResult) ExtractInto(v interface{}) error

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 `json:"adminPass,omitempty"`
}

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 is the response from a Rescue operation. Call its ExtractErr method to determine if the call succeeded or failed.

func Rescue

func Rescue(client *gophercloud.ServiceClient, id string, opts RescueOptsBuilder) (r RescueResult)

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 contains the result of a Reset operation. Call its Extract method to interpret it as a map[string]interface.

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 `json:"flavorRef" required:"true"`
}

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 allows extensions to add additional parameters to the resize request.

type Server

type Server struct {

	//volume attached
	VolumeAttached []map[string]interface{} `json:"os-extended-volumes:volumes_attached"`

	//availbility zone
	AvailbiltyZone string `json:"OS-EXT-AZ:availability_zone"`

	// host
	Host string `json:"OS-EXT-SRV-ATTR:host"`

	// task state
	TaskState string `json:"OS-EXT-STS:task_state"`

	// power state
	PowerState int `json:"OS-EXT-STS:power_state"`

	//  vm state
	VMstate string `json:"OS-EXT-STS:vm_state"`

	// 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"`

	// HostID is the host where the server is located in the cloud.
	HostID string `json:"hostid"`

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

	// Progress ranges from 0..100.
	// A request made against the server completes only once Progress reaches 100.
	Progress int `json:"progress"`

	// AccessIPv4 and AccessIPv6 contain the IP addresses of the server,
	// suitable for remote access for administration.
	AccessIPv4 string `json:"accessIPv4"`
	AccessIPv6 string `json:"accessIPv6"`

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

	// 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"`

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

	// KeyName indicates which public key was injected into the server on launch.
	KeyName string `json:"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"`

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

	// Fault contains failure information about a server.
	Fault Fault `json:"fault"`

	//DCF
	DiskConfig string `json:"OS-DCF:diskConfig"`
	//server tags
	Tags []string `json:"tags"`

	//host status
	HostStatus string `json:"host_status"`
	//host description
	Description string `json:"description"`
	//bool type whether server locked
	Locked *bool `json:"locked"`
	// server hostname
	Hostname string `json:"OS-EXT-SRV-ATTR:hostname"`
	//server kernel_id
	KernelID string `json:"OS-EXT-SRV-ATTR:kernel_id"`
	// server ramdisk_id
	RamdiskID string `json:"OS-EXT-SRV-ATTR:ramdisk_id"`
	//launch_index
	LaunchIndex *int `json:"OS-EXT-SRV-ATTR:launch_index"`
	//user_data
	UserData string `json:"OS-EXT-SRV-ATTR:user_data"`
	//reservation_id
	ReservationID string `json:"OS-EXT-SRV-ATTR:reservation_id"`
	//root_device_name
	RootDeviceName string `json:"OS-EXT-SRV-ATTR:root_device_name"`
	//hypervisor_hostname
	HypervisorHostname string `json:"OS-EXT-SRV-ATTR:hypervisor_hostname"`
	//instance_name
	InstanceName string `json:"OS-EXT-SRV-ATTR:instance_name"`

	//instance launched time
	LaunchedAt string `json:"OS-SRV-USG:launched_at"`
	//instance terminated time
	TerminatedAt string `json:"OS-SRV-USG:terminated_at"`
	//Reserved attribute
	ConfigDrive string `json:"config_drive"`
	//Reserved attribute
	EvsOpts int `json:"evs_opts"`
	//Reserved attribute
	HyperThreadAffinity string `json:"hyperThreadAffinity"`
	//Reserved attribute
	NumaOpts int `json:"numa_opts"`
	//Reserved attribute
	VcpuAffinity []int `json:"vcpuAffinity"`
}

Server represents a server/instance in the OpenStack cloud.

func ExtractServers

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

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

func (*Server) UnmarshalJSON

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

type ServerBrief

type ServerBrief struct {
	ID    string
	Name  string
	Links []interface{}
}

ListBrief接口返回的结构

func ExtractServerBriefs

func ExtractServerBriefs(r pagination.Page) ([]ServerBrief, error)

对应ListBrief接口

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 (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 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 contains the result of an Update operation. Call its Extract method to interpret it as a map[string]interface.

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 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 `json:"name,omitempty"`

	// Description for the instance.
	Description string `json:"description,omitempty"`
}

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

func (UpdateOpts) ToServerUpdateMap

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

ToServerUpdateMap formats an UpdateOpts structure into a request body.

type UpdateOptsBuilder

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

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

type UpdateResult

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

UpdateResult is the response from an Update operation. Call its Extract method to interpret it as a Server.

func Update

func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

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.

func (UpdateResult) ExtractInto

func (r UpdateResult) ExtractInto(v interface{}) error

Directories

Path Synopsis
servers unit tests
servers unit tests

Jump to

Keyboard shortcuts

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