mcir

package
v0.0.0-...-8f225d0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package mcir is to manage multi-cloud infra resource

Package mcir is to manage multi-cloud infra resource

Package mcir is to manage multi-cloud infra resource

Package mcir is to manage multi-cloud infra resource

Package mcir is to manage multi-cloud infra resource

Package mcir is to manage multi-cloud infra resource

Package mcir is to manage multi-cloud infra resource

Package mcir is to manage multi-cloud infra resource

Package mcir is to manage multi-cloud infra resource

Package mcir is to manage multi-cloud infra resource

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckChildResource

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

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

func CheckResource

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

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

func DelAllDefaultResources

func DelAllDefaultResources(nsId string) (common.IdList, error)

DelAllDefaultResources deletes all Default securityGroup, sshKey, vNet objects

func DelAllResources

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

DelAllResources deletes all TB MCIR object of given resourceType

func DelChildResource

func DelChildResource(nsId string, resourceType string, parentResourceId string, resourceId string, forceFlag string) error

DelChildResource deletes the TB MCIR object

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 MCIR object

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(connConfig string, nsId string) (specCount uint, err error)

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

func GetAssociatedObjectCount

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

GetAssociatedObjectCount returns the number of MCIR's associated Tumblebug objects

func GetAssociatedObjectList

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

GetAssociatedObjectList returns the list of MCIR's associated Tumblebug objects

func GetIdFromStruct

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

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

func GetNameFromStruct

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

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

func GetResource

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

GetResource returns the requested TB MCIR object

func ListResource

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

ListResource returns the list of TB MCIR objects of given resourceType

func ListResourceId

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

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

func LoadCommonResource

func LoadCommonResource() (common.IdList, error)

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

func LoadDefaultResource

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

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

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 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 func is a tool to replace string for name to make the name follow naming convention

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 UpdateResourceObject

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

UpdateResourceObject is func to update the resource object

Types

type CustomImageStatus

type CustomImageStatus string
const (
	MyImageAvailable   CustomImageStatus = "Available"
	MyImageUnavailable CustomImageStatus = "Unavailable"
)

type DiskStatus

type DiskStatus string
const (
	DiskCreating  DiskStatus = "Creating"
	DiskAvailable DiskStatus = "Available"
	DiskAttached  DiskStatus = "Attached"
	DiskDeleting  DiskStatus = "Deleting"
	DiskError     DiskStatus = "Error"
)

type FilterSpecsByRangeRequest

type FilterSpecsByRangeRequest struct {
	Id                 string `json:"id"`
	Name               string `json:"name"`
	ConnectionName     string `json:"connectionName"`
	ProviderName       string `json:"providerName"`
	RegionName         string `json:"regionName"`
	CspSpecName        string `json:"cspSpecName"`
	OsType             string `json:"osType"`
	NumvCPU            Range  `json:"numvCPU"`
	NumCore            Range  `json:"numcore"`
	MemGiB             Range  `json:"memGiB"`
	StorageGiB         Range  `json:"storageGiB"`
	Description        string `json:"description"`
	CostPerHour        Range  `json:"costPerHour"`
	NumStorage         Range  `json:"numStorage"`
	MaxNumStorage      Range  `json:"maxNumStorage"`
	MaxTotalStorageTiB Range  `json:"maxTotalStorageTiB"`
	NetBwGbps          Range  `json:"netBwGbps"`
	EbsBwMbps          Range  `json:"ebsBwMbps"`
	GpuModel           string `json:"gpuModel"`
	NumGpu             Range  `json:"numGpu"`
	GpuMemGiB          Range  `json:"gpuMemGiB"`
	GpuP2p             string `json:"gpuP2p"`
	EvaluationStatus   string `json:"evaluationStatus"`
	EvaluationScore01  Range  `json:"evaluationScore01"`
	EvaluationScore02  Range  `json:"evaluationScore02"`
	EvaluationScore03  Range  `json:"evaluationScore03"`
	EvaluationScore04  Range  `json:"evaluationScore04"`
	EvaluationScore05  Range  `json:"evaluationScore05"`
	EvaluationScore06  Range  `json:"evaluationScore06"`
	EvaluationScore07  Range  `json:"evaluationScore07"`
	EvaluationScore08  Range  `json:"evaluationScore08"`
	EvaluationScore09  Range  `json:"evaluationScore09"`
	EvaluationScore10  Range  `json:"evaluationScore10"`
}

FilterSpecsByRangeRequest is for 'FilterSpecsByRange'

type IdNameOnly

type IdNameOnly struct {
	Id   string
	Name string
}

type Range

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

Range struct is for 'FilterSpecsByRange'

type SpiderDiskAttachDetachReq

type SpiderDiskAttachDetachReq struct {
	VMName string
}

SpiderDiskAttachDetachReq is a struct to create JSON body of 'Attach/Detach disk request'

type SpiderDiskAttachDetachReqWrapper

type SpiderDiskAttachDetachReqWrapper struct {
	ConnectionName string
	ReqInfo        SpiderDiskAttachDetachReq
}

SpiderDiskAttachDetachReqWrapper is a wrapper struct to create JSON body of 'Attach/Detach disk request'

type SpiderDiskInfo

type SpiderDiskInfo struct {
	// Fields for request
	Name  string
	CSPid string

	// Fields for both request and response
	DiskType string // "", "SSD(gp2)", "Premium SSD", ...
	DiskSize string // "", "default", "50", "1000"  # (GB)

	// Fields for response
	IId common.IID // {NameId, SystemId}

	Status  DiskStatus // DiskCreating | DiskAvailable | DiskAttached | DiskDeleting | DiskError
	OwnerVM common.IID // When the Status is DiskAttached

	CreatedTime  time.Time
	KeyValueList []common.KeyValue
}

SpiderDiskInfo is a struct to create JSON body of 'Get disk request'

type SpiderDiskReqInfoWrapper

type SpiderDiskReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderDiskInfo
}

SpiderDiskReqInfoWrapper is a wrapper struct to create JSON body of 'Get disk request'

type SpiderDiskUpsizeReq

type SpiderDiskUpsizeReq struct {
	Size string // "", "default", "50", "1000"  # (GB)
}

SpiderDiskUpsizeReq is a struct to create JSON body of 'Upsize disk request'

type SpiderDiskUpsizeReqWrapper

type SpiderDiskUpsizeReqWrapper struct {
	ConnectionName string
	ReqInfo        SpiderDiskUpsizeReq
}

SpiderDiskUpsizeReqWrapper is a wrapper struct to create JSON body of 'Upsize disk request'

type SpiderGpuInfo

type SpiderGpuInfo struct {
	Count string
	Mfr   string
	Model string
	Mem   string
}

SpiderGpuInfo is a struct to handle GPU Info from CB-Spider.

type SpiderImageInfo

type SpiderImageInfo struct {
	// Fields for request
	Name string

	// Fields for response
	IId          common.IID // {NameId, SystemId}
	GuestOS      string     // Windows7, Ubuntu etc.
	Status       string     // available, unavailable
	KeyValueList []common.KeyValue
}

SpiderImageInfo is a struct to create JSON body of 'Get image request'

func LookupImage

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

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

type SpiderImageList

type SpiderImageList struct {
	Image []SpiderImageInfo `json:"image"`
}

SpiderImageList is struct for Spider Image List

func LookupImageList

func LookupImageList(connConfig string) (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

type SpiderImageReqInfoWrapper

type SpiderImageReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderImageInfo
}

SpiderImageReqInfoWrapper is a wrapper struct to create JSON body of 'Get image request'

type SpiderKeyPairInfo

type SpiderKeyPairInfo struct {
	// Fields for request
	Name  string
	CSPId string

	// Fields for response
	IId          common.IID // {NameId, SystemId}
	Fingerprint  string
	PublicKey    string
	PrivateKey   string
	VMUserID     string
	KeyValueList []common.KeyValue
}

SpiderKeyPairInfo is a struct to create JSON body of 'Create keypair request'

type SpiderKeyPairReqInfoWrapper

type SpiderKeyPairReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderKeyPairInfo
}

SpiderKeyPairReqInfoWrapper is a wrapper struct to create JSON body of 'Create keypair request'

type SpiderMyImageInfo

type SpiderMyImageInfo struct {
	IId common.IID // {NameId, SystemId}

	SourceVM common.IID

	Status CustomImageStatus // Available | Deleting

	CreatedTime  time.Time
	KeyValueList []common.KeyValue
}

func LookupMyImage

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

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

type SpiderMyImageRegisterReq

type SpiderMyImageRegisterReq struct {
	ConnectionName string
	ReqInfo        struct {
		Name  string
		CSPId string // or, CSPid ?
	}
}

type SpiderMyImageReq

type SpiderMyImageReq struct {
	ConnectionName string
	ReqInfo        struct {
		Name     string
		SourceVM string
	}
}

type SpiderSecurityInfo

type SpiderSecurityInfo struct {
	// Fields for request
	Name    string
	VPCName string
	CSPId   string

	// Fields for both request and response
	SecurityRules []SpiderSecurityRuleInfo

	// Fields for response
	IId          common.IID // {NameId, SystemId}
	VpcIID       common.IID // {NameId, SystemId}
	Direction    string     // @todo userd??
	KeyValueList []common.KeyValue
}

SpiderSecurityRuleInfo is a struct to create JSON body of 'Create security group request'

type SpiderSecurityReqInfoWrapper

type SpiderSecurityReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderSecurityInfo
}

SpiderSecurityReqInfoWrapper is a wrapper struct to create JSON body of 'Create security group request'

type SpiderSecurityRuleInfo

type SpiderSecurityRuleInfo struct {
	FromPort   string //`json:"fromPort"`
	ToPort     string //`json:"toPort"`
	IPProtocol string //`json:"ipProtocol"`
	Direction  string //`json:"direction"`
	CIDR       string
}

SpiderSecurityRuleInfo is a struct to handle security group rule info from/to CB-Spider.

type SpiderSecurityRuleReqInfoIntermediateWrapper

type SpiderSecurityRuleReqInfoIntermediateWrapper struct {
	RuleInfoList []SpiderSecurityRuleInfo
}

SpiderSecurityRuleReqInfoIntermediateWrapper is a intermediate wrapper struct between SpiderSecurityRuleReqInfoWrapper and SpiderSecurityRuleInfo.

type SpiderSecurityRuleReqInfoWrapper

type SpiderSecurityRuleReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderSecurityRuleReqInfoIntermediateWrapper
}

SpiderSecurityRuleReqInfoWrapper is a wrapper struct to create JSON body of 'Create security rule'

type SpiderSpecInfo

type SpiderSpecInfo struct {
	Region string
	Name   string
	VCpu   SpiderVCpuInfo
	Mem    string
	Gpu    []SpiderGpuInfo

	KeyValueList []common.KeyValue
}

SpiderSpecInfo is a struct to create JSON body of 'Get spec request'

func LookupSpec

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

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

type SpiderSpecList

type SpiderSpecList struct {
	Vmspec []SpiderSpecInfo `json:"vmspec"`
}

SpiderSpecList is a struct to handle spec list from the CB-Spider's REST API response

func LookupSpecList

func LookupSpecList(connConfig string) (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

type SpiderSubnetInfo

type SpiderSubnetInfo struct {
	IId          common.IID // {NameId, SystemId}
	IPv4_CIDR    string
	KeyValueList []common.KeyValue
}

SpiderSubnetInfo is a struct to handle subnet information from the CB-Spider's REST API response

type SpiderSubnetReqInfo

type SpiderSubnetReqInfo struct {
	Name         string `validate:"required"`
	IPv4_CIDR    string `validate:"required"`
	KeyValueList []common.KeyValue
}

SpiderSubnetReqInfo is a struct to create JSON body of 'Create subnet request'

type SpiderSubnetReqInfoWrapper

type SpiderSubnetReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderSubnetReqInfo
}

SpiderSubnetReqInfoWrapper is a wrapper struct to create JSON body of 'Create subnet request'

type SpiderVCpuInfo

type SpiderVCpuInfo struct {
	Count string
	Clock string // GHz
}

SpiderVCpuInfo is a struct to handle vCPU Info from CB-Spider.

type SpiderVPCInfo

type SpiderVPCInfo struct {
	IId            common.IID // {NameId, SystemId}
	IPv4_CIDR      string
	SubnetInfoList []SpiderSubnetInfo
	KeyValueList   []common.KeyValue
}

SpiderVPCInfo is a struct to handle VPC information from the CB-Spider's REST API response

type SpiderVPCReqInfo

type SpiderVPCReqInfo struct {
	Name           string
	IPv4_CIDR      string
	SubnetInfoList []SpiderSubnetReqInfo
	CSPId          string
}

SpiderVPCReqInfo is a struct to create JSON body of 'Create VPC request'

type SpiderVPCReqInfoWrapper

type SpiderVPCReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderVPCReqInfo
}

SpiderVPCReqInfoWrapper is a wrapper struct to create JSON body of 'Create VPC request'

type TbAttachDetachDataDiskReq

type TbAttachDetachDataDiskReq struct {
	DataDiskId string `json:"dataDiskId" validate:"required"`
}

TbAttachDetachDataDiskReq is a wrapper struct to create JSON body of 'Attach/Detach disk request'

type TbCustomImageInfo

type TbCustomImageInfo struct {
	Namespace            string            `json:"namespace,omitempty" example:"ns01"` // required to save in RDB
	Id                   string            `json:"id" example:"aws-ap-southeast-1-snapshot"`
	Name                 string            `json:"name" example:"aws-ap-southeast-1-snapshot"`
	ConnectionName       string            `json:"connectionName" example:"aws-ap-southeast-1"`
	SourceVmId           string            `json:"sourceVmId" example:"aws-ap-southeast-1-1"`
	CspCustomImageId     string            `json:"cspCustomImageId,omitempty" example:"ami-06eb41e14121c550a"`
	CspCustomImageName   string            `json:"cspCustomImageName,omitempty" example:"aws-ap-southeast-1-snapshot"`
	Description          string            `json:"description"`
	CreationDate         time.Time         `json:"creationDate,omitempty" example:"2022-10-18T08:12:48Z"`
	GuestOS              string            `json:"guestOS,omitempty"` // Windows7, Ubuntu etc.
	Status               CustomImageStatus `json:"status" example:"Available"`
	KeyValueList         []common.KeyValue `json:"keyValueList,omitempty"`
	AssociatedObjectList []string          `json:"associatedObjectList,omitempty" example:["/ns/ns01/mcis/mcis01/vm/aws-ap-southeast-1-1"]`
	IsAutoGenerated      bool              `json:"isAutoGenerated,omitempty"`

	// SystemLabel is for describing the MCIR in a keyword (any string can be used) for special System purpose
	SystemLabel string `json:"systemLabel,omitempty" example:"Managed by CB-Tumblebug" default:""`
}

func ConvertSpiderMyImageToTumblebugCustomImage

func ConvertSpiderMyImageToTumblebugCustomImage(spiderMyImage SpiderMyImageInfo) (TbCustomImageInfo, error)

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

func RegisterCustomImageWithId

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

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

func RegisterCustomImageWithInfo

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

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

type TbCustomImageReq

type TbCustomImageReq struct {
	ConnectionName string `json:"connectionName"`
	Name           string `json:"name" validate:"required"`
	SourceVmId     string `json:"sourceVmId"`
	Description    string `json:"description"`

	// This field is for 'Register existing custom image'
	CspCustomImageId string `json:"cspCustomImageId"`
}

TbCustomImageReq is a struct to handle 'Create custom image (VM snapshot)' request toward CB-Tumblebug.

type TbDataDiskInfo

type TbDataDiskInfo struct {
	Id                   string            `json:"id,omitempty" example:"aws-ap-southeast-1-datadisk"`
	Name                 string            `json:"name,omitempty" example:"aws-ap-southeast-1-datadisk"`
	ConnectionName       string            `json:"connectionName,omitempty" example:"aws-ap-southeast-1"`
	DiskType             string            `json:"diskType" example:"standard"`
	DiskSize             string            `json:"diskSize" example:"77"`
	CspDataDiskId        string            `json:"cspDataDiskId,omitempty" example:"vol-0d397c3239629bd43"`
	CspDataDiskName      string            `json:"cspDataDiskName,omitempty" example:"ns01-aws-ap-southeast-1-datadisk"`
	Status               DiskStatus        `json:"status" example:"Available"` // Available, Unavailable, Attached, ...
	AssociatedObjectList []string          `json:"associatedObjectList" example:["/ns/ns01/mcis/mcis01/vm/aws-ap-southeast-1-1"]`
	CreatedTime          time.Time         `json:"createdTime,omitempty" example:"2022-10-12T05:09:51.05Z"`
	KeyValueList         []common.KeyValue `json:"keyValueList,omitempty"`
	Description          string            `json:"description,omitempty" example:"Available"`

	// Latest system message such as error message
	SystemMessage string `json:"systemMessage" example:"Failed because ..." default:""` // systeam-given string message

	IsAutoGenerated bool `json:"isAutoGenerated,omitempty"`

	// SystemLabel is for describing the MCIR in a keyword (any string can be used) for special System purpose
	SystemLabel string `json:"systemLabel,omitempty" example:"Managed by CB-Tumblebug" default:""`
}

TbDataDiskInfo is a struct that represents TB dataDisk object.

func CreateDataDisk

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

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

func UpsizeDataDisk

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

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

type TbDataDiskReq

type TbDataDiskReq struct {
	Name           string `json:"name" validate:"required" example:"aws-ap-southeast-1-datadisk"`
	ConnectionName string `json:"connectionName" validate:"required" example:"aws-ap-southeast-1"`
	DiskType       string `json:"diskType" example:"default"`
	DiskSize       string `json:"diskSize" validate:"required" example:"77" default:"100"`
	Description    string `json:"description,omitempty"`

	// Fields for "Register existing dataDisk" feature
	// CspDataDiskId is required to register object from CSP (option=register)
	CspDataDiskId string `json:"cspDataDiskId"`
}

TbDataDiskReq is a struct to handle 'Register dataDisk' request toward CB-Tumblebug.

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.

type TbFirewallRuleInfo

type TbFirewallRuleInfo struct {
	FromPort   string `validate:"required"` //`json:"fromPort"`
	ToPort     string `validate:"required"` //`json:"toPort"`
	IPProtocol string `validate:"required"` //`json:"ipProtocol"`
	Direction  string `validate:"required"` //`json:"direction"`
	CIDR       string
}

TbFirewallRuleInfo is a struct to handle firewall rule info of CB-Tumblebug.

type TbImageInfo

type TbImageInfo struct {
	Namespace            string            `json:"namespace,omitempty"` // required to save in RDB
	Id                   string            `json:"id,omitempty"`
	Name                 string            `json:"name,omitempty"`
	ConnectionName       string            `json:"connectionName,omitempty"`
	CspImageId           string            `json:"cspImageId,omitempty"`
	CspImageName         string            `json:"cspImageName,omitempty"`
	Description          string            `json:"description,omitempty"`
	CreationDate         string            `json:"creationDate,omitempty"`
	GuestOS              string            `json:"guestOS,omitempty"` // Windows7, Ubuntu etc.
	Status               string            `json:"status,omitempty"`  // available, unavailable
	KeyValueList         []common.KeyValue `json:"keyValueList,omitempty"`
	AssociatedObjectList []string          `json:"associatedObjectList,omitempty"`
	IsAutoGenerated      bool              `json:"isAutoGenerated,omitempty"`

	// SystemLabel is for describing the MCIR in a keyword (any string can be used) for special System purpose
	SystemLabel string `json:"systemLabel,omitempty" example:"Managed by CB-Tumblebug" default:""`
}

TbImageInfo is a struct that represents TB image object.

func ConvertSpiderImageToTumblebugImage

func ConvertSpiderImageToTumblebugImage(spiderImage SpiderImageInfo) (TbImageInfo, error)

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

func RegisterImageWithId

func RegisterImageWithId(nsId string, u *TbImageReq) (TbImageInfo, error)

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

func RegisterImageWithInfo

func RegisterImageWithInfo(nsId string, content *TbImageInfo) (TbImageInfo, error)

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

func SearchImage

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

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

func UpdateImage

func UpdateImage(nsId string, imageId string, fieldsToUpdate TbImageInfo) (TbImageInfo, error)

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

type TbImageReq

type TbImageReq struct {
	Name           string `json:"name" validate:"required"`
	ConnectionName string `json:"connectionName" validate:"required"`
	CspImageId     string `json:"cspImageId" validate:"required"`
	Description    string `json:"description"`
}

TbImageReq is a struct to handle 'Register image' request toward CB-Tumblebug.

type TbSecurityGroupInfo

type TbSecurityGroupInfo struct {
	Id                   string               `json:"id"`
	Name                 string               `json:"name"`
	ConnectionName       string               `json:"connectionName"`
	VNetId               string               `json:"vNetId"`
	Description          string               `json:"description"`
	FirewallRules        []TbFirewallRuleInfo `json:"firewallRules"`
	CspSecurityGroupId   string               `json:"cspSecurityGroupId"`
	CspSecurityGroupName string               `json:"cspSecurityGroupName"`
	KeyValueList         []common.KeyValue    `json:"keyValueList"`
	AssociatedObjectList []string             `json:"associatedObjectList"`
	IsAutoGenerated      bool                 `json:"isAutoGenerated"`

	// SystemLabel is for describing the MCIR in a keyword (any string can be used) for special System purpose
	SystemLabel string `json:"systemLabel" example:"Managed by CB-Tumblebug" default:""`
}

TbSecurityGroupInfo is a struct that represents TB security group object.

func CreateFirewallRules

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

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

func CreateSecurityGroup

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

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

func DeleteFirewallRules

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

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

type TbSecurityGroupReq

type TbSecurityGroupReq struct {
	Name           string                `json:"name" validate:"required"`
	ConnectionName string                `json:"connectionName" validate:"required"`
	VNetId         string                `json:"vNetId" validate:"required"`
	Description    string                `json:"description"`
	FirewallRules  *[]TbFirewallRuleInfo `json:"firewallRules"` // validate:"required"`

	// CspSecurityGroupId is required to register object from CSP (option=register)
	CspSecurityGroupId string `json:"cspSecurityGroupId"`
}

TbSecurityGroupReq is a struct to handle 'Create security group' request toward CB-Tumblebug.

type TbSpecInfo

type TbSpecInfo struct {
	Namespace             string   `json:"namespace,omitempty"` // required to save in RDB
	Id                    string   `json:"id,omitempty"`
	Name                  string   `json:"name,omitempty"`
	ConnectionName        string   `json:"connectionName,omitempty"`
	ProviderName          string   `json:"providerName,omitempty"`
	RegionName            string   `json:"regionName,omitempty"`
	CspSpecName           string   `json:"cspSpecName,omitempty"`
	OsType                string   `json:"osType,omitempty"`
	NumvCPU               uint16   `json:"numvCPU,omitempty"`
	NumCore               uint16   `json:"numCore,omitempty"`
	MemGiB                float32  `json:"memGiB,omitempty"`
	StorageGiB            uint32   `json:"storageGiB,omitempty"`
	Description           string   `json:"description,omitempty"`
	CostPerHour           float32  `json:"costPerHour,omitempty"`
	NumStorage            uint8    `json:"numStorage,omitempty"`
	MaxNumStorage         uint8    `json:"maxNumStorage,omitempty"`
	MaxTotalStorageTiB    uint16   `json:"maxTotalStorageTiB,omitempty"`
	NetBwGbps             uint16   `json:"netBwGbps,omitempty"`
	EbsBwMbps             uint32   `json:"ebsBwMbps,omitempty"`
	GpuModel              string   `json:"gpuModel,omitempty"`
	NumGpu                uint8    `json:"numGpu,omitempty"`
	GpuMemGiB             float32  `json:"gpuMemGiB,omitempty"`
	GpuP2p                string   `json:"gpuP2p,omitempty"`
	OrderInFilteredResult uint16   `json:"orderInFilteredResult,omitempty"`
	EvaluationStatus      string   `json:"evaluationStatus,omitempty"`
	EvaluationScore01     float32  `json:"evaluationScore01"`
	EvaluationScore02     float32  `json:"evaluationScore02"`
	EvaluationScore03     float32  `json:"evaluationScore03"`
	EvaluationScore04     float32  `json:"evaluationScore04"`
	EvaluationScore05     float32  `json:"evaluationScore05"`
	EvaluationScore06     float32  `json:"evaluationScore06"`
	EvaluationScore07     float32  `json:"evaluationScore07"`
	EvaluationScore08     float32  `json:"evaluationScore08"`
	EvaluationScore09     float32  `json:"evaluationScore09"`
	EvaluationScore10     float32  `json:"evaluationScore10"`
	RootDiskType          string   `json:"rootDiskType"`
	RootDiskSize          string   `json:"rootDiskSize"`
	AssociatedObjectList  []string `json:"associatedObjectList,omitempty"`
	IsAutoGenerated       bool     `json:"isAutoGenerated,omitempty"`

	// SystemLabel is for describing the MCIR in a keyword (any string can be used) for special System purpose
	SystemLabel string `json:"systemLabel,omitempty" example:"Managed by CB-Tumblebug" default:""`
}

TbSpecInfo is a struct that represents TB spec object.

func ConvertSpiderSpecToTumblebugSpec

func ConvertSpiderSpecToTumblebugSpec(spiderSpec SpiderSpecInfo) (TbSpecInfo, error)

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

func FilterSpecs

func FilterSpecs(nsId string, filter TbSpecInfo) ([]TbSpecInfo, error)

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

func FilterSpecsByRange

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

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

func RegisterSpecWithCspSpecName

func RegisterSpecWithCspSpecName(nsId string, u *TbSpecReq) (TbSpecInfo, error)

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

func RegisterSpecWithInfo

func RegisterSpecWithInfo(nsId string, content *TbSpecInfo) (TbSpecInfo, error)

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

func SortSpecs

func SortSpecs(specList []TbSpecInfo, orderBy string, direction string) ([]TbSpecInfo, error)

SortSpecs accepts the list of TB spec objects, criteria and sorting direction, sorts and returns the sorted list of TB spec objects

func UpdateSpec

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

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

type TbSpecReq

type TbSpecReq struct {
	Name           string `json:"name" validate:"required"`
	ConnectionName string `json:"connectionName" validate:"required"`
	CspSpecName    string `json:"cspSpecName" validate:"required"`
	Description    string `json:"description"`
}

TbSpecReq is a struct to handle 'Register spec' request toward CB-Tumblebug.

type TbSshKeyInfo

type TbSshKeyInfo struct {
	Id             string `json:"id,omitempty"`
	Name           string `json:"name,omitempty"`
	ConnectionName string `json:"connectionName,omitempty"`
	Description    string `json:"description,omitempty"`

	// CspSshKeyId used for CSP-native identifier (either Name or ID)
	CspSshKeyId string `json:"cspSshKeyId,omitempty"`

	// CspSshKeyName used for CB-Spider identifier
	CspSshKeyName string `json:"cspSshKeyName,omitempty"`

	Fingerprint          string            `json:"fingerprint,omitempty"`
	Username             string            `json:"username,omitempty"`
	VerifiedUsername     string            `json:"verifiedUsername,omitempty"`
	PublicKey            string            `json:"publicKey,omitempty"`
	PrivateKey           string            `json:"privateKey,omitempty"`
	KeyValueList         []common.KeyValue `json:"keyValueList,omitempty"`
	AssociatedObjectList []string          `json:"associatedObjectList,omitempty"`
	IsAutoGenerated      bool              `json:"isAutoGenerated,omitempty"`

	// SystemLabel is for describing the MCIR in a keyword (any string can be used) for special System purpose
	SystemLabel string `json:"systemLabel,omitempty" example:"Managed by CB-Tumblebug" default:""`
}

TbSshKeyInfo is a struct that represents TB SSH key object.

func CreateSshKey

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

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

func UpdateSshKey

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

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

type TbSshKeyReq

type TbSshKeyReq struct {
	Name           string `json:"name" validate:"required"`
	ConnectionName string `json:"connectionName" validate:"required"`
	Description    string `json:"description"`

	// Fields for "Register existing SSH keys" feature
	// CspSshKeyId is required to register object from CSP (option=register)
	CspSshKeyId      string `json:"cspSshKeyId"`
	Fingerprint      string `json:"fingerprint"`
	Username         string `json:"username"`
	VerifiedUsername string `json:"verifiedUsername"`
	PublicKey        string `json:"publicKey"`
	PrivateKey       string `json:"privateKey"`
}

TbSshKeyReq is a struct to handle 'Create SSH key' request toward CB-Tumblebug.

type TbSubnetInfo

type TbSubnetInfo struct {
	Id           string
	Name         string `validate:"required"`
	IPv4_CIDR    string `validate:"required"`
	KeyValueList []common.KeyValue
	Description  string
}

TbSubnetInfo is a struct that represents TB subnet object.

type TbSubnetReq

type TbSubnetReq struct {
	Name         string `validate:"required"`
	IPv4_CIDR    string `validate:"required"`
	KeyValueList []common.KeyValue
	Description  string
}

TbSubnetReq is a struct that represents TB subnet object.

type TbVNetInfo

type TbVNetInfo struct {
	Id                   string            `json:"id"`
	Name                 string            `json:"name"`
	ConnectionName       string            `json:"connectionName"`
	CidrBlock            string            `json:"cidrBlock"`
	SubnetInfoList       []TbSubnetInfo    `json:"subnetInfoList"`
	Description          string            `json:"description"`
	CspVNetId            string            `json:"cspVNetId"`
	CspVNetName          string            `json:"cspVNetName"`
	Status               string            `json:"status"`
	KeyValueList         []common.KeyValue `json:"keyValueList"`
	AssociatedObjectList []string          `json:"associatedObjectList"`
	IsAutoGenerated      bool              `json:"isAutoGenerated"`

	// SystemLabel is for describing the MCIR in a keyword (any string can be used) for special System purpose
	SystemLabel string `json:"systemLabel" example:"Managed by CB-Tumblebug" default:""`
}

TbVNetInfo is a struct that represents TB vNet object.

func CreateSubnet

func CreateSubnet(nsId string, vNetId string, req TbSubnetReq, objectOnly bool) (TbVNetInfo, error)

CreateSubnet accepts subnet creation request, creates and returns an TB vNet object

func CreateVNet

func CreateVNet(nsId string, u *TbVNetReq, option string) (TbVNetInfo, error)

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

type TbVNetReq

type TbVNetReq struct {
	Name           string        `json:"name" validate:"required"`
	ConnectionName string        `json:"connectionName" validate:"required"`
	CidrBlock      string        `json:"cidrBlock"`
	SubnetInfoList []TbSubnetReq `json:"subnetInfoList"`
	Description    string        `json:"description"`
	CspVNetId      string        `json:"cspVNetId"`
}

TbVNetReq is a struct to handle 'Create vNet' request toward CB-Tumblebug.

Jump to

Keyboard shortcuts

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