resource

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package resource is to manage multi-cloud infra resource

Package resource is to manage multi-cloud infra resource

Package resource is to manage multi-cloud infra resource

Package resource is to manage multi-cloud infra resource

Package resource is to manage multi-cloud infra resource

Package resource is to manage multi-cloud infra resource

Package resource is to manage multi-cloud infra resource

Package resource is to manage multi-cloud infra resource

Package resource is to manage multi-cloud infra resource

Package resource is to manage multi-cloud infra resource

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddK8sNodeGroup

func AddK8sNodeGroup(nsId string, k8sClusterId string, u *model.TbK8sNodeGroupReq) (model.TbK8sClusterInfo, error)

AddK8sNodeGroup adds a NodeGroup

func ChangeK8sNodeGroupAutoscaleSize

func ChangeK8sNodeGroupAutoscaleSize(nsId string, k8sClusterId string, k8sNodeGroupName string, u *model.TbChangeK8sNodeGroupAutoscaleSizeReq) (model.TbChangeK8sNodeGroupAutoscaleSizeRes, error)

ChangeK8sNodeGroupAutoscaleSize change NodeGroup's Autoscaling Size

func CheckChildResource

func CheckChildResource(nsId string, resourceType string, parentResourceId string, resourceId string) (bool, error)

CheckChildResource returns the existence of the TB Resource resource in bool form.

func CheckK8sCluster

func CheckK8sCluster(nsId string, k8sClusterId string) (bool, error)

CheckK8sCluster returns the existence of the TB K8sCluster object in bool form.

func CheckResource

func CheckResource(nsId string, resourceType string, resourceId string) (bool, error)

CheckResource returns the existence of the TB Resource resource in bool form.

func ContainsZone added in v0.9.9

func ContainsZone(zones []string, zone string) bool

func ConvertSpiderImageToTumblebugImage

func ConvertSpiderImageToTumblebugImage(spiderImage model.SpiderImageInfo) (model.TbImageInfo, error)

ConvertSpiderImageToTumblebugImage accepts an Spider image object, converts to and returns an TB image object

func ConvertSpiderMyImageToTumblebugCustomImage

func ConvertSpiderMyImageToTumblebugCustomImage(spiderMyImage model.SpiderMyImageInfo) (model.TbCustomImageInfo, error)

ConvertSpiderMyImageToTumblebugCustomImage accepts an Spider MyImage object, converts to and returns an TB customImage object

func ConvertSpiderSpecToTumblebugSpec

func ConvertSpiderSpecToTumblebugSpec(spiderSpec model.SpiderSpecInfo) (model.TbSpecInfo, error)

ConvertSpiderSpecToTumblebugSpec accepts an Spider spec object, converts to and returns an TB spec object

func CreateDataDisk

func CreateDataDisk(nsId string, u *model.TbDataDiskReq, option string) (model.TbDataDiskInfo, error)

CreateDataDisk accepts DataDisk creation request, creates and returns an TB dataDisk object

func CreateFirewallRules

func CreateFirewallRules(nsId string, securityGroupId string, req []model.TbFirewallRuleInfo, objectOnly bool) (model.TbSecurityGroupInfo, error)

CreateFirewallRules accepts firewallRule creation request, creates and returns an TB securityGroup object

func CreateK8sCluster

func CreateK8sCluster(nsId string, req *model.TbK8sClusterReq, option string) (model.TbK8sClusterInfo, error)

CreateK8sCluster create a k8s cluster

func CreateSecurityGroup

func CreateSecurityGroup(nsId string, u *model.TbSecurityGroupReq, option string) (model.TbSecurityGroupInfo, error)

CreateSecurityGroup accepts SG creation request, creates and returns an TB SG object

func CreateSharedResource added in v0.9.10

func CreateSharedResource(nsId string, resType string, connectionName string) error

CreateSharedResource is to register default resource from asset files (../assets/*.csv)

func CreateSshKey

func CreateSshKey(nsId string, u *model.TbSshKeyReq, option string) (model.TbSshKeyInfo, error)

CreateSshKey accepts SSH key creation request, creates and returns an TB sshKey object

func CreateSubnet

func CreateSubnet(nsId string, vNetId string, subnetReq *model.TbSubnetReq) (model.TbSubnetInfo, error)

CreateSubnet creates and returns the vNet object

func CreateVNet

func CreateVNet(nsId string, vNetReq *model.TbVNetReq) (model.TbVNetInfo, error)

CreateVNet accepts vNet creation request, creates and returns an TB vNet object

func DelAllResources

func DelAllResources(nsId string, resourceType string, subString string, forceFlag string) (model.IdList, error)

DelAllResources deletes all TB Resource object of given resourceType

func DelAllSharedResources

func DelAllSharedResources(nsId string) (model.IdList, error)

DelAllSharedResources deletes all Default securityGroup, sshKey, vNet objects

func DelEleInSlice

func DelEleInSlice(arr interface{}, index int)

DelEleInSlice delete an element from slice by index

  • arr: the reference of slice
  • index: the index of element will be deleted

func DelResource

func DelResource(nsId string, resourceType string, resourceId string, forceFlag string) error

DelResource deletes the TB Resource object

func DeleteAllK8sCluster

func DeleteAllK8sCluster(nsId string, subString string, forceFlag string) (model.IdList, error)

DeleteAllK8sCluster deletes all clusters

func DeleteFirewallRules

func DeleteFirewallRules(nsId string, securityGroupId string, req []model.TbFirewallRuleInfo) (model.TbSecurityGroupInfo, error)

DeleteFirewallRules accepts firewallRule creation request, creates and returns an TB securityGroup object

func DeleteK8sCluster

func DeleteK8sCluster(nsId string, k8sClusterId string, forceFlag string) (bool, error)

DeleteK8sCluster deletes a k8s cluster

func DeleteSubnet added in v0.9.9

func DeleteSubnet(nsId string, vNetId string, subnetId string) (model.SimpleMsg, error)

DeleteSubnet deletes and returns the result

func DeleteVNet added in v0.9.9

func DeleteVNet(nsId string, vNetId string, withSubnets string) (model.SimpleMsg, error)

DeleteVNet accepts vNet creation request, creates and returns an TB vNet object

func DeregisterSubnet added in v0.9.9

func DeregisterSubnet(nsId string, vNetId string, subnetId string) (model.SimpleMsg, error)

DeregisterSubnet deregister subnet and returns the result

func DeregisterVNet added in v0.9.9

func DeregisterVNet(nsId string, vNetId string, withSubnets string) (model.SimpleMsg, error)

DeregisterVNet accepts vNet unregistration request, deregister and returns the result

func DesignVNets added in v0.9.10

DesignVNets accepts a VNet design request, designs and returns a VNet design response

func FetchImagesForAllConnConfigs

func FetchImagesForAllConnConfigs(nsId string) (connConfigCount uint, imageCount uint, err error)

FetchImagesForAllConnConfigs gets all conn configs from Spider, lookups all images for each region of conn config, and saves into TB image objects

func FetchImagesForConnConfig

func FetchImagesForConnConfig(connConfig string, nsId string) (imageCount uint, err error)

FetchImagesForAllConnConfigs gets all conn configs from Spider, lookups all images for each region of conn config, and saves into TB image objects

func FetchSpecsForAllConnConfigs

func FetchSpecsForAllConnConfigs(nsId string) (connConfigCount uint, specCount uint, err error)

FetchSpecsForAllConnConfigs gets all conn configs from Spider, lookups all specs for each region of conn config, and saves into TB spec objects

func FetchSpecsForConnConfig

func FetchSpecsForConnConfig(connConfigName string, nsId string) (uint, error)

FetchSpecsForConnConfig lookups all specs for region of conn config, and saves into TB spec objects

func FilterSpecsByRange

func FilterSpecsByRange(nsId string, filter model.FilterSpecsByRangeRequest) ([]model.TbSpecInfo, error)

FilterSpecsByRange accepts criteria ranges for filtering, and returns the list of filtered TB spec objects

func GenK8sClusterKey

func GenK8sClusterKey(nsId string, k8sClusterId string) string

GenK8sClusterKey is func to generate a key from K8sCluster ID

func GenSpecMapKey

func GenSpecMapKey(region, specName string) string

GenSpecMapKey generates a SpecMap key for storing or accessing data in a map

func GetAssociatedObjectCount

func GetAssociatedObjectCount(nsId string, resourceType string, resourceId string) (int, error)

GetAssociatedObjectCount returns the number of Resource's associated Tumblebug objects

func GetAssociatedObjectList

func GetAssociatedObjectList(nsId string, resourceType string, resourceId string) ([]string, error)

GetAssociatedObjectList returns the list of Resource's associated Tumblebug objects

func GetCspResourceName added in v0.9.10

func GetCspResourceName(nsId string, resourceType string, resourceId string) (string, error)

GetCspResourceName is func to retrieve CSP native resource ID

func GetFirstNZones added in v0.9.10

func GetFirstNZones(connectionName string, firstN int) ([]string, int, error)

GetFirstNZones returns the first N zones of the given connection

func GetIdFromStruct

func GetIdFromStruct(u interface{}) (string, error)

GetIdFromStruct accepts any struct for argument, and returns value of the field 'Id'

func GetImage

func GetImage(nsId string, imageKey string) (model.TbImageInfo, error)

GetImage accepts namespace Id and imageKey(Id,CspResourceId,GuestOS,...), and returns the TB image object

func GetK8sCluster

func GetK8sCluster(nsId string, k8sClusterId string) (model.TbK8sClusterInfo, error)

GetK8sCluster retrives a k8s cluster information

func GetNameFromStruct

func GetNameFromStruct(u interface{}) (string, error)

GetNameFromStruct accepts any struct for argument, and returns value of the field 'Name'

func GetProviderRegionZoneResourceKey

func GetProviderRegionZoneResourceKey(providerName, regionName, zoneName, resourceName string) string

func GetResource

func GetResource(nsId string, resourceType string, resourceId string) (interface{}, error)

GetResource returns the requested TB Resource object

func GetSpec

func GetSpec(nsId string, specKey string) (model.TbSpecInfo, error)

GetSpec accepts namespace Id and specKey(Id,CspResourceId,...), and returns the TB spec object

func GetSubnet added in v0.9.9

func GetSubnet(nsId string, vNetId string, subnetId string) (model.TbSubnetInfo, error)

GetSubnet

func GetVNet added in v0.9.9

func GetVNet(nsId string, vNetId string) (model.TbVNetInfo, error)

func ListK8sCluster

func ListK8sCluster(nsId string, filterKey string, filterVal string) (interface{}, error)

ListK8sCluster returns the list of TB K8sCluster objects of given nsId

func ListK8sClusterId

func ListK8sClusterId(nsId string) ([]string, error)

ListK8sClusterId returns the list of TB K8sCluster object IDs of given nsId

func ListResource

func ListResource(nsId string, resourceType string, filterKey string, filterVal string) (interface{}, error)

ListResource returns the list of TB Resource objects of given resourceType

func ListResourceId

func ListResourceId(nsId string, resourceType string) ([]string, error)

ListResourceId returns the list of TB Resource object IDs of given resourceType

func ListSubnet added in v0.9.9

func ListSubnet(nsId string, vNetId string) ([]model.TbSubnetInfo, error)

ListSubnet

func LoadAssets added in v0.9.10

func LoadAssets() (model.IdList, error)

LoadAssets is to register common resources from asset files (../assets/*.csv)

func LookupImage

func LookupImage(connConfig string, imageId string) (model.SpiderImageInfo, error)

LookupImage accepts Spider conn config and CSP image ID, lookups and returns the Spider image object

func LookupImageList

func LookupImageList(connConfig string) (model.SpiderImageList, error)

LookupImageList accepts Spider conn config, lookups and returns the list of all images in the region of conn config in the form of the list of Spider image objects

func LookupMyImage

func LookupMyImage(connConfig string, myImageId string) (model.SpiderMyImageInfo, error)

LookupMyImage accepts Spider conn config and CSP myImage ID, lookups and returns the Spider image object

func LookupSpec

func LookupSpec(connConfig string, specName string) (model.SpiderSpecInfo, error)

LookupSpec accepts Spider conn config and CSP spec name, lookups and returns the Spider spec object

func LookupSpecList

func LookupSpecList(connConfig string) (model.SpiderSpecList, error)

LookupSpecList accepts Spider conn config, lookups and returns the list of all specs in the region of conn config in the form of the list of Spider spec objects

func RegisterCustomImageWithId

func RegisterCustomImageWithId(nsId string, u *model.TbCustomImageReq) (model.TbCustomImageInfo, error)

RegisterCustomImageWithId accepts customimage creation request, creates and returns an TB customimage object

func RegisterCustomImageWithInfo

func RegisterCustomImageWithInfo(nsId string, content model.TbCustomImageInfo) (model.TbCustomImageInfo, error)

RegisterCustomImageWithInfo accepts customimage registration request, creates and returns an TB customimage object

func RegisterImageWithId

func RegisterImageWithId(nsId string, u *model.TbImageReq, update bool, RDBonly bool) (model.TbImageInfo, error)

RegisterImageWithId accepts image creation request, creates and returns an TB image object

func RegisterImageWithInfo

func RegisterImageWithInfo(nsId string, content *model.TbImageInfo, update bool) (model.TbImageInfo, error)

RegisterImageWithInfo accepts image creation request, creates and returns an TB image object

func RegisterSpecWithCspResourceId added in v0.9.10

func RegisterSpecWithCspResourceId(nsId string, u *model.TbSpecReq, update bool) (model.TbSpecInfo, error)

RegisterSpecWithCspResourceId accepts spec creation request, creates and returns an TB spec object

func RegisterSpecWithInfo

func RegisterSpecWithInfo(nsId string, content *model.TbSpecInfo, update bool) (model.TbSpecInfo, error)

RegisterSpecWithInfo accepts spec creation request, creates and returns an TB spec object

func RegisterSubnet added in v0.9.9

func RegisterSubnet(nsId string, vNetId string, subnetReq *model.TbRegisterSubnetReq) (model.TbSubnetInfo, error)

func RegisterVNet added in v0.9.9

func RegisterVNet(nsId string, vNetRegisterReq *model.TbRegisterVNetReq) (model.TbVNetInfo, error)

RegisterVNet accepts vNet registration request, register and returns an TB vNet object

func RemoveK8sNodeGroup

func RemoveK8sNodeGroup(nsId string, k8sClusterId string, k8sNodeGroupName string, forceFlag string) (bool, error)

RemoveK8sNodeGroup removes a specified NodeGroup

func SearchImage

func SearchImage(nsId string, keywords ...string) ([]model.TbImageInfo, error)

SearchImage accepts arbitrary number of keywords, and returns the list of matched TB image objects

func SetK8sNodeGroupAutoscaling

func SetK8sNodeGroupAutoscaling(nsId string, k8sClusterId string, k8sNodeGroupName string, u *model.TbSetK8sNodeGroupAutoscalingReq) (model.TbSetK8sNodeGroupAutoscalingRes, error)

SetK8sNodeGroupAutoscaling set NodeGroup's Autoscaling On/Off

func TbCustomImageReqStructLevelValidation

func TbCustomImageReqStructLevelValidation(sl validator.StructLevel)

TbImageReqStructLevelValidation func is for Validation

func TbDataDiskReqStructLevelValidation

func TbDataDiskReqStructLevelValidation(sl validator.StructLevel)

TbDataDiskReqStructLevelValidation func is for Validation

func TbImageReqStructLevelValidation

func TbImageReqStructLevelValidation(sl validator.StructLevel)

TbImageReqStructLevelValidation func is for Validation

func TbK8sClusterReqStructLevelValidation

func TbK8sClusterReqStructLevelValidation(sl validator.StructLevel)

TbK8sClusterReqStructLevelValidation is a function to validate 'model.TbK8sClusterReq' object.

func TbSecurityGroupReqStructLevelValidation

func TbSecurityGroupReqStructLevelValidation(sl validator.StructLevel)

TbSecurityGroupReqStructLevelValidation is a function to validate 'TbSecurityGroupReq' object.

func TbSpecReqStructLevelValidation

func TbSpecReqStructLevelValidation(sl validator.StructLevel)

TbSpecReqStructLevelValidation is a function to validate 'TbSpecReq' object.

func TbSshKeyReqStructLevelValidation

func TbSshKeyReqStructLevelValidation(sl validator.StructLevel)

TbSshKeyReqStructLevelValidation is a function to validate 'TbSshKeyReq' object.

func TbSubnetReqStructLevelValidation

func TbSubnetReqStructLevelValidation(sl validator.StructLevel)

TbSubnetReqStructLevelValidation is a function to validate 'TbSubnetReq' object.

func TbVNetReqStructLevelValidation

func TbVNetReqStructLevelValidation(sl validator.StructLevel)

TbVNetReqStructLevelValidation is a function to validate 'TbVNetReq' object.

func ToNamingRuleCompatible

func ToNamingRuleCompatible(rawName string) string

ToNamingRuleCompatible function transforms a given string to match the regex pattern [a-z]([-a-z0-9]*[a-z0-9])?.

func UpdateAssociatedObjectList

func UpdateAssociatedObjectList(nsId string, resourceType string, resourceId string, cmd string, objectKey string) ([]string, error)

UpdateAssociatedObjectList adds or deletes the objectKey (currently, vmKey) to/from TB object's associatedObjectList

func UpdateImage

func UpdateImage(nsId string, imageId string, fieldsToUpdate model.TbImageInfo, RDBonly bool) (model.TbImageInfo, error)

UpdateImage accepts to-be TB image objects, updates and returns the updated TB image objects

func UpdateResourceObject

func UpdateResourceObject(nsId string, resourceType string, resourceObject interface{})

UpdateResourceObject is func to update the resource object

func UpdateSpec

func UpdateSpec(nsId string, specId string, fieldsToUpdate model.TbSpecInfo) (model.TbSpecInfo, error)

UpdateSpec accepts to-be TB spec objects, updates and returns the updated TB spec objects

func UpdateSshKey

func UpdateSshKey(nsId string, sshKeyId string, fieldsToUpdate model.TbSshKeyInfo) (model.TbSshKeyInfo, error)

UpdateSshKey accepts to-be TB sshKey objects, updates and returns the updated TB sshKey objects

func UpgradeK8sCluster

func UpgradeK8sCluster(nsId string, k8sClusterId string, u *model.TbUpgradeK8sClusterReq) (model.TbK8sClusterInfo, error)

UpgradeK8sCluster upgrades an existing k8s cluster to the specified version

func UpsizeDataDisk

func UpsizeDataDisk(nsId string, resourceId string, u *model.TbDataDiskUpsizeReq) (model.TbDataDiskInfo, error)

UpsizeDataDisk accepts DataDisk upsize request, creates and returns an TB dataDisk object

func ValidateSubnetReq added in v0.9.9

func ValidateSubnetReq(subnetReq *model.TbSubnetReq, existingVNet model.TbVNetInfo) error

func ValidateVNetReq added in v0.9.9

func ValidateVNetReq(vNetReq *model.TbVNetReq) error

Types

type IdNameOnly

type IdNameOnly struct {
	Id   string
	Name string
}

type NetworkStatus added in v0.9.9

type NetworkStatus string

NetworkStatus represents the status of a network resource.

const (

	// CRUD operations
	NetworkOnConfiguring NetworkStatus = "Configuring" // Resources are being configured.
	NetworkOnReading     NetworkStatus = "Reading"     // The network information is being read.
	NetworkOnUpdating    NetworkStatus = "Updating"    // The network is being updated.
	NetworkOnDeleting    NetworkStatus = "Deleting"    // The network is being deleted.

	// Register/deregister operations
	NetworkOnRegistering   NetworkStatus = "Registering"  // The network is being registered.
	NetworkOnDeregistering NetworkStatus = "Dergistering" // The network is being registered.

	// Available status
	NetworkAvailable NetworkStatus = "Available" // The network is fully created and ready for use.

	// In Use status
	NetworkInUse NetworkStatus = "InUse" // The network is currently in use.

	// Unknwon status
	NetworkUnknown NetworkStatus = "Unknown" // The network status is unknown.

	// Error Handling
	NetworkError              NetworkStatus = "Error"              // An error occurred during a CRUD operation.
	NetworkErrorOnConfiguring NetworkStatus = "ErrorOnConfiguring" // An error occurred during the configuring operation.
	NetworkErrorOnReading     NetworkStatus = "ErrorOnReading"     // An error occurred during the reading operation.
	NetworkErrorOnUpdating    NetworkStatus = "ErrorOnUpdating"    // An error occurred during the updating operation.
	NetworkErrorOnDeleting    NetworkStatus = "ErrorOnDeleting"    // An error occurred during the deleting operation.
	NetworkErrorOnRegistering NetworkStatus = "ErrorOnRegistering" // An error occurred during the registering operation.
)

type Range

type Range struct {
	Min float32 `json:"min"`
	Max float32 `json:"max"`
}

Range struct is for 'FilterSpecsByRange'

type TbDataDiskUpsizeReq

type TbDataDiskUpsizeReq struct {
	DiskSize    string `json:"diskSize" validate:"required"`
	Description string `json:"description"`
}

TbDataDiskUpsizeReq is a struct to handle 'Upsize dataDisk' request toward CB-Tumblebug.

Jump to

Keyboard shortcuts

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