openstack

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromIntIPversion

func FromIntIPversion(v int) IPVersion.Enum

FromIntIPversion ...

func ParseBadRequest

func ParseBadRequest(badRequestError string) map[string]string

ParseBadRequest parses BadRequest JSON error and returns fields

func ParseNeutronError

func ParseNeutronError(neutronError string) map[string]string

ParseNeutronError parses neutron json error and returns fields

func ProviderErrorToString

func ProviderErrorToString(err error) string

ProviderErrorToString creates an error string from openstack api error

func ToGopherIPversion

func ToGopherIPversion(v IPVersion.Enum) gc.IPVersion

ToGopherIPversion ...

func VerifyEndpoints

func VerifyEndpoints(service *Client) (bool, error)

VerifyEndpoints ...

Types

type AuthOptions

type AuthOptions struct {
	// IdentityEndpoint specifies the HTTP endpoint that is required to work with
	// the Identity API of the appropriate version. While it's ultimately needed by
	// all of the identity services, it will often be populated by a provider-level
	// function.
	IdentityEndpoint string

	// Username is required if using Identity V2 API. Consult with your provider's
	// control panel to discover your account's username. In Identity V3, either
	// UserID or a combination of Username and DomainID or DomainName are needed.
	Username, UserID string

	// Exactly one of Password or APIKey is required for the Identity V2 and V3
	// APIs. Consult with your provider's control panel to discover your account's
	// preferred method of authentication.
	Password, APIKey string

	// At most one of DomainID and DomainName must be provided if using Username
	// with Identity V3. Otherwise, either are optional.
	DomainID, DomainName string

	// The TenantID and TenantName fields are optional for the Identity V2 API.
	// Some providers allow you to specify a TenantName instead of the TenantId.
	// Some require both. Your provider's authentication policies will determine
	// how these fields influence authentication.
	TenantID, TenantName string

	// AllowReauth should be set to true if you grant permission for Gophercloud to
	// cache your credentials in memory, and to allow Gophercloud to attempt to
	// re-authenticate automatically if/when your token expires.  If you set it to
	// false, it will not cache these settings, but re-authentication will not be
	// possible. This setting defaults to false.
	//
	// NOTE: The reauth function will try to re-authenticate endlessly if left unchecked.
	// The way to limit the number of attempts is to provide a custom HTTP client to the provider client
	// and provide a transport that implements the RoundTripper interface and stores the number of failed retries.
	// For an example of this, see here: https://github.com/gophercloud/rack/blob/1.0.0/auth/clients.go#L311
	AllowReauth bool

	// TokenID allows users to authenticate (possibly as another user) with an
	// authentication token ID.
	TokenID string

	//Openstack region (data center) where the infrstructure will be created
	Region string

	//FloatingIPPool name of the floating IP pool
	//Necessary only if UseFloatingIP is true
	FloatingIPPool string
}

AuthOptions fields are the union of those recognized by each identity implementation and provider.

type CfgOptions

type CfgOptions struct {
	// Name of the provider (external) network
	ProviderNetwork string
	// DNSList list of DNS
	DNSList []string
	// UseFloatingIP indicates if floating IP are used (optional)
	UseFloatingIP bool
	// UseLayer3Networking indicates if layer 3 networking features (router) can be used
	// if UseFloatingIP is true UseLayer3Networking must be true
	UseLayer3Networking bool
	// AutoHostNetworkInterfaces indicates if network interfaces are configured automatically by the provider or needs a post configuration
	AutoHostNetworkInterfaces bool
	// VolumeSpeeds map volume types with volume speeds
	VolumeSpeeds map[string]VolumeSpeed.Enum
	// // ObjectStorageType type of Object Storage (ex: swift or s3)
	// ObjectStorageType string
	// MetadataBucket contains the name of the bucket storing metadata
	MetadataBucket string
	DefaultImage   string
}

CfgOptions configuration options

type Client

type Client struct {
	Opts     *AuthOptions
	Cfg      *CfgOptions
	Provider *gc.ProviderClient
	Compute  *gc.ServiceClient
	Network  *gc.ServiceClient
	Volume   *gc.ServiceClient

	SecurityGroup     *secgroups.SecurityGroup
	ProviderNetworkID string
}

Client is the implementation of the openstack driver regarding to the api.ClientAPI

func AuthenticatedClient

func AuthenticatedClient(opts AuthOptions, cfg CfgOptions) (*Client, error)

AuthenticatedClient returns an authenticated client

func (*Client) Build

func (client *Client) Build(params map[string]interface{}) (api.ClientAPI, error)

Build build a new Client from configuration parameter

func (*Client) CreateGateway

func (client *Client) CreateGateway(req model.GatewayRequest) (*model.Host, error)

CreateGateway creates a public Gateway for a private network

func (*Client) CreateHost

func (client *Client) CreateHost(request model.HostRequest) (*model.Host, error)

CreateHost creates an host satisfying request

func (*Client) CreateKeyPair

func (client *Client) CreateKeyPair(name string) (*model.KeyPair, error)

CreateKeyPair creates and import a key pair

func (*Client) CreateNetwork

func (client *Client) CreateNetwork(req model.NetworkRequest) (*model.Network, error)

CreateNetwork creates a network named name

func (*Client) CreateVolume

func (client *Client) CreateVolume(request model.VolumeRequest) (*model.Volume, error)

CreateVolume creates a block volume - name is the name of the volume - size is the size of the volume in GB - volumeType is the type of volume to create, if volumeType is empty the driver use a default type

func (*Client) CreateVolumeAttachment

func (client *Client) CreateVolumeAttachment(request model.VolumeAttachmentRequest) (string, error)

CreateVolumeAttachment attaches a volume to an host - 'name' of the volume attachment - 'volume' to attach - 'host' on which the volume is attached

func (*Client) DeleteGateway

func (client *Client) DeleteGateway(id string) error

DeleteGateway delete the public gateway of a private network

func (*Client) DeleteHost

func (client *Client) DeleteHost(id string) error

DeleteHost deletes the host identified by id

func (*Client) DeleteKeyPair

func (client *Client) DeleteKeyPair(id string) error

DeleteKeyPair deletes the key pair identified by id

func (*Client) DeleteNetwork

func (client *Client) DeleteNetwork(id string) error

DeleteNetwork deletes the network identified by id

func (*Client) DeleteVolume

func (client *Client) DeleteVolume(id string) error

DeleteVolume deletes the volume identified by id

func (*Client) DeleteVolumeAttachment

func (client *Client) DeleteVolumeAttachment(serverID, vaID string) error

DeleteVolumeAttachment deletes the volume attachment identifed by id

func (*Client) GetAuthOpts

func (client *Client) GetAuthOpts() (model.Config, error)

GetAuthOpts returns the auth options

func (*Client) GetCfgOpts

func (client *Client) GetCfgOpts() (model.Config, error)

GetCfgOpts return configuration parameters

func (*Client) GetHost

func (client *Client) GetHost(hostParam interface{}) (*model.Host, error)

GetHost updates the data inside host with the data from provider

func (*Client) GetHostByName

func (client *Client) GetHostByName(name string) (*model.Host, error)

GetHostByName returns the host using the name passed as parameter

func (*Client) GetHostState

func (client *Client) GetHostState(hostParam interface{}) (HostState.Enum, error)

GetHostState returns the current state of host identified by id hostParam can be a string or an instance of *model.Host; any other type will panic

func (*Client) GetImage

func (client *Client) GetImage(id string) (*model.Image, error)

GetImage returns the Image referenced by id

func (*Client) GetKeyPair

func (client *Client) GetKeyPair(id string) (*model.KeyPair, error)

GetKeyPair returns the key pair identified by id

func (*Client) GetNetwork

func (client *Client) GetNetwork(id string) (*model.Network, error)

GetNetwork returns the network identified by id

func (*Client) GetNetworkByName

func (client *Client) GetNetworkByName(name string) (*model.Network, error)

GetNetworkByName ...

func (*Client) GetTemplate

func (client *Client) GetTemplate(id string) (*model.HostTemplate, error)

GetTemplate returns the Template referenced by id

func (*Client) GetVolume

func (client *Client) GetVolume(id string) (*model.Volume, error)

GetVolume returns the volume identified by id

func (*Client) GetVolumeAttachment

func (client *Client) GetVolumeAttachment(serverID, id string) (*model.VolumeAttachment, error)

GetVolumeAttachment returns the volume attachment identified by id

func (*Client) ListAvailabilityZones

func (client *Client) ListAvailabilityZones(all bool) (map[string]bool, error)

ListAvailabilityZones lists the usable AvailabilityZones

func (*Client) ListHosts

func (client *Client) ListHosts() ([]*model.Host, error)

ListHosts lists all hosts

func (*Client) ListImages

func (client *Client) ListImages(all bool) ([]model.Image, error)

ListImages lists available OS images

func (*Client) ListKeyPairs

func (client *Client) ListKeyPairs() ([]model.KeyPair, error)

ListKeyPairs lists available key pairs

func (*Client) ListNetworks

func (client *Client) ListNetworks() ([]*model.Network, error)

ListNetworks lists available networks

func (*Client) ListRouters

func (client *Client) ListRouters() ([]Router, error)

ListRouters lists available routers

func (*Client) ListTemplates

func (client *Client) ListTemplates(all bool) ([]model.HostTemplate, error)

ListTemplates lists available Host templates Host templates are sorted using Dominant Resource Fairness Algorithm

func (*Client) ListVolumeAttachments

func (client *Client) ListVolumeAttachments(serverID string) ([]model.VolumeAttachment, error)

ListVolumeAttachments lists available volume attachment

func (*Client) ListVolumes

func (client *Client) ListVolumes() ([]model.Volume, error)

ListVolumes returns the list of all volumes known on the current tenant

func (*Client) RebootHost

func (client *Client) RebootHost(id string) error

RebootHost reboots inconditionnaly the host identified by id

func (*Client) StartHost

func (client *Client) StartHost(id string) error

StartHost starts the host identified by id

func (*Client) StopHost

func (client *Client) StopHost(id string) error

StopHost stops the host identified by id

func (*Client) WaitHostReady

func (client *Client) WaitHostReady(hostParam interface{}, timeout time.Duration) (*model.Host, error)

WaitHostReady waits an host achieve ready state hostParam can be an ID of host, or an instance of *model.Host; any other type will panic

type Router

type Router struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	//NetworkID is the Network ID which the router gateway is connected to.
	NetworkID string `json:"network_id,omitempty"`
}

Router represents a router

type RouterRequest

type RouterRequest struct {
	Name string `json:"name,omitempty"`
	//NetworkID is the Network ID which the router gateway is connected to.
	NetworkID string `json:"network_id,omitempty"`
}

RouterRequest represents a router request

type Subnet

type Subnet struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	//IPVersion is IPv4 or IPv6 (see IPVersion)
	IPVersion IPVersion.Enum `json:"ip_version,omitempty"`
	//Mask mask in CIDR notation
	Mask string `json:"mask,omitempty"`
	//NetworkID id of the parent network
	NetworkID string `json:"network_id,omitempty"`
}

Subnet define a sub network

Jump to

Keyboard shortcuts

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