diff --git a/src/api/rest/docs/docs.go b/src/api/rest/docs/docs.go index 0b15b5c71..01b5bca1c 100644 --- a/src/api/rest/docs/docs.go +++ b/src/api/rest/docs/docs.go @@ -4209,7 +4209,7 @@ const docTemplate = `{ "required": true }, { - "description": "Request body to provision MCIS dynamically", + "description": "Request body to provision MCIS dynamically. Must include commonSpec and commonImage info of each VM request.(ex: {name: mcis01,vm: [{commonImage: aws+ap-northeast-2+ubuntu22.04,commonSpec: aws+ap-northeast-2+t2.small}]} ) You can use /mcisRecommendVm and /mcisDynamicCheckRequest to get it) Check the guide: https://github.com/cloud-barista/cb-tumblebug/discussions/1570", "name": "mcisReq", "in": "body", "required": true, @@ -9996,16 +9996,22 @@ const docTemplate = `{ "type": "string" } }, + "image": { + "type": "array", + "items": { + "$ref": "#/definitions/mcir.TbImageInfo" + } + }, "region": { "$ref": "#/definitions/common.RegionDetail" }, + "spec": { + "$ref": "#/definitions/mcir.TbSpecInfo" + }, "systemMessage": { "description": "Latest system message such as error message", "type": "string", "example": "Failed because ..." - }, - "vmSpec": { - "$ref": "#/definitions/mcir.TbSpecInfo" } } }, @@ -10058,11 +10064,11 @@ const docTemplate = `{ "metric": { "type": "string", "enum": [ - "cpu", - "memory", - "cost" + "vCPU", + "memoryGiB", + "costPerHour" ], - "example": "cpu" + "example": "vCPU" } } }, @@ -10212,7 +10218,7 @@ const docTemplate = `{ }, "example": [ "aws+ap-northeast-2+t2.small", - "gcp+us-west1+g1.small" + "gcp+us-west1+g1-small" ] } } diff --git a/src/api/rest/docs/swagger.json b/src/api/rest/docs/swagger.json index fce4de271..bb8566382 100644 --- a/src/api/rest/docs/swagger.json +++ b/src/api/rest/docs/swagger.json @@ -4202,7 +4202,7 @@ "required": true }, { - "description": "Request body to provision MCIS dynamically", + "description": "Request body to provision MCIS dynamically. Must include commonSpec and commonImage info of each VM request.(ex: {name: mcis01,vm: [{commonImage: aws+ap-northeast-2+ubuntu22.04,commonSpec: aws+ap-northeast-2+t2.small}]} ) You can use /mcisRecommendVm and /mcisDynamicCheckRequest to get it) Check the guide: https://github.com/cloud-barista/cb-tumblebug/discussions/1570", "name": "mcisReq", "in": "body", "required": true, @@ -9989,16 +9989,22 @@ "type": "string" } }, + "image": { + "type": "array", + "items": { + "$ref": "#/definitions/mcir.TbImageInfo" + } + }, "region": { "$ref": "#/definitions/common.RegionDetail" }, + "spec": { + "$ref": "#/definitions/mcir.TbSpecInfo" + }, "systemMessage": { "description": "Latest system message such as error message", "type": "string", "example": "Failed because ..." - }, - "vmSpec": { - "$ref": "#/definitions/mcir.TbSpecInfo" } } }, @@ -10051,11 +10057,11 @@ "metric": { "type": "string", "enum": [ - "cpu", - "memory", - "cost" + "vCPU", + "memoryGiB", + "costPerHour" ], - "example": "cpu" + "example": "vCPU" } } }, @@ -10205,7 +10211,7 @@ }, "example": [ "aws+ap-northeast-2+t2.small", - "gcp+us-west1+g1.small" + "gcp+us-west1+g1-small" ] } } diff --git a/src/api/rest/docs/swagger.yaml b/src/api/rest/docs/swagger.yaml index cfa9c7424..2ff3db67a 100644 --- a/src/api/rest/docs/swagger.yaml +++ b/src/api/rest/docs/swagger.yaml @@ -1242,14 +1242,18 @@ definitions: items: type: string type: array + image: + items: + $ref: '#/definitions/mcir.TbImageInfo' + type: array region: $ref: '#/definitions/common.RegionDetail' + spec: + $ref: '#/definitions/mcir.TbSpecInfo' systemMessage: description: Latest system message such as error message example: Failed because ... type: string - vmSpec: - $ref: '#/definitions/mcir.TbSpecInfo' type: object mcis.ClusterStatus: enum: @@ -1287,10 +1291,10 @@ definitions: type: array metric: enum: - - cpu - - memory - - cost - example: cpu + - vCPU + - memoryGiB + - costPerHour + example: vCPU type: string type: object mcis.FilterInfo: @@ -1386,7 +1390,7 @@ definitions: description: CommonSpec is field for id of a spec in common namespace example: - aws+ap-northeast-2+t2.small - - gcp+us-west1+g1.small + - gcp+us-west1+g1-small items: type: string type: array @@ -5700,7 +5704,11 @@ paths: name: nsId required: true type: string - - description: Request body to provision MCIS dynamically + - description: 'Request body to provision MCIS dynamically. Must include commonSpec + and commonImage info of each VM request.(ex: {name: mcis01,vm: [{commonImage: + aws+ap-northeast-2+ubuntu22.04,commonSpec: aws+ap-northeast-2+t2.small}]} + ) You can use /mcisRecommendVm and /mcisDynamicCheckRequest to get it) Check + the guide: https://github.com/cloud-barista/cb-tumblebug/discussions/1570' in: body name: mcisReq required: true diff --git a/src/api/rest/server/mcis/provisioning.go b/src/api/rest/server/mcis/provisioning.go index bb3f39e13..f9d8776b4 100644 --- a/src/api/rest/server/mcis/provisioning.go +++ b/src/api/rest/server/mcis/provisioning.go @@ -114,7 +114,7 @@ func RestPostSystemMcis(c echo.Context) error { // @Accept json // @Produce json // @Param nsId path string true "Namespace ID" default(ns01) -// @Param mcisReq body TbMcisDynamicReq true "Request body to provision MCIS dynamically" +// @Param mcisReq body TbMcisDynamicReq true "Request body to provision MCIS dynamically. Must include commonSpec and commonImage info of each VM request.(ex: {name: mcis01,vm: [{commonImage: aws+ap-northeast-2+ubuntu22.04,commonSpec: aws+ap-northeast-2+t2.small}]} ) You can use /mcisRecommendVm and /mcisDynamicCheckRequest to get it) Check the guide: https://github.com/cloud-barista/cb-tumblebug/discussions/1570" // @Param option query string false "Option for MCIS creation" Enums(hold) // @Success 200 {object} TbMcisInfo // @Failure 404 {object} common.SimpleMsg diff --git a/src/core/mcis/provisioning.go b/src/core/mcis/provisioning.go index b84f1f54c..25725e9d4 100644 --- a/src/core/mcis/provisioning.go +++ b/src/core/mcis/provisioning.go @@ -245,7 +245,7 @@ type TbVmDynamicReq struct { // McisConnectionConfigCandidatesReq is struct for a request to check requirements to create a new MCIS instance dynamically (with default resource option) type McisConnectionConfigCandidatesReq struct { // CommonSpec is field for id of a spec in common namespace - CommonSpecs []string `json:"commonSpec" validate:"required" example:"aws+ap-northeast-2+t2.small,gcp+us-west1+g1.small"` + CommonSpecs []string `json:"commonSpec" validate:"required" example:"aws+ap-northeast-2+t2.small,gcp+us-west1+g1-small"` } // CheckMcisDynamicReqInfo is struct to check requirements to create a new MCIS instance dynamically (with default resource option) @@ -259,11 +259,10 @@ type CheckVmDynamicReqInfo struct { // ConnectionConfigCandidates will provide ConnectionConfig options ConnectionConfigCandidates []string `json:"connectionConfigCandidates" default:""` - // CommonImage is field for id of a image in common namespace - // CommonImage string `json:"commonImage" validate:"required" example:"ubuntu18.04"` //RootDiskSize string `json:"rootDiskSize,omitempty" example:"default, 30, 42, ..."` // "default", Integer (GB): ["50", ..., "1000"] - VmSpec mcir.TbSpecInfo `json:"vmSpec" default:""` + Spec mcir.TbSpecInfo `json:"spec" default:""` + Image []mcir.TbImageInfo `json:"image" default:""` Region common.RegionDetail `json:"region" default:""` // Latest system message such as error message @@ -1179,7 +1178,13 @@ func CheckMcisDynamicReq(req *McisConnectionConfigCandidatesReq) (*CheckMcisDyna } } - vmReqInfo.VmSpec = specInfo + vmReqInfo.Spec = specInfo + imageSearchKey := specInfo.ProviderName + "+" + specInfo.RegionName + availableImageList, err := mcir.SearchImage(common.SystemCommonNs, imageSearchKey) + if err != nil { + errMessage += "//Failed to search images for Spec (" + k + ")" + } + vmReqInfo.Image = availableImageList vmReqInfo.Region = regionInfo vmReqInfo.SystemMessage = errMessage mcisReqInfo.ReqCheck = append(mcisReqInfo.ReqCheck, vmReqInfo) @@ -1388,6 +1393,10 @@ func checkCommonResAvailable(req *TbVmDynamicReq) error { osType := strings.ReplaceAll(k.CommonImage, " ", "") vmReq.ImageId = mcir.GetProviderRegionZoneResourceKey(connection.ProviderName, connection.RegionDetail.RegionName, "", osType) + // incase of user provided image id completely (e.g. aws+ap-northeast-2+ubuntu22.04) + if strings.Contains(k.CommonImage, "+") { + vmReq.ImageId = k.CommonImage + } tempInterface, err = mcir.GetResource(common.SystemCommonNs, common.StrImage, vmReq.ImageId) if err != nil { err := fmt.Errorf("Failed to get Image " + k.CommonImage + " from " + vmReq.ConnectionName) @@ -1444,6 +1453,10 @@ func getVmReqFromDynamicReq(nsId string, req *TbVmDynamicReq) (*TbVmReq, error) vmReq.SpecId = specInfo.Id osType := strings.ReplaceAll(k.CommonImage, " ", "") vmReq.ImageId = mcir.GetProviderRegionZoneResourceKey(connection.ProviderName, connection.RegionDetail.RegionName, "", osType) + // incase of user provided image id completely (e.g. aws+ap-northeast-2+ubuntu22.04) + if strings.Contains(k.CommonImage, "+") { + vmReq.ImageId = k.CommonImage + } tempInterface, err = mcir.GetResource(common.SystemCommonNs, common.StrImage, vmReq.ImageId) if err != nil { err := fmt.Errorf("Failed to get the Image " + vmReq.ImageId + " from " + vmReq.ConnectionName) diff --git a/src/core/mcis/recommendation.go b/src/core/mcis/recommendation.go index c85528789..b4987434c 100644 --- a/src/core/mcis/recommendation.go +++ b/src/core/mcis/recommendation.go @@ -48,7 +48,7 @@ type FilterInfo struct { // FilterCondition is struct for . type FilterCondition struct { - Metric string `json:"metric" example:"cpu" enums:"cpu,memory,cost"` + Metric string `json:"metric" example:"vCPU" enums:"vCPU,memoryGiB,costPerHour"` Condition []Operation `json:"condition"` }