edgecenter

package
v0.7.13 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MPL-2.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderOptPermanentToken    = "permanent_api_token"
	ProviderOptSkipCredsAuthErr  = "ignore_creds_auth_error" // nolint: gosec
	ProviderOptSingleAPIEndpoint = "api_endpoint"
	RegionIDField                = "region_id"
	RegionNameField              = "region_name"
	ProjectIDField               = "project_id"
	ProjectNameField             = "project_name"
	CreatedAtField               = "created_at"
	UpdatedAtField               = "updated_at"
	LastUpdatedField             = "last_updated"
	IDField                      = "id"
	InstanceIDField              = "instance_id"
	ClientIDField                = "client_id"
	NameField                    = "name"
	TagsField                    = "tags"
	DescriptionField             = "description"
	StateField                   = "state"
	IsDefaultField               = "is_default"
	TypeField                    = "type"
	TypeNameField                = "type_name"
	OrderField                   = "order"
	KeyField                     = "key"
	NetworkIDField               = "network_id"
	NetworkNameField             = "network_name"
	SubnetIDField                = "subnet_id"
	SubnetNameField              = "subnet_name"
	PortIDField                  = "port_id"
	IsParentField                = "is_parent"
	PasswordField                = "password"
	UsernameField                = "username"
	MetadataMapField             = "metadata_map"
	IPAddressField               = "ip_address"
	SecurityGroupField           = "security_group"
	SecurityGroupsField          = "security_groups"
	SecurityGroupIDsField        = "security_group_ids"
	AllSecurityGroupIDsField     = "all_security_group_ids"
	OverwriteExistingField       = "overwrite_existing"
	MetadataField                = "metadata"
	ValueField                   = "value"
	FlavorField                  = "flavor"
	FlavorNameField              = "flavor_name"
	FlavorIDField                = "flavor_id"
	RAMField                     = "ram"
	VCPUsField                   = "vcpus"
	StatusField                  = "status"
	OperatingStatusField         = "operating_status"
	ProvisioningStatusField      = "provisioning_status"
	LifecyclePolicyResource      = "edgecenter_lifecyclepolicy"
)
View Source
const (
	BmInstanceDeletingTimeout int = 1200
	BmInstanceCreatingTimeout int = 3600
	BmInstancePoint               = "bminstances"
)
View Source
const (
	DNSZoneResource   = "edgecenter_dns_zone"
	DNSZoneSchemaName = "name"
)
View Source
const (
	DNSZoneRecordResource = "edgecenter_dns_zone_record"

	DNSZoneRecordSchemaZone      = "zone"
	DNSZoneRecordSchemaDomain    = "domain"
	DNSZoneRecordSchemaType      = "type"
	DNSZoneRecordSchemaTTL       = "ttl"
	DNSZoneRecordSchemaRRSetMeta = "meta"
	DNSZoneRecordSchemaFailover  = "failover"
	DNSZoneRecordSchemaFilter    = "filter"

	DNSZoneRecordSchemaFailoverProtocol       = "protocol"
	DNSZoneRecordSchemaFailoverFrequency      = "frequency"
	DNSZoneRecordSchemaFailoverHost           = "host"
	DNSZoneRecordSchemaFailoverHTTPStatusCode = "http_status_code"
	DNSZoneRecordSchemaFailoverMethod         = "method"
	DNSZoneRecordSchemaFailoverPort           = "port"
	DNSZoneRecordSchemaFailoverRegexp         = "regexp"
	DNSZoneRecordSchemaFailoverTimeout        = "timeout"
	DNSZoneRecordSchemaFailoverTLS            = "tls"
	DNSZoneRecordSchemaFailoverURL            = "url"
	DNSZoneRecordSchemaFailoverVerify         = "verify"

	DNSZoneRecordSchemaFilterLimit  = "limit"
	DNSZoneRecordSchemaFilterType   = "type"
	DNSZoneRecordSchemaFilterStrict = "strict"

	DNSZoneRecordSchemaResourceRecord = "resource_record"
	DNSZoneRecordSchemaContent        = "content"
	DNSZoneRecordSchemaEnabled        = "enabled"
	DNSZoneRecordSchemaMeta           = "meta"

	DNSZoneRecordSchemaMetaAsn        = "asn"
	DNSZoneRecordSchemaMetaIP         = "ip"
	DNSZoneRecordSchemaMetaCountries  = "countries"
	DNSZoneRecordSchemaMetaContinents = "continents"
	DNSZoneRecordSchemaMetaLatLong    = "latlong"
	DNSZoneRecordSchemaMetaNotes      = "notes"
	DNSZoneRecordSchemaMetaDefault    = "default"
)
View Source
const (
	FloatingIPsPoint        = "floatingips"
	FloatingIPCreateTimeout = 1200 * time.Second
	FloatingIPDeleteTimeout = 1200 * time.Second
)
View Source
const (
	InstanceCreateTimeout = 1200 * time.Second
	InstanceDeleteTimeout = 1200 * time.Second
	InstanceUpdateTimeout = 1200 * time.Second
	InstancePoint         = "instances"

	InstanceVMStateActive  = "active"
	InstanceVMStateStopped = "stopped"
)
View Source
const (
	InstanceVolumeSizeField            = "size"
	InstanceVolumeIDField              = "volume_id"
	InstanceBootVolumesField           = "boot_volumes"
	InstanceDataVolumesField           = "data_volumes"
	InstanceInterfacesField            = "interfaces"
	InstanceVMStateField               = "vm_state"
	InstanceAddressesField             = "addresses"
	InstanceAddressesAddrField         = "addr"
	InstanceAddressesNetField          = "net"
	InstanceNameTemplateField          = "name_template"
	InstanceBootVolumesBootIndexField  = "boot_index"
	InstanceVolumesAttachmentTagField  = "attachment_tag"
	InstanceInterfaceFipSourceField    = "fip_source"
	InstanceKeypairNameField           = "keypair_name"
	InstanceServerGroupField           = "server_group"
	InstanceConfigurationField         = "configuration"
	InstanceUserDataField              = "user_data"
	InstanceAllowAppPortsField         = "allow_app_ports"
	InstanceReservedFixedIPPortIDField = "reserved_fixed_ip_port_id"
)
View Source
const (
	PortSecurityDisabledField         = "port_security_disabled"
	InstancePortSecurityCreateTimeout = 1200 * time.Second
	InstancePortSecurityReadTimeout   = 1200 * time.Second
	InstancePortSecurityDeleteTimeout = 1200 * time.Second
	InstancePortSecurityUpdateTimeout = 1200 * time.Second
)
View Source
const (
	K8sPoint         = "k8s/clusters"
	K8sCreateTimeout = 3600
)
View Source
const (
	LBL7PolicyCreateTimeout         = 2400 * time.Second
	LBL7PolicyUpdateTimeout         = 2400 * time.Second
	LBL7PolicyDeleteTimeout         = 2400 * time.Second
	LBL7PolicyRedirectHTTPCodeField = "redirect_http_code"
	LBL7PolicyRedirectPrefixField   = "redirect_prefix"
	LBL7PolicyRedirectURLField      = "redirect_url"
	LBL7PolicyRedirectPoolIDField   = "redirect_pool_id"
	LBL7PolicyTagsField             = "tags"
	LBL7PolicyRulesField            = "rules"
	LBL7PolicyPositionField         = "position"
	LBL7PolicyActionField           = "action"
	LBL7PolicyListenerIDField       = "listener_id"
	LBL7PolicyNameField             = "name"
	LBL7OperatingStatusField        = "operating_status"
	LBL7ProvisioningStatusField     = "provisioning_status"
)
View Source
const (
	LB7RuleCompareTypeField = "compare_type"
	LBL7RuleL7PolicyIDField = "l7policy_id"
	LBL7RuleValueField      = "value"
	LBL7RuleInvertField     = "invert"
	LBL7RuleCreateTimeout   = 10 * time.Minute
	LBL7RuleUpdateTimeout   = 10 * time.Minute
	LBL7RuleDeleteTimeout   = 10 * time.Minute
)
View Source
const (
	LBListenersPoint        = "lblisteners"
	TimeoutClientData       = "timeout_client_data"
	TimeoutMemberData       = "timeout_member_data"
	TimeoutMemberConnect    = "timeout_member_connect"
	LBListenerCreateTimeout = 2400 * time.Second
	LBListenerUpdateTimeout = 2400 * time.Second
	LBListenerDeleteTimeout = 2400 * time.Second
)
View Source
const (
	LBMemberCreateTimeout = 2400 * time.Second
	LBMemberUpdateTimeout = 2400 * time.Second
	LBMemberDeleteTimeout = 2400 * time.Second
)
View Source
const (
	LBPoolsPoint         = "lbpools"
	LBPoolsCreateTimeout = 2400 * time.Second
	LBPoolsUpdateTimeout = 2400 * time.Second
	LBPoolsDeleteTimeout = 2400 * time.Second
)
View Source
const (
	LoadBalancersPoint        = "loadbalancers"
	LoadBalancerCreateTimeout = 2400 * time.Second
	LoadBalancerDeleteTimeout = 2400 * time.Second
	LoadBalancerUpdateTimeout = 2400 * time.Second
)
View Source
const (
	NetworkDeletingTimeout = 1200 * time.Second
	NetworkCreatingTimeout = 1200 * time.Second
	NetworksPoint          = "networks"
	SharedNetworksPoint    = "availablenetworks"
)
View Source
const (
	ProjectResource      = "edgecenter_project"
	ProjectDeleteTimeout = 1200 * time.Second
)
View Source
const (
	ReservedFixedIPsPoint        = "reserved_fixed_ips"
	ReservedFixedIPCreateTimeout = 1200 * time.Second
	ReservedFixedIPDeleteTimeout = 1200 * time.Second
)
View Source
const (
	RouterPoint           = "routers"
	RouterDeletingTimeout = 1200 * time.Second
	RouterCreatingTimeout = 1200 * time.Second
)
View Source
const (
	SecretDeletingTimeout = 1200 * time.Second
	SecretCreatingTimeout = 1200 * time.Second
	SecretPoint           = "secrets"
	// RFC3339NoZ is the time format used in Heat (Orchestration).
	RFC3339NoZ          = "2006-01-02T15:04:05"
	RFC3339WithTimeZone = "2006-01-02T15:04:05+00:00"
)
View Source
const (
	StorageS3SchemaGenerateAccessKey  = "generated_access_key"
	StorageS3SchemaGenerateSecretKey  = "generated_secret_key"
	StorageSchemaGenerateHTTPEndpoint = "generated_http_endpoint"
	StorageSchemaGenerateS3Endpoint   = "generated_s3_endpoint"
	StorageSchemaGenerateEndpoint     = "generated_endpoint"

	StorageSchemaLocation = "location"
	StorageSchemaName     = "name"
	StorageSchemaID       = "storage_id"
	StorageSchemaClientID = "client_id"
)
View Source
const (
	StorageS3BucketSchemaName      = "name"
	StorageS3BucketSchemaStorageID = "storage_id"
)
View Source
const (
	SubnetCreatingTimeout = 1200 * time.Second
	SubnetPoint           = "subnets"
)
View Source
const (
	VolumeCreatingTimeout = 1200 * time.Second

	VolumesPoint = "volumes"
)
View Source
const (
	VersionPointV1 = "v1"
	VersionPointV2 = "v2"

	ProjectPoint = "projects"
	RegionPoint  = "regions"
)
View Source
const KeypairsPoint = "keypairs"
View Source
const LBL7RuleL7PolicyNameField = "l7policy_name"
View Source
const (
	LifecyclePolicyPoint = "lifecycle_policies"
)
View Source
const ReservedFixedIPVIPDisabledPortSecurityErrMsg = "Port Security must be enabled in order to have allowed address pairs on a port"
View Source
const (
	SecurityGroupPoint = "securitygroups"
)
View Source
const (
	ServerGroupsPoint = "servergroups"
)
View Source
const (
	SnapshotsPoint = "snapshots"
)

Variables

View Source
var ErrCannotDeleteSGRule = errors.New("error when deleting security group rule")
View Source
var ErrInstancePortSecNotImplemented = fmt.Errorf("instance_port_security are not impelemented yet")

Functions

func AllowedNetworkTypes added in v0.5.0

func AllowedNetworkTypes() []string

func AssignSecurityGroupsToInstancePort added in v0.7.0

func AssignSecurityGroupsToInstancePort(ctx context.Context, client *edgecloudV2.Client, instanceID, portID string, assignSGIDs []interface{}) error

AssignSecurityGroupsToInstancePort assigns one or more security groups to a specific instance port.

func CheckAllImagesIsBootable added in v0.7.0

func CheckAllImagesIsBootable(ctx context.Context, client *edgecloudV2.Client, volumes map[string]map[string]interface{}) error

func CheckL7ListenerProtocol added in v0.5.0

func CheckL7ListenerProtocol(ctx context.Context, client *edgecloudV2.Client, listenerID string) diag.Diagnostics

func CheckUniqueSequentialBootIndexes added in v0.7.0

func CheckUniqueSequentialBootIndexes(volumes map[string]map[string]interface{}) error

func CreateClient

func CreateClient(provider *edgecloud.ProviderClient, d *schema.ResourceData, endpoint string, version string) (*edgecloud.ServiceClient, error)

CreateClient creates a new edgecloud.ServiceClient.

func EnrichVolumeData added in v0.7.0

func EnrichVolumeData(instanceVolumes []edgecloudV2.Volume, volumesState map[string]map[string]interface{}) []interface{}

func ExtractHostAndPath

func ExtractHostAndPath(uri string) (string, string, error)

ExtractHostAndPath splits a given URI into the host and path components.

func Filter added in v0.7.4

func Filter[T any](arr []T, predicate func(T) bool) []T

Filter iterates over elements of the collection, returning a slice of all elements for which the predicate returns true. - arr []T is a slice of elements of type T. - predicate func(T) bool is a function that takes an element of type T and returns bool.

func GetLBL7Policy added in v0.5.0

func GetLBL7Policy(ctx context.Context, client *edgecloudV2.Client, l7PolicyID, l7PolicyName string) (*edgecloudV2.L7Policy, error)

func GetListenerL7PolicyUUIDS added in v0.5.0

func GetListenerL7PolicyUUIDS(ctx context.Context, client *edgecloudV2.Client, listenerID string) ([]string, error)

func GetProject

func GetProject(provider *edgecloud.ProviderClient, projectID int, projectName string) (int, error)

GetProject returns a valid project ID for a resource. If the projectID is provided, it will be returned directly. If projectName is provided instead, the function will search for the project by name and return its ID. Returns an error if the project is not found or there is an issue with the client. ToDo Remove after migrate to Edgecenterclient-go V2.

func GetProjectByIDV2 added in v0.6.0

func GetProjectByIDV2(
	ctx context.Context,
	client *edgecloudV2.Client,
	projectID int,
) (*edgecloudV2.Project, error)

GetProjectByIDV2 returns a valid project for a resource. Use new version Edgecenterclient-go V2. If projectName is provided instead, the function will search for the project by id and return its. Returns an error if the project is not found or there is an issue with the client.

func GetProjectByNameV2 added in v0.6.0

func GetProjectByNameV2(
	ctx context.Context,
	client *edgecloudV2.Client,
	projectName string,
) (*edgecloudV2.Project, error)

GetProjectByNameV2 returns a valid project for a resource. Use new version Edgecenterclient-go V2. If the projectID is provided, it will be returned directly. If projectName is provided instead, the function will search for the project by name and return its. Returns an error if the project is not found or there is an issue with the client.

func GetProjectID added in v0.6.0

func GetProjectID(
	ctx context.Context,
	client *edgecloudV2.Client,
	d *schema.ResourceData,
) (int, error)

func GetProjectV2 added in v0.2.0

func GetProjectV2(
	ctx context.Context,
	clientV2 *edgecloudV2.Client,
	projectID int,
	projectName string,
) (*edgecloudV2.Project, error)

func GetRegion

func GetRegion(provider *edgecloud.ProviderClient, regionID int, regionName string) (int, error)

GetRegion returns a valid region ID for a resource. If the regionID is provided, it will be returned directly. If regionName is provided instead, the function will search for the region by name and return its ID. Returns an error if the region is not found or there is an issue with the client. ToDo Remove after migrate to Edgecenterclient-go V2.

func GetRegionID added in v0.6.0

func GetRegionID(
	ctx context.Context,
	client *edgecloudV2.Client,
	d *schema.ResourceData,
) (int, error)

func GetRegionIDandProjectID added in v0.2.0

func GetRegionIDandProjectID(
	ctx context.Context,
	client *edgecloudV2.Client,
	d *schema.ResourceData,
) (regionID int, projectID int, err error)

GetRegionIDandProjectID search for project ID and region ID by name or return project ID and region ID if they exist in the terraform configuration. Use new version Edgecenterclient-go V2. nolint: nonamedreturns

func GetRegionLegacy added in v0.2.0

func GetRegionLegacy(provider *edgecloud.ProviderClient, regionID int, regionName string) (int, error)

GetRegionLegacy to support backwards compatibility.

func GetRegionV2 added in v0.2.0

func GetRegionV2(ctx context.Context, client *edgecloudV2.Client, regionID int, regionName string) (int, error)

GetRegionV2 returns a valid region ID for a resource. Use new version Edgecenterclient-go V2. If the regionID is provided, it will be returned directly. If regionName is provided instead, the function will search for the region by name and return its ID. Returns an error if the region is not found or there is an issue with the client.

func ImportStringParser

func ImportStringParser(infoStr string) (projectID int, regionID int, id3 string, err error)

ImportStringParser parses a string containing project ID, region ID, and another field, and returns them as separate values along with any error encountered.

func ImportStringParserExtended

func ImportStringParserExtended(infoStr string) (projectID int, regionID int, id3 string, id4 string, err error)

ImportStringParserExtended parses a string containing project ID, region ID, and two other fields, and returns them as separate values along with any error encountered.

func InitCloudClient added in v0.4.0

func InitCloudClient(
	ctx context.Context,
	d *schema.ResourceData,
	m interface{},
	clientConf *CloudClientConf,
) (*edgecloudV2.Client, error)

func MapInterfaceToMapString added in v0.2.0

func MapInterfaceToMapString(mapInterface interface{}) (*map[string]string, error)

func MapStructureDecoder

func MapStructureDecoder(strct interface{}, v *map[string]interface{}, config *mapstructure.DecoderConfig) error

MapStructureDecoder decodes the given map into the provided structure using the specified decoder configuration.

func PrepareAndValidateAssignSecurityGroupRequestOpts added in v0.7.0

func PrepareAndValidateAssignSecurityGroupRequestOpts(ctx context.Context, client *edgecloudV2.Client, sgIDs []string, portID string) (*edgecloudV2.AssignSecurityGroupRequest, error)

func PrepareMetadata added in v0.1.11

func PrepareMetadata(apiMetadataRaw interface{}) (map[string]string, []map[string]interface{})

func PrepareMetadataReadonly added in v0.1.11

func PrepareMetadataReadonly(apiMetadataRaw interface{}) []map[string]interface{}

func PrepareVolumesDataToSet added in v0.7.0

func PrepareVolumesDataToSet(instanceVolumes []edgecloudV2.Volume) (bootVolumes, dataVolumes []interface{})

func Provider

func Provider() *schema.Provider

func Reduce added in v0.7.4

func Reduce[T any, U any](arr []T, reduceFunc func(U, T) U, acc U) U

Reduce accumulates a value based on a reduction function and initial accumulator value. - arr []T is a slice of elements of type T. - reduceFunc func(U, T) U is a function that takes an accumulator of type U and an element of type T, and returns a new accumulator of type U. - acc U is the initial value of the accumulator of type U.

func ServerV2StateRefreshFuncV2 added in v0.2.0

func ServerV2StateRefreshFuncV2(ctx context.Context, client *edgecloudV2.Client, instanceID string) retry.StateRefreshFunc

ServerV2StateRefreshFuncV2 returns a StateRefreshFunc to track the state of an instance using its instanceID.

func StringToNetHookFunc

func StringToNetHookFunc() mapstructure.DecodeHookFuncType

StringToNetHookFunc returns a DecodeHookFunc for the mapstructure package to handle the custom conversion of string values to net.IP and edgecloud.CIDR types.

func StringToNetHookFuncV2 added in v0.2.0

func StringToNetHookFuncV2() mapstructure.DecodeHookFuncType

StringToNetHookFuncV2 returns a DecodeHookFunc for the mapstructure package to handle the custom conversion of string values to net.IP and edgecloudV2.CIDR types.

func StructToMap

func StructToMap(obj interface{}) (map[string]interface{}, error)

StructToMap converts the struct to map[string]interface{}. Returns an error if the conversion fails.

func UpdateVolumes added in v0.7.0

func UpdateVolumes(ctx context.Context, d *schema.ResourceData, client *edgecloudV2.Client, instanceID string, oldVolumesRaw, newVolumesRaw interface{}) error

func VolumeV2StateRefreshFuncV2 added in v0.7.0

func VolumeV2StateRefreshFuncV2(ctx context.Context, client *edgecloudV2.Client, volumeID string) retry.StateRefreshFunc

VolumeV2StateRefreshFuncV2 returns a StateRefreshFunc to track the state of attaching volume using its volumeID.

Types

type CloudClientConf added in v0.7.0

type CloudClientConf struct {
	DoNotUseRegionID  bool
	DoNotUseProjectID bool
}

type Config

type Config struct {
	PermanentToken string
	CloudBaseURL   string
	UserAgent      string
	Provider       *edgecloud.ProviderClient
	CDNClient      cdn.ClientService
	StorageClient  *storageSDK.SDK
	DNSClient      *dnsSDK.Client
}

func NewConfig added in v0.7.0

func NewConfig(
	provider *edgecloud.ProviderClient,
	cdnClient cdn.ClientService,
	storageClient *storageSDK.SDK,
	dnsClient *dnsSDK.Client,
	permanentToken,
	cloudBaseURL,
	userAgent string,
) Config

type InstanceInterfaceMapWithIPAddress added in v0.7.0

type InstanceInterfaceMapWithIPAddress struct {
	InstanceInterface map[string]interface{}
	IPAddress         string
}

type InstanceInterfaceWithIPAddress added in v0.2.0

type InstanceInterfaceWithIPAddress struct {
	InstanceInterface edgecloudV2.InstanceInterface
	IPAddress         string
}

type InstancePortSecurityOpts added in v0.1.31

type InstancePortSecurityOpts struct {
	PortID               string
	PortSecurityDisabled bool
	SubnetID             string
	IPAddress            string
}

type K8sConfig added in v0.1.17

type K8sConfig struct {
	APIVersion     string   `yaml:"apiVersion"`
	Kind           string   `yaml:"kind"`
	CurrentContext string   `yaml:"current-context"` // nolint: tagliatelle
	Preferences    struct{} `yaml:"preferences"`

	Clusters []struct {
		Name    string `yaml:"name"`
		Cluster struct {
			CertificateAuthorityData string `yaml:"certificate-authority-data"` // nolint: tagliatelle
			Server                   string `yaml:"server"`
		} `yaml:"cluster"`
	} `yaml:"clusters"`

	Contexts []struct {
		Name    string `yaml:"name"`
		Context struct {
			Cluster string `yaml:"cluster"`
			User    string `yaml:"user"`
		} `yaml:"context"`
	} `yaml:"contexts"`

	Users []struct {
		Name string `yaml:"name"`
		User struct {
			ClientCertificateData string `yaml:"client-certificate-data"` // nolint: tagliatelle
			ClientKeyData         string `yaml:"client-key-data"`         // nolint: tagliatelle
		} `yaml:"user"`
	} `yaml:"users"`
}

type OrderedInterfaceOpts

type OrderedInterfaceOpts struct {
	InstanceInterfaceWithIPAddress
	Order int
}

Source Files

Jump to

Keyboard shortcuts

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