util

package
v2.0.31 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MPL-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const Attempts uint = 10
View Source
const InstanceShutoffStatus = "SHUTOFF"
View Source
const SnapshotReadyStatus = "available"

Variables

View Source
var (
	ErrFloatingIPsNotFound = errors.New("no FloatingIPs were found for the specified search criteria")
	ErrFloatingIPNotFound  = errors.New("no FloatingIP was found for the specified search criteria")
)
View Source
var (
	ErrLoadbalancersNotFound           = errors.New("no Loadbalancers were found for the specified search criteria")
	ErrLoadbalancerPoolsNotFound       = errors.New("no Loadbalancer pools were found for the specified search criteria")
	ErrLoadbalancerPoolsMemberNotFound = errors.New("no Loadbalancer pool member were found for the specified search criteria")
	ErrLoadbalancerListenerNotFound    = errors.New("no Loadbalancer listener were found for the specified search criteria")
	ErrMultipleResults                 = errors.New("multiple results where only one expected")
	ErrErrorState                      = errors.New("loadbalancer in Error state")
	ErrNotActiveStatus                 = errors.New("waiting for Active status")
)
View Source
var (
	ErrSnapshotsNotFound = errors.New("no Snapshots were found for the specified search criteria")
	ErrSnapshotNotReady  = errors.New("snapshot failed to be ready within the allocated time")
)
View Source
var (
	ErrVolumesNotFound    = errors.New("no Volumes were found for the specified search criteria")
	ErrVolumesNotAttached = errors.New("volume failed to be attached within the allocated time")
	ErrVolumesNotDetached = errors.New("volume failed to be detached within the allocated time")
)
View Source
var ErrInstanceNotShutOff = errors.New("the instance is not shut off")
View Source
var ErrL7PoliciesNotFound = errors.New("no l7Policies were found for the specified search criteria")
View Source
var ErrServerGroupNotFound = errors.New("no server group was found for the specified search criteria")

Functions

func DeletePoolByNameIfExist

func DeletePoolByNameIfExist(ctx context.Context, client *edgecloud.Client, name, loadBalancerID string) error

func DeleteResourceIfExist

func DeleteResourceIfExist(ctx context.Context, client *edgecloud.Client, resource interface{}, resourceID string, timeouts ...time.Duration) error

func DeleteUnusedPools

func DeleteUnusedPools(ctx context.Context, client *edgecloud.Client, oldPools []edgecloud.Pool, newPoolsIDs []string, attempts *uint) error

func FindPoolMemberByAddressPortAndSubnetID

func FindPoolMemberByAddressPortAndSubnetID(pool edgecloud.Pool, addr net.IP, protocolPort int, subnetID string) (found bool)

func FlavorIsAvailable

func FlavorIsAvailable(ctx context.Context, client *edgecloud.Client, flavorName string, checkFlavorVolumeRequest *edgecloud.InstanceCheckFlavorVolumeRequest) (bool, error)

func FlavorIsExist

func FlavorIsExist(ctx context.Context, client *edgecloud.Client, flavorName string) (bool, error)

func FloatingIPDetailedByID

func FloatingIPDetailedByID(ctx context.Context, client *edgecloud.Client, id string) (*edgecloud.FloatingIP, error)

func FloatingIPDetailedByIPAddress

func FloatingIPDetailedByIPAddress(ctx context.Context, client *edgecloud.Client, floatingIPAddress string) (*edgecloud.FloatingIP, error)

func FloatingIPsListByPortID

func FloatingIPsListByPortID(ctx context.Context, client *edgecloud.Client, portID string) ([]edgecloud.FloatingIP, error)

func GetLbL7PolicyFromName added in v2.0.29

func GetLbL7PolicyFromName(ctx context.Context, client *edgecloud.Client, name string) (*edgecloud.L7Policy, error)

func L7PoliciesListByListenerID

func L7PoliciesListByListenerID(ctx context.Context, client *edgecloud.Client, listenerID string) ([]edgecloud.L7Policy, error)

func LBListenerGetByName

func LBListenerGetByName(ctx context.Context, client *edgecloud.Client, name, loadBalancerID string) (*edgecloud.Listener, error)

func LBPoolGetByName

func LBPoolGetByName(ctx context.Context, client *edgecloud.Client, name, loadBalancerID string) (*edgecloud.Pool, error)

func LBSharedPoolList

func LBSharedPoolList(ctx context.Context, client *edgecloud.Client, loadBalancerID string) ([]edgecloud.Pool, error)

func LoadbalancerFlavorIsExist

func LoadbalancerFlavorIsExist(ctx context.Context, client *edgecloud.Client, flavorName string) (bool, error)

func LoadbalancerGetByName

func LoadbalancerGetByName(ctx context.Context, client *edgecloud.Client, name string) (*edgecloud.Loadbalancer, error)

func PoolMemberGetByID

func PoolMemberGetByID(ctx context.Context, client *edgecloud.Client, poolID, memberID string) (*edgecloud.PoolMember, error)

func ResourceIsDeleted

func ResourceIsDeleted[T any](ctx context.Context, getResourceFunc GetResourceFunc[T], id string) error

func ResourceIsExist

func ResourceIsExist[T any](ctx context.Context, getResourceFunc GetResourceFunc[T], id string) (bool, error)

func ServerGroupGetByInstance

func ServerGroupGetByInstance(ctx context.Context, client *edgecloud.Client, instanceID string) (*edgecloud.ServerGroup, error)

func SnapshotsListByNameAndVolumeID

func SnapshotsListByNameAndVolumeID(ctx context.Context, client *edgecloud.Client, name, volumeID string) ([]edgecloud.Snapshot, error)

func SnapshotsListByStatusAndVolumeID

func SnapshotsListByStatusAndVolumeID(ctx context.Context, client *edgecloud.Client, status, volumeID string) ([]edgecloud.Snapshot, error)

func VolumesListByName

func VolumesListByName(ctx context.Context, client *edgecloud.Client, name string) ([]edgecloud.Volume, error)

func WaitAndGetTaskInfo

func WaitAndGetTaskInfo(ctx context.Context, client *edgecloud.Client, taskID string, timeouts ...time.Duration) (*edgecloud.Task, error)

func WaitForInstanceShutoff

func WaitForInstanceShutoff(ctx context.Context, client *edgecloud.Client, instanceID string, attempts *uint) error

func WaitForTaskComplete

func WaitForTaskComplete(ctx context.Context, client *edgecloud.Client, taskID string, timeouts ...time.Duration) error

func WaitLoadbalancerProvisioningStatusActive

func WaitLoadbalancerProvisioningStatusActive(ctx context.Context, client *edgecloud.Client, loadBalancerID string, attempts *uint) error

func WaitSnapshotStatusReady

func WaitSnapshotStatusReady(ctx context.Context, client *edgecloud.Client, snapshotID string, attempts *uint) error

func WaitVolumeAttachedToInstance

func WaitVolumeAttachedToInstance(ctx context.Context, client *edgecloud.Client, volumeID, instanceID string, attempts *uint) error

func WaitVolumeDetachedFromInstance

func WaitVolumeDetachedFromInstance(ctx context.Context, client *edgecloud.Client, volumeID, instanceID string, attempts *uint) error

func WithRetry

func WithRetry(f retry.RetryableFunc, attempts *uint) error

Types

type GetResourceFunc

type GetResourceFunc[T any] func(ctx context.Context, id string) (*T, *edgecloud.Response, error)

type SecurityGroupRuleProtocol added in v2.0.5

type SecurityGroupRuleProtocol edgecloud.SecurityGroupRuleProtocol

func (SecurityGroupRuleProtocol) List added in v2.0.5

func (SecurityGroupRuleProtocol) StringList added in v2.0.5

func (s SecurityGroupRuleProtocol) StringList() []string

type TaskAPIFunc

type TaskAPIFunc[T any] func(ctx context.Context, opt T) (*edgecloud.TaskResponse, *edgecloud.Response, error)

type TaskResult

type TaskResult struct {
	DdosProfiles     []int    `json:"ddos_profiles"`
	FloatingIPs      []string `json:"floatingips"`
	HealthMonitors   []string `json:"healthmonitors"`
	Images           []string `json:"images"`
	Instances        []string `json:"instances"`
	L7Polices        []string `json:"l7polices"`
	L7Rules          []string `json:"l7rules"`
	Listeners        []string `json:"listeners"`
	Loadbalancers    []string `json:"loadbalancers"`
	Members          []string `json:"members"`
	Networks         []string `json:"networks"`
	Pools            []string `json:"pools"`
	Ports            []string `json:"ports"`
	Projects         []string `json:"projects"`
	ReservedFixedIPs []string `json:"reserved_fixed_ips"`
	Routers          []string `json:"routers"`
	Secrets          []string `json:"secrets"`
	ServerGroups     []string `json:"servergroups"`
	Snapshots        []string `json:"snapshots"`
	Subnets          []string `json:"subnets"`
	Volumes          []string `json:"volumes"`
}

func ExecuteAndExtractTaskResult

func ExecuteAndExtractTaskResult[T any](ctx context.Context, apiFunc TaskAPIFunc[T], opt T, client *edgecloud.Client, timeouts ...time.Duration) (*TaskResult, error)

func ExtractTaskResultFromTask

func ExtractTaskResultFromTask(task *edgecloud.Task) (*TaskResult, error)

Jump to

Keyboard shortcuts

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