instances

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAvailabilityZone = "nova"

Variables

This section is empty.

Functions

func Create

func Create(client *gcorecloud.ServiceClient, opts CreateOptsBuilder) (r tasks.Result)

Create creates an instance.

func Delete

func Delete(client *gcorecloud.ServiceClient, instanceID string, opts DeleteOptsBuilder) (r tasks.Result)

func ExtractInstanceIDFromTask

func ExtractInstanceIDFromTask(task *tasks.Task) (string, error)

func ExtractInstanceInterfacesInto

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

func ExtractInstanceSecurityGroupInto

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

func ExtractInstanceSecurityGroups

func ExtractInstanceSecurityGroups(r pagination.Page) ([]gcorecloud.ItemIDName, error)

ExtractInstanceSecurityGroups accepts a Page struct, specifically a InstanceSecurityGroupPage struct, and extracts the elements into a slice of instance security group structs. In other words, a generic collection is mapped into a relevant slice.

func ExtractInstancesInto

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

func ExtractMetadataInto

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

func ListInterfaces

func ListInterfaces(client *gcorecloud.ServiceClient, id string) pagination.Pager

ListInterfaces retrieves network interfaces for instance

func ListSecurityGroups

func ListSecurityGroups(client *gcorecloud.ServiceClient, id string) pagination.Pager

ListSecurityGroups retrieves security groups interfaces for instance

func ListSecurityGroupsAll

func ListSecurityGroupsAll(client *gcorecloud.ServiceClient, id string) ([]gcorecloud.ItemIDName, error)

ListSecurityGroupsAll is a convenience function that returns all instance security groups.

func MetadataList

func MetadataList(client *gcorecloud.ServiceClient, id string) pagination.Pager

func Resize

func Resize(client *gcorecloud.ServiceClient, id string, opts ChangeFlavorOptsBuilder) (r tasks.Result)

Resize instance.

Types

type ChangeFlavorOpts

type ChangeFlavorOpts struct {
	FlavorID string `json:"flavor_id" required:"true" validate:"required"`
}

func (ChangeFlavorOpts) ToChangeFlavorActionMap

func (opts ChangeFlavorOpts) ToChangeFlavorActionMap() (map[string]interface{}, error)

ToChangeFlavorActionMap builds a request body from ChangeFlavorOpts.

func (ChangeFlavorOpts) Validate

func (opts ChangeFlavorOpts) Validate() error

type ChangeFlavorOptsBuilder

type ChangeFlavorOptsBuilder interface {
	ToChangeFlavorActionMap() (map[string]interface{}, error)
}

ChangeFlavorOptsBuilder builds parameters or change flavor request.

type CreateInterfaceOpts added in v0.2.11

type CreateInterfaceOpts struct {
	Type       types.InterfaceType               `json:"type" required:"true" validate:"required,enum"`
	NetworkID  string                            `json:"network_id,omitempty" validate:"rfe=Type:subnet,sfe=Type:external,omitempty,uuid4"`
	SubnetID   string                            `json:"subnet_id,omitempty" validate:"rfe=Type:subnet,sfe=Type:external,omitempty,uuid4"`
	FloatingIP *CreateNewInterfaceFloatingIPOpts `json:"floating_ip,omitempty" validate:"omitempty,sfe=Type:external,dive"`
}

func (CreateInterfaceOpts) Validate added in v0.2.11

func (opts CreateInterfaceOpts) Validate() error

Validate

type CreateNewInterfaceFloatingIPOpts

type CreateNewInterfaceFloatingIPOpts struct {
	Source             types.FloatingIPSource `json:"source" validate:"required,enum"`
	ExistingFloatingID string                 `json:"existing_floating_id" validate:"rfe=Source:existing,sfe=Source:new,omitempty,ip"`
}

func (CreateNewInterfaceFloatingIPOpts) Validate

func (opts CreateNewInterfaceFloatingIPOpts) Validate() error

Validate

type CreateOpts

type CreateOpts struct {
	Flavor         string                `json:"flavor" required:"true"`
	Names          []string              `json:"names,omitempty" validate:"required_without=NameTemplates"`
	NameTemplates  []string              `json:"name_templates,omitempty" validate:"required_without=Names"`
	Volumes        []CreateVolumeOpts    `json:"volumes" required:"true" validate:"required,dive"`
	Interfaces     []CreateInterfaceOpts `json:"interfaces" required:"true" validate:"required,dive"`
	SecurityGroups []gcorecloud.ItemID   `json:"security_groups" validate:"omitempty,dive,uuid4"`
	Keypair        string                `json:"keypair_name"`
	Password       string                `json:"password" validate:"omitempty,required_with=Username"`
	Username       string                `json:"username" validate:"omitempty,required_with=Password"`
	UserData       string                `json:"user_data" validate:"omitempty,base64"`
	Metadata       *MetadataSetOpts      `json:"metadata,omitempty" validate:"omitempty,dive"`
}

CreateOpts represents options used to create a instance.

func (CreateOpts) ToInstanceCreateMap

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

ToInstanceCreateMap builds a request body from CreateOpts.

func (CreateOpts) Validate

func (opts CreateOpts) Validate() error

Validate

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToInstanceCreateMap() (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 represents the result of a create operation. Call its Extract method to interpret it as a Instance.

func (CreateResult) Extract

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

Extract is a function that accepts a result and extracts a instance resource.

func (CreateResult) ExtractInto

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

type CreateVolumeOpts

type CreateVolumeOpts struct {
	Source     types.VolumeSource `json:"source" required:"true" validate:"required,enum"`
	BootIndex  int                `json:"boot_index"`
	Size       int                `json:"size,omitempty" validate:"rfe=Source:image;new-volume,sfe=Source:snapshot;existing-volume"`
	TypeName   volumes.VolumeType `json:"type_name" required:"true" validate:"required,enum"`
	Name       string             `json:"name,omitempty" validate:"omitempty"`
	ImageID    string             `` /* 156-byte string literal not displayed */
	SnapshotID string             `` /* 156-byte string literal not displayed */
	VolumeID   string             `` /* 156-byte string literal not displayed */
}

CreateVolumeOpts represents options used to create a volume.

func (*CreateVolumeOpts) Validate

func (opts *CreateVolumeOpts) Validate() error

type DeleteOpts

type DeleteOpts struct {
	Volumes         []string `q:"volumes" validate:"omitempty,dive,uuid4" delimiter:"comma"`
	DeleteFloatings bool     `q:"delete_floatings" validate:"omitempty,allowed_without=FloatingIPs"`
	FloatingIPs     []string `q:"floatings" validate:"omitempty,allowed_without=DeleteFloatings,dive,uuid4" delimiter:"comma"`
}

DeleteOpts. Set parameters for delete operation

func (DeleteOpts) ToInstanceDeleteQuery

func (opts DeleteOpts) ToInstanceDeleteQuery() (string, error)

ToInstanceDeleteQuery formats a DeleteOpts into a query string.

func (*DeleteOpts) Validate

func (opts *DeleteOpts) Validate() error

type DeleteOptsBuilder

type DeleteOptsBuilder interface {
	ToInstanceDeleteQuery() (string, error)
}

DeleteOptsBuilder allows extensions to add additional parameters to the Delete request.

type DeleteResult

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

DeleteResult represents the result of a delete operation

func (DeleteResult) Extract

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

Extract is a function that accepts a result and extracts a instance resource.

func (DeleteResult) ExtractInto

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

type FloatingIP

type FloatingIP struct {
	FloatingIPAddress net.IP                   `json:"floating_ip_address"`
	RouterID          string                   `json:"router_id"`
	SubnetID          string                   `json:"subnet_id"`
	Status            string                   `json:"status"`
	ID                string                   `json:"id"`
	PortID            string                   `json:"port_id"`
	DNSDomain         string                   `json:"dns_domain"`
	DNSName           string                   `json:"dns_name"`
	FixedIPAddress    net.IP                   `json:"fixed_ip_address"`
	UpdatedAt         *gcorecloud.JSONRFC3339Z `json:"updated_at"`
	CreatedAt         gcorecloud.JSONRFC3339Z  `json:"created_at"`
	CreatorTaskID     *string                  `json:"creator_task_id"`
	ProjectID         int                      `json:"project_id"`
	RegionID          int                      `json:"region_id"`
	Region            string                   `json:"region"`
}

FloatingIP represents a floating ip of instance port.

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

func Get

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

Get retrieves a specific instance based on its unique ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts a instance resource.

func (GetResult) ExtractInto

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

type Instance

type Instance struct {
	ID               string                       `json:"instance_id"`
	Name             string                       `json:"instance_name"`
	Description      string                       `json:"instance_description"`
	CreatedAt        gcorecloud.JSONRFC3339ZZ     `json:"instance_created"`
	Status           string                       `json:"status"`
	VMState          string                       `json:"vm_state"`
	TaskState        *string                      `json:"task_state"`
	Flavor           flavors.Flavor               `json:"flavor"`
	Metadata         map[string]interface{}       `json:"metadata"`
	Volumes          []InstanceVolume             `json:"volumes"`
	Addresses        map[string][]InstanceAddress `json:"addresses"`
	SecurityGroups   []gcorecloud.ItemName        `json:"security_groups"`
	CreatorTaskID    *string                      `json:"creator_task_id"`
	TaskID           *string                      `json:"task_id"`
	ProjectID        int                          `json:"project_id"`
	RegionID         int                          `json:"region_id"`
	Region           string                       `json:"region"`
	AvailabilityZone string                       `json:"availability_zone"`
}

Instance represents a instance structure.

func ExtractInstances

func ExtractInstances(r pagination.Page) ([]Instance, error)

ExtractInstances accepts a Page struct, specifically a InstancePage struct, and extracts the elements into a slice of instance structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

func ListAll(client *gcorecloud.ServiceClient, opts ListOptsBuilder) ([]Instance, error)

ListAll is a convenience function that returns all instances.

func (*Instance) UnmarshalJSON

func (i *Instance) UnmarshalJSON(data []byte) error

UnmarshalJSON - implements Unmarshaler interface

type InstanceAddress

type InstanceAddress struct {
	Type       types.AddressType `json:"type"`
	Address    net.IP            `json:"addr"`
	SubnetID   *string           `json:"subnet_id,omitempty"`
	SubnetName *string           `json:"subnet_name,omitempty"`
}

type InstanceInterfacePage

type InstanceInterfacePage struct {
	pagination.LinkedPageBase
}

InstanceInterfacePage is the page returned by a pager when traversing over a collection of instance interfaces.

func (InstanceInterfacePage) IsEmpty

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

IsEmpty checks whether a InstanceInterfacePage struct is empty.

func (InstanceInterfacePage) NextPageURL

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

NextPageURL is invoked when a paginated collection of instance interfaces 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 InstancePage

type InstancePage struct {
	pagination.LinkedPageBase
}

InstancePage is the page returned by a pager when traversing over a collection of instances.

func (InstancePage) IsEmpty

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

IsEmpty checks whether a InstancePage struct is empty.

func (InstancePage) NextPageURL

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

NextPageURL is invoked when a paginated collection of instances 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 InstanceSecurityGroupPage

type InstanceSecurityGroupPage struct {
	pagination.LinkedPageBase
}

InstanceSecurityGroupPage is the page returned by a pager when traversing over a collection of instance security groups.

func (InstanceSecurityGroupPage) IsEmpty

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

IsEmpty checks whether a InstanceSecurityGroupPage struct is empty.

func (InstanceSecurityGroupPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of instance security groups 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 InstanceTaskResult

type InstanceTaskResult struct {
	Instances   []string `json:"instances"`
	Volumes     []string `json:"volumes"`
	FloatingIPs []string `json:"floating_ips"`
	Ports       []string `json:"ports"`
}

type InstanceVolume

type InstanceVolume struct {
	ID                  string `json:"id"`
	DeleteOnTermination bool   `json:"delete_on_termination"`
}

type Interface

type Interface struct {
	PortID            string         `json:"port_id"`
	MacAddress        gcorecloud.MAC `json:"mac_address"`
	NetworkID         string         `json:"network_id"`
	IPAssignments     []PortIP       `json:"ip_assignments"`
	NetworkDetails    NetworkDetail  `json:"network_details"`
	FloatingIPDetails []FloatingIP   `json:"floatingip_details"`
}

Interface represents a instance port interface.

func ExtractInstanceInterfaces

func ExtractInstanceInterfaces(r pagination.Page) ([]Interface, error)

ExtractInstanceInterfaces accepts a Page struct, specifically a InstanceInterfacePage struct, and extracts the elements into a slice of instance interface structs. In other words, a generic collection is mapped into a relevant slice.

func ListInterfacesAll

func ListInterfacesAll(client *gcorecloud.ServiceClient, id string) ([]Interface, error)

ListInterfacesAll is a convenience function that returns all instance interfaces.

type ListOpts

type ListOpts struct {
	ExcludeSecGroup   string `q:"exclude_secgroup"`
	AvailableFloating bool   `q:"available_floating"`
}

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

func (ListOpts) ToInstanceListQuery

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

ToInstanceListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type Metadata

type Metadata struct {
	Key      string `json:"key"`
	Value    string `json:"value"`
	ReadOnly bool   `json:"read_only"`
}

func ExtractMetadata

func ExtractMetadata(r pagination.Page) ([]Metadata, error)

ExtractMetadata accepts a Page struct, specifically a MetadataPage struct, and extracts the elements into a slice of instance metadata structs. In other words, a generic collection is mapped into a relevant slice.

func MetadataListAll

func MetadataListAll(client *gcorecloud.ServiceClient, id string) ([]Metadata, error)

type MetadataActionResult

type MetadataActionResult struct {
	gcorecloud.ErrResult
}

MetadataActionResult represents the result of a create, delete or update operation(no content)

func MetadataCreate

func MetadataCreate(client *gcorecloud.ServiceClient, id string, opts MetadataSetOpts) (r MetadataActionResult)

MetadataCreate creates a metadata for an instance.

func MetadataDelete

func MetadataDelete(client *gcorecloud.ServiceClient, id string, key string) (r MetadataActionResult)

MetadataDelete deletes defined metadata key for an instance.

func MetadataUpdate

func MetadataUpdate(client *gcorecloud.ServiceClient, id string, opts MetadataSetOpts) (r MetadataActionResult)

MetadataUpdate updates a metadata for an instance.

type MetadataOpts

type MetadataOpts struct {
	Key   string `json:"key" validate:"required,max=255"`
	Value string `json:"value" validate:"required,max=255"`
}

MetadataOpts. Set parameters for Create or Update operation

func (MetadataOpts) Validate

func (opts MetadataOpts) Validate() error

Validate

type MetadataOptsBuilder

type MetadataOptsBuilder interface {
	ToMetadataMap() (string, error)
}

MetadataOptsBuilder allows extensions to add additional parameters to the metadata Create and Update request.

type MetadataPage

type MetadataPage struct {
	pagination.LinkedPageBase
}

MetadataPage is the page returned by a pager when traversing over a collection of instance metadata objects.

func (MetadataPage) IsEmpty

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

IsEmpty checks whether a MetadataPage struct is empty.

func (MetadataPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of instance metadata objects 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 MetadataResult

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

MetadataResult represents the result of a get operation

func MetadataGet

func MetadataGet(client *gcorecloud.ServiceClient, id string, key string) (r MetadataResult)

MetadataGet gets defined metadata key for an instance.

func (MetadataResult) Extract

func (r MetadataResult) Extract() (*Metadata, error)

Extract is a function that accepts a result and extracts a instance metadata resource.

func (MetadataResult) ExtractInto

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

type MetadataSetOpts

type MetadataSetOpts struct {
	Metadata []MetadataOpts `json:"metadata" validate:"required,min=1,dive"`
}

MetadataSetOpts. Set parameters for Create or Update operation

func (MetadataSetOpts) ToMetadataMap

func (opts MetadataSetOpts) ToMetadataMap() (map[string]interface{}, error)

ToMetadataMap builds a request body from MetadataSetOpts.

func (MetadataSetOpts) Validate

func (opts MetadataSetOpts) Validate() error

Validate

type NetworkDetail

type NetworkDetail struct {
	Mtu           int                      `json:"mtu"`
	UpdatedAt     *gcorecloud.JSONRFC3339Z `json:"updated_at"`
	CreatedAt     gcorecloud.JSONRFC3339Z  `json:"created_at"`
	ID            string                   `json:"id"`
	External      bool                     `json:"external"`
	Default       bool                     `json:"default"`
	Name          string                   `json:"name"`
	Shared        bool                     `json:"shared"`
	Subnets       []Subnet                 `json:"subnets"`
	ProjectID     int                      `json:"project_id"`
	RegionID      int                      `json:"region_id"`
	Region        string                   `json:"region"`
	TaskID        *string                  `json:"task_id"`
	CreatorTaskID *string                  `json:"creator_task_id"`
}

NetworkDetail represents a NetworkDetails of instance port.

type PortIP

type PortIP struct {
	IPAddress net.IP `json:"ip_address"`
	SubnetID  string `json:"subnet_id"`
}

PortIP

type SecurityGroupActionResult

type SecurityGroupActionResult struct {
	gcorecloud.ErrResult
}

SecurityGroupActionResult represents the result of a actions operation(no content)

func AssignSecurityGroup

func AssignSecurityGroup(client *gcorecloud.ServiceClient, id string, opts SecurityGroupOptsBuilder) (r SecurityGroupActionResult)

AssignSecurityGroup adds a security groups to the instance.

func UnAssignSecurityGroup

func UnAssignSecurityGroup(client *gcorecloud.ServiceClient, id string, opts SecurityGroupOptsBuilder) (r SecurityGroupActionResult)

UnAssignSecurityGroup removes a security groups from the instance.

type SecurityGroupOpts

type SecurityGroupOpts struct {
	Name string `json:"name" required:"true" validate:"required"`
}

func (SecurityGroupOpts) ToSecurityGroupActionMap

func (opts SecurityGroupOpts) ToSecurityGroupActionMap() (map[string]interface{}, error)

ToSecurityGroupActionMap builds a request body from SecurityGroupOpts.

func (SecurityGroupOpts) Validate

func (opts SecurityGroupOpts) Validate() error

Validate.

type SecurityGroupOptsBuilder

type SecurityGroupOptsBuilder interface {
	ToSecurityGroupActionMap() (map[string]interface{}, error)
}

SecurityGroupOptsBuilder allows extensions to add parameters to the security groups request.

type Subnet

type Subnet struct {
	ID            string                   `json:"id"`
	Name          string                   `json:"name"`
	IPVersion     gcorecloud.IPVersion     `json:"ip_version"`
	EnableDHCP    bool                     `json:"enable_dhcp"`
	Cidr          gcorecloud.CIDR          `json:"cidr"`
	CreatedAt     gcorecloud.JSONRFC3339Z  `json:"created_at"`
	UpdatedAt     *gcorecloud.JSONRFC3339Z `json:"updated_at"`
	NetworkID     string                   `json:"network_id"`
	TaskID        *string                  `json:"task_id"`
	CreatorTaskID *string                  `json:"creator_task_id"`
	ProjectID     int                      `json:"project_id"`
	RegionID      int                      `json:"region_id"`
	Region        string                   `json:"region"`
}

Subnet port subnet

type UpdateResult

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

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a Instance.

func PowerCycle

func PowerCycle(client *gcorecloud.ServiceClient, id string) (r UpdateResult)

PowerCycle instance.

func Reboot

func Reboot(client *gcorecloud.ServiceClient, id string) (r UpdateResult)

Reboot instance.

func Resume

func Resume(client *gcorecloud.ServiceClient, id string) (r UpdateResult)

Resume instance.

func Start

func Start(client *gcorecloud.ServiceClient, id string) (r UpdateResult)

Start instance.

func Stop

func Stop(client *gcorecloud.ServiceClient, id string) (r UpdateResult)

Stop instance.

func Suspend

func Suspend(client *gcorecloud.ServiceClient, id string) (r UpdateResult)

Suspend instance.

func (UpdateResult) Extract

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

Extract is a function that accepts a result and extracts a instance resource.

func (UpdateResult) ExtractInto

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

Directories

Path Synopsis
instances unit tests
instances unit tests

Jump to

Keyboard shortcuts

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