Help us shape the future of Go! Take the 2026 Go Developer Survey

clustertemplates

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package clustertemplates contains functionality for working with Magnum Cluster Templates resources.

Package clustertemplates provides information and interaction with the cluster-templates through the OpenStack Container Infra service.

Example to Create Cluster Template

boolFalse := false
boolTrue := true
createOpts := clustertemplates.CreateOpts{
	Name:                "test-cluster-template",
	Labels:              map[string]string{},
	FixedSubnet:         "",
	MasterFlavorID:      "",
	NoProxy:             "10.0.0.0/8,172.0.0.0/8,192.0.0.0/8,localhost",
	HTTPSProxy:          "http://10.164.177.169:8080",
	TLSDisabled:         &boolFalse,
	KeyPairID:           "kp",
	Public:              &boolFalse,
	HTTPProxy:           "http://10.164.177.169:8080",
	ServerType:          "vm",
	ExternalNetworkID:   "public",
	ImageID:             "fedora-atomic-latest",
	VolumeDriver:        "cinder",
	RegistryEnabled:     &boolFalse,
	DockerStorageDriver: "devicemapper",
	NetworkDriver:       "flannel",
	FixedNetwork:        "",
	COE:                 "kubernetes",
	FlavorID:            "m1.small",
	MasterLBEnabled:     &boolTrue,
	DNSNameServer:       "8.8.8.8",
}

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

Example to Delete Cluster Template

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

Example to List Clusters Templates

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

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

allClusterTemplates, err := clusters.ExtractClusterTemplates(allPages)
if err != nil {
	panic(err)
}

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

Example to Update Cluster Template

updateOpts := []clustertemplates.UpdateOptsBuilder{
	clustertemplates.UpdateOpts{
		Op:    clustertemplates.ReplaceOp,
		Path:  "/master_lb_enabled",
		Value: "True",
	},
	clustertemplates.UpdateOpts{
		Op:    clustertemplates.ReplaceOp,
		Path:  "/registry_enabled",
		Value: "True",
	},
}

clustertemplate, err := clustertemplates.Update(serviceClient, updateOpts).Extract()
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 cluster-templates. It accepts a ListOptsBuilder, which allows you to sort the returned collection for greater efficiency.

Types

type ClusterTemplate

type ClusterTemplate struct {
	APIServerPort       int                `json:"apiserver_port"`
	COE                 string             `json:"coe"`
	ClusterDistro       string             `json:"cluster_distro"`
	CreatedAt           time.Time          `json:"created_at"`
	DNSNameServer       string             `json:"dns_nameserver"`
	DockerStorageDriver string             `json:"docker_storage_driver"`
	DockerVolumeSize    int                `json:"docker_volume_size"`
	ExternalNetworkID   string             `json:"external_network_id"`
	FixedNetwork        string             `json:"fixed_network"`
	FixedSubnet         string             `json:"fixed_subnet"`
	FlavorID            string             `json:"flavor_id"`
	FloatingIPEnabled   bool               `json:"floating_ip_enabled"`
	HTTPProxy           string             `json:"http_proxy"`
	HTTPSProxy          string             `json:"https_proxy"`
	ImageID             string             `json:"image_id"`
	InsecureRegistry    string             `json:"insecure_registry"`
	KeyPairID           string             `json:"keypair_id"`
	Labels              map[string]string  `json:"labels"`
	Links               []gophercloud.Link `json:"links"`
	MasterFlavorID      string             `json:"master_flavor_id"`
	MasterLBEnabled     bool               `json:"master_lb_enabled"`
	Name                string             `json:"name"`
	NetworkDriver       string             `json:"network_driver"`
	NoProxy             string             `json:"no_proxy"`
	ProjectID           string             `json:"project_id"`
	Public              bool               `json:"public"`
	RegistryEnabled     bool               `json:"registry_enabled"`
	ServerType          string             `json:"server_type"`
	TLSDisabled         bool               `json:"tls_disabled"`
	UUID                string             `json:"uuid"`
	UpdatedAt           time.Time          `json:"updated_at"`
	UserID              string             `json:"user_id"`
	VolumeDriver        string             `json:"volume_driver"`
}

Represents a template for a Cluster Template

func ExtractClusterTemplates

func ExtractClusterTemplates(r pagination.Page) ([]ClusterTemplate, error)

ExtractClusterTemplates accepts a Page struct, specifically a ClusterTemplatePage struct, and extracts the elements into a slice of cluster templates structs. In other words, a generic collection is mapped into a relevant slice.

type ClusterTemplatePage

type ClusterTemplatePage struct {
	pagination.LinkedPageBase
}

ClusterTemplatePage is the page returned by a pager when traversing over a collection of cluster-templates.

func (ClusterTemplatePage) IsEmpty

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

IsEmpty checks whether a ClusterTemplatePage struct is empty.

func (ClusterTemplatePage) NextPageURL

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

NextPageURL is invoked when a paginated collection of cluster template 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 {
	APIServerPort       *int              `json:"apiserver_port,omitempty"`
	COE                 string            `json:"coe" required:"true"`
	DNSNameServer       string            `json:"dns_nameserver,omitempty"`
	DockerStorageDriver string            `json:"docker_storage_driver,omitempty"`
	DockerVolumeSize    *int              `json:"docker_volume_size,omitempty"`
	ExternalNetworkID   string            `json:"external_network_id,omitempty"`
	FixedNetwork        string            `json:"fixed_network,omitempty"`
	FixedSubnet         string            `json:"fixed_subnet,omitempty"`
	FlavorID            string            `json:"flavor_id,omitempty"`
	FloatingIPEnabled   *bool             `json:"floating_ip_enabled,omitempty"`
	HTTPProxy           string            `json:"http_proxy,omitempty"`
	HTTPSProxy          string            `json:"https_proxy,omitempty"`
	ImageID             string            `json:"image_id" required:"true"`
	InsecureRegistry    string            `json:"insecure_registry,omitempty"`
	KeyPairID           string            `json:"keypair_id,omitempty"`
	Labels              map[string]string `json:"labels,omitempty"`
	MasterFlavorID      string            `json:"master_flavor_id,omitempty"`
	MasterLBEnabled     *bool             `json:"master_lb_enabled,omitempty"`
	Name                string            `json:"name,omitempty"`
	NetworkDriver       string            `json:"network_driver,omitempty"`
	NoProxy             string            `json:"no_proxy,omitempty"`
	Public              *bool             `json:"public,omitempty"`
	RegistryEnabled     *bool             `json:"registry_enabled,omitempty"`
	ServerType          string            `json:"server_type,omitempty"`
	TLSDisabled         *bool             `json:"tls_disabled,omitempty"`
	VolumeDriver        string            `json:"volume_driver,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() (*ClusterTemplate, error)

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

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the result 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 deletes the specified cluster ID.

type GetResult

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

GetResult is the response of a Get operations.

func Get

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

Get retrieves a specific cluster-template based on its unique ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts a cluster-template 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 templates attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.

func (ListOpts) ToClusterTemplateListQuery

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

ToClusterTemplateListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

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

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

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

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToClusterTemplateUpdateMap() (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() (*ClusterTemplate, error)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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