diff --git a/src/api/rest/docs/docs.go b/src/api/rest/docs/docs.go index 2e4ebd8af..9b9293e92 100644 --- a/src/api/rest/docs/docs.go +++ b/src/api/rest/docs/docs.go @@ -1276,7 +1276,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/mcis.RestPostCmdMcisResponseWrapper" + "$ref": "#/definitions/mcis.SshCmdResultWrapper" } }, "404": { @@ -1537,7 +1537,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/mcis.RestPostCmdMcisResponseWrapper" + "$ref": "#/definitions/mcis.SshCmdResultWrapper" } }, "404": { @@ -9380,17 +9380,6 @@ const docTemplate = `{ } } }, - "mcis.RestPostCmdMcisResponseWrapper": { - "type": "object", - "properties": { - "results": { - "type": "array", - "items": { - "$ref": "#/definitions/mcis.SshCmdResult" - } - } - } - }, "mcis.SpiderVMInfo": { "type": "object", "properties": { @@ -9519,6 +9508,12 @@ const docTemplate = `{ "mcis.SshCmdResult": { "type": "object", "properties": { + "command": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, "err": {}, "mcisId": { "type": "string" @@ -9543,6 +9538,17 @@ const docTemplate = `{ } } }, + "mcis.SshCmdResultWrapper": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/mcis.SshCmdResult" + } + } + } + }, "mcis.StatusCountInfo": { "type": "object", "properties": { diff --git a/src/api/rest/docs/swagger.json b/src/api/rest/docs/swagger.json index 2e0170064..15601d86a 100644 --- a/src/api/rest/docs/swagger.json +++ b/src/api/rest/docs/swagger.json @@ -1268,7 +1268,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/mcis.RestPostCmdMcisResponseWrapper" + "$ref": "#/definitions/mcis.SshCmdResultWrapper" } }, "404": { @@ -1529,7 +1529,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/mcis.RestPostCmdMcisResponseWrapper" + "$ref": "#/definitions/mcis.SshCmdResultWrapper" } }, "404": { @@ -9372,17 +9372,6 @@ } } }, - "mcis.RestPostCmdMcisResponseWrapper": { - "type": "object", - "properties": { - "results": { - "type": "array", - "items": { - "$ref": "#/definitions/mcis.SshCmdResult" - } - } - } - }, "mcis.SpiderVMInfo": { "type": "object", "properties": { @@ -9511,6 +9500,12 @@ "mcis.SshCmdResult": { "type": "object", "properties": { + "command": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, "err": {}, "mcisId": { "type": "string" @@ -9535,6 +9530,17 @@ } } }, + "mcis.SshCmdResultWrapper": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/mcis.SshCmdResult" + } + } + } + }, "mcis.StatusCountInfo": { "type": "object", "properties": { diff --git a/src/api/rest/docs/swagger.yaml b/src/api/rest/docs/swagger.yaml index fe100556f..804fff05a 100644 --- a/src/api/rest/docs/swagger.yaml +++ b/src/api/rest/docs/swagger.yaml @@ -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: @@ -1619,6 +1612,10 @@ definitions: type: object mcis.SshCmdResult: properties: + command: + additionalProperties: + type: string + type: object err: {} mcisId: type: string @@ -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: @@ -3262,7 +3266,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/mcis.RestPostCmdMcisResponseWrapper' + $ref: '#/definitions/mcis.SshCmdResultWrapper' "404": description: Not Found schema: @@ -3443,7 +3447,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/mcis.RestPostCmdMcisResponseWrapper' + $ref: '#/definitions/mcis.SshCmdResultWrapper' "404": description: Not Found schema: diff --git a/src/api/rest/server/mcis/benchmark.go b/src/api/rest/server/mcis/benchmark.go index f8f1adc3f..2a94da61b 100644 --- a/src/api/rest/server/mcis/benchmark.go +++ b/src/api/rest/server/mcis/benchmark.go @@ -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] diff --git a/src/core/mcis/remoteCommand.go b/src/core/mcis/remoteCommand.go index e10c89bdc..446c83aee 100644 --- a/src/core/mcis/remoteCommand.go +++ b/src/core/mcis/remoteCommand.go @@ -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 @@ -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