Skip to content

Commit

Permalink
Merge pull request #475 from seokho-son/importexport
Browse files Browse the repository at this point in the history
Provide SystemMessage to vm status object
  • Loading branch information
jihoon-seo authored Apr 20, 2021
2 parents 00f1626 + ae31bcd commit f320331
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 14 deletions.
6 changes: 3 additions & 3 deletions assets/cloudlocation.csv
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ alibaba,eu-central-1,Germany (Frankfurt),50.4000,8.7000
alibaba,eu-west-1,UK (London),51.8000,-0.2000
alibaba,me-east-1,UAE (Dubai),25.2770,55.2962
cloudit,default,South Korea (Seoul),37.2665,126.7780
mock,default,South Korea (Seoul),37.0000,126.0000
openstack,regionone,South Korea (Daejeon),36.3804,127.3650
ncp,kr-1,South Korea (Seoul),37.4767,126.8841
ncp,kr-2,South Korea (Seoul),37.3881,126.9705
ncp,hk-1,Hong Kong,22.3964,114.1095
ncp,sgn-1,Singapore,1.3400,103.7041
ncp,jpn-1,Japan,35.6895,139.6917
ncp,uswn-1,US Western,37.3500,-121.9600
ncp,den-1,Germany,50.1109,8.6821
ufc,ufc,South Korea (Seoul),37.4767,126.8841
openstack,regionone,South Korea (Daejeon),36.3804,127.3650
cloudtwin,default,South Korea (Daejeon),36.3804,127.3650
mock,default,South Korea (Seoul),37.0000,126.0000
ufc,ufc,South Korea (Seoul),37.4767,126.8841
26 changes: 18 additions & 8 deletions src/core/mcis/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ type TbVmInfo struct {
// Montoring agent status
MonAgentStatus string `json:"monAgentStatus" example:"[installed, notInstalled, failed]"` // yes or no// installed, notInstalled, failed

// Created time
CreatedTime string `json:"createdTime" example:"2022-11-10 23:00:00" default:""`

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

// Created time
CreatedTime string `json:"createdTime" example:"2022-11-10 23:00:00" default:""`

Label string `json:"label"`
Description string `json:"description"`

Expand Down Expand Up @@ -259,6 +259,12 @@ type TbVmStatusInfo struct {
// Montoring agent status
MonAgentStatus string `json:"monAgentStatus" example:"[installed, notInstalled, failed]"` // yes or no// installed, notInstalled, failed

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

// Created time
CreatedTime string `json:"createdTime" example:"2022-11-10 23:00:00" default:""`

Public_ip string `json:"public_ip"`
Private_ip string `json:"private_ip"`
SSHPort string `json:"sshPort"`
Expand Down Expand Up @@ -3063,7 +3069,7 @@ func ControlVmAsync(wg *sync.WaitGroup, nsId string, mcisId string, vmId string,

common.PrintJsonPretty(resultTmp)

fmt.Println("[Calling SPIDER]END vmControl\n")
fmt.Println("[Calling SPIDER]END vmControl")

if action != ActionTerminate {
//When VM is restared, temporal PublicIP will be chanaged. Need update.
Expand Down Expand Up @@ -3454,10 +3460,10 @@ func GetMcisStatus(nsId string, mcisId string) (McisStatusInfo, error) {
}
wg.Wait() //goroutine sync wg

for num, v := range vmList {
// set master IP of MCIS (Default rule: select 1st VM as master)
if num == 0 {
vmtmp, _ := GetVmObject(nsId, mcisId, v)
for _, v := range vmList {
// set master IP of MCIS (Default rule: select 1st Running VM as master)
vmtmp, _ := GetVmObject(nsId, mcisId, v)
if vmtmp.Status == StatusRunning {
mcisStatus.MasterVmId = vmtmp.Id
mcisStatus.MasterIp = vmtmp.PublicIP
mcisStatus.MasterSSHPort = vmtmp.SSHPort
Expand Down Expand Up @@ -3579,6 +3585,7 @@ func GetVmStatusAsync(wg *sync.WaitGroup, nsId string, mcisId string, vmId strin
if err != nil {
common.CBLog.Error(err)
vmStatusTmp.Status = StatusFailed
vmStatusTmp.SystemMessage = err.Error()
}

results.Vm = append(results.Vm, vmStatusTmp)
Expand Down Expand Up @@ -3738,6 +3745,9 @@ func GetVmStatus(nsId string, mcisId string, vmId string) (TbVmStatusInfo, error

vmStatusTmp.MonAgentStatus = temp.MonAgentStatus

vmStatusTmp.CreatedTime = temp.CreatedTime
vmStatusTmp.SystemMessage = temp.SystemMessage

// Temporal CODE. This should be changed after CB-Spider fixes status types and strings/
if statusResponseTmp.Status == "Creating" {
statusResponseTmp.Status = StatusCreating
Expand Down
12 changes: 11 additions & 1 deletion src/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4870,7 +4870,7 @@ var doc = `{
"type": "string"
},
"region": {
"description": "Provided by CB-Spider",
"description": "AWS, ex) {us-east1, us-east1-c} or {ap-northeast-2}",
"type": "object",
"$ref": "#/definitions/mcis.RegionInfo"
},
Expand Down Expand Up @@ -5047,6 +5047,11 @@ var doc = `{
"mcis.TbVmStatusInfo": {
"type": "object",
"properties": {
"createdTime": {
"description": "Created time",
"type": "string",
"example": "2022-11-10 23:00:00"
},
"csp_vm_id": {
"type": "string"
},
Expand Down Expand Up @@ -5080,6 +5085,11 @@ var doc = `{
"status": {
"type": "string"
},
"systemMessage": {
"description": "Latest system message such as error message",
"type": "string",
"example": "Failed because ..."
},
"targetAction": {
"type": "string"
},
Expand Down
12 changes: 11 additions & 1 deletion src/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4855,7 +4855,7 @@
"type": "string"
},
"region": {
"description": "Provided by CB-Spider",
"description": "AWS, ex) {us-east1, us-east1-c} or {ap-northeast-2}",
"type": "object",
"$ref": "#/definitions/mcis.RegionInfo"
},
Expand Down Expand Up @@ -5032,6 +5032,11 @@
"mcis.TbVmStatusInfo": {
"type": "object",
"properties": {
"createdTime": {
"description": "Created time",
"type": "string",
"example": "2022-11-10 23:00:00"
},
"csp_vm_id": {
"type": "string"
},
Expand Down Expand Up @@ -5065,6 +5070,11 @@
"status": {
"type": "string"
},
"systemMessage": {
"description": "Latest system message such as error message",
"type": "string",
"example": "Failed because ..."
},
"targetAction": {
"type": "string"
},
Expand Down
10 changes: 9 additions & 1 deletion src/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ definitions:
type: string
region:
$ref: '#/definitions/mcis.RegionInfo'
description: Provided by CB-Spider
description: AWS, ex) {us-east1, us-east1-c} or {ap-northeast-2}
type: object
securityGroupIds:
items:
Expand Down Expand Up @@ -1114,6 +1114,10 @@ definitions:
type: object
mcis.TbVmStatusInfo:
properties:
createdTime:
description: Created time
example: "2022-11-10 23:00:00"
type: string
csp_vm_id:
type: string
id:
Expand All @@ -1137,6 +1141,10 @@ definitions:
type: string
status:
type: string
systemMessage:
description: Latest system message such as error message
example: Failed because ...
type: string
targetAction:
type: string
targetStatus:
Expand Down

0 comments on commit f320331

Please sign in to comment.