openstack

package
v0.0.0-...-78eb850 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

OpenStack Client with Golang

Index

Constants

View Source
const (
	POLICY_NEVER     = "never"
	POLICY_ON_DEMAND = "on-demand"
)
View Source
const (
	URL_LIST_SECURITY_GROUPS      = "security-groups"
	URL_SHOW_SECURITY_GROUP       = "security-groups/%s"
	URL_LIST_SECURITY_GROUP_RULES = "security-group-rules"
	URL_SHOW_SECURITY_GROUP_RULE  = "security-group-rules/%s"
)
View Source
const (
	V2_1                    = "v2.1"
	URL_DETAIL              = "detail"
	URL_SERVER_VOLUMES_BOOT = "os-volumes_boot"
	URL_VOLUME_ATTACH       = "%s/os-volume_attachments"
	URL_VOLUME_DETACH       = "%s/os-volume_attachments/%s"
	URL_INTERFACE_ATTACH    = "%s/os-interface"
	URL_INTERFACE_DETACH    = "%s/os-interface/%s"
)
View Source
const V2 = "v2"
View Source
const V3 = "v3"
View Source
const X_OPENSTACK_REQUEST_ID = "X-Openstack-Request-Id"

Variables

View Source
var COMPUTE_API_VERSION string
View Source
var MIGRATION_POLICYS = []string{POLICY_NEVER, POLICY_ON_DEMAND}

Functions

func FoundResource

func FoundResource[T any](api ResourceApi, idOrName string) (*T, error)

func InvalidMIgrationPoicy

func InvalidMIgrationPoicy(policy string) error

Types

type CinderV2

type CinderV2 struct {
	RestClient2
}

func (CinderV2) Backup

func (c CinderV2) Backup() backupApi

func (CinderV2) GetCurrentVersion

func (c CinderV2) GetCurrentVersion() (*model.ApiVersion, error)

func (CinderV2) Service

func (c CinderV2) Service() volumeServiceApi

func (CinderV2) Snapshot

func (c CinderV2) Snapshot() snapshotApi

func (CinderV2) Volume

func (c CinderV2) Volume() volumeApi

func (CinderV2) VolumeType

func (c CinderV2) VolumeType() volumeTypeApi

type EndpointApi

type EndpointApi struct {
	KeystoneV3
}

func (EndpointApi) Create

func (c EndpointApi) Create(endpoint keystone.Endpoint) (*keystone.Endpoint, error)

func (EndpointApi) List

func (c EndpointApi) List(query url.Values) ([]keystone.Endpoint, error)

type Glance

type Glance struct {
	RestClient2
}

func (Glance) GetCurrentVersion

func (c Glance) GetCurrentVersion() (*model.ApiVersion, error)

func (Glance) Images

func (c Glance) Images() ImageApi

type ImageApi

type ImageApi struct {
	Glance
}

func (ImageApi) Create

func (c ImageApi) Create(options glance.Image) (*glance.Image, error)

func (ImageApi) Delete

func (c ImageApi) Delete(id string) error

func (ImageApi) Download

func (c ImageApi) Download(id string, fileName string, process bool) error

func (ImageApi) Found

func (c ImageApi) Found(idOrName string) (*glance.Image, error)

func (ImageApi) FoundByName

func (c ImageApi) FoundByName(name string) (*glance.Image, error)

func (ImageApi) List

func (c ImageApi) List(query url.Values, total int) ([]glance.Image, error)

func (ImageApi) ListByName

func (c ImageApi) ListByName(name string) ([]glance.Image, error)

func (ImageApi) Set

func (c ImageApi) Set(id string, params map[string]interface{}) (*glance.Image, error)

func (ImageApi) Show

func (c ImageApi) Show(id string) (*glance.Image, error)

func (ImageApi) Upload

func (c ImageApi) Upload(id string, file string) error

type ItemNotFound

type ItemNotFound struct {
	OpenstackError
}

func ItemNotFoundError

func ItemNotFoundError(format string, args ...interface{}) ItemNotFound

type KeystoneV3

type KeystoneV3 struct {
	RestClient2
}

func (KeystoneV3) Endpoint

func (c KeystoneV3) Endpoint() *endpointApi

func (KeystoneV3) Endpoints

func (c KeystoneV3) Endpoints() EndpointApi

func (KeystoneV3) GetCurrentVersion

func (c KeystoneV3) GetCurrentVersion() (*model.ApiVersion, error)

func (KeystoneV3) GetStableVersion

func (c KeystoneV3) GetStableVersion() (*model.ApiVersion, error)

func (KeystoneV3) Project

func (c KeystoneV3) Project() projectApi

func (KeystoneV3) Projects

func (c KeystoneV3) Projects() ProjectApi

func (KeystoneV3) Region

func (c KeystoneV3) Region() regionApi

func (KeystoneV3) Regions

func (c KeystoneV3) Regions() RegionApi

func (KeystoneV3) RoleAssignment

func (c KeystoneV3) RoleAssignment() roleAssignmentApi

func (KeystoneV3) RoleAssignments

func (c KeystoneV3) RoleAssignments() RoleAssignmentApi

func (KeystoneV3) Service

func (c KeystoneV3) Service() serviceApi

func (KeystoneV3) Services

func (c KeystoneV3) Services() ServiceApi

func (KeystoneV3) User

func (c KeystoneV3) User() userApi

func (KeystoneV3) Users

func (c KeystoneV3) Users() UserApi

type MultiItems

type MultiItems struct {
	OpenstackError
}

func MultiItemsError

func MultiItemsError(format string, args ...interface{}) MultiItems

type NeutronV2

type NeutronV2 struct {
	RestClient2
	// contains filtered or unexported fields
}

func (NeutronV2) Agent

func (c NeutronV2) Agent() agentApi

func (*NeutronV2) GetCurrentVersion

func (c *NeutronV2) GetCurrentVersion() (*model.ApiVersion, error)

func (NeutronV2) ListRouterPorts

func (c NeutronV2) ListRouterPorts(routerId string) (neutron.Ports, error)

func (NeutronV2) Network

func (c NeutronV2) Network() networkApi

func (NeutronV2) Port

func (c NeutronV2) Port() portApi

func (NeutronV2) QosPolicy

func (c NeutronV2) QosPolicy() qosPolicyApi

func (NeutronV2) QosRule

func (c NeutronV2) QosRule() qosRuleApi

func (NeutronV2) Router

func (c NeutronV2) Router() routerApi

func (NeutronV2) SecurityGroup

func (c NeutronV2) SecurityGroup() sgApi

func (NeutronV2) SecurityGroupRule

func (c NeutronV2) SecurityGroupRule() sgRuleApi

func (NeutronV2) Subnet

func (c NeutronV2) Subnet() subnetApi

type NovaV2

type NovaV2 struct {
	RestClient2

	MicroVersion model.ApiVersion
	// contains filtered or unexported fields
}

func (NovaV2) AZ

func (c NovaV2) AZ() azApi

func (NovaV2) Aggregate

func (c NovaV2) Aggregate() aggregateApi

func (NovaV2) Flavor

func (c NovaV2) Flavor() flavorApi

func (*NovaV2) GetCurrentVersion

func (c *NovaV2) GetCurrentVersion() (*model.ApiVersion, error)

func (NovaV2) Hypervisor

func (c NovaV2) Hypervisor() hypervisorApi

func (NovaV2) Keypair

func (c NovaV2) Keypair() keypairApi

func (*NovaV2) MicroVersionLargeEqual

func (c *NovaV2) MicroVersionLargeEqual(version string) bool

func (NovaV2) Migration

func (c NovaV2) Migration() migrationApi

func (NovaV2) Quota

func (c NovaV2) Quota() computeQuotaApi

func (NovaV2) Server

func (c NovaV2) Server() serverApi

func (NovaV2) ServerGroup

func (c NovaV2) ServerGroup() serverGroupApi

func (NovaV2) Service

func (c NovaV2) Service() computeServiceApi

func (*NovaV2) String

func (c *NovaV2) String() string

type Openstack

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

func ClientWithRegion

func ClientWithRegion(region string) *Openstack

func DefaultClient

func DefaultClient() *Openstack

func NewClient

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

func (*Openstack) CinderV2

func (o *Openstack) CinderV2() *CinderV2

func (*Openstack) GlanceV2

func (o *Openstack) GlanceV2() *Glance

func (*Openstack) KeystoneV3

func (o *Openstack) KeystoneV3() *KeystoneV3

func (*Openstack) NeutronV2

func (o *Openstack) NeutronV2() *NeutronV2

func (*Openstack) NovaV2

func (o *Openstack) NovaV2() *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

type OpenstackError

type OpenstackError struct {
	Message string
}

func (OpenstackError) Error

func (err OpenstackError) Error() string

type ProjectApi

type ProjectApi struct {
	KeystoneV3
}

type RegionApi

type RegionApi struct {
	KeystoneV3
}

type ResourceApi

type ResourceApi struct {
	Endpoint        string
	BaseUrl         string
	Client          *httpclient.RESTClient
	MicroVersion    model.ApiVersion
	EnableAllTenant bool

	SingularKey string
	PluralKey   string
	// contains filtered or unexported fields
}

func (*ResourceApi) AddQuery

func (api *ResourceApi) AddQuery(k, v string) *ResourceApi

func (*ResourceApi) AppendUrl

func (api *ResourceApi) AppendUrl(url string) *ResourceApi

func (*ResourceApi) AppendUrlf

func (api *ResourceApi) AppendUrlf(u string, args ...any) *ResourceApi

func (ResourceApi) Delete

func (api ResourceApi) Delete(res interface{}) (*resty.Response, error)

func (ResourceApi) Get

func (api ResourceApi) Get(res interface{}) (*resty.Response, error)

func (*ResourceApi) GetMicroVersion

func (api *ResourceApi) GetMicroVersion() microVersion

func (*ResourceApi) Index

func (api *ResourceApi) Index() (*resty.Response, error)

func (ResourceApi) IsAdmin

func (api ResourceApi) IsAdmin() bool

func (*ResourceApi) MicroVersionLargeEqual

func (api *ResourceApi) MicroVersionLargeEqual(version string) bool

func (ResourceApi) Patch

func (api ResourceApi) Patch(res interface{}) (*resty.Response, error)

func (*ResourceApi) PopUrl

func (api *ResourceApi) PopUrl() *ResourceApi

func (ResourceApi) Post

func (api ResourceApi) Post(res interface{}) (*resty.Response, error)

func (ResourceApi) Put

func (api ResourceApi) Put(res interface{}) (*resty.Response, error)

func (*ResourceApi) SetBody

func (api *ResourceApi) SetBody(body interface{}) *ResourceApi

func (*ResourceApi) SetHeader

func (api *ResourceApi) SetHeader(h, v string) *ResourceApi

func (*ResourceApi) SetHeaders

func (api *ResourceApi) SetHeaders(headers map[string]string) *ResourceApi

func (*ResourceApi) SetQuery

func (api *ResourceApi) SetQuery(query url.Values) *ResourceApi

func (*ResourceApi) SetResult

func (api *ResourceApi) SetResult(result interface{}) *ResourceApi

func (*ResourceApi) SetUrl

func (api *ResourceApi) SetUrl(url string) *ResourceApi

type ResourceInterface

type ResourceInterface interface {
	GetName() string
}

type RestClient2

type RestClient2 struct {
	BaseUrl string
	// contains filtered or unexported fields
}

func NewRestClient2

func NewRestClient2(baseUrl string, authPlugin httpclient.AuthPluginInterface) RestClient2

func (*RestClient2) AddBaseHeader

func (rest *RestClient2) AddBaseHeader(key, value string)

func (*RestClient2) Delete

func (rest *RestClient2) Delete(url string, headers map[string]string) (*resty.Response, error)

func (*RestClient2) Get

func (rest *RestClient2) Get(url string, query url.Values) (*resty.Response, error)

func (*RestClient2) GetAndUnmarshal

func (rest *RestClient2) GetAndUnmarshal(url string, query url.Values, body interface{}) error

func (*RestClient2) GetResponseRequstId

func (rest *RestClient2) GetResponseRequstId(resp *resty.Response) string

func (*RestClient2) Index

func (rest *RestClient2) Index() (*resty.Response, error)

func (*RestClient2) Patch

func (rest *RestClient2) Patch(url string, query url.Values, body interface{}, headers map[string]string) (*resty.Response, error)

func (*RestClient2) Post

func (rest *RestClient2) Post(url string, body interface{}, headers map[string]string) (*resty.Response, error)

func (*RestClient2) Put

func (rest *RestClient2) Put(url string, body interface{}, headers map[string]string) (*resty.Response, error)

type RoleAssignmentApi

type RoleAssignmentApi struct {
	KeystoneV3
}

func (RoleAssignmentApi) List

type ServiceApi

type ServiceApi struct {
	KeystoneV3
}

func (ServiceApi) Create

func (c ServiceApi) Create(service keystone.Service) (*keystone.Service, error)

type UserApi

type UserApi struct {
	KeystoneV3
}

func (UserApi) List

func (c UserApi) List(query url.Values) ([]auth.User, error)

func (UserApi) ListByProjectId

func (c UserApi) ListByProjectId(projectId string) ([]auth.User, error)

func (UserApi) Show

func (c UserApi) Show(id string) (*auth.User, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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