openstack

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 30 Imported by: 4

Documentation

Overview

Package openstack backups provides an implementation of Cinder Backup features cinder functions using Gophercloud.

Package openstack snapshots provides an implementation of Cinder Snapshot features cinder functions using Gophercloud.

Index

Constants

View Source
const (
	BackupMaxDurationSecondsPerGBDefault = 20
	BackupMaxDurationPerGB               = "backup-max-duration-seconds-per-gb"
)
View Source
const (
	SnapshotForceCreate      = "force-create"
	SnapshotType             = "type"
	SnapshotAvailabilityZone = "availability"
)
View Source
const (
	VolumeAvailableStatus = "available"
	VolumeInUseStatus     = "in-use"
	VolumeDetachingStatus = "detaching"
)

Variables

View Source
var (
	OsInstances map[string]IOpenStack
)

Functions

func AddExtraFlags added in v1.16.0

func AddExtraFlags(fs *pflag.FlagSet)

AddExtraFlags is called by the main package to add component specific command line flags

func InitOpenStackProvider

func InitOpenStackProvider(cfgFiles []string, httpEndpoint string)

Types

type BlockStorageOpts added in v1.15.0

type BlockStorageOpts struct {
	NodeVolumeAttachLimit    int64 `gcfg:"node-volume-attach-limit"`
	RescanOnResize           bool  `gcfg:"rescan-on-resize"`
	IgnoreVolumeAZ           bool  `gcfg:"ignore-volume-az"`
	IgnoreVolumeMicroversion bool  `gcfg:"ignore-volume-microversion"`
}

type Config

type Config struct {
	Global       map[string]*client.AuthOpts
	Metadata     metadata.Opts
	BlockStorage BlockStorageOpts
}

func GetConfigFromFiles added in v1.22.0

func GetConfigFromFiles(configFilePaths []string) (Config, error)

GetConfigFromFiles retrieves config options from file

type IOpenStack

type IOpenStack interface {
	CreateVolume(context.Context, *volumes.CreateOpts, volumes.SchedulerHintOptsBuilder) (*volumes.Volume, error)
	DeleteVolume(ctx context.Context, volumeID string) error
	AttachVolume(ctx context.Context, instanceID, volumeID string) (string, error)
	ListVolumes(ctx context.Context, limit int, startingToken string) ([]volumes.Volume, string, error)
	WaitDiskAttached(ctx context.Context, instanceID string, volumeID string) error
	DetachVolume(ctx context.Context, instanceID, volumeID string) error
	WaitDiskDetached(ctx context.Context, instanceID string, volumeID string) error
	WaitVolumeTargetStatus(ctx context.Context, volumeID string, tStatus []string) error
	GetAttachmentDiskPath(ctx context.Context, instanceID, volumeID string) (string, error)
	GetVolume(ctx context.Context, volumeID string) (*volumes.Volume, error)
	GetVolumesByName(ctx context.Context, name string) ([]volumes.Volume, error)
	GetVolumeByName(ctx context.Context, name string) (*volumes.Volume, error)
	CreateSnapshot(ctx context.Context, name, volID string, tags map[string]string) (*snapshots.Snapshot, error)
	ListSnapshots(ctx context.Context, filters map[string]string) ([]snapshots.Snapshot, string, error)
	DeleteSnapshot(ctx context.Context, snapID string) error
	GetSnapshotByID(ctx context.Context, snapshotID string) (*snapshots.Snapshot, error)
	WaitSnapshotReady(ctx context.Context, snapshotID string) (string, error)
	CreateBackup(ctx context.Context, name, volID, snapshotID, availabilityZone string, tags map[string]string) (*backups.Backup, error)
	ListBackups(ctx context.Context, filters map[string]string) ([]backups.Backup, error)
	DeleteBackup(ctx context.Context, backupID string) error
	GetBackupByID(ctx context.Context, backupID string) (*backups.Backup, error)
	BackupsAreEnabled() (bool, error)
	WaitBackupReady(ctx context.Context, backupID string, snapshotSize int, backupMaxDurationSecondsPerGB int) (string, error)
	GetInstanceByID(ctx context.Context, instanceID string) (*servers.Server, error)
	ExpandVolume(ctx context.Context, volumeID string, status string, size int) error
	GetMaxVolLimit() int64
	GetMetadataOpts() metadata.Opts
	GetBlockStorageOpts() BlockStorageOpts
	ResolveVolumeListToUUIDs(ctx context.Context, volumes string) (string, error)
}

func CreateOpenStackProvider added in v1.14.0

func CreateOpenStackProvider(cloudName string) (IOpenStack, error)

CreateOpenStackProvider creates Openstack Instance with custom Global config param

func GetOpenStackProvider

func GetOpenStackProvider(cloudName string) (IOpenStack, error)

GetOpenStackProvider returns Openstack Instance

type OpenStack

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

func (*OpenStack) AttachVolume

func (os *OpenStack) AttachVolume(ctx context.Context, instanceID, volumeID string) (string, error)

AttachVolume attaches given cinder volume to the compute

func (*OpenStack) BackupsAreEnabled added in v1.30.0

func (os *OpenStack) BackupsAreEnabled() (bool, error)

func (*OpenStack) CreateBackup added in v1.30.0

func (os *OpenStack) CreateBackup(ctx context.Context, name, volID, snapshotID, availabilityZone string, tags map[string]string) (*backups.Backup, error)

CreateBackup issues a request to create a Backup from the specified Snapshot with the corresponding ID and returns the resultant gophercloud Backup Item upon success.

func (*OpenStack) CreateSnapshot

func (os *OpenStack) CreateSnapshot(ctx context.Context, name, volID string, tags map[string]string) (*snapshots.Snapshot, error)

CreateSnapshot issues a request to take a Snapshot of the specified Volume with the corresponding ID and returns the resultant gophercloud Snapshot Item upon success

func (*OpenStack) CreateVolume

func (os *OpenStack) CreateVolume(ctx context.Context, opts *volumes.CreateOpts, schedulerHints volumes.SchedulerHintOptsBuilder) (*volumes.Volume, error)

CreateVolume creates a volume of given size

func (*OpenStack) DeleteBackup added in v1.30.0

func (os *OpenStack) DeleteBackup(ctx context.Context, backupID string) error

DeleteBackup issues a request to delete the Backup with the specified ID from the Cinder backend.

func (*OpenStack) DeleteSnapshot

func (os *OpenStack) DeleteSnapshot(ctx context.Context, snapID string) error

DeleteSnapshot issues a request to delete the Snapshot with the specified ID from the Cinder backend

func (*OpenStack) DeleteVolume

func (os *OpenStack) DeleteVolume(ctx context.Context, volumeID string) error

DeleteVolume delete a volume

func (*OpenStack) DetachVolume

func (os *OpenStack) DetachVolume(ctx context.Context, instanceID, volumeID string) error

DetachVolume detaches given cinder volume from the compute

func (*OpenStack) ExpandVolume added in v1.16.0

func (os *OpenStack) ExpandVolume(ctx context.Context, volumeID string, status string, newSize int) error

ExpandVolume expands the volume to new size

func (*OpenStack) GetAttachmentDiskPath

func (os *OpenStack) GetAttachmentDiskPath(ctx context.Context, instanceID, volumeID string) (string, error)

GetAttachmentDiskPath gets device path of attached volume to the compute

func (*OpenStack) GetBackupByID added in v1.30.0

func (os *OpenStack) GetBackupByID(ctx context.Context, backupID string) (*backups.Backup, error)

GetBackupByID returns backup details by id.

func (*OpenStack) GetBlockStorageOpts added in v1.18.0

func (os *OpenStack) GetBlockStorageOpts() BlockStorageOpts

GetBlockStorageOpts returns OpenStack block storage options

func (*OpenStack) GetInstanceByID added in v1.16.0

func (os *OpenStack) GetInstanceByID(ctx context.Context, instanceID string) (*servers.Server, error)

GetInstanceByID returns server with specified instanceID

func (*OpenStack) GetMaxVolLimit added in v1.16.0

func (os *OpenStack) GetMaxVolLimit() int64

GetMaxVolLimit returns max vol limit

func (*OpenStack) GetMetadataOpts added in v1.18.0

func (os *OpenStack) GetMetadataOpts() metadata.Opts

GetMetadataOpts returns metadataopts

func (*OpenStack) GetSnapshotByID added in v1.14.0

func (os *OpenStack) GetSnapshotByID(ctx context.Context, snapshotID string) (*snapshots.Snapshot, error)

GetSnapshotByID returns snapshot details by id

func (*OpenStack) GetVolume

func (os *OpenStack) GetVolume(ctx context.Context, volumeID string) (*volumes.Volume, error)

GetVolume retrieves Volume by its ID.

func (*OpenStack) GetVolumeByName added in v1.32.0

func (os *OpenStack) GetVolumeByName(ctx context.Context, n string) (*volumes.Volume, error)

GetVolumeByName is a wrapper around GetVolumesByName that returns a single Volume reference with the specified name

func (*OpenStack) GetVolumesByName

func (os *OpenStack) GetVolumesByName(ctx context.Context, n string) ([]volumes.Volume, error)

GetVolumesByName is a wrapper around ListVolumes that creates a Name filter to act as a GetByName Returns a list of Volume references with the specified name

func (*OpenStack) ListBackups added in v1.30.0

func (os *OpenStack) ListBackups(ctx context.Context, filters map[string]string) ([]backups.Backup, error)

ListBackups retrieves a list of active backups from Cinder for the corresponding Tenant. We also provide the ability to provide limit and offset to enable the consumer to provide accurate pagination. In addition the filters argument provides a mechanism for passing in valid filter strings to the list operation. Valid filter keys are: Name, Status, VolumeID, Limit, Marker (TenantID has no effect).

func (*OpenStack) ListSnapshots

func (os *OpenStack) ListSnapshots(ctx context.Context, filters map[string]string) ([]snapshots.Snapshot, string, error)

ListSnapshots retrieves a list of active snapshots from Cinder for the corresponding Tenant. We also provide the ability to provide limit and offset to enable the consumer to provide accurate pagination. In addition the filters argument provides a mechanism for passing in valid filter strings to the list operation. Valid filter keys are: Name, Status, VolumeID, Limit, Marker (TenantID has no effect)

func (*OpenStack) ListVolumes added in v1.14.0

func (os *OpenStack) ListVolumes(ctx context.Context, limit int, startingToken string) ([]volumes.Volume, string, error)

ListVolumes list all the volumes

func (*OpenStack) ResolveVolumeListToUUIDs added in v1.32.0

func (os *OpenStack) ResolveVolumeListToUUIDs(ctx context.Context, affinityList string) (string, error)

ResolveVolumeListToUUIDs resolves a list of volume names or UUIDs to a string of UUIDs

func (*OpenStack) WaitBackupReady added in v1.30.0

func (os *OpenStack) WaitBackupReady(ctx context.Context, backupID string, snapshotSize int, backupMaxDurationSecondsPerGB int) (string, error)

WaitBackupReady waits until backup is ready. It waits longer depending on the size of the corresponding snapshot.

func (*OpenStack) WaitDiskAttached

func (os *OpenStack) WaitDiskAttached(ctx context.Context, instanceID string, volumeID string) error

WaitDiskAttached waits for attached

func (*OpenStack) WaitDiskDetached

func (os *OpenStack) WaitDiskDetached(ctx context.Context, instanceID string, volumeID string) error

WaitDiskDetached waits for detached

func (*OpenStack) WaitSnapshotReady added in v1.14.0

func (os *OpenStack) WaitSnapshotReady(ctx context.Context, snapshotID string) (string, error)

WaitSnapshotReady waits till snapshot is ready

func (*OpenStack) WaitVolumeTargetStatus added in v1.21.0

func (os *OpenStack) WaitVolumeTargetStatus(ctx context.Context, volumeID string, tStatus []string) error

WaitVolumeTargetStatus waits for volume to be in target state

type OpenStackMock

type OpenStackMock struct {
	mock.Mock
}

revive:disable:exported OpenStackMock is an autogenerated mock type for the IOpenStack type ORIGINALLY GENERATED BY mockery with hand edits

func (*OpenStackMock) AttachVolume

func (_m *OpenStackMock) AttachVolume(ctx context.Context, instanceID string, volumeID string) (string, error)

AttachVolume provides a mock function with given fields: instanceID, volumeID

func (*OpenStackMock) BackupsAreEnabled added in v1.30.0

func (_m *OpenStackMock) BackupsAreEnabled() (bool, error)

func (*OpenStackMock) CreateBackup added in v1.30.0

func (_m *OpenStackMock) CreateBackup(ctx context.Context, name, volID, snapshotID, availabilityZone string, tags map[string]string) (*backups.Backup, error)

func (*OpenStackMock) CreateSnapshot

func (_m *OpenStackMock) CreateSnapshot(ctx context.Context, name string, volID string, tags map[string]string) (*snapshots.Snapshot, error)

CreateSnapshot provides a mock function with given fields: name, volID, tags

func (*OpenStackMock) CreateVolume

CreateVolume provides a mock function with given fields: name, size, vtype, availability, tags

func (*OpenStackMock) DeleteBackup added in v1.30.0

func (_m *OpenStackMock) DeleteBackup(ctx context.Context, backupID string) error

func (*OpenStackMock) DeleteSnapshot

func (_m *OpenStackMock) DeleteSnapshot(ctx context.Context, snapID string) error

DeleteSnapshot provides a mock function with given fields: snapID

func (*OpenStackMock) DeleteVolume

func (_m *OpenStackMock) DeleteVolume(ctx context.Context, volumeID string) error

DeleteVolume provides a mock function with given fields: volumeID

func (*OpenStackMock) DetachVolume

func (_m *OpenStackMock) DetachVolume(ctx context.Context, instanceID string, volumeID string) error

DetachVolume provides a mock function with given fields: instanceID, volumeID

func (*OpenStackMock) ExpandVolume added in v1.16.0

func (_m *OpenStackMock) ExpandVolume(ctx context.Context, volumeID string, status string, size int) error

ExpandVolume provides a mock function with given fields: instanceID, volumeID

func (*OpenStackMock) GetAttachmentDiskPath

func (_m *OpenStackMock) GetAttachmentDiskPath(ctx context.Context, instanceID string, volumeID string) (string, error)

GetAttachmentDiskPath provides a mock function with given fields: instanceID, volumeID

func (*OpenStackMock) GetAvailabilityZone added in v1.14.0

func (_m *OpenStackMock) GetAvailabilityZone(ctx context.Context) (string, error)

func (*OpenStackMock) GetBackupByID added in v1.30.0

func (_m *OpenStackMock) GetBackupByID(ctx context.Context, backupID string) (*backups.Backup, error)

func (*OpenStackMock) GetBlockStorageOpts added in v1.18.0

func (_m *OpenStackMock) GetBlockStorageOpts() BlockStorageOpts

GetBlockStorageOpts provides a mock function to return BlockStorageOpts

func (*OpenStackMock) GetInstanceByID added in v1.16.0

func (_m *OpenStackMock) GetInstanceByID(ctx context.Context, instanceID string) (*servers.Server, error)

func (*OpenStackMock) GetInstanceID added in v1.14.0

func (_m *OpenStackMock) GetInstanceID() (string, error)

func (*OpenStackMock) GetMaxVolLimit added in v1.15.0

func (_m *OpenStackMock) GetMaxVolLimit() int64

func (*OpenStackMock) GetMetadataOpts added in v1.18.0

func (_m *OpenStackMock) GetMetadataOpts() metadata.Opts

func (*OpenStackMock) GetSnapshotByID added in v1.14.0

func (_m *OpenStackMock) GetSnapshotByID(ctx context.Context, snapshotID string) (*snapshots.Snapshot, error)

func (*OpenStackMock) GetVolume added in v1.15.0

func (_m *OpenStackMock) GetVolume(ctx context.Context, volumeID string) (*volumes.Volume, error)

GetVolume provides a mock function with given fields: volumeID

func (*OpenStackMock) GetVolumeByName added in v1.32.0

func (_m *OpenStackMock) GetVolumeByName(ctx context.Context, name string) (*volumes.Volume, error)

GetVolumeByName provides a mock function with given fields: name

func (*OpenStackMock) GetVolumesByName

func (_m *OpenStackMock) GetVolumesByName(ctx context.Context, name string) ([]volumes.Volume, error)

GetVolumesByName provides a mock function with given fields: name

func (*OpenStackMock) ListBackups added in v1.30.0

func (_m *OpenStackMock) ListBackups(ctx context.Context, filters map[string]string) ([]backups.Backup, error)

func (*OpenStackMock) ListSnapshots

func (_m *OpenStackMock) ListSnapshots(ctx context.Context, filters map[string]string) ([]snapshots.Snapshot, string, error)

ListSnapshots provides a mock function with given fields: limit, offset, filters

func (*OpenStackMock) ListVolumes added in v1.14.0

func (_m *OpenStackMock) ListVolumes(ctx context.Context, limit int, marker string) ([]volumes.Volume, string, error)

ListVolumes provides a mock function without param

func (*OpenStackMock) ResolveVolumeListToUUIDs added in v1.32.0

func (_m *OpenStackMock) ResolveVolumeListToUUIDs(ctx context.Context, v string) (string, error)

ResolveVolumeListToUUIDs provides a mock function to return volume UUIDs

func (*OpenStackMock) WaitBackupReady added in v1.30.0

func (_m *OpenStackMock) WaitBackupReady(ctx context.Context, backupID string, snapshotSize int, backupMaxDurationSecondsPerGB int) (string, error)

func (*OpenStackMock) WaitDiskAttached

func (_m *OpenStackMock) WaitDiskAttached(ctx context.Context, instanceID string, volumeID string) error

WaitDiskAttached provides a mock function with given fields: instanceID, volumeID

func (*OpenStackMock) WaitDiskDetached

func (_m *OpenStackMock) WaitDiskDetached(ctx context.Context, instanceID string, volumeID string) error

WaitDiskDetached provides a mock function with given fields: instanceID, volumeID

func (*OpenStackMock) WaitSnapshotReady added in v1.14.0

func (_m *OpenStackMock) WaitSnapshotReady(ctx context.Context, snapshotID string) (string, error)

func (*OpenStackMock) WaitVolumeTargetStatus added in v1.21.0

func (_m *OpenStackMock) WaitVolumeTargetStatus(ctx context.Context, volumeID string, tStatus []string) error

WaitVolumeTargetStatus provides a mock function with given fields: volumeID, tStatus

Jump to

Keyboard shortcuts

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