capsules

package
v1.1.31 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package capsules contains functionality for working with Zun capsule resources. A capsule is a container group, as the co-located and co-scheduled unit, is the same like pod in Kubernetes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCapsules

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

ExtractCapsules accepts a Page struct, specifically a CapsulePage struct, and extracts the elements into an interface. This interface should be able to be casted as either a Capsule or CapsuleV132 struct

func List

List makes a request against the API to list capsules accessible to you.

Types

type Address

type Address struct {
	PreserveOnDelete bool    `json:"preserve_on_delete"`
	Addr             string  `json:"addr"`
	Port             string  `json:"port"`
	Version          float64 `json:"version"`
	SubnetID         string  `json:"subnet_id"`
}

type Capsule

type Capsule struct {
	// UUID for the capsule
	UUID string `json:"uuid"`

	// User ID for the capsule
	UserID string `json:"user_id"`

	// Project ID for the capsule
	ProjectID string `json:"project_id"`

	// cpu for the capsule
	CPU float64 `json:"cpu"`

	// Memory for the capsule
	Memory string `json:"memory"`

	// The name of the capsule
	MetaName string `json:"meta_name"`

	// Indicates whether capsule is currently operational.
	Status string `json:"status"`

	// Indicates whether capsule is currently operational.
	StatusReason string `json:"status_reason"`

	// The created time of the capsule.
	CreatedAt time.Time `json:"-"`

	// The updated time of the capsule.
	UpdatedAt time.Time `json:"-"`

	// Links includes HTTP references to the itself, useful for passing along to
	// other APIs that might want a capsule reference.
	Links []interface{} `json:"links"`

	// The capsule version
	CapsuleVersion string `json:"capsule_version"`

	// The capsule restart policy
	RestartPolicy string `json:"restart_policy"`

	// The capsule metadata labels
	MetaLabels map[string]string `json:"meta_labels"`

	// The list of containers uuids inside capsule.
	ContainersUUIDs []string `json:"containers_uuids"`

	// The capsule IP addresses
	Addresses map[string][]Address `json:"addresses"`

	// The capsule volume attached information
	VolumesInfo map[string][]string `json:"volumes_info"`

	// The container object inside capsule
	Containers []Container `json:"containers"`

	// The capsule host
	Host string `json:"host"`
}

Represents a Capsule

func ExtractCapsulesBase

func ExtractCapsulesBase(r pagination.Page) ([]Capsule, error)

ExtractCapsulesBase accepts a Page struct, specifically a CapsulePage struct, and extracts the elements into a slice of Capsule structs. In other words, a generic collection is mapped into the relevant slice.

func (*Capsule) UnmarshalJSON

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

type CapsulePage

type CapsulePage struct {
	pagination.LinkedPageBase
}

func (CapsulePage) IsEmpty

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

IsEmpty checks whether a CapsulePage struct is empty.

func (CapsulePage) NextPageURL

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

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

type CapsuleV132 struct {
	// UUID for the capsule
	UUID string `json:"uuid"`

	// User ID for the capsule
	UserID string `json:"user_id"`

	// Project ID for the capsule
	ProjectID string `json:"project_id"`

	// cpu for the capsule
	CPU float64 `json:"cpu"`

	// Memory for the capsule
	Memory string `json:"memory"`

	// The name of the capsule
	MetaName string `json:"name"`

	// Indicates whether capsule is currently operational.
	Status string `json:"status"`

	// Indicates whether capsule is currently operational.
	StatusReason string `json:"status_reason"`

	// The created time of the capsule.
	CreatedAt time.Time `json:"-"`

	// The updated time of the capsule.
	UpdatedAt time.Time `json:"-"`

	// Links includes HTTP references to the itself, useful for passing along to
	// other APIs that might want a capsule reference.
	Links []interface{} `json:"links"`

	// The capsule restart policy
	RestartPolicy map[string]string `json:"restart_policy"`

	// The capsule metadata labels
	MetaLabels map[string]string `json:"labels"`

	// The capsule IP addresses
	Addresses map[string][]Address `json:"addresses"`

	// The container object inside capsule
	Containers []Container `json:"containers"`

	// The capsule host
	Host string `json:"host"`
}

Represents a Capsule at microversion v1.32 or greater.

func ExtractCapsulesV132

func ExtractCapsulesV132(r pagination.Page) ([]CapsuleV132, error)

ExtractCapsulesV132 accepts a Page struct, specifically a CapsulePage struct, and extracts the elements into a slice of CapsuleV132 structs. In other words, a generic collection is mapped into a relevant slice.

func (*CapsuleV132) UnmarshalJSON

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

type Container

type Container struct {
	// The Container IP addresses
	Addresses map[string][]Address `json:"addresses"`

	// UUID for the container
	UUID string `json:"uuid"`

	// User ID for the container
	UserID string `json:"user_id"`

	// Project ID for the container
	ProjectID string `json:"project_id"`

	// cpu for the container
	CPU float64 `json:"cpu"`

	// Memory for the container
	Memory string `json:"memory"`

	// Image for the container
	Image string `json:"image"`

	// The container container
	Labels map[string]string `json:"labels"`

	// The created time of the container
	CreatedAt time.Time `json:"-"`

	// The updated time of the container
	UpdatedAt time.Time `json:"-"`

	// The started time of the container
	StartedAt time.Time `json:"-"`

	// Name for the container
	Name string `json:"name"`

	// Links includes HTTP references to the itself, useful for passing along to
	// other APIs that might want a capsule reference.
	Links []interface{} `json:"links"`

	// auto remove flag token for the container
	AutoRemove bool `json:"auto_remove"`

	// Host for the container
	Host string `json:"host"`

	// Work directory for the container
	WorkDir string `json:"workdir"`

	// Disk for the container
	Disk int `json:"disk"`

	// Image pull policy for the container
	ImagePullPolicy string `json:"image_pull_policy"`

	// Task state for the container
	TaskState string `json:"task_state"`

	// Host name for the container
	HostName string `json:"hostname"`

	// Environment for the container
	Environment map[string]string `json:"environment"`

	// Status for the container
	Status string `json:"status"`

	// Auto Heal flag for the container
	AutoHeal bool `json:"auto_heal"`

	// Status details for the container
	StatusDetail string `json:"status_detail"`

	// Status reason for the container
	StatusReason string `json:"status_reason"`

	// Image driver for the container
	ImageDriver string `json:"image_driver"`

	// Command for the container
	Command []string `json:"command"`

	// Image for the container
	Runtime string `json:"runtime"`

	// Interactive flag for the container
	Interactive bool `json:"interactive"`

	// Restart Policy for the container
	RestartPolicy map[string]string `json:"restart_policy"`

	// Ports information for the container
	Ports []int `json:"ports"`

	// Security groups for the container
	SecurityGroups []string `json:"security_groups"`
}

func (*Container) UnmarshalJSON

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

type CreateOpts

type CreateOpts 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"`
}

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

func (CreateOpts) ToCapsuleCreateMap

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

ToCapsuleCreateMap assembles a request body based on the contents of a CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToCapsuleCreateMap() (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 {
	// contains filtered or unexported fields
}

CreateResult is the response from a Create operation. Call its Extract method to interpret it as a Capsule.

func Create

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

Create implements create capsule request.

func (CreateResult) Extract

func (r CreateResult) Extract() (interface{}, error)

Extract is a function that accepts a result and extracts a capsule result. The result will be returned as an interface{} where it should be able to be casted as either a Capsule or CapsuleV132.

func (CreateResult) ExtractBase

func (r CreateResult) ExtractBase() (*Capsule, error)

ExtractBase is a function that accepts a result and extracts a base a capsule resource.

func (CreateResult) ExtractV132

func (r CreateResult) ExtractV132() (*CapsuleV132, error)

ExtractV132 is a function that accepts a result and extracts a capsule resource.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a delete operation.

func Delete

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

Delete implements Capsule delete request.

type ErrInvalidDataFormat

type ErrInvalidDataFormat struct {
	gophercloud.BaseError
}

func (ErrInvalidDataFormat) Error

func (e ErrInvalidDataFormat) Error() string

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 requests details on a single capsule, by ID.

func (GetResult) Extract

func (r GetResult) Extract() (interface{}, error)

Extract is a function that accepts a result and extracts a capsule result. The result will be returned as an interface{} where it should be able to be casted as either a Capsule or CapsuleV132.

func (GetResult) ExtractBase

func (r GetResult) ExtractBase() (*Capsule, error)

ExtractBase is a function that accepts a result and extracts a base a capsule resource.

func (GetResult) ExtractV132

func (r GetResult) ExtractV132() (*CapsuleV132, error)

ExtractV132 is a function that accepts a result and extracts a capsule resource.

type ListOpts

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

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 capsule attributes you want to see returned. Marker and Limit are used for pagination.

func (ListOpts) ToCapsuleListQuery

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

ToCapsuleListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type Template

type Template struct {
	// Bin stores the contents of the template or environment.
	Bin []byte
	// 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{}
}

Template is a structure that represents OpenStack Zun Capsule templates

func (*Template) Parse

func (t *Template) Parse() error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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