mcir

package
v0.0.0-...-3d28840 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 DelAllResources

func DelAllResources(nsId string, resourceType string, forceFlag string) error

DelAllResources deletes all TB MCIR object of given resourceType

func DelRecommendSpec

func DelRecommendSpec(nsId string, specId string, cpuSize uint16, memSize uint16, diskSize uint32) error

DelRecommendSpec deletes the spec recommendation info

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 GetNameFromStruct

func GetNameFromStruct(u interface{}) string

GetNameFromStruct accepts any struct for argument, and returns

func GetResource

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

GetResource returns the requested TB MCIR object

func InspectResources

func InspectResources(connConfig string, resourceType string) (interface{}, error)

InspectResources returns the state list of TB MCIR objects of given connConfig and resourceType

func ListResource

func ListResource(nsId string, resourceType 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 RefineImageName

func RefineImageName(imageName string) string

func RefineSpecName

func RefineSpecName(specName string) string

func RegisterRecommendList

func RegisterRecommendList(nsId string, connectionName string, cpuSize uint16, memSize uint16, diskSize uint32, specId string, price float32) error

RegisterRecommendList creates the spec recommendation info

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

Types

type FilterSpecsByRangeRequest

type FilterSpecsByRangeRequest struct {
	Id                    string `json:"id"`
	Name                  string `json:"name"`
	ConnectionName        string `json:"connectionName"`
	CspSpecName           string `json:"cspSpecName"`
	Os_type               string `json:"os_type"`
	Num_vCPU              Range  `json:"num_vCPU"`
	Num_core              Range  `json:"num_core"`
	Mem_GiB               Range  `json:"mem_GiB"`
	Storage_GiB           Range  `json:"storage_GiB"`
	Description           string `json:"description"`
	Cost_per_hour         Range  `json:"cost_per_hour"`
	Num_storage           Range  `json:"num_storage"`
	Max_num_storage       Range  `json:"max_num_storage"`
	Max_total_storage_TiB Range  `json:"max_total_storage_TiB"`
	Net_bw_Gbps           Range  `json:"net_bw_Gbps"`
	Ebs_bw_Mbps           Range  `json:"ebs_bw_Mbps"`
	Gpu_model             string `json:"gpu_model"`
	Num_gpu               Range  `json:"num_gpu"`
	Gpumem_GiB            Range  `json:"gpumem_GiB"`
	Gpu_p2p               string `json:"gpu_p2p"`
	EvaluationStatus      string `json:"evaluationStatus"`
	EvaluationScore_01    Range  `json:"evaluationScore_01"`
	EvaluationScore_02    Range  `json:"evaluationScore_02"`
	EvaluationScore_03    Range  `json:"evaluationScore_03"`
	EvaluationScore_04    Range  `json:"evaluationScore_04"`
	EvaluationScore_05    Range  `json:"evaluationScore_05"`
	EvaluationScore_06    Range  `json:"evaluationScore_06"`
	EvaluationScore_07    Range  `json:"evaluationScore_07"`
	EvaluationScore_08    Range  `json:"evaluationScore_08"`
	EvaluationScore_09    Range  `json:"evaluationScore_09"`
	EvaluationScore_10    Range  `json:"evaluationScore_10"`
}

type NameOnly

type NameOnly struct {
	Name string
}

type Range

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

type ReturnValue

type ReturnValue struct {
	CustomStruct interface{}
}

type SpiderAllList

type SpiderAllList struct {
	MappedList     []SpiderNameIdSystemId
	OnlySpiderList []SpiderNameIdSystemId
	OnlyCSPList    []SpiderNameIdSystemId
}

type SpiderAllListWrapper

type SpiderAllListWrapper struct {
	AllList SpiderAllList
}

type SpiderGpuInfo

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

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
}

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"`
}

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
}

type SpiderKeyPairInfo

type SpiderKeyPairInfo struct {
	// Fields for request
	Name string

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

type SpiderKeyPairReqInfoWrapper

type SpiderKeyPairReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderKeyPairInfo
}

type SpiderNameIdSystemId

type SpiderNameIdSystemId struct {
	NameId   string
	SystemId string
}

type SpiderSecurityInfo

type SpiderSecurityInfo struct {
	// Fields for request
	Name    string
	VPCName 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
}

type SpiderSecurityReqInfoWrapper

type SpiderSecurityReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderSecurityInfo
}

type SpiderSecurityRuleInfo

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

type SpiderSpecInfo

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

	KeyValueList []common.KeyValue
}

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"`
}

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
}

type SpiderSubnetReqInfo

type SpiderSubnetReqInfo struct {
	Name         string
	IPv4_CIDR    string
	KeyValueList []common.KeyValue
}

type SpiderVCpuInfo

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

type SpiderVPCInfo

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

type SpiderVPCReqInfo

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

type SpiderVPCReqInfoWrapper

type SpiderVPCReqInfoWrapper struct {
	ConnectionName string
	ReqInfo        SpiderVPCReqInfo
}

type TbImageInfo

type TbImageInfo struct {
	Namespace            string            `json:"namespace"` // required to save in RDB
	Id                   string            `json:"id"`
	Name                 string            `json:"name"`
	ConnectionName       string            `json:"connectionName"`
	CspImageId           string            `json:"cspImageId"`
	CspImageName         string            `json:"cspImageName"`
	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"`
	IsAutoGenerated      bool              `json:"isAutoGenerated"`
}

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

type TbImageReq

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

type TbInspectResourcesResponse

type TbInspectResourcesResponse struct {
	// ResourcesOnCsp       interface{} `json:"resourcesOnCsp"`
	// ResourcesOnSpider    interface{} `json:"resourcesOnSpider"`
	// ResourcesOnTumblebug interface{} `json:"resourcesOnTumblebug"`
	ResourcesOnCsp       []resourceOnCspOrSpider `json:"resourcesOnCsp"`
	ResourcesOnSpider    []resourceOnCspOrSpider `json:"resourcesOnSpider"`
	ResourcesOnTumblebug []resourceOnTumblebug   `json:"resourcesOnTumblebug"`
}

Response struct for InspectResources

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        *[]SpiderSecurityRuleInfo `json:"firewallRules"`
	CspSecurityGroupId   string                    `json:"cspSecurityGroupId"`
	CspSecurityGroupName string                    `json:"cspSecurityGroupName"`
	KeyValueList         []common.KeyValue         `json:"keyValueList"`
	AssociatedObjectList []string                  `json:"associatedObjectList"`
	IsAutoGenerated      bool                      `json:"isAutoGenerated"`
}

func CreateSecurityGroup

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

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

type TbSecurityGroupReq

type TbSecurityGroupReq struct {
	Name           string                    `json:"name"`
	ConnectionName string                    `json:"connectionName"`
	VNetId         string                    `json:"vNetId"`
	Description    string                    `json:"description"`
	FirewallRules  *[]SpiderSecurityRuleInfo `json:"firewallRules"`
}

type TbSpecInfo

type TbSpecInfo struct {
	Namespace             string   `json:"namespace"` // required to save in RDB
	Id                    string   `json:"id"`
	Name                  string   `json:"name"`
	ConnectionName        string   `json:"connectionName"`
	CspSpecName           string   `json:"cspSpecName"`
	Os_type               string   `json:"os_type"`
	Num_vCPU              uint16   `json:"num_vCPU"`
	Num_core              uint16   `json:"num_core"`
	Mem_GiB               uint16   `json:"mem_GiB"`
	Storage_GiB           uint32   `json:"storage_GiB"`
	Description           string   `json:"description"`
	Cost_per_hour         float32  `json:"cost_per_hour"`
	Num_storage           uint8    `json:"num_storage"`
	Max_num_storage       uint8    `json:"max_num_storage"`
	Max_total_storage_TiB uint16   `json:"max_total_storage_TiB"`
	Net_bw_Gbps           uint16   `json:"net_bw_Gbps"`
	Ebs_bw_Mbps           uint32   `json:"ebs_bw_Mbps"`
	Gpu_model             string   `json:"gpu_model"`
	Num_gpu               uint8    `json:"num_gpu"`
	Gpumem_GiB            uint16   `json:"gpumem_GiB"`
	Gpu_p2p               string   `json:"gpu_p2p"`
	OrderInFilteredResult uint16   `json:"orderInFilteredResult"`
	EvaluationStatus      string   `json:"evaluationStatus"`
	EvaluationScore_01    float32  `json:"evaluationScore_01"`
	EvaluationScore_02    float32  `json:"evaluationScore_02"`
	EvaluationScore_03    float32  `json:"evaluationScore_03"`
	EvaluationScore_04    float32  `json:"evaluationScore_04"`
	EvaluationScore_05    float32  `json:"evaluationScore_05"`
	EvaluationScore_06    float32  `json:"evaluationScore_06"`
	EvaluationScore_07    float32  `json:"evaluationScore_07"`
	EvaluationScore_08    float32  `json:"evaluationScore_08"`
	EvaluationScore_09    float32  `json:"evaluationScore_09"`
	EvaluationScore_10    float32  `json:"evaluationScore_10"`
	AssociatedObjectList  []string `json:"associatedObjectList"`
	IsAutoGenerated       bool     `json:"isAutoGenerated"`
}

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, newSpec 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"`
	ConnectionName string `json:"connectionName"`
	CspSpecName    string `json:"cspSpecName"`
	Description    string `json:"description"`
}

type TbSshKeyInfo

type TbSshKeyInfo struct {
	Id                   string            `json:"id"`
	Name                 string            `json:"name"`
	ConnectionName       string            `json:"connectionName"`
	Description          string            `json:"description"`
	CspSshKeyName        string            `json:"cspSshKeyName"`
	Fingerprint          string            `json:"fingerprint"`
	Username             string            `json:"username"`
	VerifiedUsername     string            `json:"verifiedUsername"`
	PublicKey            string            `json:"publicKey"`
	PrivateKey           string            `json:"privateKey"`
	KeyValueList         []common.KeyValue `json:"keyValueList"`
	AssociatedObjectList []string          `json:"associatedObjectList"`
	IsAutoGenerated      bool              `json:"isAutoGenerated"`
}

func CreateSshKey

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

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

type TbSshKeyReq

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

type TbVNetInfo

type TbVNetInfo struct {
	Id                   string             `json:"id"`
	Name                 string             `json:"name"`
	ConnectionName       string             `json:"connectionName"`
	CidrBlock            string             `json:"cidrBlock"`
	SubnetInfoList       []SpiderSubnetInfo `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"`
}

func CreateVNet

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

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

type TbVNetReq

type TbVNetReq struct {
	Name           string                `json:"name"`
	ConnectionName string                `json:"connectionName"`
	CidrBlock      string                `json:"cidrBlock"`
	SubnetInfoList []SpiderSubnetReqInfo `json:"subnetInfoList"`
	Description    string                `json:"description"`
}

Jump to

Keyboard shortcuts

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