Commit cdbf9cd5 authored by Stefan Dähling's avatar Stefan Dähling
Browse files

fixes in api

parent 8cfac050
Pipeline #416625 passed with stages
in 8 minutes and 52 seconds
......@@ -5,6 +5,8 @@ services:
container_name: kubestub
hostname: kubestub
image: registry.git.rwth-aachen.de/acs/public/cloud/mas/clonemap/clonemap_local
environment:
CLONEMAP_LOG_LEVEL: ${CLONEMAP_LOG_LEVEL}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
......
......@@ -112,7 +112,7 @@ func StartAgency(task func(*Agent) error) (err error) {
signal.Notify(gracefulStop, syscall.SIGINT)
go agency.terminate(gracefulStop)
serv := agency.server(13000)
serv := agency.server(10000)
if err != nil {
agency.logError.Println(err)
return
......
......@@ -147,6 +147,7 @@ func (agent *Agent) updateCustomData(custom string) {
agent.mutex.Lock()
agent.custom = custom
agent.mutex.Unlock()
agent.logInfo.Println("Updated config of agent ", agent.GetAgentID())
return
}
......
......@@ -175,7 +175,7 @@ func (agency *Agency) handleGetAgentStatus(w http.ResponseWriter, r *http.Reques
}
// handlePutAgentCustom is the handler for put requests to path /api/agency/agents/{agentid}/custom
func (agency *Agency) handleAgentCustom(w http.ResponseWriter, r *http.Request) {
func (agency *Agency) handlePutAgentCustom(w http.ResponseWriter, r *http.Request) {
var cmapErr, httpErr error
defer agency.logErrors(r.URL.Path, cmapErr, httpErr)
vars := mux.Vars(r)
......@@ -257,7 +257,7 @@ func (agency *Agency) server(port int) (serv *http.Server) {
s.Path("/agency/agents/{agentid}/status").Methods("PUT", "DELETE", "POST").
HandlerFunc(agency.methodNotAllowed)
s.Path("/agency/agents/{agentid}/custom").Methods("PUT").
HandlerFunc(agency.handleGetAgentStatus)
HandlerFunc(agency.handlePutAgentCustom)
s.Path("/agency/agents/{agentid}/custom").Methods("GET", "DELETE", "POST").
HandlerFunc(agency.methodNotAllowed)
s.Use(agency.loggingMiddleware)
......
......@@ -225,8 +225,8 @@ func (ams *AMS) updateAgentCustom(masID int, agentID int, custom string) (err er
}
var httpStatus int
httpStatus, err = ams.agencyClient.PutAgentCustom(agentAddress.Agency, agentID, custom)
if httpStatus != http.StatusOK {
err = errors.New("error updating custom data")
if httpStatus != http.StatusOK || err != nil {
err = errors.New("error updating custom data " + err.Error())
}
return
}
......@@ -234,6 +234,10 @@ func (ams *AMS) updateAgentCustom(masID int, agentID int, custom string) (err er
// getAgentsByName returns IDs of all agents with matching name
func (ams *AMS) getAgentsByName(masID int, name string) (agentIDs []int, err error) {
var agents schemas.Agents
agents, err = ams.stor.getAgents(masID)
if err != nil {
return
}
for i := range agents.Inst {
if agents.Inst[i].Spec.Name == name {
agentIDs = append(agentIDs, i)
......
......@@ -511,7 +511,7 @@ func (ams *AMS) server(port int) (serv *http.Server) {
s.Path("/clonemap/mas/{masid}/agents/{agentid}/custom").Methods("DELETE", "POST", "GET").
HandlerFunc(ams.methodNotAllowed)
s.Path("/clonemap/mas/{masid}/agents/name/{name}").Methods("GET").
HandlerFunc(ams.handleGetAgentAddress)
HandlerFunc(ams.handleGetAgentName)
s.Path("/clonemap/mas/{masid}/agents/name/{name}").Methods("DELETE", "POST", "PUT").
HandlerFunc(ams.methodNotAllowed)
s.Path("/clonemap/mas/{masid}/agencies").Methods("GET").HandlerFunc(ams.handleGetAgencies)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment