openstack

package
v0.0.0-...-8943671 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

OpenStack Client with Golang

Index

Constants

View Source
const (
	V2   = "v2"
	V2_0 = "v2.0"
	V2_1 = "v2.1"
	V3   = "v3"

	IDENTITY  = "identity"
	NETWORK   = "network"
	VOLUME    = "volume"
	VOLUME_V2 = "volumev2"
	VOLUME_V3 = "volumev3"
	STORAGE   = "storage"
	COMPUTE   = "compute"
	IMAGE     = "image"

	KEYSTONE  = "keystone"
	NOVA      = "nova"
	CINDER    = "cinder"
	CINDER_V2 = "cinderv2"
	CINDER_V3 = "cinderv3"
	GLANCE    = "glance"
	NEUTRON   = "neutron"

	PUBLIC   = "public"
	INTERNAL = "internal"
	ADMIN    = "admin"
)

Variables

View Source
var COMPUTE_API_VERSION string

Functions

func CloudName

func CloudName() string

func LoadConfig

func LoadConfig(file ...string) (err error)

func SetCloudName

func SetCloudName(name string)

func SetOpenstackConfig

func SetOpenstackConfig(c Config)

Types

type Api

type Api struct {
	Version string `yaml:"version"`
}

type Auth

type Auth struct {
	AuthUrl         string `yaml:"auth_url" mapstructure:"auth_url"`
	ProjectDomainId string `yaml:"project_domain_id" mapstructure:"project_domain_id"`
	UserDomainId    string `yaml:"user_domain_id" mapstructure:"user_domain_id"`
	ProjectName     string `yaml:"project_name" mapstructure:"project_name"`
	Username        string `yaml:"username" mapstructure:"username"`
	Password        string `yaml:"password" mapstructure:"password"`
}

type Cloud

type Cloud struct {
	TokenExpireTime int         `yaml:"tokenExpireTime"`
	Identity        Identity    `yaml:"identity"`
	Neutron         NeutronConf `yaml:"neutron"`
	Compute         Compute     `yaml:"compute"`
	RegionName      string      `yaml:"region_name" mapstructure:"region_name"`
	Auth            Auth        `yaml:"auth"`
}

func CloudConfig

func CloudConfig() Cloud

func (Cloud) Region

func (c Cloud) Region() string

type Compute

type Compute struct {
	Api Api `yaml:"api"`
}

type Config

type Config struct {
	HttpTimeoutSecond   int `yaml:"httpTimeoutSecond"`
	RetryWaitTimeSecond int `yaml:"retryWaitTimeSecond"`
	RetryCount          int `yaml:"retryCount"`

	Clouds map[string]Cloud `yaml:"clouds"`
}
var CONF Config

type Identity

type Identity struct {
	Api Api `yaml:"api"`
}

type NeutronConf

type NeutronConf struct {
	Endpoint string `yaml:"endpoint"`
}

type Openstack

type Openstack struct {
	AuthPlugin        auth_plugin.AuthPlugin
	ComputeApiVersion string
	// contains filtered or unexported fields
}

func Connect

func Connect(name ...string) (*Openstack, error)

如果指定 cloud 名称, 优先使用 cloud对应的配置; 否则从环境变量读取 cloud; 最后,使用默认的cloud.

func GetOne

func GetOne(name string) (*Openstack, error)

func NewClient

func NewClient(authUrl string, user model.User, project model.Project, regionName string) *Openstack

func (*Openstack) CinderV2

func (o *Openstack) CinderV2() *internal.CinderV2

func (*Openstack) GlanceV2

func (o *Openstack) GlanceV2() *internal.GlanceV2

func (*Openstack) IsAdmin

func (o *Openstack) IsAdmin() bool

func (*Openstack) KeystoneV3

func (o *Openstack) KeystoneV3() *internal.KeystoneV3

func (*Openstack) NeutronV2

func (o *Openstack) NeutronV2() *internal.NeutronV2

func (*Openstack) NovaV2

func (o *Openstack) NovaV2(microVersion ...string) *internal.NovaV2

func (Openstack) ProjectId

func (o Openstack) ProjectId() (string, error)

func (Openstack) PrunePorts

func (o Openstack) PrunePorts(ports []neutron.Port)

func (Openstack) PruneServers

func (o Openstack) PruneServers(query url.Values, yes bool, waitDeleted bool)

func (Openstack) PruneVolumes

func (o Openstack) PruneVolumes(query url.Values, matchName string, volumeType string,
	yes bool)

func (Openstack) Region

func (o Openstack) Region() string

func (*Openstack) ResetAllClients

func (o *Openstack) ResetAllClients()

func (*Openstack) SetComputeApiVersion

func (o *Openstack) SetComputeApiVersion(version string)

func (*Openstack) SetHttpTimeout

func (o *Openstack) SetHttpTimeout(timeout time.Duration)

func (*Openstack) SetNeutronEndpoint

func (o *Openstack) SetNeutronEndpoint(endpoint string)

func (*Openstack) SetRegion

func (o *Openstack) SetRegion(region string) *Openstack

func (*Openstack) SetRetryCount

func (o *Openstack) SetRetryCount(count int)

func (*Openstack) SetRetryWaitMaxTime

func (o *Openstack) SetRetryWaitMaxTime(timeout time.Duration)

func (*Openstack) SetRetryWaitTime

func (o *Openstack) SetRetryWaitTime(timeout time.Duration)

func (*Openstack) WithRegion

func (o *Openstack) WithRegion(region string) *Openstack

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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