clusters

package
v0.0.0-...-e3434e5 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package clusters contains functionality for working with Magnum Cluster resources.

Example to Create a Cluster

masterCount := 1
nodeCount := 1
createTimeout := 30
opts := clusters.CreateOpts{
	ClusterTemplateID: "0562d357-8641-4759-8fed-8173f02c9633",
	CreateTimeout:     &createTimeout,
	DiscoveryURL:      "",
	FlavorID:          "m1.small",
	KeyPair:           "my_keypair",
	Labels:            map[string]string{},
	MasterCount:       &masterCount,
	MasterFlavorID:    "m1.small",
	Name:              "k8s",
	NodeCount:         &nodeCount,
}

cluster, err := clusters.Create(serviceClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Get a Cluster

clusterName := "cluster123"
cluster, err := clusters.Get(serviceClient, clusterName).Extract()
if err != nil {
	panic(err)
}
fmt.Printf("%+v\n", cluster)

Example to List Clusters

listOpts := clusters.ListOpts{
	Limit: 20,
}

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

allClusters, err := clusters.ExtractClusters(allPages)
if err != nil {
	panic(err)
}

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

Example to List Clusters with detailed information

allPagesDetail, err := clusters.ListDetail(serviceClient, clusters.ListOpts{}).AllPages()
if err != nil {
    panic(err)
}

allClustersDetail, err := clusters.ExtractClusters(allPagesDetail)
if err != nil {
    panic(err)
}

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

Example to Update a Cluster

updateOpts := []clusters.UpdateOptsBuilder{
	clusters.UpdateOpts{
		Op:    clusters.ReplaceOp,
		Path:  "/master_lb_enabled",
		Value: "True",
	},
	clusters.UpdateOpts{
		Op:    clusters.ReplaceOp,
		Path:  "/registry_enabled",
		Value: "True",
	},
}
clusterUUID, err := clusters.Update(serviceClient, clusterUUID, updateOpts).Extract()
if err != nil {
	panic(err)
}
fmt.Printf("%s\n", clusterUUID)

Example to Delete a Cluster

clusterUUID := "dc6d336e3fc4c0a951b5698cd1236ee"
err := clusters.Delete(serviceClient, clusterUUID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List returns a Pager which allows you to iterate over a collection of clusters. It accepts a ListOptsBuilder, which allows you to sort the returned collection for greater efficiency.

func ListDetail

ListDetail returns a Pager which allows you to iterate over a collection of clusters with detailed information. It accepts a ListOptsBuilder, which allows you to sort the returned collection for greater efficiency.

Types

type Cluster

type Cluster struct {
	APIAddress        string             `json:"api_address"`
	COEVersion        string             `json:"coe_version"`
	ClusterTemplateID string             `json:"cluster_template_id"`
	ContainerVersion  string             `json:"container_version"`
	CreateTimeout     int                `json:"create_timeout"`
	CreatedAt         time.Time          `json:"created_at"`
	DiscoveryURL      string             `json:"discovery_url"`
	DockerVolumeSize  int                `json:"docker_volume_size"`
	Faults            map[string]string  `json:"faults"`
	FlavorID          string             `json:"flavor_id"`
	KeyPair           string             `json:"keypair"`
	Labels            map[string]string  `json:"labels"`
	Links             []gophercloud.Link `json:"links"`
	MasterFlavorID    string             `json:"master_flavor_id"`
	MasterAddresses   []string           `json:"master_addresses"`
	MasterCount       int                `json:"master_count"`
	Name              string             `json:"name"`
	NodeAddresses     []string           `json:"node_addresses"`
	NodeCount         int                `json:"node_count"`
	ProjectID         string             `json:"project_id"`
	StackID           string             `json:"stack_id"`
	Status            string             `json:"status"`
	StatusReason      string             `json:"status_reason"`
	UUID              string             `json:"uuid"`
	UpdatedAt         time.Time          `json:"updated_at"`
	UserID            string             `json:"user_id"`
	FloatingIPEnabled bool               `json:"floating_ip_enabled"`
	FixedNetwork      string             `json:"fixed_network"`
	FixedSubnet       string             `json:"fixed_subnet"`
}

func ExtractClusters

func ExtractClusters(r pagination.Page) ([]Cluster, error)

type ClusterPage

type ClusterPage struct {
	pagination.LinkedPageBase
}

func (ClusterPage) IsEmpty

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

IsEmpty checks whether a ClusterPage struct is empty.

func (ClusterPage) NextPageURL

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

type CreateOpts

type CreateOpts struct {
	ClusterTemplateID string            `json:"cluster_template_id" required:"true"`
	CreateTimeout     *int              `json:"create_timeout"`
	DiscoveryURL      string            `json:"discovery_url,omitempty"`
	DockerVolumeSize  *int              `json:"docker_volume_size,omitempty"`
	FlavorID          string            `json:"flavor_id,omitempty"`
	Keypair           string            `json:"keypair,omitempty"`
	Labels            map[string]string `json:"labels,omitempty"`
	MasterCount       *int              `json:"master_count,omitempty"`
	MasterFlavorID    string            `json:"master_flavor_id,omitempty"`
	Name              string            `json:"name"`
	NodeCount         *int              `json:"node_count,omitempty"`
	FloatingIPEnabled *bool             `json:"floating_ip_enabled,omitempty"`
	FixedNetwork      string            `json:"fixed_network,omitempty"`
	FixedSubnet       string            `json:"fixed_subnet,omitempty"`
}

CreateOpts params

func (CreateOpts) ToClusterCreateMap

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

ToClusterCreateMap constructs a request body from CreateOpts.

type CreateOptsBuilder

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

CreateOptsBuilder Builder.

type CreateResult

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

CreateResult is the response of a Create operations.

func Create

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

Create requests the creation of a new cluster.

func (CreateResult) Extract

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

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the result from a Delete operation. Call its Extract or ExtractErr method to determine if the call succeeded or failed.

func Delete

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

Delete deletes the specified cluster ID.

type GetResult

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

GetResult represents the result of a get operation.

func Get

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

Get retrieves a specific clusters based on its unique ID.

func (GetResult) Extract

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

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

type ListOpts

type ListOpts struct {
	Marker  string `q:"marker"`
	Limit   int    `q:"limit"`
	SortKey string `q:"sort_key"`
	SortDir string `q:"sort_dir"`
}

ListOpts allows the sorting of paginated collections through the API. SortKey allows you to sort by a particular cluster attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.

func (ListOpts) ToClustersListQuery

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

ToClustersListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type ResizeOpts

type ResizeOpts struct {
	NodeCount     *int     `json:"node_count" required:"true"`
	NodesToRemove []string `json:"nodes_to_remove,omitempty"`
	NodeGroup     string   `json:"nodegroup,omitempty"`
}

ResizeOpts params

func (ResizeOpts) ToClusterResizeMap

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

ToClusterResizeMap constructs a request body from ResizeOpts.

type ResizeOptsBuilder

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

ResizeOptsBuilder allows extensions to add additional parameters to the Resize request.

type ResizeResult

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

ResizeResult is the response of a Resize operations.

func Resize

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

Resize an existing cluster node count.

func (ResizeResult) Extract

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

type UpdateOp

type UpdateOp string
const (
	AddOp     UpdateOp = "add"
	RemoveOp  UpdateOp = "remove"
	ReplaceOp UpdateOp = "replace"
)

type UpdateOpts

type UpdateOpts struct {
	Op    UpdateOp    `json:"op" required:"true"`
	Path  string      `json:"path" required:"true"`
	Value interface{} `json:"value,omitempty"`
}

func (UpdateOpts) ToClustersUpdateMap

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

ToClusterUpdateMap assembles a request body based on the contents of UpdateOpts.

type UpdateOptsBuilder

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

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

type UpdateResult

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

UpdateResult is the response of a Update operations.

func Update

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

Update implements cluster updated request.

func (UpdateResult) Extract

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

Jump to

Keyboard shortcuts

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