provider

package
v0.0.0-...-9561690 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VpcVolumeAttachment = "vpcVolumeAttachment"
	StatusAttached      = "attached"
	StatusAttaching     = "attaching"
	StatusDetaching     = "detaching"
)

VpcVolumeAttachment ...

View Source
const (

	// VPCClassic ...
	VPCClassic = "gc"
	// VPCNextGen ...
	VPCNextGen = "g2"
	// PrivatePrefix ...
	PrivatePrefix = "private-"
	// BasePrivateURL ...
	BasePrivateURL = "https://" + PrivatePrefix
	// HTTPSLength ...
	HTTPSLength = 8
	// NEXTGenProvider ...
	NEXTGenProvider = 2
)
View Source
const (
	// VPC storage provider
	VPC = provider.VolumeProvider("VPC")
	// VolumeType ...
	VolumeType = provider.VolumeType("vpc-block")
	// SnapshotMask ...
	SnapshotMask = "" /* 337-byte string literal not displayed */
)
View Source
const (
	ConstantRetryGap = 10 // seconds
)

ConstantRetryGap ...

Variables

View Source
var (
	// DeleteVolumeReason ...
	DeleteVolumeReason = "deleted by ibm-volume-lib on behalf of user request"
)

Functions

func FromProviderToLibVolume

func FromProviderToLibVolume(vpcVolume *models.Volume, logger *zap.Logger) (libVolume *provider.Volume)

FromProviderToLibVolume converting vpc provider volume type to generic lib volume type

func IsValidVolumeIDFormat

func IsValidVolumeIDFormat(volID string) bool

IsValidVolumeIDFormat validating(gc has 5 parts and NG has 6 parts)

func NewProvider

func NewProvider(conf *config.Config, logger *zap.Logger) (local.Provider, error)

NewProvider initialises an instance of an IaaS provider.

func SetRetryParameters

func SetRetryParameters(maxAttempts int, maxGap int)

SetRetryParameters sets the retry logic parameters

func SkipRetryForIKS

func SkipRetryForIKS(err error) bool

SkipRetryForIKS skip retry as per listed error codes

func ToInt

func ToInt(valueInInt string) int

ToInt ...

func ToInt64

func ToInt64(valueInInt string) int64

ToInt64 ...

func WaitForValidVolumeState

func WaitForValidVolumeState(vpcs *VPCSession, volumeID string) (err error)

WaitForValidVolumeState checks the volume for valid status

func WaitForVolumeDeletion

func WaitForVolumeDeletion(vpcs *VPCSession, volumeID string) (err error)

WaitForVolumeDeletion checks the volume for valid status

Types

type Error

type Error struct {
	// Fault ...
	Fault Fault
}

Error implements the error interface for a Fault. Most easily constructed using util.NewError() or util.NewErrorWithProperties()

func (Error) Code

func (err Error) Code() reasoncode.ReasonCode

Code satisfies the legacy provider.Error interface

func (Error) Error

func (err Error) Error() string

Error satisfies the error contract

func (Error) Properties

func (err Error) Properties() map[string]string

Properties satisfies the legacy provider.Error interface

func (Error) Wrapped

func (err Error) Wrapped() []string

Wrapped mirrors the legacy provider.Error interface

type Fault

type Fault struct {
	// Message is the fault message (required)
	Message string `json:"msg"`

	// ReasonCode is fault reason code (required)  //TODO: will have better reasoncode mechanism
	ReasonCode reasoncode.ReasonCode `json:"code"`

	// WrappedErrors contains wrapped error messages (if applicable)
	Wrapped []string `json:"wrapped,omitempty"`

	// Properties contains diagnostic properties (if applicable)
	Properties map[string]string `json:"properties,omitempty"`
}

Fault encodes a fault condition. Does not implement the error interface so that cannot be accidentally misassigned to error variables when returned in a function response.

type FaultResponse

type FaultResponse struct {
	Fault *Fault `json:"fault,omitempty"`
}

FaultResponse is an optional Fault

type FlexyRetry

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

FlexyRetry ...

func NewFlexyRetry

func NewFlexyRetry(maxRtyAtmpt int, maxrRtyGap int) FlexyRetry

NewFlexyRetry ...

func NewFlexyRetryDefault

func NewFlexyRetryDefault() FlexyRetry

NewFlexyRetryDefault ...

func (*FlexyRetry) FlexyRetry

func (fRetry *FlexyRetry) FlexyRetry(logger *zap.Logger, funcToRetry func() (error, bool)) error

FlexyRetry ...

func (*FlexyRetry) FlexyRetryWithConstGap

func (fRetry *FlexyRetry) FlexyRetryWithConstGap(logger *zap.Logger, funcToRetry func() (error, bool)) error

FlexyRetryWithConstGap ...

type VPCBlockProvider

type VPCBlockProvider struct {
	ContextCF local.ContextCredentialsFactory

	ClientProvider riaas.RegionalAPIClientProvider

	APIConfig riaas.Config
	// contains filtered or unexported fields
}

VPCBlockProvider implements provider.Provider

func (*VPCBlockProvider) ContextCredentialsFactory

func (vpcp *VPCBlockProvider) ContextCredentialsFactory(zone *string) (local.ContextCredentialsFactory, error)

ContextCredentialsFactory ...

func (*VPCBlockProvider) OpenSession

func (vpcp *VPCBlockProvider) OpenSession(ctx context.Context, contextCredentials provider.ContextCredentials, ctxLogger *zap.Logger) (provider.Session, error)

OpenSession opens a session on the provider

type VPCSession

type VPCSession struct {
	VPCAccountID          string
	Config                *config.VPCProviderConfig
	ContextCredentials    provider.ContextCredentials
	VolumeType            provider.VolumeType
	Provider              provider.VolumeProvider
	Apiclient             riaas.RegionalAPI
	APIClientVolAttachMgr instances.VolumeAttachManager
	APIVersion            string
	Logger                *zap.Logger
	APIRetry              FlexyRetry
}

VPCSession implements lib.Session

func (*VPCSession) AttachVolume

func (vpcs *VPCSession) AttachVolume(volumeAttachmentRequest provider.VolumeAttachmentRequest) (*provider.VolumeAttachmentResponse, error)

AttachVolume attach volume based on given volume attachment request

func (*VPCSession) AuthorizeVolume

func (vpcs *VPCSession) AuthorizeVolume(volumeAuthorization provider.VolumeAuthorization) error

AuthorizeVolume allows aceess to volume based on given authorization

func (*VPCSession) Close

func (*VPCSession) Close()

Close at present does nothing

func (*VPCSession) CreateSnapshot

func (vpcs *VPCSession) CreateSnapshot(volumeRequest *provider.Volume, tags map[string]string) (*provider.Snapshot, error)

CreateSnapshot Create snapshot from given volume

func (*VPCSession) CreateVolume

func (vpcs *VPCSession) CreateVolume(volumeRequest provider.Volume) (volumeResponse *provider.Volume, err error)

CreateVolume Get the volume by using ID

func (*VPCSession) CreateVolumeFromSnapshot

func (vpcs *VPCSession) CreateVolumeFromSnapshot(snapshot provider.Snapshot, tags map[string]string) (*provider.Volume, error)

CreateVolumeFromSnapshot creates the volume by using ID

func (*VPCSession) DeleteSnapshot

func (vpcs *VPCSession) DeleteSnapshot(snapshot *provider.Snapshot) error

DeleteSnapshot delete snapshot

func (*VPCSession) DeleteVolume

func (vpcs *VPCSession) DeleteVolume(volume *provider.Volume) (err error)

DeleteVolume deletes the volume

func (*VPCSession) DetachVolume

func (vpcs *VPCSession) DetachVolume(volumeAttachmentTemplate provider.VolumeAttachmentRequest) (*http.Response, error)

DetachVolume detach volume based on given volume attachment request

func (*VPCSession) GetProviderDisplayName

func (vpcs *VPCSession) GetProviderDisplayName() provider.VolumeProvider

GetProviderDisplayName returns the name of the VPC provider

func (*VPCSession) GetSnapshot

func (vpcs *VPCSession) GetSnapshot(snapshotID string) (*provider.Snapshot, error)

GetSnapshot get snapshot

func (*VPCSession) GetSnapshotWithVolumeID

func (vpcs *VPCSession) GetSnapshotWithVolumeID(volumeID string, snapshotID string) (*provider.Snapshot, error)

GetSnapshotWithVolumeID get snapshot

func (*VPCSession) GetVolume

func (vpcs *VPCSession) GetVolume(id string) (respVolume *provider.Volume, err error)

GetVolume gets the volume by using ID

func (*VPCSession) GetVolumeAttachment

func (vpcs *VPCSession) GetVolumeAttachment(volumeAttachmentRequest provider.VolumeAttachmentRequest) (*provider.VolumeAttachmentResponse, error)

GetVolumeAttachment get the volume attachment based on the request

func (*VPCSession) GetVolumeByName

func (vpcs *VPCSession) GetVolumeByName(name string) (respVolume *provider.Volume, err error)

GetVolumeByName ...

func (*VPCSession) GetVolumeByRequestID

func (vpcs *VPCSession) GetVolumeByRequestID(requestID string) (*provider.Volume, error)

GetVolumeByRequestID get volume by volume ID

func (*VPCSession) ListAllSnapshots

func (vpcs *VPCSession) ListAllSnapshots(volumeID string) ([]*provider.Snapshot, error)

ListAllSnapshots list all snapshots

func (*VPCSession) ListSnapshots

func (vpcs *VPCSession) ListSnapshots() ([]*provider.Snapshot, error)

ListSnapshots list all snapshots

func (*VPCSession) ListVolumes

func (vpcs *VPCSession) ListVolumes(limit int, start string, tags map[string]string) (*provider.VolumeList, error)

ListVolumes list all volumes

func (*VPCSession) OrderSnapshot

func (vpcs *VPCSession) OrderSnapshot(volumeRequest provider.Volume) error

OrderSnapshot order snapshot

func (*VPCSession) ProviderName

func (vpcs *VPCSession) ProviderName() provider.VolumeProvider

ProviderName ...

func (*VPCSession) Type

func (vpcs *VPCSession) Type() provider.VolumeType

Type ...

func (*VPCSession) UpdateVolume

func (vpc *VPCSession) UpdateVolume(volumeTemplate provider.Volume) error

UpdateVolume POSTs to /volumes

func (*VPCSession) WaitForAttachVolume

func (vpcs *VPCSession) WaitForAttachVolume(volumeAttachmentTemplate provider.VolumeAttachmentRequest) (*provider.VolumeAttachmentResponse, error)

WaitForAttachVolume waits for volume to be attached to node. e.g waits till status becomes attached

func (*VPCSession) WaitForDetachVolume

func (vpcs *VPCSession) WaitForDetachVolume(volumeAttachmentTemplate provider.VolumeAttachmentRequest) error

WaitForDetachVolume waits for volume to be detached from node. e.g waits till no volume attachment is found

Jump to

Keyboard shortcuts

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