client

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServerGroupPolicyAntiAffinity is a constant for the anti-affinity server group policy.
	ServerGroupPolicyAntiAffinity = "anti-affinity"
	// ServerGroupPolicyAffinity is a constant for the affinity server group policy.
	ServerGroupPolicyAffinity = "affinity"
)

Variables

This section is empty.

Functions

func IgnoreNotFoundError

func IgnoreNotFoundError(err error) error

IgnoreNotFoundError ignore not found error

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if an error returned by OpenStack is caused by HTTP 404 status code.

Types

type Compute

type Compute interface {
	CreateServerGroup(ctx context.Context, name, policy string) (*servergroups.ServerGroup, error)
	GetServerGroup(ctx context.Context, id string) (*servergroups.ServerGroup, error)
	DeleteServerGroup(ctx context.Context, id string) error
	// Server
	CreateServer(ctx context.Context, createOpts servers.CreateOpts) (*servers.Server, error)
	DeleteServer(ctx context.Context, id string) error
	ListServerGroups(ctx context.Context) ([]servergroups.ServerGroup, error)
	FindServersByName(ctx context.Context, name string) ([]servers.Server, error)

	// Flavor
	FindFlavorID(ctx context.Context, name string) (string, error)

	// KeyPairs
	CreateKeyPair(ctx context.Context, name, publicKey string) (*keypairs.KeyPair, error)
	GetKeyPair(ctx context.Context, name string) (*keypairs.KeyPair, error)
	DeleteKeyPair(ctx context.Context, name string) error
}

Compute describes the operations of a client interacting with OpenStack's Compute service.

type ComputeClient

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

ComputeClient is a client for the Nova service.

func (*ComputeClient) CreateKeyPair

func (c *ComputeClient) CreateKeyPair(ctx context.Context, name, publicKey string) (*keypairs.KeyPair, error)

CreateKeyPair creates an SSH key pair

func (*ComputeClient) CreateServer

func (c *ComputeClient) CreateServer(ctx context.Context, createOpts servers.CreateOpts) (*servers.Server, error)

CreateServer retrieves the Create of Compute service.

func (*ComputeClient) CreateServerGroup

func (c *ComputeClient) CreateServerGroup(ctx context.Context, name, policy string) (*servergroups.ServerGroup, error)

CreateServerGroup creates a server group with the specified policy.

func (*ComputeClient) DeleteKeyPair

func (c *ComputeClient) DeleteKeyPair(ctx context.Context, name string) error

DeleteKeyPair deletes an SSH key pair by name

func (*ComputeClient) DeleteServer

func (c *ComputeClient) DeleteServer(ctx context.Context, id string) error

DeleteServer delete the Compute service.

func (*ComputeClient) DeleteServerGroup

func (c *ComputeClient) DeleteServerGroup(ctx context.Context, id string) error

DeleteServerGroup deletes the server group with the specified id. It returns nil if the server group could not be found.

func (*ComputeClient) FindFlavorID

func (c *ComputeClient) FindFlavorID(ctx context.Context, name string) (string, error)

FindFlavorID find flavor ID by flavor name

func (*ComputeClient) FindImageByID

func (c *ComputeClient) FindImageByID(ctx context.Context, id string) (*images.Image, error)

FindImageByID returns the image with the given ID. It returns nil if the image is not found.

func (*ComputeClient) FindImages

func (c *ComputeClient) FindImages(ctx context.Context, name string) ([]images.Image, error)

FindImages find image ID by images name

func (*ComputeClient) FindServersByName

func (c *ComputeClient) FindServersByName(ctx context.Context, name string) ([]servers.Server, error)

FindServersByName retrieves the Compute Server by Name

func (*ComputeClient) GetKeyPair

func (c *ComputeClient) GetKeyPair(ctx context.Context, name string) (*keypairs.KeyPair, error)

GetKeyPair gets an SSH key pair by name

func (*ComputeClient) GetServerGroup

func (c *ComputeClient) GetServerGroup(ctx context.Context, id string) (*servergroups.ServerGroup, error)

GetServerGroup retrieves the server group with the specified id.

func (*ComputeClient) ListImages

func (c *ComputeClient) ListImages(ctx context.Context, listOpts images.ListOpts) ([]images.Image, error)

ListImages list all images

func (*ComputeClient) ListServerGroups

func (c *ComputeClient) ListServerGroups(ctx context.Context) ([]servergroups.ServerGroup, error)

ListServerGroups retrieves the list of server groups.

type DNS

type DNS interface {
	GetZones(ctx context.Context) (map[string]string, error)
	CreateOrUpdateRecordSet(ctx context.Context, zoneID, name, recordType string, records []string, ttl int) error
	DeleteRecordSet(ctx context.Context, zoneID, name, recordType string) error
}

DNS describes the operations of a client interacting with OpenStack's DNS service.

type DNSClient

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

DNSClient is a client for the Designate service.

func (*DNSClient) CreateOrUpdateRecordSet

func (c *DNSClient) CreateOrUpdateRecordSet(ctx context.Context, zoneID, name, recordType string, records []string, ttl int) error

CreateOrUpdateRecordSet creates or updates the recordset with the given name, record type, records, and ttl in the zone with the given zone ID.

func (*DNSClient) DeleteRecordSet

func (c *DNSClient) DeleteRecordSet(ctx context.Context, zoneID, name, recordType string) error

DeleteRecordSet deletes the recordset with the given name and record type in the zone with the given zone ID.

func (*DNSClient) GetZones

func (c *DNSClient) GetZones(ctx context.Context) (map[string]string, error)

GetZones returns a map of all zone names mapped to their IDs.

type Factory

type Factory interface {
	Compute(options ...Option) (Compute, error)
	Storage(options ...Option) (Storage, error)
	DNS(options ...Option) (DNS, error)
	Networking(options ...Option) (Networking, error)
	Loadbalancing(options ...Option) (Loadbalancing, error)
	Images(options ...Option) (Images, error)
}

Factory is an interface for constructing OpenStack service clients.

func NewOpenStackClientFromSecretRef

func NewOpenStackClientFromSecretRef(ctx context.Context, c client.Client, secretRef corev1.SecretReference, keyStoneURL *string) (Factory, error)

NewOpenStackClientFromSecretRef returns a Factory implementation that can be used to create clients for OpenStack services. The credentials are fetched from the Kubernetes secret referenced by <secretRef>.

func NewOpenstackClientFromCredentials

func NewOpenstackClientFromCredentials(ctx context.Context, credentials *os.Credentials) (Factory, error)

NewOpenstackClientFromCredentials returns a Factory implementation that can be used to create clients for OpenStack services. TODO: respect CloudProfile's requestTimeout for the OpenStack client. see https://github.com/kubernetes/cloud-provider-openstack/blob/c44d941cdb5c7fe651f5cb9191d0af23e266c7cb/pkg/openstack/openstack.go#L257

type FactoryFactory

type FactoryFactory interface {
	// NewFactory creates a new instance of Factory for the given Openstack credentials.
	NewFactory(ctx context.Context, credentials *openstack.Credentials) (Factory, error)
}

FactoryFactory creates instances of Factory.

type FactoryFactoryFunc

type FactoryFactoryFunc func(ctx context.Context, credentials *openstack.Credentials) (Factory, error)

FactoryFactoryFunc is a function that implements FactoryFactory.

func (FactoryFactoryFunc) NewFactory

func (f FactoryFactoryFunc) NewFactory(ctx context.Context, credentials *openstack.Credentials) (Factory, error)

NewFactory creates a new instance of Factory for the given Openstack credentials.

type ImageClient

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

ImageClient is a client for images

func (*ImageClient) ListImages

func (c *ImageClient) ListImages(ctx context.Context, listOpts images.ListOpts) ([]images.Image, error)

ListImages lists all images filtered by listOpts

type Images

type Images interface {
	ListImages(ctx context.Context, opts images.ListOpts) ([]images.Image, error)
}

Images describes the operations of a client interacting with images

type Loadbalancing

type Loadbalancing interface {
	ListLoadbalancers(ctx context.Context, opts loadbalancers.ListOpts) ([]loadbalancers.LoadBalancer, error)
	DeleteLoadbalancer(ctx context.Context, id string, opts loadbalancers.DeleteOpts) error
	GetLoadbalancer(ctx context.Context, id string) (*loadbalancers.LoadBalancer, error)
}

Loadbalancing describes the operations of a client interacting with OpenStack's Octavia service.

type LoadbalancingClient

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

LoadbalancingClient is a client for Octavia service.

func (*LoadbalancingClient) DeleteLoadbalancer

func (c *LoadbalancingClient) DeleteLoadbalancer(ctx context.Context, id string, opts loadbalancers.DeleteOpts) error

DeleteLoadbalancer deletes the loadbalancer with the specified ID.

func (*LoadbalancingClient) GetLoadbalancer

func (c *LoadbalancingClient) GetLoadbalancer(ctx context.Context, id string) (*loadbalancers.LoadBalancer, error)

GetLoadbalancer returns the loadbalancer with the specified ID.

func (*LoadbalancingClient) ListLoadbalancers

func (c *LoadbalancingClient) ListLoadbalancers(ctx context.Context, listOpts loadbalancers.ListOpts) ([]loadbalancers.LoadBalancer, error)

ListLoadbalancers returns a list of all loadbalancers info by listOpts

type Networking

type Networking interface {
	// External Network
	GetExternalNetworkNames(ctx context.Context) ([]string, error)
	GetExternalNetworkByName(ctx context.Context, name string) (*networks.Network, error)
	// Network
	CreateNetwork(ctx context.Context, opts networks.CreateOpts) (*networks.Network, error)
	ListNetwork(ctx context.Context, listOpts networks.ListOpts) ([]networks.Network, error)
	UpdateNetwork(ctx context.Context, networkID string, opts networks.UpdateOpts) (*networks.Network, error)
	GetNetworkByName(ctx context.Context, name string) ([]networks.Network, error)
	GetNetworkByID(ctx context.Context, id string) (*networks.Network, error)
	DeleteNetwork(ctx context.Context, networkID string) error
	// FloatingIP
	CreateFloatingIP(ctx context.Context, createOpts floatingips.CreateOpts) (*floatingips.FloatingIP, error)
	DeleteFloatingIP(ctx context.Context, id string) error
	ListFip(ctx context.Context, listOpts floatingips.ListOpts) ([]floatingips.FloatingIP, error)
	GetFipByName(ctx context.Context, name string) ([]floatingips.FloatingIP, error)
	// Security Group
	CreateSecurityGroup(ctx context.Context, listOpts groups.CreateOpts) (*groups.SecGroup, error)
	DeleteSecurityGroup(ctx context.Context, groupID string) error
	ListSecurityGroup(ctx context.Context, listOpts groups.ListOpts) ([]groups.SecGroup, error)
	GetSecurityGroup(ctx context.Context, groupID string) (*groups.SecGroup, error)
	GetSecurityGroupByName(ctx context.Context, name string) ([]groups.SecGroup, error)
	// Security Group rules
	CreateRule(ctx context.Context, createOpts rules.CreateOpts) (*rules.SecGroupRule, error)
	ListRules(ctx context.Context, listOpts rules.ListOpts) ([]rules.SecGroupRule, error)
	DeleteRule(ctx context.Context, ruleID string) error
	// Routers
	GetRouterByID(ctx context.Context, id string) (*routers.Router, error)
	ListRouters(ctx context.Context, listOpts routers.ListOpts) ([]routers.Router, error)
	UpdateRoutesForRouter(ctx context.Context, routes []routers.Route, routerID string) (*routers.Router, error)
	UpdateRouter(ctx context.Context, routerID string, updateOpts routers.UpdateOpts) (*routers.Router, error)
	CreateRouter(ctx context.Context, createOpts routers.CreateOpts) (*routers.Router, error)
	DeleteRouter(ctx context.Context, routerID string) error
	AddRouterInterface(ctx context.Context, routerID string, addOpts routers.AddInterfaceOpts) (*routers.InterfaceInfo, error)
	RemoveRouterInterface(ctx context.Context, routerID string, removeOpts routers.RemoveInterfaceOpts) (*routers.InterfaceInfo, error)
	// Subnets
	CreateSubnet(ctx context.Context, createOpts subnets.CreateOpts) (*subnets.Subnet, error)
	GetSubnetByID(ctx context.Context, id string) (*subnets.Subnet, error)
	ListSubnets(ctx context.Context, listOpts subnets.ListOpts) ([]subnets.Subnet, error)
	UpdateSubnet(ctx context.Context, subnetID string, updateOpts subnets.UpdateOpts) (*subnets.Subnet, error)
	DeleteSubnet(ctx context.Context, subnetID string) error
	// Ports
	GetPort(ctx context.Context, portID string) (*ports.Port, error)
	GetRouterInterfacePort(ctx context.Context, routerID, subnetID string) (*ports.Port, error)
	GetRouterInterfacePortsByNetwork(ctx context.Context, networkID string) ([]ports.Port, error)
	// Tags
	AddTag(ctx context.Context, resourceType string, resourceID string, tag string) error
}

Networking describes the operations of a client interacting with OpenStack's Networking service.

type NetworkingClient

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

NetworkingClient is a client for the Neutron service.

func (*NetworkingClient) AddRouterInterface

func (c *NetworkingClient) AddRouterInterface(ctx context.Context, routerID string, addOpts routers.AddInterfaceOpts) (*routers.InterfaceInfo, error)

AddRouterInterface adds a router interface

func (*NetworkingClient) AddTag

func (c *NetworkingClient) AddTag(ctx context.Context, resourceType string, resourceID string, tag string) error

AddTag adds a tag to the resource specified by resourceType and resourceID

func (*NetworkingClient) CreateFloatingIP

func (c *NetworkingClient) CreateFloatingIP(ctx context.Context, createOpts floatingips.CreateOpts) (*floatingips.FloatingIP, error)

CreateFloatingIP create floating ip

func (*NetworkingClient) CreateNetwork

func (c *NetworkingClient) CreateNetwork(ctx context.Context, opts networks.CreateOpts) (*networks.Network, error)

CreateNetwork creates a network

func (*NetworkingClient) CreateRouter

func (c *NetworkingClient) CreateRouter(ctx context.Context, createOpts routers.CreateOpts) (*routers.Router, error)

CreateRouter creates a router

func (*NetworkingClient) CreateRule

func (c *NetworkingClient) CreateRule(ctx context.Context, createOpts rules.CreateOpts) (*rules.SecGroupRule, error)

CreateRule create security group rule

func (*NetworkingClient) CreateSecurityGroup

func (c *NetworkingClient) CreateSecurityGroup(ctx context.Context, listOpts groups.CreateOpts) (*groups.SecGroup, error)

CreateSecurityGroup create a security group

func (*NetworkingClient) CreateSubnet

func (c *NetworkingClient) CreateSubnet(ctx context.Context, createOpts subnets.CreateOpts) (*subnets.Subnet, error)

CreateSubnet creates a subnet

func (*NetworkingClient) DeleteFloatingIP

func (c *NetworkingClient) DeleteFloatingIP(ctx context.Context, id string) error

DeleteFloatingIP delete floatingip by floatingip id

func (*NetworkingClient) DeleteNetwork

func (c *NetworkingClient) DeleteNetwork(ctx context.Context, networkID string) error

DeleteNetwork deletes a network

func (*NetworkingClient) DeleteRouter

func (c *NetworkingClient) DeleteRouter(ctx context.Context, routerID string) error

DeleteRouter deletes a router by identifier

func (*NetworkingClient) DeleteRule

func (c *NetworkingClient) DeleteRule(ctx context.Context, ruleID string) error

DeleteRule delete security group rule

func (*NetworkingClient) DeleteSecurityGroup

func (c *NetworkingClient) DeleteSecurityGroup(ctx context.Context, groupID string) error

DeleteSecurityGroup delete a security group

func (*NetworkingClient) DeleteSubnet

func (c *NetworkingClient) DeleteSubnet(ctx context.Context, subnetID string) error

DeleteSubnet deletes a subnet by identifier

func (*NetworkingClient) GetExternalNetworkByName

func (c *NetworkingClient) GetExternalNetworkByName(ctx context.Context, name string) (*networks.Network, error)

GetExternalNetworkByName returns an external network by name

func (*NetworkingClient) GetExternalNetworkNames

func (c *NetworkingClient) GetExternalNetworkNames(ctx context.Context) ([]string, error)

GetExternalNetworkNames returns a list of all external network names.

func (*NetworkingClient) GetFipByName

func (c *NetworkingClient) GetFipByName(ctx context.Context, name string) ([]floatingips.FloatingIP, error)

GetFipByName returns floating IP info by floatingip name

func (*NetworkingClient) GetNetworkByID

func (c *NetworkingClient) GetNetworkByID(ctx context.Context, id string) (*networks.Network, error)

GetNetworkByID return a network info by id

func (*NetworkingClient) GetNetworkByName

func (c *NetworkingClient) GetNetworkByName(ctx context.Context, name string) ([]networks.Network, error)

GetNetworkByName return a network info by name

func (*NetworkingClient) GetPort

func (c *NetworkingClient) GetPort(ctx context.Context, portID string) (*ports.Port, error)

GetPort gets a port by identifier

func (*NetworkingClient) GetRouterByID

func (c *NetworkingClient) GetRouterByID(ctx context.Context, id string) (*routers.Router, error)

GetRouterByID return a router info by name

func (*NetworkingClient) GetRouterInterfacePort

func (c *NetworkingClient) GetRouterInterfacePort(ctx context.Context, routerID, subnetID string) (*ports.Port, error)

GetRouterInterfacePort gets a port for a router interface

func (*NetworkingClient) GetRouterInterfacePortsByNetwork

func (c *NetworkingClient) GetRouterInterfacePortsByNetwork(ctx context.Context, networkID string) ([]ports.Port, error)

GetRouterInterfacePortsByNetwork gets all router ports in a network

func (*NetworkingClient) GetSecurityGroup

func (c *NetworkingClient) GetSecurityGroup(ctx context.Context, groupID string) (*groups.SecGroup, error)

GetSecurityGroup returns a security group info by id

func (*NetworkingClient) GetSecurityGroupByName

func (c *NetworkingClient) GetSecurityGroupByName(ctx context.Context, name string) ([]groups.SecGroup, error)

GetSecurityGroupByName returns a security group info by security group name

func (*NetworkingClient) GetSubnetByID

func (c *NetworkingClient) GetSubnetByID(ctx context.Context, id string) (*subnets.Subnet, error)

GetSubnetByID return a subnet info by id

func (*NetworkingClient) ListFip

ListFip returns a list of all network info

func (*NetworkingClient) ListNetwork

func (c *NetworkingClient) ListNetwork(ctx context.Context, listOpts networks.ListOpts) ([]networks.Network, error)

ListNetwork returns a list of all network info by listOpts

func (*NetworkingClient) ListRouters

func (c *NetworkingClient) ListRouters(ctx context.Context, listOpts routers.ListOpts) ([]routers.Router, error)

ListRouters returns a list of routers

func (*NetworkingClient) ListRules

func (c *NetworkingClient) ListRules(ctx context.Context, listOpts rules.ListOpts) ([]rules.SecGroupRule, error)

ListRules returns a list of security group rules

func (*NetworkingClient) ListSecurityGroup

func (c *NetworkingClient) ListSecurityGroup(ctx context.Context, listOpts groups.ListOpts) ([]groups.SecGroup, error)

ListSecurityGroup returns a list of security group

func (*NetworkingClient) ListSubnets

func (c *NetworkingClient) ListSubnets(ctx context.Context, listOpts subnets.ListOpts) ([]subnets.Subnet, error)

ListSubnets returns a list of subnets

func (*NetworkingClient) RemoveRouterInterface

func (c *NetworkingClient) RemoveRouterInterface(ctx context.Context, routerID string, removeOpts routers.RemoveInterfaceOpts) (*routers.InterfaceInfo, error)

RemoveRouterInterface removes a router interface

func (*NetworkingClient) UpdateNetwork

func (c *NetworkingClient) UpdateNetwork(ctx context.Context, networkID string, opts networks.UpdateOpts) (*networks.Network, error)

UpdateNetwork updates settings of a network resource

func (*NetworkingClient) UpdateRouter

func (c *NetworkingClient) UpdateRouter(ctx context.Context, routerID string, updateOpts routers.UpdateOpts) (*routers.Router, error)

UpdateRouter updates router settings

func (*NetworkingClient) UpdateRoutesForRouter

func (c *NetworkingClient) UpdateRoutesForRouter(ctx context.Context, routes []routers.Route, routerID string) (*routers.Router, error)

UpdateRoutesForRouter updates the route list for a router

func (*NetworkingClient) UpdateSubnet

func (c *NetworkingClient) UpdateSubnet(ctx context.Context, id string, updateOpts subnets.UpdateOpts) (*subnets.Subnet, error)

UpdateSubnet updates a subnet

type OpenstackClientFactory

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

OpenstackClientFactory implements a factory that can construct clients for Openstack services.

func (*OpenstackClientFactory) Compute

func (oc *OpenstackClientFactory) Compute(options ...Option) (Compute, error)

Compute returns a Compute client. The client uses Nova v2 API for issuing calls.

func (*OpenstackClientFactory) DNS

func (oc *OpenstackClientFactory) DNS(options ...Option) (DNS, error)

DNS returns a DNS client. The client uses Designate v2 API for issuing calls.

func (*OpenstackClientFactory) Images

func (oc *OpenstackClientFactory) Images(options ...Option) (Images, error)

Images creates a Images client

func (*OpenstackClientFactory) Loadbalancing

func (oc *OpenstackClientFactory) Loadbalancing(options ...Option) (Loadbalancing, error)

Loadbalancing creates a Loadbalancing client.

func (*OpenstackClientFactory) Networking

func (oc *OpenstackClientFactory) Networking(options ...Option) (Networking, error)

Networking returns a Networking client. The client uses Neutron v2 API for issuing calls.

func (*OpenstackClientFactory) Storage

func (oc *OpenstackClientFactory) Storage(options ...Option) (Storage, error)

Storage returns a Storage client. The client uses Swift v1 API for issuing calls.

type Option

Option can be passed to Factory implementations to modify the produced clients.

func WithRegion

func WithRegion(region string) Option

WithRegion returns an Option that can modify the region a client targets.

type Storage

type Storage interface {
	DeleteObjectsWithPrefix(ctx context.Context, container, prefix string) error
	CreateContainerIfNotExists(ctx context.Context, container string) error
	DeleteContainerIfExists(ctx context.Context, container string) error
}

Storage describes the operations of a client interacting with OpenStack's ObjectStorage service. NOTE: DONE!

func NewStorageClientFromSecretRef

func NewStorageClientFromSecretRef(ctx context.Context, c client.Client, secretRef corev1.SecretReference, region string) (Storage, error)

NewStorageClientFromSecretRef retrieves the openstack client from specified by the secret reference.

type StorageClient

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

StorageClient is a client for the Swift service.

func (*StorageClient) CreateContainerIfNotExists

func (s *StorageClient) CreateContainerIfNotExists(ctx context.Context, container string) error

CreateContainerIfNotExists creates the openstack blob container with name <container>. If it already exist, no error is returned.

func (*StorageClient) DeleteContainerIfExists

func (s *StorageClient) DeleteContainerIfExists(ctx context.Context, container string) error

DeleteContainerIfExists deletes the openstack blob container with name <container>. If it does not exist, no error is returned.

func (*StorageClient) DeleteObjectsWithPrefix

func (s *StorageClient) DeleteObjectsWithPrefix(ctx context.Context, container, prefix string) error

DeleteObjectsWithPrefix deletes the blob objects with the specific <prefix> from <container>. If it does not exist, no error is returned.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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