util

package
v2.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MPL-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const Attempts uint = 10
View Source
const (
	DBaaSClusterHealthyStatus = "HEALTHY"
)
View Source
const InstanceShutoffStatus = "SHUTOFF"
View Source
const SnapshotReadyStatus = "available"

Variables

View Source
var (
	ErrDBaaSClustersNotFound = errors.New("no DBaaS clusters were found for the specified search criteria")
	ErrDBaaSClusterNotReady  = errors.New("DBaaS cluster failed to become healthy within the allocated time")
)
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 (
	ErrInstanceNotShutOff        = errors.New("the instance is not shut off")
	ErrInstanceInterfaceNotFound = errors.New("instance interface not found")
	ErrInstancePortNotFound      = errors.New("instance port not found")
)
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 ErrDefaultSGNotFound = errors.New("default security group is not found")
View Source
var ErrL7PoliciesNotFound = errors.New("no l7Policies were found for the specified search criteria")
View Source
var ErrSecGroupNotFound = errors.New("security group is not found")
View Source
var ErrServerGroupNotFound = errors.New("no server group was found for the specified search criteria")

Functions

func CreateDBaaSClusterAndWait added in v2.5.9

func CreateDBaaSClusterAndWait(ctx context.Context, client *edgecloud.Client, req edgecloud.DBaaSClusterCreateRequest, timeouts ...time.Duration) (*edgecloud.DBaaSCluster, error)

func DBaaSClusterGetByCreatorTaskID added in v2.5.9

func DBaaSClusterGetByCreatorTaskID(ctx context.Context, client *edgecloud.Client, name string, creatorTaskID string) (*edgecloud.DBaaSCluster, error)

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 FindDefaultSG added in v2.1.3

func FindDefaultSG(ctx context.Context, client *edgecloud.Client) (*edgecloud.SecurityGroup, 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 GenerateRandomString added in v2.5.0

func GenerateRandomString(length int, includeLetters, includeDigits, includeSpecial bool) (string, error)

func GetLbL7PolicyFromName added in v2.0.29

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

func InstanceNetworkInterfaceByID added in v2.1.5

func InstanceNetworkInterfaceByID(ctx context.Context, client *edgecloud.Client, instanceID string, portID string) (*edgecloud.InstancePortInterface, error)

func InstanceNetworkPortByID added in v2.1.5

func InstanceNetworkPortByID(ctx context.Context, client *edgecloud.Client, instanceID string, portID string) (*edgecloud.InstancePort, error)

func IsLockedErr added in v2.5.6

func IsLockedErr(resp *edgecloud.Response) bool

func IsNotFoundErr added in v2.5.6

func IsNotFoundErr(resp *edgecloud.Response) bool

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 RetryDeleteLocked added in v2.5.6

func RetryDeleteLocked(ctx context.Context, client *edgecloud.Client,
	deleter func(ctx context.Context, resourceID string) (*edgecloud.TaskResponse, *edgecloud.Response, error),
	resourceID string,
	timeouts ...time.Duration,
) error

func SecurityGroupListByIDs added in v2.1.5

func SecurityGroupListByIDs(ctx context.Context, client *edgecloud.Client, targetSgIDs []string) (sgs []edgecloud.SecurityGroup, err 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 WaitDBaaSClusterByCreatorTaskID added in v2.5.9

func WaitDBaaSClusterByCreatorTaskID(ctx context.Context, client *edgecloud.Client, name string, creatorTaskID string, timeouts ...time.Duration) (*edgecloud.DBaaSCluster, error)

func WaitDBaaSClusterStatusHealthy added in v2.5.9

func WaitDBaaSClusterStatusHealthy(ctx context.Context, client *edgecloud.Client, clusterID string, timeouts ...time.Duration) (*edgecloud.DBaaSCluster, 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"`
	Routers        []string  `json:"routers"`
	Secrets        []string  `json:"secrets"`
	ServerGroups   []string  `json:"servergroups"`
	Snapshots      []string  `json:"snapshots"`
	Subnets        []string  `json:"subnets"`
	Volumes        []string  `json:"volumes"`
	MkaasClusters  []float64 `json:"mkaasclusters"`
	MkaasPools     []float64 `json:"mkaaspools"`
	DbaasClusters  []string  `json:"dbaasclusters"`
}

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