diff --git a/src/api/rest/docs/docs.go b/src/api/rest/docs/docs.go index 1d2687569..dcbf23fc2 100644 --- a/src/api/rest/docs/docs.go +++ b/src/api/rest/docs/docs.go @@ -6358,6 +6358,18 @@ const docTemplate = `{ "description": "ex) {us-east1, us-east1-c} or {ap-northeast-2}", "$ref": "#/definitions/mcis.RegionInfo" }, + "rootDeviceName": { + "description": "\"/dev/sda1\", ...", + "type": "string" + }, + "rootDiskSize": { + "description": "\"default\", \"50\", \"1000\" (GB)", + "type": "string" + }, + "rootDiskType": { + "description": "\"SSD(gp2)\", \"Premium SSD\", ...", + "type": "string" + }, "securityGroupIIds": { "description": "AWS, ex) sg-0b7452563e1121bb6", "type": "array", @@ -6390,7 +6402,7 @@ const docTemplate = `{ "type": "string" }, "vmbootDisk": { - "description": "ex) /dev/sda1", + "description": "Deprecated soon // ex) /dev/sda1", "type": "string" }, "vmspecName": { @@ -6659,6 +6671,11 @@ const docTemplate = `{ "type": "string", "example": "vm01" }, + "rootDiskSize": { + "description": "\"default\", Integer (GB): [\"50\", ..., \"1000\"]", + "type": "string", + "example": "default, 30, 42, ..." + }, "vmGroupSize": { "description": "if vmGroupSize is (not empty) \u0026\u0026 (\u003e 0), VM group will be gernetad. VMs will be created accordingly.", "type": "string", @@ -6723,6 +6740,15 @@ const docTemplate = `{ "description": "AWS, ex) {us-east1, us-east1-c} or {ap-northeast-2}", "$ref": "#/definitions/mcis.RegionInfo" }, + "rootDeviceName": { + "type": "string" + }, + "rootDiskSize": { + "type": "string" + }, + "rootDiskType": { + "type": "string" + }, "securityGroupIds": { "type": "array", "items": { @@ -6787,6 +6813,7 @@ const docTemplate = `{ "securityGroupIds", "specId", "sshKeyId", + "subnetId", "vNetId" ], "properties": { @@ -6814,6 +6841,16 @@ const docTemplate = `{ "type": "string", "example": "vm01" }, + "rootDiskSize": { + "description": "\"default\", Integer (GB): [\"50\", ..., \"1000\"]", + "type": "string", + "example": "default, 30, 42, ..." + }, + "rootDiskType": { + "description": "\"\", \"default\", \"TYPE1\", AWS: [\"standard\", \"gp2\", \"gp3\"], Azure: [\"PremiumSSD\", \"StandardSSD\", \"StandardHHD\"], GCP: [\"pd-standard\", \"pd-balanced\", \"pd-ssd\", \"pd-extreme\"], ALIBABA: [\"cloud_efficiency\", \"cloud\", \"cloud_ssd\"], TENCENT: [\"CLOUD_PREMIUM\", \"CLOUD_SSD\"]", + "type": "string", + "example": "default, TYPE1, ..." + }, "securityGroupIds": { "type": "array", "items": { diff --git a/src/api/rest/docs/swagger.json b/src/api/rest/docs/swagger.json index 96a448d9b..3f66bf2e9 100644 --- a/src/api/rest/docs/swagger.json +++ b/src/api/rest/docs/swagger.json @@ -6350,6 +6350,18 @@ "description": "ex) {us-east1, us-east1-c} or {ap-northeast-2}", "$ref": "#/definitions/mcis.RegionInfo" }, + "rootDeviceName": { + "description": "\"/dev/sda1\", ...", + "type": "string" + }, + "rootDiskSize": { + "description": "\"default\", \"50\", \"1000\" (GB)", + "type": "string" + }, + "rootDiskType": { + "description": "\"SSD(gp2)\", \"Premium SSD\", ...", + "type": "string" + }, "securityGroupIIds": { "description": "AWS, ex) sg-0b7452563e1121bb6", "type": "array", @@ -6382,7 +6394,7 @@ "type": "string" }, "vmbootDisk": { - "description": "ex) /dev/sda1", + "description": "Deprecated soon // ex) /dev/sda1", "type": "string" }, "vmspecName": { @@ -6651,6 +6663,11 @@ "type": "string", "example": "vm01" }, + "rootDiskSize": { + "description": "\"default\", Integer (GB): [\"50\", ..., \"1000\"]", + "type": "string", + "example": "default, 30, 42, ..." + }, "vmGroupSize": { "description": "if vmGroupSize is (not empty) \u0026\u0026 (\u003e 0), VM group will be gernetad. VMs will be created accordingly.", "type": "string", @@ -6715,6 +6732,15 @@ "description": "AWS, ex) {us-east1, us-east1-c} or {ap-northeast-2}", "$ref": "#/definitions/mcis.RegionInfo" }, + "rootDeviceName": { + "type": "string" + }, + "rootDiskSize": { + "type": "string" + }, + "rootDiskType": { + "type": "string" + }, "securityGroupIds": { "type": "array", "items": { @@ -6779,6 +6805,7 @@ "securityGroupIds", "specId", "sshKeyId", + "subnetId", "vNetId" ], "properties": { @@ -6806,6 +6833,16 @@ "type": "string", "example": "vm01" }, + "rootDiskSize": { + "description": "\"default\", Integer (GB): [\"50\", ..., \"1000\"]", + "type": "string", + "example": "default, 30, 42, ..." + }, + "rootDiskType": { + "description": "\"\", \"default\", \"TYPE1\", AWS: [\"standard\", \"gp2\", \"gp3\"], Azure: [\"PremiumSSD\", \"StandardSSD\", \"StandardHHD\"], GCP: [\"pd-standard\", \"pd-balanced\", \"pd-ssd\", \"pd-extreme\"], ALIBABA: [\"cloud_efficiency\", \"cloud\", \"cloud_ssd\"], TENCENT: [\"CLOUD_PREMIUM\", \"CLOUD_SSD\"]", + "type": "string", + "example": "default, TYPE1, ..." + }, "securityGroupIds": { "type": "array", "items": { diff --git a/src/api/rest/docs/swagger.yaml b/src/api/rest/docs/swagger.yaml index 77d27368d..a6c28e238 100644 --- a/src/api/rest/docs/swagger.yaml +++ b/src/api/rest/docs/swagger.yaml @@ -1137,6 +1137,15 @@ definitions: region: $ref: '#/definitions/mcis.RegionInfo' description: ex) {us-east1, us-east1-c} or {ap-northeast-2} + rootDeviceName: + description: '"/dev/sda1", ...' + type: string + rootDiskSize: + description: '"default", "50", "1000" (GB)' + type: string + rootDiskType: + description: '"SSD(gp2)", "Premium SSD", ...' + type: string securityGroupIIds: description: AWS, ex) sg-0b7452563e1121bb6 items: @@ -1160,7 +1169,7 @@ definitions: description: ex) type: string vmbootDisk: - description: ex) /dev/sda1 + description: Deprecated soon // ex) /dev/sda1 type: string vmspecName: description: Fields for both request and response @@ -1365,6 +1374,10 @@ definitions: a group, actual VM name will be generated with -N postfix. example: vm01 type: string + rootDiskSize: + description: '"default", Integer (GB): ["50", ..., "1000"]' + example: default, 30, 42, ... + type: string vmGroupSize: description: if vmGroupSize is (not empty) && (> 0), VM group will be gernetad. VMs will be created accordingly. @@ -1414,6 +1427,12 @@ definitions: region: $ref: '#/definitions/mcis.RegionInfo' description: AWS, ex) {us-east1, us-east1-c} or {ap-northeast-2} + rootDeviceName: + type: string + rootDiskSize: + type: string + rootDiskType: + type: string securityGroupIds: items: type: string @@ -1473,6 +1492,17 @@ definitions: a group, actual VM name will be generated with -N postfix. example: vm01 type: string + rootDiskSize: + description: '"default", Integer (GB): ["50", ..., "1000"]' + example: default, 30, 42, ... + type: string + rootDiskType: + description: '"", "default", "TYPE1", AWS: ["standard", "gp2", "gp3"], Azure: + ["PremiumSSD", "StandardSSD", "StandardHHD"], GCP: ["pd-standard", "pd-balanced", + "pd-ssd", "pd-extreme"], ALIBABA: ["cloud_efficiency", "cloud", "cloud_ssd"], + TENCENT: ["CLOUD_PREMIUM", "CLOUD_SSD"]' + example: default, TYPE1, ... + type: string securityGroupIds: items: type: string @@ -1501,6 +1531,7 @@ definitions: - securityGroupIds - specId - sshKeyId + - subnetId - vNetId type: object mcis.TbVmStatusInfo: diff --git a/src/core/mcis/provisioning.go b/src/core/mcis/provisioning.go index f1b8989fa..13d3e1677 100644 --- a/src/core/mcis/provisioning.go +++ b/src/core/mcis/provisioning.go @@ -197,11 +197,13 @@ type TbVmReq struct { SpecId string `json:"specId" validate:"required"` ImageId string `json:"imageId" validate:"required"` VNetId string `json:"vNetId" validate:"required"` - SubnetId string `json:"subnetId"` + SubnetId string `json:"subnetId" validate:"required"` SecurityGroupIds []string `json:"securityGroupIds" validate:"required"` SshKeyId string `json:"sshKeyId" validate:"required"` VmUserAccount string `json:"vmUserAccount,omitempty"` VmUserPassword string `json:"vmUserPassword,omitempty"` + RootDiskType string `json:"rootDiskType,omitempty" example:"default, TYPE1, ..."` // "", "default", "TYPE1", AWS: ["standard", "gp2", "gp3"], Azure: ["PremiumSSD", "StandardSSD", "StandardHHD"], GCP: ["pd-standard", "pd-balanced", "pd-ssd", "pd-extreme"], ALIBABA: ["cloud_efficiency", "cloud", "cloud_ssd"], TENCENT: ["CLOUD_PREMIUM", "CLOUD_SSD"] + RootDiskSize string `json:"rootDiskSize,omitempty" example:"default, 30, 42, ..."` // "default", Integer (GB): ["50", ..., "1000"] } // TbVmDynamicReq is struct to get requirements to create a new server instance dynamically (with default resource option) @@ -220,6 +222,8 @@ type TbVmDynamicReq struct { CommonSpec string `json:"commonSpec" validate:"required" example:"aws-ap-northeast-2-t2-small"` // 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"] } // SpiderVMReqInfoWrapper is struct from CB-Spider (VMHandler.go) for wrapping SpiderVMInfo @@ -240,9 +244,11 @@ type SpiderVMInfo struct { // Spider CSPid string // VM ID given by CSP (required for registering VM) // Fields for both request and response - VMSpecName string // instance type or flavour, etc... ex) t2.micro or f1.micro + VMSpecName string // instance type or flavour, etc... ex) t2.micro or f1.micro VMUserId string // ex) user1 VMUserPasswd string + RootDiskType string // "SSD(gp2)", "Premium SSD", ... + RootDiskSize string // "default", "50", "1000" (GB) // Fields for response IId common.IID // {NameId, SystemId} @@ -258,7 +264,8 @@ type SpiderVMInfo struct { // Spider PublicDNS string PrivateIP string PrivateDNS string - VMBootDisk string // ex) /dev/sda1 + RootDeviceName string // "/dev/sda1", ... + VMBootDisk string // Deprecated soon // ex) /dev/sda1 VMBlockDisk string // ex) SSHAccessPoint string KeyValueList []common.KeyValue @@ -312,14 +319,17 @@ type TbVmInfo struct { Label string `json:"label"` Description string `json:"description"` - Region RegionInfo `json:"region"` // AWS, ex) {us-east1, us-east1-c} or {ap-northeast-2} - PublicIP string `json:"publicIP"` - SSHPort string `json:"sshPort"` - PublicDNS string `json:"publicDNS"` - PrivateIP string `json:"privateIP"` - PrivateDNS string `json:"privateDNS"` - VMBootDisk string `json:"vmBootDisk"` // ex) /dev/sda1 - VMBlockDisk string `json:"vmBlockDisk"` + Region RegionInfo `json:"region"` // AWS, ex) {us-east1, us-east1-c} or {ap-northeast-2} + PublicIP string `json:"publicIP"` + SSHPort string `json:"sshPort"` + PublicDNS string `json:"publicDNS"` + PrivateIP string `json:"privateIP"` + PrivateDNS string `json:"privateDNS"` + RootDiskType string `json:"rootDiskType"` + RootDiskSize string `json:"rootDiskSize"` + RootDeviceName string `json:"rootDeviceName"` + VMBootDisk string `json:"vmBootDisk"` // ex) /dev/sda1 + VMBlockDisk string `json:"vmBlockDisk"` ConnectionName string `json:"connectionName"` SpecId string `json:"specId"` @@ -639,6 +649,9 @@ func CreateMcisGroupVm(nsId string, mcisId string, vmRequest *TbVmReq) (*TbMcisI vmInfoData.SshKeyId = vmRequest.SshKeyId vmInfoData.Description = vmRequest.Description + vmInfoData.RootDiskType = vmRequest.RootDiskType + vmInfoData.RootDiskSize = vmRequest.RootDiskSize + vmInfoData.VmUserAccount = vmRequest.VmUserAccount vmInfoData.VmUserPassword = vmRequest.VmUserPassword @@ -879,6 +892,8 @@ func CreateMcis(nsId string, req *TbMcisReq, option string) (*TbMcisInfo, error) vmInfoData.Description = k.Description vmInfoData.VmUserAccount = k.VmUserAccount vmInfoData.VmUserPassword = k.VmUserPassword + vmInfoData.RootDiskType = k.RootDiskType + vmInfoData.RootDiskSize = k.RootDiskSize vmInfoData.Label = k.Label @@ -1061,6 +1076,8 @@ func CreateMcisDynamic(nsId string, req *TbMcisDynamicReq) (*TbMcisInfo, error) vmReq.Label = k.Label vmReq.VmGroupSize = k.VmGroupSize vmReq.Description = k.Description + //vmReq.RootDiskType = k.RootDiskType + vmReq.RootDiskSize = k.RootDiskSize mcisReq.Vm = append(mcisReq.Vm, vmReq) @@ -1293,6 +1310,9 @@ func CreateVm(nsId string, mcisId string, vmInfoData *TbVmInfo, option string) e tempReq.ReqInfo.VMUserId = vmInfoData.VmUserAccount tempReq.ReqInfo.VMUserPasswd = vmInfoData.VmUserPassword + tempReq.ReqInfo.RootDiskType = vmInfoData.RootDiskType + tempReq.ReqInfo.RootDiskSize = vmInfoData.RootDiskSize + fmt.Printf("\n[Request body to CB-SPIDER for Creating VM]\n") common.PrintJsonPretty(tempReq) @@ -1422,6 +1442,9 @@ func CreateVm(nsId string, mcisId string, vmInfoData *TbVmInfo, option string) e vmInfoData.PublicDNS = tempSpiderVMInfo.PublicDNS vmInfoData.PrivateIP = tempSpiderVMInfo.PrivateIP vmInfoData.PrivateDNS = tempSpiderVMInfo.PrivateDNS + vmInfoData.RootDiskType = tempSpiderVMInfo.RootDiskType + vmInfoData.RootDiskSize = tempSpiderVMInfo.RootDiskSize + vmInfoData.RootDeviceName = tempSpiderVMInfo.RootDeviceName vmInfoData.VMBootDisk = tempSpiderVMInfo.VMBootDisk vmInfoData.VMBlockDisk = tempSpiderVMInfo.VMBlockDisk //vmInfoData.KeyValueList = temp.KeyValueList diff --git a/src/testclient/scripts/8.mcis/create-mcis.sh b/src/testclient/scripts/8.mcis/create-mcis.sh index 69241d6c8..361997f22 100755 --- a/src/testclient/scripts/8.mcis/create-mcis.sh +++ b/src/testclient/scripts/8.mcis/create-mcis.sh @@ -37,7 +37,9 @@ "vNetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'", "subnetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'", "description": "description", - "vmUserPassword": "" + "vmUserPassword": "", + "rootDiskType": "", + "rootDiskSize": "77" } ] }' | jq '' diff --git a/src/testclient/scripts/8.mcis/create-single-vm-mcis.sh b/src/testclient/scripts/8.mcis/create-single-vm-mcis.sh index f4532141f..5de920497 100755 --- a/src/testclient/scripts/8.mcis/create-single-vm-mcis.sh +++ b/src/testclient/scripts/8.mcis/create-single-vm-mcis.sh @@ -35,7 +35,9 @@ "vNetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'", "subnetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'", "description": "description", - "vmUserPassword": "" + "vmUserPassword": "", + "rootDiskType": "", + "rootDiskSize": "77" } ] }' | jq ''