openstack

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

nolint: dupl // we can't extract this code because of generics

nolint: dupl // we can't extract this code because of generics

The openstack package provides you an incomplete interface to access openstack resource via gophercloud's openstack functions. All CRUD calls on the interface will invoke gophercloud functions.

To use this package, create OSServerClient an initialize it with the Client.Configure method.

osClient := openstack.OSClient{}
err := osClient.Configure(iniData)

If you want to mock the interface, you can use testing.MockClient and the implementations of callback clients (e.g. testing.CallbackRuleClient)

mockClient := testing.MockClient{}
mockClient.StoredValues = map[string]interface{}{}
mockClient.GroupClientObj = &testing.CallbackGroupClient{
	ListFunc: func(opts groups.ListOpts) ([]groups.SecGroup, error) {
		return []groups.SecGroup{
			{
				Name:  "sec-group-name",
				ID:    "sec-group-id",
				Rules: desiredRules,
			},
		}, nil
	},
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Takes the content of an ini-file, to configure the openstack client
	Configure(ini []byte, overwrite OSClientOverwrite, timeout time.Duration, promCounter *prometheus.CounterVec) error
	// Returns the FipClient created from the configured ini
	FipClient(ctx context.Context) (FipClient, error)
	// Returns the PortClient created from the configured ini
	PortClient(ctx context.Context) (PortClient, error)
	// Returns the GroupClient created from the configured ini
	GroupClient(ctx context.Context) (GroupClient, error)
	// Returns the RuleClient created from the configured ini
	RuleClient(ctx context.Context) (RuleClient, error)
	// Returns the ServerClient created from the configured ini
	ServerClient(ctx context.Context) (ServerClient, error)
	// Returns the ServerClient created from the configured ini
	ServerGroupClient(ctx context.Context) (ServerGroupClient, error)
	// Returns the KeyPairClient created from the configured ini
	KeyPairClient(ctx context.Context) (KeyPairClient, error)
}

Client provides a interface to configure and use different OpenStack clients.

type FipClient

FipClient is used to modify FloatingIPs in an OpenStack environment. It provides methods with CRUD functionalities

type GetOSClientFunc added in v0.11.0

type GetOSClientFunc func(iniData []byte, overwrite OSClientOverwrite) (Client, error)

type GroupClient

type GroupClient interface {
	List(ctx context.Context, opts groups.ListOpts) ([]groups.SecGroup, error)
	Create(ctx context.Context, opts groups.CreateOptsBuilder) (*groups.SecGroup, error)
	Update(ctx context.Context, id string, opts groups.UpdateOptsBuilder) (*groups.SecGroup, error)
	Get(ctx context.Context, id string) (*groups.SecGroup, error)
	Delete(ctx context.Context, id string) error
}

GroupClient is used to modify Network Security Groups in an OpenStack environment. It provides methods with CRUD functionalities.

type KeyPairClient

type KeyPairClient interface {
	List(ctx context.Context) ([]keypairs.KeyPair, error)
	Create(ctx context.Context, opts keypairs.CreateOptsBuilder) (*keypairs.KeyPair, error)
	Get(ctx context.Context, name string) (*keypairs.KeyPair, error)
	Delete(ctx context.Context, name string) error
}

KeyPairClient is used to create and delete ssh keys in an OpenStack environment. It provides methods with CRD functionalities.

type MetricAPI

type MetricAPI string
const (
	MetricAPINova    MetricAPI = "nova"
	MetricAPINeutron MetricAPI = "neutron"
)

type MetricObject

type MetricObject string
const (
	MetricObjectFloatingIP  MetricObject = "floatingip"
	MetricObjectGroup       MetricObject = "group"
	MetricObjectKeyPair     MetricObject = "keypair"
	MetricObjectPort        MetricObject = "port"
	MetricObjectRule        MetricObject = "rule"
	MetricObjectServer      MetricObject = "server"
	MetricObjectServerGroup MetricObject = "servergroup"
)

type MetricOperation

type MetricOperation string
const (
	MetricOperationCreate MetricOperation = "create"
	MetricOperationDelete MetricOperation = "delete"
	MetricOperationGet    MetricOperation = "get"
	MetricOperationList   MetricOperation = "list"
	MetricOperationUpdate MetricOperation = "update"
)

type OSClient

type OSClient struct {
	// contains filtered or unexported fields
}

OSClient is an implementation of Client. It must be configured by calling Configure(). When requesting any specific client the required resources will be created on first call. Mind, that you should not call Configure() again, because the created resources will not be invalidated.

func (*OSClient) Configure

func (r *OSClient) Configure(
	iniBytes []byte,
	overwrite OSClientOverwrite,
	timeout time.Duration,
	promCounter *prometheus.CounterVec,
) error

Configures the OSClient with the data of an os auth ini file. Used and required flags are auth-url, username, password, domain-name, tenant-name, region in the [global] directive.

Example ini file:

[Global]
auth-url="https://this-is-my-keystone-ep:5000/v3"
domain-name="default"
tenant-name="mycooltenant"
username="itmyuser"
password="suupersecret"
region="eu01"

func (*OSClient) FipClient

func (r *OSClient) FipClient(ctx context.Context) (FipClient, error)

Returns a configured OSFloatingIPClient as FipClient. Make sure that you invoked Configure() before this.

func (*OSClient) GroupClient

func (r *OSClient) GroupClient(ctx context.Context) (GroupClient, error)

Returns a configured OSGroupClient as GroupClient. Make sure that you invoked Configure() before this.

func (*OSClient) KeyPairClient

func (r *OSClient) KeyPairClient(ctx context.Context) (KeyPairClient, error)

Returns a configured OSKeypairClient as KeyPairClient. Make sure that you invoked Configure() before this.

func (*OSClient) PortClient

func (r *OSClient) PortClient(ctx context.Context) (PortClient, error)

Returns a configured OSPortClient as PortClient. Make sure that you invoked Configure() before this.

func (*OSClient) RuleClient

func (r *OSClient) RuleClient(ctx context.Context) (RuleClient, error)

Returns a configured OSRuleClient as RuleClient. Make sure that you invoked Configure() before this.

func (*OSClient) ServerClient

func (r *OSClient) ServerClient(ctx context.Context) (ServerClient, error)

Returns a configured OSServerClient as ServerClient. Make sure that you invoked Configure() before this.

func (*OSClient) ServerGroupClient added in v0.11.0

func (r *OSClient) ServerGroupClient(ctx context.Context) (ServerGroupClient, error)

Returns a configured OSServerGroupClient as ServerGroupClient. Make sure that you invoked Configure() before this.

type OSClientOverwrite added in v0.11.0

type OSClientOverwrite struct {
	ProjectID *string
}

type OSFloatingIPClient

type OSFloatingIPClient struct {
	// contains filtered or unexported fields
}

The OSFloatingIPClient is a implementation for FipClient. When you want to use this struct be sure to call Configure() before calling any other method. Otherwise it will result in errors.

As an easier abstraction you can use OSClient in this package, where you can insert data from an ini file to automatically initialize all modules you want to use.

func (*OSFloatingIPClient) Configure

func (r *OSFloatingIPClient) Configure(
	networkV2 *gophercloud.ServiceClient,
	timeout time.Duration,
	promCounter *prometheus.CounterVec,
) *OSFloatingIPClient

Configure takes NetworkV2 ServiceClient to receive endpoints and auth info for further calls against openstack.

func (*OSFloatingIPClient) Create

Invokes floatingips.Create() in gophercloud's floatingip package. Uses the networkV2 client provided in Configure().

func (*OSFloatingIPClient) Delete

func (r *OSFloatingIPClient) Delete(ctx context.Context, id string) error

Invokes floatingips.Delete() in gophercloud's floatingip package. Uses the networkV2 client provided in Configure().

func (*OSFloatingIPClient) Get

Invokes floatingips.Get() in gophercloud's floatingip package. Uses the networkV2 client provided in Configure().

func (*OSFloatingIPClient) List

Invokes floatingips.List() in gophercloud's floating ip package and extracts all floating ips. Uses the networkV2 client provided in Configure().

func (*OSFloatingIPClient) Update

Invokes floatingips.Update() in gophercloud's floatingip package. Uses the networkV2 client provided in Configure().

type OSGroupClient

type OSGroupClient struct {
	// contains filtered or unexported fields
}

The OSGroupClient is a implementation for GroupClient. When you want to use this struct be sure to call Configure() before calling any other method. Otherwise it will result in errors.

As an easier abstraction you can use OSClient in this package, where you can insert data from an ini file to automatically initialize all modules you want to use.

func (*OSGroupClient) Configure

func (r *OSGroupClient) Configure(
	networkClient *gophercloud.ServiceClient,
	timeout time.Duration,
	promCounter *prometheus.CounterVec,
) *OSGroupClient

Configure takes NetworkV2 ServiceClient to receive endpoints and auth info for further calls against openstack.

func (*OSGroupClient) Create

Create Invokes groups.Create() in gophercloud's groups package. Uses the networkV2 client provided in Configure().

func (*OSGroupClient) Delete

func (r *OSGroupClient) Delete(ctx context.Context, id string) error

Delete Invokes groups.Delete() in gophercloud's groups package. Uses the networkV2 client provided in Configure().

func (*OSGroupClient) Get

func (r *OSGroupClient) Get(ctx context.Context, id string) (*groups.SecGroup, error)

Get Invokes groups.Get() in gophercloud's groups package. Uses the networkV2 client provided in Configure().

func (*OSGroupClient) List

func (r *OSGroupClient) List(ctx context.Context, opts groups.ListOpts) ([]groups.SecGroup, error)

List Invokes groups.List() in gophercloud's groups package and extracts all security groups. Uses the networkV2 client provided in Configure().

func (*OSGroupClient) Update

Update Invokes groups.Update() in gophercloud's groups package. Uses the networkV2 client provided in Configure().

type OSKeypairClient

type OSKeypairClient struct {
	// contains filtered or unexported fields
}

The OSKeypairClient is a implementation for KeyPairClient. When you want to use this struct be sure to call Configure() before calling any other method. Otherwise it will result in errors.

As an easier abstraction you can use OSClient in this package, where you can insert data from an ini file to automatically initialize all modules you want to use.

func (*OSKeypairClient) Configure

func (r *OSKeypairClient) Configure(
	computeV2 *gophercloud.ServiceClient,
	timeout time.Duration,
	promCounter *prometheus.CounterVec,
) *OSKeypairClient

Configure takes ComputeV2 ServiceClient to receive endpoints and auth info for further calls against openstack.

func (*OSKeypairClient) Create

Create Invokes keypairs.Create() in gophercloud's keypairs package. Uses the computeV2 client provided in Configure().

func (*OSKeypairClient) Delete

func (r *OSKeypairClient) Delete(ctx context.Context, name string) error

Delete Invokes keypairs.Delete() in gophercloud's keypairs package. Uses the computeV2 client provided in Configure().

func (*OSKeypairClient) Get

func (r *OSKeypairClient) Get(ctx context.Context, name string) (*keypairs.KeyPair, error)

Get Invokes keypairs.Get() in gophercloud's keypairs package. Uses the computeV2 client provided in Configure().

func (*OSKeypairClient) List

List Invokes keypairs.List() in gophercloud's keypairs package. Uses the computeV2 client provided in Configure().

type OSPortClient

type OSPortClient struct {
	// contains filtered or unexported fields
}

The OSPortClient is a implementation for PortClient. When you want to use this struct be sure to call Configure() before calling any other method. Otherwise it will result in errors.

As an easier abstraction you can use OSClient in this package, where you can insert data from an ini file to automatically initialize all modules you want to use.

func (*OSPortClient) Configure

func (r *OSPortClient) Configure(
	networkClient *gophercloud.ServiceClient,
	timeout time.Duration,
	promCounter *prometheus.CounterVec,
) *OSPortClient

Configure takes NetworkV2 ServiceClient to receive endpoints and auth info for further calls against openstack.

func (*OSPortClient) Create

Invokes groups.Create() in gophercloud's ports package. Uses the networkV2 client provided in Configure().

func (*OSPortClient) Delete

func (r *OSPortClient) Delete(ctx context.Context, id string) error

Invokes groups.Delete() in gophercloud's ports package. Uses the networkV2 client provided in Configure().

func (*OSPortClient) Get

func (r *OSPortClient) Get(ctx context.Context, id string) (*ports.Port, error)

Invokes groups.Get() in gophercloud's ports package. Uses the networkV2 client provided in Configure().

func (*OSPortClient) List

func (r *OSPortClient) List(ctx context.Context, opts ports.ListOptsBuilder) ([]ports.Port, error)

Invokes ports.List() in gophercloud's ports package and extracts all ports. Uses the networkV2 client provided in Configure().

func (*OSPortClient) Update

func (r *OSPortClient) Update(ctx context.Context, id string, opts ports.UpdateOptsBuilder) (*ports.Port, error)

Invokes groups.Update() in gophercloud's ports package. Uses the networkV2 client provided in Configure().

type OSRuleClient

type OSRuleClient struct {
	// contains filtered or unexported fields
}

The OSRuleClient is a implementation for RuleClient. When you want to use this struct be sure to call Configure() before calling any other method. Otherwise it will result in errors.

As an easier abstraction you can use OSClient in this package, where you can insert data from an ini file to automatically initialize all modules you want to use.

func (*OSRuleClient) Configure

func (r *OSRuleClient) Configure(
	networkClient *gophercloud.ServiceClient,
	timeout time.Duration,
	promCounter *prometheus.CounterVec,
) *OSRuleClient

Configure takes NetworkV2 ServiceClient to receive endpoints and auth info for further calls against openstack.

func (*OSRuleClient) Create

Invokes rules.Create() in gophercloud's rules package and extracts all security groups. Uses the networkV2 client provided in Configure().

func (*OSRuleClient) Delete

func (r *OSRuleClient) Delete(ctx context.Context, id string) error

Invokes rules.Delete() in gophercloud's rules package Uses the networkV2 client provided in Configure().

func (*OSRuleClient) Get

Invokes rules.Get() in gophercloud's rules package and extracts all security groups. Uses the networkV2 client provided in Configure().

func (*OSRuleClient) List

Invokes rules.List() in gophercloud's rules package and extracts all security groups. Uses the networkV2 client provided in Configure().

type OSServerClient

type OSServerClient struct {
	// contains filtered or unexported fields
}

The OSServerClient is a implementation for ServerClient. When you want to use this struct be sure to call Configure() before calling any other method. Otherwise it will result in errors.

As an easier abstraction you can use OSClient in this package, where you can insert data from an ini file to automatically initialize all modules you want to use.

func (*OSServerClient) Configure

func (r *OSServerClient) Configure(
	networkClient *gophercloud.ServiceClient,
	timeout time.Duration,
	promCounter *prometheus.CounterVec,
) *OSServerClient

Configure takes ComputeV2 ServiceClient to receive endpoints and auth info for further calls against openstack.

func (*OSServerClient) Create

Invokes servers.Create() in gophercloud's servers package. Uses the computeV2 client provided in Configure().

func (*OSServerClient) Delete

func (r *OSServerClient) Delete(ctx context.Context, id string) error

Invokes servers.Delete() in gophercloud's servers package. Uses the computeV2 client provided in Configure().

func (*OSServerClient) Get

func (r *OSServerClient) Get(ctx context.Context, id string) (*servers.Server, error)

Invokes servers.Get() in gophercloud's servers package. Uses the computeV2 client provided in Configure().

func (*OSServerClient) List

Invokes servers.List() in gophercloud's servers package. Uses the computeV2 client provided in Configure().

func (*OSServerClient) Update

Invokes servers.Update() in gophercloud's servers package. Uses the computeV2 client provided in Configure().

type OSServerGroupClient added in v0.11.0

type OSServerGroupClient struct {
	// contains filtered or unexported fields
}

The OSServerGroupClient is a implementation for ServerGroupClient. When you want to use this struct be sure to call Configure() before calling any other method. Otherwise it will result in errors.

As an easier abstraction you can use OSClient in this package, where you can insert data from an ini file to automatically initialize all modules you want to use.

func (*OSServerGroupClient) Configure added in v0.11.0

func (r *OSServerGroupClient) Configure(
	computeClient *gophercloud.ServiceClient,
	timeout time.Duration,
	promCounter *prometheus.CounterVec,
) *OSServerGroupClient

Configure takes ComputeV2 ServiceClient to receive endpoints and auth info for further calls against openstack.

func (*OSServerGroupClient) Create added in v0.11.0

Invokes servergroups.Create() in gophercloud's servergroups package. Uses the computeV2 client provided in Configure().

func (*OSServerGroupClient) Delete added in v0.11.0

func (r *OSServerGroupClient) Delete(ctx context.Context, id string) error

Invokes servergroups.Delete() in gophercloud's servergroups package. Uses the computeV2 client provided in Configure().

func (*OSServerGroupClient) Get added in v0.11.0

Invokes servergroups.Get() in gophercloud's servergroups package. Uses the computeV2 client provided in Configure().

func (*OSServerGroupClient) List added in v0.11.0

Invokes servergroups.List() in gophercloud's servers package. Uses the computeV2 client provided in Configure().

type PortClient

type PortClient interface {
	List(ctx context.Context, opts ports.ListOptsBuilder) ([]ports.Port, error)
	Get(ctx context.Context, id string) (*ports.Port, error)
	Create(ctx context.Context, opts ports.CreateOptsBuilder) (*ports.Port, error)
	Update(ctx context.Context, id string, opts ports.UpdateOptsBuilder) (*ports.Port, error)
	Delete(ctx context.Context, id string) error
}

PortClient is used to modify Network Ports in an OpenStack environment. It provides methods with CRUD functionalities.

type RuleClient

type RuleClient interface {
	List(ctx context.Context, opts rules.ListOpts) ([]rules.SecGroupRule, error)
	Create(ctx context.Context, opts rules.CreateOptsBuilder) (*rules.SecGroupRule, error)
	Get(ctx context.Context, id string) (*rules.SecGroupRule, error)
	Delete(ctx context.Context, id string) error
}

RuleClient is used to modify Network Security Rules in an OpenStack environment. Rules must be created in the context of a Security Group, which can be created with the GroupClient. It provides methods with CRUD functionalities.

type ServerClient

type ServerClient interface {
	List(ctx context.Context, opts servers.ListOptsBuilder) ([]servers.Server, error)
	Create(ctx context.Context, opts servers.CreateOptsBuilder) (*servers.Server, error)
	Get(ctx context.Context, id string) (*servers.Server, error)
	Update(ctx context.Context, id string, opts servers.UpdateOptsBuilder) (*servers.Server, error)
	Delete(ctx context.Context, id string) error
}

ServerClient is used to modify Virtual Machines in an OpenStack environment. It provides methods with CRUD functionalities.

type ServerGroupClient added in v0.11.0

ServerGroupClient is used to modify ServerGroups in an OpenStack environment. It provides methods with CRUD functionalities.

Directories

Path Synopsis
This package is used for testing.
This package is used for testing.

Jump to

Keyboard shortcuts

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