Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RootDiskType, RootDiskSize handling feature #974

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -6390,7 +6402,7 @@ const docTemplate = `{
"type": "string"
},
"vmbootDisk": {
"description": "ex) /dev/sda1",
"description": "Deprecated soon // ex) /dev/sda1",
"type": "string"
},
"vmspecName": {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -6787,6 +6813,7 @@ const docTemplate = `{
"securityGroupIds",
"specId",
"sshKeyId",
"subnetId",
"vNetId"
],
"properties": {
Expand Down Expand Up @@ -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": {
Expand Down
39 changes: 38 additions & 1 deletion src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -6382,7 +6394,7 @@
"type": "string"
},
"vmbootDisk": {
"description": "ex) /dev/sda1",
"description": "Deprecated soon // ex) /dev/sda1",
"type": "string"
},
"vmspecName": {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -6779,6 +6805,7 @@
"securityGroupIds",
"specId",
"sshKeyId",
"subnetId",
"vNetId"
],
"properties": {
Expand Down Expand Up @@ -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": {
Expand Down
33 changes: 32 additions & 1 deletion src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1501,6 +1531,7 @@ definitions:
- securityGroupIds
- specId
- sshKeyId
- subnetId
- vNetId
type: object
mcis.TbVmStatusInfo:
Expand Down
45 changes: 34 additions & 11 deletions src/core/mcis/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/testclient/scripts/8.mcis/create-mcis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"vNetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
"subnetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
"description": "description",
"vmUserPassword": ""
"vmUserPassword": "",
"rootDiskType": "",
"rootDiskSize": "77"
}
]
}' | jq ''
Expand Down
4 changes: 3 additions & 1 deletion src/testclient/scripts/8.mcis/create-single-vm-mcis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"vNetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
"subnetId": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
"description": "description",
"vmUserPassword": ""
"vmUserPassword": "",
"rootDiskType": "",
"rootDiskSize": "77"
}
]
}' | jq ''
Expand Down