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 scaleOut feature for VMGroup in a MCIS #1181

Merged
merged 5 commits into from
Sep 29, 2022
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
2 changes: 1 addition & 1 deletion src/api/grpc/server/mcis/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (s *MCISService) CreateMcisVMGroup(ctx context.Context, req *pb.TbVmGroupCr
return nil, gc.ConvGrpcStatusErr(err, "", "MCISService.CreateMcisVMGroup()")
}

result, err := mcis.CreateMcisGroupVm(req.NsId, req.McisId, &mcisObj)
result, err := mcis.CreateMcisGroupVm(req.NsId, req.McisId, &mcisObj, true)
if err != nil {
return nil, gc.ConvGrpcStatusErr(err, "", "MCISService.CreateMcisVMGroup()")
}
Expand Down
81 changes: 81 additions & 0 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2788,6 +2788,74 @@ const docTemplate = `{
}
}
}
},
"post": {
"description": "ScaleOut VM group in specified MCIS",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Infra service] MCIS Provisioning management"
],
"summary": "ScaleOut VM group in specified MCIS",
"parameters": [
{
"type": "string",
"default": "ns01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "mcis01",
"description": "MCIS ID",
"name": "mcisId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "group-0",
"description": "VM Group ID",
"name": "vmgroupId",
"in": "path",
"required": true
},
{
"description": "VM Group scaleOut request",
"name": "vmReq",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/mcis.TbScaleOutVmGroupReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.TbMcisInfo"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
}
}
}
},
"/ns/{nsId}/mcisDynamic": {
Expand Down Expand Up @@ -8320,6 +8388,19 @@ const docTemplate = `{
}
}
},
"mcis.TbScaleOutVmGroupReq": {
"type": "object",
"required": [
"vmGroupSize"
],
"properties": {
"vmGroupSize": {
"description": "Define addtional VMs to scaleOut",
"type": "string",
"example": "2"
}
}
},
"mcis.TbVmDynamicReq": {
"type": "object",
"required": [
Expand Down
81 changes: 81 additions & 0 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2780,6 +2780,74 @@
}
}
}
},
"post": {
"description": "ScaleOut VM group in specified MCIS",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Infra service] MCIS Provisioning management"
],
"summary": "ScaleOut VM group in specified MCIS",
"parameters": [
{
"type": "string",
"default": "ns01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "mcis01",
"description": "MCIS ID",
"name": "mcisId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "group-0",
"description": "VM Group ID",
"name": "vmgroupId",
"in": "path",
"required": true
},
{
"description": "VM Group scaleOut request",
"name": "vmReq",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/mcis.TbScaleOutVmGroupReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.TbMcisInfo"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
}
}
}
},
"/ns/{nsId}/mcisDynamic": {
Expand Down Expand Up @@ -8312,6 +8380,19 @@
}
}
},
"mcis.TbScaleOutVmGroupReq": {
"type": "object",
"required": [
"vmGroupSize"
],
"properties": {
"vmGroupSize": {
"description": "Define addtional VMs to scaleOut",
"type": "string",
"example": "2"
}
}
},
"mcis.TbVmDynamicReq": {
"type": "object",
"required": [
Expand Down
56 changes: 56 additions & 0 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,15 @@ definitions:
- type
- vNetId
type: object
mcis.TbScaleOutVmGroupReq:
properties:
vmGroupSize:
description: Define addtional VMs to scaleOut
example: "2"
type: string
required:
- vmGroupSize
type: object
mcis.TbVmDynamicReq:
properties:
commonImage:
Expand Down Expand Up @@ -3961,6 +3970,53 @@ paths:
summary: List VMs with a VMGroup label in a specified MCIS
tags:
- '[Infra service] MCIS Provisioning management'
post:
consumes:
- application/json
description: ScaleOut VM group in specified MCIS
parameters:
- default: ns01
description: Namespace ID
in: path
name: nsId
required: true
type: string
- default: mcis01
description: MCIS ID
in: path
name: mcisId
required: true
type: string
- default: group-0
description: VM Group ID
in: path
name: vmgroupId
required: true
type: string
- description: VM Group scaleOut request
in: body
name: vmReq
required: true
schema:
$ref: '#/definitions/mcis.TbScaleOutVmGroupReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/mcis.TbMcisInfo'
"404":
description: Not Found
schema:
$ref: '#/definitions/common.SimpleMsg'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/common.SimpleMsg'
summary: ScaleOut VM group in specified MCIS
tags:
- '[Infra service] MCIS Provisioning management'
/ns/{nsId}/mcisDynamic:
post:
consumes:
Expand Down
37 changes: 36 additions & 1 deletion src/api/rest/server/mcis/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,42 @@ func RestPostMcisVmGroup(c echo.Context) error {
}
common.PrintJsonPretty(*vmInfoData)

result, err := mcis.CreateMcisGroupVm(nsId, mcisId, vmInfoData)
result, err := mcis.CreateMcisGroupVm(nsId, mcisId, vmInfoData, true)
if err != nil {
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
}
common.PrintJsonPretty(*result)

return c.JSON(http.StatusCreated, result)
}

// RestPostMcisVmGroupScaleOut godoc
// @Summary ScaleOut VM group in specified MCIS
// @Description ScaleOut VM group in specified MCIS
// @Tags [Infra service] MCIS Provisioning management
// @Accept json
// @Produce json
// @Param nsId path string true "Namespace ID" default(ns01)
// @Param mcisId path string true "MCIS ID" default(mcis01)
// @Param vmgroupId path string true "VM Group ID" default(group-0)
// @Param vmReq body mcis.TbScaleOutVmGroupReq true "VM Group scaleOut request"
// @Success 200 {object} mcis.TbMcisInfo
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /ns/{nsId}/mcis/{mcisId}/vmgroup/{vmgroupId} [post]
func RestPostMcisVmGroupScaleOut(c echo.Context) error {

nsId := c.Param("nsId")
mcisId := c.Param("mcisId")
vmgroupId := c.Param("vmgroupId")

scaleOutReq := &mcis.TbScaleOutVmGroupReq{}
if err := c.Bind(scaleOutReq); err != nil {
return err
}

result, err := mcis.ScaleOutMcisVmGroup(nsId, mcisId, vmgroupId, scaleOutReq.NumVMsToAdd)
if err != nil {
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
Expand Down
1 change: 1 addition & 0 deletions src/api/rest/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func RunServer(port string) {

g.POST("/:nsId/mcis/:mcisId/vm", rest_mcis.RestPostMcisVm)
g.POST("/:nsId/mcis/:mcisId/vmgroup", rest_mcis.RestPostMcisVmGroup)
g.POST("/:nsId/mcis/:mcisId/vmgroup/:vmgroupId", rest_mcis.RestPostMcisVmGroupScaleOut)
g.GET("/:nsId/mcis/:mcisId/vm/:vmId", rest_mcis.RestGetMcisVm)
g.GET("/:nsId/mcis/:mcisId/vmgroup", rest_mcis.RestGetMcisGroupIds)
g.GET("/:nsId/mcis/:mcisId/vmgroup/:vmgroupId", rest_mcis.RestGetMcisGroupVms)
Expand Down
Loading