pools

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MPL-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(client *edgecloud.ServiceClient, clusterID string, opts CreateOptsBuilder) (r tasks.Result)

Create accepts a CreateOpts struct and creates a new cluster Pool using the values provided.

func Delete

func Delete(client *edgecloud.ServiceClient, clusterID, nodeGroupID string) (r tasks.Result)

Delete accepts a unique ID and deletes the cluster Pool associated with it.

func ExtractClusterPoolIDFromTask

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

func ExtractClusterPoolsInto

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

func Instances

func Instances(client *edgecloud.ServiceClient, clusterID string, id string) pagination.Pager

Instances returns a Pager which allows you to iterate over a collection of pool instances.

func InstancesAll

func InstancesAll(client *edgecloud.ServiceClient, clusterID, id string) ([]instances.Instance, error)

InstancesAll returns all pool instances.

func List

func List(client *edgecloud.ServiceClient, clusterID string, opts ListOptsBuilder) pagination.Pager

List makes a request to the Magnum API to retrieve pools belonging to the given cluster. The request can be modified to filter or sort the list using the options available in ListOpts.

Use the AllPages method of the returned Pager to ensure that all pools are returned (for example when using the Limit option to limit the number of node groups returned per page).

Not all node group fields are returned in a list request. Only the fields UUID, Name, FlavorID, ImageID, NodeCount, Role, IsDefault, Status and StackID are returned, all other fields are omitted and will have their zero value when extracted.

func Update

func Update(client *edgecloud.ServiceClient, clusterID, poolID string, opts UpdateOptsBuilder) (r tasks.Result)

Update accepts a UpdateOpts struct and updates an existing Pool using the values provided.

func Volumes

func Volumes(client *edgecloud.ServiceClient, clusterID string, id string) pagination.Pager

Volumes returns a Pager which allows you to iterate over a collection of pool instances.

func VolumesAll

func VolumesAll(client *edgecloud.ServiceClient, clusterID, id string) ([]volumes.Volume, error)

VolumesAll returns all pool volumes.

Types

type ClusterPool

type ClusterPool struct {
	ProjectID     string            `json:"project_id"`
	Labels        map[string]string `json:"labels"`
	NodeAddresses []net.IP          `json:"node_addresses"`
	StatusReason  string            `json:"status_reason"`
	*ClusterPoolList
}

ClusterPool represents a cluster Pool.

type ClusterPoolList added in v0.1.6

type ClusterPoolList struct {
	UUID             string             `json:"uuid"`
	Name             string             `json:"name"`
	ClusterID        string             `json:"cluster_id"`
	FlavorID         string             `json:"flavor_id"`
	ImageID          string             `json:"image_id"`
	NodeCount        int                `json:"node_count"`
	MinNodeCount     int                `json:"min_node_count"`
	MaxNodeCount     *int               `json:"max_node_count"`
	DockerVolumeSize *int               `json:"docker_volume_size"`
	DockerVolumeType volumes.VolumeType `json:"docker_volume_type"`
	IsDefault        bool               `json:"is_default"`
	StackID          string             `json:"stack_id"`
	Status           string             `json:"status"`
	Role             types.PoolRole     `json:"role"`
	CreatedAt        time.Time          `json:"created_at"`
	UpdatedAt        *time.Time         `json:"updated_at"`
}

ClusterPoolList represents a cluster Pool in the list response.

func ExtractClusterPools

func ExtractClusterPools(r pagination.Page, clusterID *string) ([]ClusterPoolList, error)

ExtractClusterPools accepts a Page struct, specifically a ClusterPoolPage struct, and extracts the elements into a slice of ClusterPool structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

func ListAll(client *edgecloud.ServiceClient, clusterID string, opts ListOptsBuilder) ([]ClusterPoolList, error)

ListAll is a convenience function that returns all cluster pools.

type ClusterPoolPage

type ClusterPoolPage struct {
	pagination.LinkedPageBase
	ClusterID *string
}

ClusterPoolPage is the page returned by a pager when traversing over a collection of networks.

func (ClusterPoolPage) IsEmpty

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

IsEmpty checks whether a ClusterPool struct is empty.

func (ClusterPoolPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of cluster Pools 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 CreateOpts

type CreateOpts struct {
	Name             string             `json:"name" required:"true" validate:"required"`
	FlavorID         string             `json:"flavor_id" required:"true" validate:"required"`
	NodeCount        *int               `json:"node_count,omitempty" validate:"omitempty,gt=0"`
	DockerVolumeSize *int               `json:"docker_volume_size,omitempty" validate:"omitempty,gt=0"`
	DockerVolumeType volumes.VolumeType `json:"docker_volume_type,omitempty" validate:"omitempty,enum"`
	MinNodeCount     int                `json:"min_node_count,omitempty" validate:"omitempty,gt=0,ltefield=NodeCount"`
	MaxNodeCount     *int               `json:"max_node_count,omitempty" validate:"omitempty,gt=0,gtefield=MinNodeCount,gtefield=NodeCount"`
	Labels           map[string]string  `json:"labels,omitempty"`
	ImageID          string             `json:"image_id,omitempty"`
}

CreateOpts is used to set available fields upon node group creation.

If unset, some fields have defaults or will inherit from the cluster value.

func (CreateOpts) ToClusterPoolCreateMap

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

ToClusterPoolCreateMap builds a request body from CreateOpts.

func (CreateOpts) Validate

func (opts CreateOpts) Validate() error

Validate CreateOpts.

type CreateOptsBuilder

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

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

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

func Get

func Get(client *edgecloud.ServiceClient, clusterID, poolID string) (r GetResult)

Get retrieves a specific cluster pool based on its unique ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts a cluster Pool resource.

func (GetResult) ExtractInto

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

type ListOpts

type ListOpts struct {
	// Pagination marker for large data sets. (UUID field from node group).
	Marker int `q:"marker"`
	// Maximum number of resources to return in a single page.
	Limit int `q:"limit"`
	// Column to sort results by. Default: id.
	SortKey string `q:"sort_key"`
	// Direction to sort. "asc" or "desc". Default: asc.
	SortDir string `q:"sort_dir"`
	// List all pools with the specified role.
	Role string `q:"role"`
	// Details
	Detail bool `q:"detail"`
}

ListOpts is used to filter and sort the pool of a cluster when using List.

func (ListOpts) ToClusterPoolsListQuery

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

ToClusterPoolsListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type PoolTaskResult

type PoolTaskResult struct {
	K8sPools []string `json:"k8s_pools" mapstructure:"k8s_pools"`
}

type UpdateOpts

type UpdateOpts struct {
	Name         string `json:"name,omitempty" validate:"required_without_all=MinNodeCount MaxNodeCount,omitempty"`
	MinNodeCount int    `json:"min_node_count,omitempty" validate:"required_without_all=Name MaxNodeCount,omitempty,gt=0"`
	MaxNodeCount int    `json:"max_node_count,omitempty" validate:"required_without_all=Name MixNodeCount,omitempty,gt=0,gtefield=MinNodeCount"`
}

UpdateOpts represents options used to update a pool.

func (UpdateOpts) ToClusterPoolUpdateMap

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

ToClusterPoolUpdateMap builds a request body from UpdateOpts.

func (UpdateOpts) Validate

func (opts UpdateOpts) Validate() error

Validate UpdateOpts.

type UpdateOptsBuilder

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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