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 command field for SshCmdResult #1357

Merged
merged 2 commits into from
Oct 10, 2023
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
32 changes: 19 additions & 13 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.RestPostCmdMcisResponseWrapper"
"$ref": "#/definitions/mcis.SshCmdResultWrapper"
}
},
"404": {
Expand Down Expand Up @@ -1537,7 +1537,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.RestPostCmdMcisResponseWrapper"
"$ref": "#/definitions/mcis.SshCmdResultWrapper"
}
},
"404": {
Expand Down Expand Up @@ -9380,17 +9380,6 @@ const docTemplate = `{
}
}
},
"mcis.RestPostCmdMcisResponseWrapper": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"$ref": "#/definitions/mcis.SshCmdResult"
}
}
}
},
"mcis.SpiderVMInfo": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -9519,6 +9508,12 @@ const docTemplate = `{
"mcis.SshCmdResult": {
"type": "object",
"properties": {
"command": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"err": {},
"mcisId": {
"type": "string"
Expand All @@ -9543,6 +9538,17 @@ const docTemplate = `{
}
}
},
"mcis.SshCmdResultWrapper": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"$ref": "#/definitions/mcis.SshCmdResult"
}
}
}
},
"mcis.StatusCountInfo": {
"type": "object",
"properties": {
Expand Down
32 changes: 19 additions & 13 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.RestPostCmdMcisResponseWrapper"
"$ref": "#/definitions/mcis.SshCmdResultWrapper"
}
},
"404": {
Expand Down Expand Up @@ -1529,7 +1529,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.RestPostCmdMcisResponseWrapper"
"$ref": "#/definitions/mcis.SshCmdResultWrapper"
}
},
"404": {
Expand Down Expand Up @@ -9372,17 +9372,6 @@
}
}
},
"mcis.RestPostCmdMcisResponseWrapper": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"$ref": "#/definitions/mcis.SshCmdResult"
}
}
}
},
"mcis.SpiderVMInfo": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -9511,6 +9500,12 @@
"mcis.SshCmdResult": {
"type": "object",
"properties": {
"command": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"err": {},
"mcisId": {
"type": "string"
Expand All @@ -9535,6 +9530,17 @@
}
}
},
"mcis.SshCmdResultWrapper": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"$ref": "#/definitions/mcis.SshCmdResult"
}
}
}
},
"mcis.StatusCountInfo": {
"type": "object",
"properties": {
Expand Down
22 changes: 13 additions & 9 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1523,13 +1523,6 @@ definitions:
host:
type: string
type: object
mcis.RestPostCmdMcisResponseWrapper:
properties:
results:
items:
$ref: '#/definitions/mcis.SshCmdResult'
type: array
type: object
mcis.SpiderVMInfo:
properties:
cspid:
Expand Down Expand Up @@ -1619,6 +1612,10 @@ definitions:
type: object
mcis.SshCmdResult:
properties:
command:
additionalProperties:
type: string
type: object
err: {}
mcisId:
type: string
Expand All @@ -1635,6 +1632,13 @@ definitions:
vmIp:
type: string
type: object
mcis.SshCmdResultWrapper:
properties:
results:
items:
$ref: '#/definitions/mcis.SshCmdResult'
type: array
type: object
mcis.StatusCountInfo:
properties:
countCreating:
Expand Down Expand Up @@ -3262,7 +3266,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/mcis.RestPostCmdMcisResponseWrapper'
$ref: '#/definitions/mcis.SshCmdResultWrapper'
"404":
description: Not Found
schema:
Expand Down Expand Up @@ -3443,7 +3447,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/mcis.RestPostCmdMcisResponseWrapper'
$ref: '#/definitions/mcis.SshCmdResultWrapper'
"404":
description: Not Found
schema:
Expand Down
2 changes: 1 addition & 1 deletion src/api/rest/server/mcis/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
// @Param mcisId path string true "MCIS ID" default(mcis01)
// @Param mcisCmdReq body mcis.McisCmdReq true "MCIS Command Request"
// @Param option query string false "Option for checking update" Enums(update)
// @Success 200 {object} mcis.RestPostCmdMcisResponseWrapper
// @Success 200 {object} SshCmdResultWrapper
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /ns/{nsId}/installBenchmarkAgent/mcis/{mcisId} [post]
Expand Down
17 changes: 11 additions & 6 deletions src/core/mcis/remoteCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ func TbMcisCmdReqStructLevelValidation(sl validator.StructLevel) {

// SshCmdResult is struct for SshCmd Result
type SshCmdResult struct { // Tumblebug
McisId string `json:"mcisId"`
VmId string `json:"vmId"`
VmIp string `json:"vmIp"`
Stdout map[int]string `json:"stdout"`
Stderr map[int]string `json:"stderr"`
Err error `json:"err"`
McisId string `json:"mcisId"`
VmId string `json:"vmId"`
VmIp string `json:"vmIp"`
Command map[int]string `json:"command"`
Stdout map[int]string `json:"stdout"`
Stderr map[int]string `json:"stderr"`
Err error `json:"err"`
}

// RemoteCommandToMcis is func to command to all VMs in MCIS by SSH
Expand Down Expand Up @@ -224,6 +225,10 @@ func RunRemoteCommandAsync(wg *sync.WaitGroup, nsId string, mcisId string, vmId
sshResultTmp.McisId = mcisId
sshResultTmp.VmId = vmId
sshResultTmp.VmIp = vmIP
sshResultTmp.Command = make(map[int]string)
for i, c := range cmd {
sshResultTmp.Command[i] = c
}

if err != nil {
sshResultTmp.Stdout = stdoutResults
Expand Down