stacks

package
Version: v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package stacks provides operation for working with Heat stacks. A stack is a group of resources (servers, load balancers, databases, and so forth) combined to fulfill a useful purpose. Based on a template, Heat orchestration engine creates an instantiated set of resources (a stack) to run the application framework or component specified (in the template). A stack is a running instance of a template. The result of creating a stack is a deployment of the application framework or component.

Index

Constants

View Source
const InvalidEnvironment = `` /* 320-byte string literal not displayed */

InvalidEnvironment is an invalid environment as it has an extra section called `resources`

View Source
const InvalidTemplateNoVersion = `` /* 304-byte string literal not displayed */

InvalidTemplateNoVersion is an invalid template as it has no `version` section

View Source
const ValidJSONEnvironment = `` /* 839-byte string literal not displayed */

ValidJSONEnvironment is a valid environment for a stack in JSON format

View Source
const ValidJSONTemplate = `` /* 458-byte string literal not displayed */

ValidJSONTemplate is a valid OpenStack Heat template in JSON format

View Source
const ValidYAMLEnvironment = `` /* 886-byte string literal not displayed */

ValidYAMLEnvironment is a valid environment for a stack in YAML format

View Source
const ValidYAMLTemplate = `` /* 338-byte string literal not displayed */

ValidYAMLTemplate is a valid OpenStack Heat template in YAML format

Variables

View Source
var (
	// SortAsc is used to sort a list of stacks in ascending order.
	SortAsc SortDir = "asc"
	// SortDesc is used to sort a list of stacks in descending order.
	SortDesc SortDir = "desc"
	// SortName is used to sort a list of stacks by name.
	SortName SortKey = "name"
	// SortStatus is used to sort a list of stacks by status.
	SortStatus SortKey = "status"
	// SortCreatedAt is used to sort a list of stacks by date created.
	SortCreatedAt SortKey = "created_at"
	// SortUpdatedAt is used to sort a list of stacks by date updated.
	SortUpdatedAt SortKey = "updated_at"
)
View Source
var EnvironmentSections = map[string]bool{
	"parameters":         true,
	"parameter_defaults": true,
	"resource_registry":  true,
}

EnvironmentSections is a map containing allowed sections in a stack environment file

View Source
var TemplateFormatVersions = map[string]bool{
	"HeatTemplateFormatVersion": true,
	"heat_template_version":     true,
	"AWSTemplateFormatVersion":  true,
}

TemplateFormatVersions is a map containing allowed variations of the template format version Note that this contains the permitted variations of the _keys_ not the values.

View Source
var ValidJSONEnvironmentParsed = map[string]interface{}{
	"parameters": map[string]interface{}{
		"user_key": "userkey",
	},
	"resource_registry": map[string]interface{}{
		"My::WP::Server":         "file:///home/shardy/git/heat-templates/hot/F18/WordPress_Native.yaml",
		"OS::Quantum*":           "OS::Neutron*",
		"AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml",
		"OS::Metering::Alarm":    "OS::Ceilometer::Alarm",
		"AWS::RDS::DBInstance":   "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml",
		"resources": map[string]interface{}{
			"my_db_server": map[string]interface{}{
				"OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
			},
			"my_server": map[string]interface{}{
				"OS::DBInstance": "file:///home/mine/all_my_cool_templates/db.yaml",
				"hooks":          "pre-create",
			},
			"nested_stack": map[string]interface{}{
				"nested_resource": map[string]interface{}{
					"hooks": "pre-update",
				},
				"another_resource": map[string]interface{}{
					"hooks": []interface{}{
						"pre-create",
						"pre-update",
					},
				},
			},
		},
	},
}

ValidJSONEnvironmentParsed is the expected parsed version of ValidJSONEnvironment

View Source
var ValidJSONTemplateParsed = map[string]interface{}{
	"heat_template_version": "2014-10-16",
	"parameters": map[string]interface{}{
		"flavor": map[string]interface{}{
			"default":     "debian2G",
			"description": "Flavor for the server to be created",
			"hidden":      true,
			"type":        "string",
		},
	},
	"resources": map[string]interface{}{
		"test_server": map[string]interface{}{
			"properties": map[string]interface{}{
				"flavor": "2 GB General Purpose v1",
				"image":  "Debian 7 (Wheezy) (PVHVM)",
				"name":   "test-server",
			},
			"type": "OS::Nova::Server",
		},
	},
}

ValidJSONTemplateParsed is the expected parsed version of ValidJSONTemplate

Functions

func List

List returns a Pager which allows you to iterate over a collection of stacks. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Types

type AbandonResult

type AbandonResult struct {
	gophercloud.Result
}

AbandonResult represents the result of an Abandon operation.

func Abandon

func Abandon(c *gophercloud.ServiceClient, stackName, stackID string) (r AbandonResult)

Abandon deletes the stack with the provided stackName and stackID, but leaves its resources intact, and returns data describing the stack and its resources.

func (AbandonResult) Extract

func (r AbandonResult) Extract() (*AbandonedStack, error)

Extract returns a pointer to an AbandonedStack object and is called after an Abandon operation.

func (AbandonResult) String

func (r AbandonResult) String() (string, error)

String converts an AbandonResult to a string. This is useful to when passing the result of an Abandon operation to an AdoptOpts AdoptStackData field.

type AbandonedStack

type AbandonedStack struct {
	Status             string                 `json:"status"`
	Name               string                 `json:"name"`
	Template           map[string]interface{} `json:"template"`
	Action             string                 `json:"action"`
	ID                 string                 `json:"id"`
	Resources          map[string]interface{} `json:"resources"`
	Files              map[string]string      `json:"files"`
	StackUserProjectID string                 `json:"stack_user_project_id"`
	ProjectID          string                 `json:"project_id"`
	Environment        map[string]interface{} `json:"environment"`
}

AbandonedStack represents the result of an Abandon operation.

type AdoptOpts

type AdoptOpts struct {
	// Existing resources data represented as a string to add to the
	// new stack. Data returned by Abandon could be provided as AdoptsStackData.
	AdoptStackData string `json:"adopt_stack_data" required:"true"`
	// The name of the stack. It must start with an alphabetic character.
	Name string `json:"stack_name" required:"true"`
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	TemplateOpts *Template `json:"-" required:"true"`
	// The timeout for stack creation in minutes.
	Timeout int `json:"timeout_mins,omitempty"`
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	//TemplateOpts *Template `json:"-" required:"true"`
	// Enables or disables deletion of all stack resources when a stack
	// creation fails. Default is true, meaning all resources are not deleted when
	// stack creation fails.
	DisableRollback *bool `json:"disable_rollback,omitempty"`
	// A structure that contains details for the environment of the stack.
	EnvironmentOpts *Environment `json:"-"`
	// User-defined parameters to pass to the template.
	Parameters map[string]string `json:"parameters,omitempty"`
}

AdoptOpts is the common options struct used in this package's Adopt operation.

func (AdoptOpts) ToStackAdoptMap

func (opts AdoptOpts) ToStackAdoptMap() (map[string]interface{}, error)

ToStackAdoptMap casts a CreateOpts struct to a map.

type AdoptOptsBuilder

type AdoptOptsBuilder interface {
	ToStackAdoptMap() (map[string]interface{}, error)
}

AdoptOptsBuilder is the interface options structs have to satisfy in order to be used in the Adopt function in this package. Since many extensions decorate or modify the common logic, it is useful for them to satisfy a basic interface in order for them to be used.

type AdoptResult

type AdoptResult struct {
	CreateResult
}

AdoptResult represents the result of an Adopt operation. AdoptResult has the same form as CreateResult.

func Adopt

Adopt accepts an AdoptOpts struct and creates a new stack using the resources from another stack.

type Client

type Client interface {
	Get(string) (*http.Response, error)
}

Client is an interface that expects a Get method similar to http.Get. This is needed for unit testing, since we can mock an http client. Thus, the client will usually be an http.Client EXCEPT in unit tests.

type CreateOpts

type CreateOpts struct {
	// The name of the stack. It must start with an alphabetic character.
	Name string `json:"stack_name" required:"true"`
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	TemplateOpts *Template `json:"-" required:"true"`
	// Enables or disables deletion of all stack resources when a stack
	// creation fails. Default is true, meaning all resources are not deleted when
	// stack creation fails.
	DisableRollback *bool `json:"disable_rollback,omitempty"`
	// A structure that contains details for the environment of the stack.
	EnvironmentOpts *Environment `json:"-"`
	// User-defined parameters to pass to the template.
	Parameters map[string]string `json:"parameters,omitempty"`
	// The timeout for stack creation in minutes.
	Timeout int `json:"timeout_mins,omitempty"`
	// A list of tags to assosciate with the Stack
	Tags []string `json:"-"`
}

CreateOpts is the common options struct used in this package's Create operation.

func (CreateOpts) ToStackCreateMap

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

ToStackCreateMap casts a CreateOpts struct to a map.

type CreateOptsBuilder

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

CreateOptsBuilder is the interface options structs have to satisfy in order to be used in the main Create operation in this package. Since many extensions decorate or modify the common logic, it is useful for them to satisfy a basic interface in order for them to be used.

type CreateResult

type CreateResult struct {
	gophercloud.Result
}

CreateResult represents the result of a Create operation.

func Create

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

func (CreateResult) Extract

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

Extract returns a pointer to a CreatedStack object and is called after a Create operation.

type CreatedStack

type CreatedStack struct {
	ID    string             `json:"id"`
	Links []gophercloud.Link `json:"links"`
}

CreatedStack represents the object extracted from a Create operation.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a Delete operation.

func Delete

func Delete(c *gophercloud.ServiceClient, stackName, stackID string) (r DeleteResult)

Delete deletes a stack based on the stack name and stack ID.

type Environment

type Environment struct {
	TE
}

Environment is a structure that represents stack environments

func (*Environment) Validate

func (e *Environment) Validate() error

Validate validates the contents of the Environment

type GetResult

type GetResult struct {
	gophercloud.Result
}

GetResult represents the result of a Get operation.

func Get

func Get(c *gophercloud.ServiceClient, stackName, stackID string) (r GetResult)

Get retreives a stack based on the stack name and stack ID.

func (GetResult) Extract

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

Extract returns a pointer to a RetrievedStack object and is called after a Get operation.

type ListOpts

type ListOpts struct {
	Status  string  `q:"status"`
	Name    string  `q:"name"`
	Marker  string  `q:"marker"`
	Limit   int     `q:"limit"`
	SortKey SortKey `q:"sort_keys"`
	SortDir SortDir `q:"sort_dir"`
}

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 network attributes you want to see returned. SortKey allows you to sort by a particular network attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.

func (ListOpts) ToStackListQuery

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

ToStackListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type ListedStack

type ListedStack struct {
	CreationTime time.Time          `json:"-"`
	Description  string             `json:"description"`
	ID           string             `json:"id"`
	Links        []gophercloud.Link `json:"links"`
	Name         string             `json:"stack_name"`
	Status       string             `json:"stack_status"`
	StatusReason string             `json:"stack_status_reason"`
	Tags         []string           `json:"tags"`
	UpdatedTime  time.Time          `json:"-"`
}

ListedStack represents an element in the slice extracted from a List operation.

func ExtractStacks

func ExtractStacks(r pagination.Page) ([]ListedStack, error)

ExtractStacks extracts and returns a slice of ListedStack. It is used while iterating over a stacks.List call.

func (*ListedStack) UnmarshalJSON

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

type PreviewOpts

type PreviewOpts struct {
	// The name of the stack. It must start with an alphabetic character.
	Name string `json:"stack_name" required:"true"`
	// The timeout for stack creation in minutes.
	Timeout int `json:"timeout_mins" required:"true"`
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	TemplateOpts *Template `json:"-" required:"true"`
	// Enables or disables deletion of all stack resources when a stack
	// creation fails. Default is true, meaning all resources are not deleted when
	// stack creation fails.
	DisableRollback *bool `json:"disable_rollback,omitempty"`
	// A structure that contains details for the environment of the stack.
	EnvironmentOpts *Environment `json:"-"`
	// User-defined parameters to pass to the template.
	Parameters map[string]string `json:"parameters,omitempty"`
}

PreviewOpts contains the common options struct used in this package's Preview operation.

func (PreviewOpts) ToStackPreviewMap

func (opts PreviewOpts) ToStackPreviewMap() (map[string]interface{}, error)

ToStackPreviewMap casts a PreviewOpts struct to a map.

type PreviewOptsBuilder

type PreviewOptsBuilder interface {
	ToStackPreviewMap() (map[string]interface{}, error)
}

PreviewOptsBuilder is the interface options structs have to satisfy in order to be used in the Preview operation in this package.

type PreviewResult

type PreviewResult struct {
	gophercloud.Result
}

PreviewResult represents the result of a Preview operation.

func Preview

Preview accepts a PreviewOptsBuilder interface and creates a preview of a stack using the values provided.

func (PreviewResult) Extract

func (r PreviewResult) Extract() (*PreviewedStack, error)

Extract returns a pointer to a PreviewedStack object and is called after a Preview operation.

type PreviewedStack

type PreviewedStack struct {
	Capabilities        []interface{}      `json:"capabilities"`
	CreationTime        time.Time          `json:"-"`
	Description         string             `json:"description"`
	DisableRollback     bool               `json:"disable_rollback"`
	ID                  string             `json:"id"`
	Links               []gophercloud.Link `json:"links"`
	Name                string             `json:"stack_name"`
	NotificationTopics  []interface{}      `json:"notification_topics"`
	Parameters          map[string]string  `json:"parameters"`
	Resources           []interface{}      `json:"resources"`
	TemplateDescription string             `json:"template_description"`
	Timeout             int                `json:"timeout_mins"`
	UpdatedTime         time.Time          `json:"-"`
}

PreviewedStack represents the result of a Preview operation.

func (*PreviewedStack) UnmarshalJSON

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

type RetrievedStack

type RetrievedStack struct {
	Capabilities        []interface{}            `json:"capabilities"`
	CreationTime        time.Time                `json:"-"`
	Description         string                   `json:"description"`
	DisableRollback     bool                     `json:"disable_rollback"`
	ID                  string                   `json:"id"`
	Links               []gophercloud.Link       `json:"links"`
	NotificationTopics  []interface{}            `json:"notification_topics"`
	Outputs             []map[string]interface{} `json:"outputs"`
	Parameters          map[string]string        `json:"parameters"`
	Name                string                   `json:"stack_name"`
	Status              string                   `json:"stack_status"`
	StatusReason        string                   `json:"stack_status_reason"`
	Tags                []string                 `json:"tags"`
	TemplateDescription string                   `json:"template_description"`
	Timeout             int                      `json:"timeout_mins"`
	UpdatedTime         time.Time                `json:"-"`
}

RetrievedStack represents the object extracted from a Get operation.

func (*RetrievedStack) UnmarshalJSON

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

type SortDir

type SortDir string

SortDir is a type for specifying in which direction to sort a list of stacks.

type SortKey

type SortKey string

SortKey is a type for specifying by which key to sort a list of stacks.

type StackPage

type StackPage struct {
	pagination.SinglePageBase
}

StackPage is a pagination.Pager that is returned from a call to the List function.

func (StackPage) IsEmpty

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

IsEmpty returns true if a ListResult contains no Stacks.

type TE

type TE struct {
	// Bin stores the contents of the template or environment.
	Bin []byte
	// URL stores the URL of the template. This is allowed to be a 'file://'
	// for local files.
	URL string
	// Parsed contains a parsed version of Bin. Since there are 2 different
	// fields referring to the same value, you must be careful when accessing
	// this filed.
	Parsed map[string]interface{}
	// Files contains a mapping between the urls in templates to their contents.
	Files map[string]string
	// contains filtered or unexported fields
}

TE is a base structure for both Template and Environment

func (*TE) Fetch

func (t *TE) Fetch() error

Fetch fetches the contents of a TE from its URL. Once a TE structure has a URL, call the fetch method to fetch the contents.

func (*TE) Parse

func (t *TE) Parse() error

Parse will parse the contents and then validate. The contents MUST be either JSON or YAML.

func (*TE) Validate

func (t *TE) Validate() error

Validate validates the contents of TE

type Template

type Template struct {
	TE
}

Template is a structure that represents OpenStack Heat templates

func (*Template) Validate

func (t *Template) Validate() error

Validate validates the contents of the Template

type UpdateOpts

type UpdateOpts struct {
	// A structure that contains either the template file or url. Call the
	// associated methods to extract the information relevant to send in a create request.
	TemplateOpts *Template `json:"-" required:"true"`
	// A structure that contains details for the environment of the stack.
	EnvironmentOpts *Environment `json:"-"`
	// User-defined parameters to pass to the template.
	Parameters map[string]string `json:"parameters,omitempty"`
	// The timeout for stack creation in minutes.
	Timeout int `json:"timeout_mins,omitempty"`
	// A list of tags to assosciate with the Stack
	Tags []string `json:"-"`
}

UpdateOpts contains the common options struct used in this package's Update operation.

func (UpdateOpts) ToStackUpdateMap

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

ToStackUpdateMap casts a CreateOpts struct to a map.

type UpdateOptsBuilder

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

UpdateOptsBuilder is the interface options structs have to satisfy in order to be used in the Update operation in this package.

type UpdateResult

type UpdateResult struct {
	gophercloud.ErrResult
}

UpdateResult represents the result of a Update operation.

func Update

func Update(c *gophercloud.ServiceClient, stackName, stackID string, opts UpdateOptsBuilder) (r UpdateResult)

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

Directories

Path Synopsis
orchestration_stacks_v1
orchestration_stacks_v1

Jump to

Keyboard shortcuts

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