Skip to content

Commit

Permalink
Merge pull request #13 from MZC-CSC/main
Browse files Browse the repository at this point in the history
update mcis to mci
  • Loading branch information
MZC-CSC authored Aug 26, 2024
2 parents 95aad55 + dcddb28 commit 1bc9c03
Show file tree
Hide file tree
Showing 24 changed files with 160 additions and 1,473 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ COPY --from=builder /go/src/github.com/cloud-barista/cm-ant/config.yaml /app/con
COPY --from=builder /go/src/github.com/cloud-barista/cm-ant/test_plan /app/test_plan
COPY --from=builder /go/src/github.com/cloud-barista/cm-ant/script /app/script
COPY --from=builder /go/src/github.com/cloud-barista/cm-ant/meta /app/meta
COPY --from=builder /go/src/github.com/cloud-barista/cm-ant/web /app/web

HEALTHCHECK --interval=10s --timeout=5s --start-period=10s \
CMD curl -f "http://cm-ant:8880/ant/api/v1/readyz" || exit 1
Expand Down
12 changes: 6 additions & 6 deletions api/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
},
"/api/v1/load/monitoring/agent/install": {
"post": {
"description": "Install a monitoring agent on specific MCIS.",
"description": "Install a monitoring agent on specific mci.",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -380,8 +380,8 @@
},
{
"type": "string",
"description": "MCIS ID",
"name": "mcisId",
"description": "MCI ID",
"name": "mciId",
"in": "query"
},
{
Expand Down Expand Up @@ -427,7 +427,7 @@
},
"/api/v1/load/monitoring/agents/uninstall": {
"post": {
"description": "Uninstall monitoring agents from specified VMs or all VMs in an MCIS.",
"description": "Uninstall monitoring agents from specified VMs or all VMs in an mci.",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -1303,7 +1303,7 @@
"app.MonitoringAgentInstallationReq": {
"type": "object",
"properties": {
"mcisId": {
"mciId": {
"type": "string"
},
"nsId": {
Expand Down Expand Up @@ -1990,7 +1990,7 @@
"id": {
"type": "integer"
},
"mcisId": {
"mciId": {
"type": "string"
},
"nsId": {
Expand Down
12 changes: 6 additions & 6 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ definitions:
type: object
app.MonitoringAgentInstallationReq:
properties:
mcisId:
mciId:
type: string
nsId:
type: string
Expand Down Expand Up @@ -673,7 +673,7 @@ definitions:
type: string
id:
type: integer
mcisId:
mciId:
type: string
nsId:
type: string
Expand Down Expand Up @@ -946,7 +946,7 @@ paths:
post:
consumes:
- application/json
description: Install a monitoring agent on specific MCIS.
description: Install a monitoring agent on specific mci.
operationId: InstallMonitoringAgent
parameters:
- description: Monitoring Agent Installation Request
Expand Down Expand Up @@ -984,9 +984,9 @@ paths:
in: query
name: nsId
type: string
- description: MCIS ID
- description: MCI ID
in: query
name: mcisId
name: mciId
type: string
- description: VM ID
in: query
Expand Down Expand Up @@ -1023,7 +1023,7 @@ paths:
consumes:
- application/json
description: Uninstall monitoring agents from specified VMs or all VMs in an
MCIS.
mci.
operationId: UninstallMonitoringAgent
parameters:
- description: Monitoring Agent Uninstallation Request
Expand Down
28 changes: 14 additions & 14 deletions internal/app/load_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func (s *AntServer) getLoadTestExecutionState(c echo.Context) error {
// installMonitoringAgent handler function that handles a monitoring request request to collect metric.
// @Id InstallMonitoringAgent
// @Summary Install Metrics Monitoring Agent
// @Description Install a monitoring agent on specific MCIS.
// @Description Install a monitoring agent on specific mci.
// @Tags [Monitoring Agent Management]
// @Accept json
// @Produce json
Expand All @@ -515,9 +515,9 @@ func (s *AntServer) installMonitoringAgent(c echo.Context) error {
}

arg := load.MonitoringAgentInstallationParams{
NsId: req.NsId,
McisId: req.McisId,
VmIds: req.VmIds,
NsId: req.NsId,
MciId: req.MciId,
VmIds: req.VmIds,
}

result, err := s.services.loadService.InstallMonitoringAgent(arg)
Expand All @@ -541,7 +541,7 @@ func (s *AntServer) installMonitoringAgent(c echo.Context) error {
// @Accept json
// @Produce json
// @Param nsId query string false "Namespace ID" default:""
// @Param mcisId query string false "MCIS ID" default:""
// @Param mciId query string false "MCI ID" default:""
// @Param vmId query string false "VM ID" default:""
// @Param size query integer false "Number of results per page" default:"10"
// @Param page query integer false "Page number for pagination" default:"1"
Expand All @@ -562,11 +562,11 @@ func (s *AntServer) getAllMonitoringAgentInfos(c echo.Context) error {
}

arg := load.GetAllMonitoringAgentInfosParam{
Page: req.Page,
Size: req.Size,
NsId: req.NsId,
McisId: req.McisId,
VmId: req.VmId,
Page: req.Page,
Size: req.Size,
NsId: req.NsId,
MciId: req.MciId,
VmId: req.VmId,
}

result, err := s.services.loadService.GetAllMonitoringAgentInfos(arg)
Expand All @@ -581,7 +581,7 @@ func (s *AntServer) getAllMonitoringAgentInfos(c echo.Context) error {
// uninstallMonitoringAgent handler function that initiates the uninstallation of monitoring agents.
// @Id UninstallMonitoringAgent
// @Summary Uninstall Monitoring Agents
// @Description Uninstall monitoring agents from specified VMs or all VMs in an MCIS.
// @Description Uninstall monitoring agents from specified VMs or all VMs in an mci.
// @Tags [Monitoring Agent Management]
// @Accept json
// @Produce json
Expand All @@ -598,9 +598,9 @@ func (s *AntServer) uninstallMonitoringAgent(c echo.Context) error {
}

arg := load.MonitoringAgentInstallationParams{
NsId: req.NsId,
McisId: req.McisId,
VmIds: req.VmIds,
NsId: req.NsId,
MciId: req.MciId,
VmIds: req.VmIds,
}

affectedResults, err := s.services.loadService.UninstallMonitoringAgent(arg)
Expand Down
16 changes: 8 additions & 8 deletions internal/app/load_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package app
import "github.com/cloud-barista/cm-ant/internal/core/common/constant"

type MonitoringAgentInstallationReq struct {
NsId string `json:"nsId"`
McisId string `json:"mcisId"`
VmIds []string `json:"vmIds,omitempty"`
NsId string `json:"nsId"`
MciId string `json:"mciId"`
VmIds []string `json:"vmIds,omitempty"`
}

type GetAllMonitoringAgentInfosReq struct {
Page int `query:"page"`
Size int `query:"size"`
NsId string `query:"nsId"`
McisId string `query:"mcisId"`
VmId string `query:"vmId"`
Page int `query:"page"`
Size int `query:"size"`
NsId string `query:"nsId"`
MciId string `query:"mciId"`
VmId string `query:"vmId"`
}

type InstallLoadGeneratorReq struct {
Expand Down
15 changes: 5 additions & 10 deletions internal/app/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package app
import (
"time"

"github.com/cloud-barista/cm-ant/internal/render"
"github.com/cloud-barista/cm-ant/internal/utils"

_ "github.com/cloud-barista/cm-ant/api"
Expand All @@ -16,12 +15,8 @@ import (
)

func (server *AntServer) InitRouter() error {
setStatic(server.e)
setMiddleware(server.e)

tmpl := render.NewTemplate()
server.e.Renderer = tmpl

antRouter := server.e.Group("/ant")

{
Expand Down Expand Up @@ -86,11 +81,11 @@ func (server *AntServer) InitRouter() error {
}

// setStatic sets up static file serving for CSS, JS, and templates.
func setStatic(e *echo.Echo) {
e.Static("/web/templates", utils.RootPath()+"/web/templates")
e.Static("/css", utils.RootPath()+"/web/css")
e.Static("/js", utils.RootPath()+"/web/js")
}
// func setStatic(e *echo.Echo) {
// e.Static("/web/templates", utils.RootPath()+"/web/templates")
// e.Static("/css", utils.RootPath()+"/web/css")
// e.Static("/js", utils.RootPath()+"/web/js")
// }

// setMiddleware configures middleware for the Echo server.
func setMiddleware(e *echo.Echo) {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/load/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type MonitoringAgentInfo struct {
AgentType string

NsId string
McisId string
MciId string
VmId string
VmCount int
}
Expand Down
12 changes: 6 additions & 6 deletions internal/core/load/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func (r *LoadRepository) InsertMonitoringAgentInfoTx(ctx context.Context, param
err := r.execInTransaction(ctx, func(d *gorm.DB) error {
return d.
Where(
"ns_id = ? AND mcis_id = ? AND vm_id = ? AND username = ? AND agent_type = ?",
param.NsId, param.McisId, param.VmId, param.Username, param.AgentType,
"ns_id = ? AND mci_id = ? AND vm_id = ? AND username = ? AND agent_type = ?",
param.NsId, param.MciId, param.VmId, param.Username, param.AgentType,
).
FirstOrCreate(
param,
Expand Down Expand Up @@ -85,8 +85,8 @@ func (r *LoadRepository) GetPagingMonitoringAgentInfosTx(ctx context.Context, pa
q = q.Where("ns_id = ?", param.NsId)
}

if param.McisId != "" {
q = q.Where("mcis_id = ?", param.McisId)
if param.MciId != "" {
q = q.Where("mci_id = ?", param.MciId)
}

if param.VmId != "" {
Expand Down Expand Up @@ -120,8 +120,8 @@ func (r *LoadRepository) GetAllMonitoringAgentInfosTx(ctx context.Context, param
q = q.Where("ns_id = ?", param.NsId)
}

if param.McisId != "" {
q = q.Where("mcis_id = ?", param.McisId)
if param.MciId != "" {
q = q.Where("mci_id = ?", param.MciId)
}

if param.VmIds != nil && len(param.VmIds) > 0 {
Expand Down
Loading

0 comments on commit 1bc9c03

Please sign in to comment.