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

endpoint for agent custom; refactor ams client

parent aedbd515
Pipeline #404853 failed with stages
in 1 minute and 23 seconds
......@@ -52,7 +52,6 @@ import (
"strconv"
agencyclient "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/agency/client"
amsclient "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
......@@ -144,7 +143,7 @@ func (agency *Agency) requestAgentAddress(agentID int) (address schemas.Address,
agency.mutex.Lock()
masID := agency.info.MASID
agency.mutex.Unlock()
address, _, err = amsclient.GetAgentAddress(masID, agentID)
address, _, err = agency.amsClient.GetAgentAddress(masID, agentID)
return
}
......
......@@ -58,7 +58,7 @@ import (
"syscall"
"time"
amsclient "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/status"
)
......@@ -75,6 +75,7 @@ type Agency struct {
msgIn chan []schemas.ACLMessage
logger *loggerClient
mqtt *mqttClient
amsClient *ams.Client
logInfo *log.Logger // logger for info logging
logError *log.Logger // logger for error logging
}
......@@ -88,6 +89,7 @@ func StartAgency(task func(*Agent) error) (err error) {
remoteAgents: make(map[int]*Agent),
remoteAgencies: make(map[string]*remoteAgency),
msgIn: make(chan []schemas.ACLMessage, 1000),
amsClient: ams.NewClient(time.Second*60, time.Second*1, 4),
logError: log.New(os.Stderr, "[ERROR] ", log.LstdFlags),
}
err = agency.init()
......@@ -168,7 +170,7 @@ func (agency *Agency) terminate(gracefulStop chan os.Signal) {
func (agency *Agency) startAgents() (err error) {
// request configuration
var agencyInfoFull schemas.AgencyInfoFull
agencyInfoFull, _, err = amsclient.GetAgencyInfo(agency.info.MASID, agency.info.ImageGroupID,
agencyInfoFull, _, err = agency.amsClient.GetAgencyInfo(agency.info.MASID, agency.info.ImageGroupID,
agency.info.ID)
agency.mutex.Lock()
agency.info.ID = agencyInfoFull.ID
......
......@@ -189,6 +189,16 @@ func (ams *AMS) updateAgentAddress(masID int, agentID int, address schemas.Addre
return
}
// updateAgentCustom sets custom config of agent and sends PUT to agency
func (ams *AMS) updateAgentCustom(masID int, agentID int, custom string) (err error) {
err = ams.stor.setAgentCustom(masID, agentID, custom)
if err != nil {
return
}
// ToDo Post new custom to agency
return
}
// getAgencies returns specs of all agencies in MAS
func (ams *AMS) getAgencies(masID int) (ret schemas.Agencies, err error) {
ret, err = ams.stor.getAgencies(masID)
......
......@@ -51,7 +51,6 @@ import (
"testing"
"time"
amsclient "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/common/httpreply"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
......@@ -114,12 +113,13 @@ func stubHandler(w http.ResponseWriter, r *http.Request) {
// dummyClient makes requests to ams and terminates ams server at end
func dummyClient(s *http.Server, t *testing.T) {
time.Sleep(time.Second * 1)
amsclient.Host = "localhost"
amsclient.Port = 10000
amsClient := NewClient(time.Second*60, time.Second*1, 4)
amsClient.Host = "localhost"
amsClient.Port = 10000
var err error
var httpStatus int
_, httpStatus, err = amsclient.GetCloneMAP()
_, httpStatus, err = amsClient.GetCloneMAP()
if err != nil {
t.Error(err)
}
......@@ -153,7 +153,7 @@ func dummyClient(s *http.Server, t *testing.T) {
},
},
}
httpStatus, err = amsclient.PostMAS(mas)
httpStatus, err = amsClient.PostMAS(mas)
if err != nil {
t.Error(err)
}
......@@ -161,7 +161,7 @@ func dummyClient(s *http.Server, t *testing.T) {
t.Error("Error PostMAS " + strconv.Itoa(httpStatus))
}
_, httpStatus, err = amsclient.GetMASsShort()
_, httpStatus, err = amsClient.GetMASsShort()
if err != nil {
t.Error(err)
}
......@@ -169,7 +169,7 @@ func dummyClient(s *http.Server, t *testing.T) {
t.Error("Error GetMASs " + strconv.Itoa(httpStatus))
}
_, httpStatus, err = amsclient.GetMAS(0)
_, httpStatus, err = amsClient.GetMAS(0)
if err != nil {
t.Error(err)
}
......@@ -177,7 +177,7 @@ func dummyClient(s *http.Server, t *testing.T) {
t.Error("Error GetMAS " + strconv.Itoa(httpStatus))
}
_, httpStatus, err = amsclient.GetAgents(0)
_, httpStatus, err = amsClient.GetAgents(0)
if err != nil {
t.Error(err)
}
......@@ -185,7 +185,7 @@ func dummyClient(s *http.Server, t *testing.T) {
t.Error("Error GetAgents " + strconv.Itoa(httpStatus))
}
_, httpStatus, err = amsclient.GetAgent(0, 0)
_, httpStatus, err = amsClient.GetAgent(0, 0)
if err != nil {
t.Error(err)
}
......@@ -193,7 +193,7 @@ func dummyClient(s *http.Server, t *testing.T) {
t.Error("Error GetAgent " + strconv.Itoa(httpStatus))
}
_, httpStatus, err = amsclient.GetAgentAddress(0, 0)
_, httpStatus, err = amsClient.GetAgentAddress(0, 0)
if err != nil {
t.Error(err)
}
......@@ -201,7 +201,7 @@ func dummyClient(s *http.Server, t *testing.T) {
t.Error("Error GetAgentAddress " + strconv.Itoa(httpStatus))
}
_, httpStatus, err = amsclient.GetAgencies(0)
_, httpStatus, err = amsClient.GetAgencies(0)
if err != nil {
t.Error(err)
}
......@@ -209,7 +209,7 @@ func dummyClient(s *http.Server, t *testing.T) {
t.Error("Error GetAgencies " + strconv.Itoa(httpStatus))
}
_, httpStatus, err = amsclient.GetAgencyInfo(0, 0, 0)
_, httpStatus, err = amsClient.GetAgencyInfo(0, 0, 0)
if err != nil {
t.Error(err)
}
......
......@@ -42,8 +42,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// Package client contains code for interaction with ams
package client
// contains code for interaction with ams
package ams
import (
"encoding/json"
......@@ -57,21 +58,20 @@ import (
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
// Host contains the host name of ams (IP or k8s service name)
var Host = "ams"
// Port contains the port on which ams is listening
var Port = 9000
var httpClient = &http.Client{Timeout: time.Second * 60}
var delay = time.Second * 1
var numRetries = 4
// Client is the ams client
type Client struct {
httpClient *http.Client // http client
Host string // ams host name
Port int // ams port
delay time.Duration // delay between two retries
numRetries int // number of retries
}
// Alive tests if alive
func Alive() (alive bool) {
func (cli *Client) Alive() (alive bool) {
alive = false
_, httpStatus, err := httpretry.Get(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/alive", time.Second*2, 2)
_, httpStatus, err := httpretry.Get(cli.httpClient, cli.prefix()+"/api/alive",
time.Second*2, 2)
if err == nil && httpStatus == http.StatusOK {
alive = true
}
......@@ -79,10 +79,10 @@ func Alive() (alive bool) {
}
// GetCloneMAP requests CloneMAP information
func GetCloneMAP() (cmap schemas.CloneMAP, httpStatus int, err error) {
func (cli *Client) GetCloneMAP() (cmap schemas.CloneMAP, httpStatus int, err error) {
var body []byte
body, httpStatus, err = httpretry.Get(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap", time.Second*2, 2)
body, httpStatus, err = httpretry.Get(cli.httpClient, cli.prefix()+"/api/clonemap",
time.Second*2, 2)
if err != nil {
return
}
......@@ -94,10 +94,10 @@ func GetCloneMAP() (cmap schemas.CloneMAP, httpStatus int, err error) {
}
// GetMASsShort requests mas information
func GetMASsShort() (mass []schemas.MASInfoShort, httpStatus int, err error) {
func (cli *Client) GetMASsShort() (mass []schemas.MASInfoShort, httpStatus int, err error) {
var body []byte
body, httpStatus, err = httpretry.Get(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas", time.Second*2, 2)
body, httpStatus, err = httpretry.Get(cli.httpClient, cli.prefix()+"/api/clonemap/mas",
time.Second*2, 2)
if err != nil {
return
}
......@@ -109,18 +109,18 @@ func GetMASsShort() (mass []schemas.MASInfoShort, httpStatus int, err error) {
}
// PostMAS post an mas
func PostMAS(mas schemas.MASSpec) (httpStatus int, err error) {
func (cli *Client) PostMAS(mas schemas.MASSpec) (httpStatus int, err error) {
js, _ := json.Marshal(mas)
_, httpStatus, err = httpretry.Post(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas", "application/json", js, time.Second*2, 2)
_, httpStatus, err = httpretry.Post(cli.httpClient, cli.prefix()+"/api/clonemap/mas",
"application/json", js, time.Second*2, 2)
return
}
// GetMAS requests mas information
func GetMAS(masID int) (mas schemas.MASInfo, httpStatus int, err error) {
func (cli *Client) GetMAS(masID int) (mas schemas.MASInfo, httpStatus int, err error) {
var body []byte
body, httpStatus, err = httpretry.Get(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas/"+strconv.Itoa(masID), time.Second*2, 2)
body, httpStatus, err = httpretry.Get(cli.httpClient, cli.prefix()+"/api/clonemap/mas/"+
strconv.Itoa(masID), time.Second*2, 2)
if err != nil {
return
}
......@@ -132,18 +132,18 @@ func GetMAS(masID int) (mas schemas.MASInfo, httpStatus int, err error) {
}
// DeleteMAS deletes a MAS
func DeleteMAS(masID int) (httpStatus int, err error) {
httpStatus, err = httpretry.Delete(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas/"+strconv.Itoa(masID), nil,
func (cli *Client) DeleteMAS(masID int) (httpStatus int, err error) {
httpStatus, err = httpretry.Delete(cli.httpClient, cli.prefix()+"/api/clonemap/mas/"+
strconv.Itoa(masID), nil,
time.Second*2, 2)
return
}
// GetAgents requests agent information
func GetAgents(masID int) (agents schemas.Agents, httpStatus int, err error) {
func (cli *Client) GetAgents(masID int) (agents schemas.Agents, httpStatus int, err error) {
var body []byte
body, httpStatus, err = httpretry.Get(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas/"+strconv.Itoa(masID)+"/agents", time.Second*2, 2)
body, httpStatus, err = httpretry.Get(cli.httpClient, cli.prefix()+"/api/clonemap/mas/"+
strconv.Itoa(masID)+"/agents", time.Second*2, 2)
if err != nil {
return
}
......@@ -155,19 +155,20 @@ func GetAgents(masID int) (agents schemas.Agents, httpStatus int, err error) {
}
// PostAgents post agents to mas
func PostAgents(masID int, ags []schemas.ImageGroupSpec) (httpStatus int, err error) {
func (cli *Client) PostAgents(masID int, ags []schemas.ImageGroupSpec) (httpStatus int, err error) {
js, _ := json.Marshal(ags)
_, httpStatus, err = httpretry.Post(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas/"+strconv.Itoa(masID)+"/agents", "application/json", js, time.Second*2,
_, httpStatus, err = httpretry.Post(cli.httpClient, cli.prefix()+"/api/clonemap/mas/"+
strconv.Itoa(masID)+"/agents", "application/json", js, time.Second*2,
2)
return
}
// GetAgent requests agent information
func GetAgent(masID int, agentID int) (agent schemas.AgentInfo, httpStatus int, err error) {
func (cli *Client) GetAgent(masID int, agentID int) (agent schemas.AgentInfo, httpStatus int,
err error) {
var body []byte
body, httpStatus, err = httpretry.Get(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas/"+strconv.Itoa(masID)+"/agents/"+strconv.Itoa(agentID), time.Second*2, 2)
body, httpStatus, err = httpretry.Get(cli.httpClient, cli.prefix()+"/api/clonemap/mas/"+
strconv.Itoa(masID)+"/agents/"+strconv.Itoa(agentID), time.Second*2, 2)
if err != nil {
return
}
......@@ -179,10 +180,11 @@ func GetAgent(masID int, agentID int) (agent schemas.AgentInfo, httpStatus int,
}
// GetAgentAddress requests agent address
func GetAgentAddress(masID int, agentID int) (address schemas.Address, httpStatus int, err error) {
func (cli *Client) GetAgentAddress(masID int, agentID int) (address schemas.Address, httpStatus int,
err error) {
var body []byte
ip := getIP()
body, httpStatus, err = httpretry.Get(httpClient, "http://"+ip+":"+strconv.Itoa(Port)+
ip := cli.getIP()
body, httpStatus, err = httpretry.Get(cli.httpClient, "http://"+ip+":"+strconv.Itoa(cli.Port)+
"/api/clonemap/mas/"+strconv.Itoa(masID)+"/agents/"+strconv.Itoa(agentID)+"/address",
time.Second*2, 2)
if err != nil {
......@@ -196,18 +198,18 @@ func GetAgentAddress(masID int, agentID int) (address schemas.Address, httpStatu
}
// DeleteAgent deletes an agent
func DeleteAgent(masID int, agentID int) (httpStatus int, err error) {
httpStatus, err = httpretry.Delete(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas/"+strconv.Itoa(masID)+"/agents/"+strconv.Itoa(agentID), nil,
func (cli *Client) DeleteAgent(masID int, agentID int) (httpStatus int, err error) {
httpStatus, err = httpretry.Delete(cli.httpClient, cli.prefix()+"/api/clonemap/mas/"+
strconv.Itoa(masID)+"/agents/"+strconv.Itoa(agentID), nil,
time.Second*2, 2)
return
}
// GetAgencies requests agency information
func GetAgencies(masID int) (agencies schemas.Agencies, httpStatus int, err error) {
func (cli *Client) GetAgencies(masID int) (agencies schemas.Agencies, httpStatus int, err error) {
var body []byte
body, httpStatus, err = httpretry.Get(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas/"+strconv.Itoa(masID)+"/agencies", time.Second*2, 2)
body, httpStatus, err = httpretry.Get(cli.httpClient, cli.prefix()+"/api/clonemap/mas/"+
strconv.Itoa(masID)+"/agencies", time.Second*2, 2)
if err != nil {
return
}
......@@ -219,11 +221,11 @@ func GetAgencies(masID int) (agencies schemas.Agencies, httpStatus int, err erro
}
// GetAgencyInfo requests agency information
func GetAgencyInfo(masID int, imID int, agencyID int) (agency schemas.AgencyInfoFull,
func (cli *Client) GetAgencyInfo(masID int, imID int, agencyID int) (agency schemas.AgencyInfoFull,
httpStatus int, err error) {
var body []byte
body, httpStatus, err = httpretry.Get(httpClient, "http://"+Host+":"+strconv.Itoa(Port)+
"/api/clonemap/mas/"+strconv.Itoa(masID)+"/imgroup/"+strconv.Itoa(imID)+"/agency/"+
body, httpStatus, err = httpretry.Get(cli.httpClient, cli.prefix()+"/api/clonemap/mas/"+
strconv.Itoa(masID)+"/imgroup/"+strconv.Itoa(imID)+"/agency/"+
strconv.Itoa(agencyID), time.Second*2, 2)
if err != nil {
return
......@@ -236,16 +238,9 @@ func GetAgencyInfo(masID int, imID int, agencyID int) (agency schemas.AgencyInfo
return
}
// Init initializes the client
func Init(timeout time.Duration, del time.Duration, numRet int) {
httpClient.Timeout = timeout
delay = del
numRetries = numRet
}
func getIP() (ret string) {
func (cli *Client) getIP() (ret string) {
for {
ips, err := net.LookupHost(Host)
ips, err := net.LookupHost(cli.Host)
if len(ips) > 0 && err == nil {
ret = ips[0]
break
......@@ -253,3 +248,20 @@ func getIP() (ret string) {
}
return
}
func (cli *Client) prefix() (ret string) {
ret = "http://" + cli.Host + ":" + strconv.Itoa(cli.Port)
return
}
// NewClient creates a new AMS client
func NewClient(timeout time.Duration, del time.Duration, numRet int) (cli *Client) {
cli = &Client{
httpClient: &http.Client{Timeout: timeout},
Host: "ams",
Port: 9000,
delay: del,
numRetries: numRet,
}
return
}
......@@ -56,6 +56,7 @@ THE SOFTWARE.
// ams/mas/<masID>/im/<imID>/agency/<agencyID>: schemas.AgencyInfo
// ams/mas/<masID>/agentcounter int (agentCounter)
// ams/mas/<masID>/agent/<agentID>: schemas.AgentInfo
// ams/mas/<masID>/agent/<agentID>/address: schemas.Adress
//
// df/graph/<masID>: schemas.Graph
......@@ -115,8 +116,27 @@ func (stor *etcdStorage) setCloneMAPInfo(cloneMAP schemas.CloneMAP) (err error)
// setAgentAddress sets address of agent
func (stor *etcdStorage) setAgentAddress(masID int, agentID int,
address schemas.Address) (err error) {
err = stor.etcdPutResource("ams/mas/"+strconv.Itoa(masID)+"/agent/"+strconv.Itoa(agentID)+
"/address", address)
var agentInfo schemas.AgentInfo
agentInfo, err = stor.getAgentInfo(masID, agentID)
if err != nil {
return
}
agentInfo.Address = address
err = stor.etcdPutResource("ams/mas/"+strconv.Itoa(masID)+"/agent/"+strconv.Itoa(agentID),
agentInfo)
return
}
// setAgentCustom sets custom config of agent
func (stor *etcdStorage) setAgentCustom(masID int, agentID int, custom string) (err error) {
var agentInfo schemas.AgentInfo
agentInfo, err = stor.getAgentInfo(masID, agentID)
if err != nil {
return
}
agentInfo.Spec.Custom = custom
err = stor.etcdPutResource("ams/mas/"+strconv.Itoa(masID)+"/agent/"+strconv.Itoa(agentID),
agentInfo)
return
}
......
......@@ -406,6 +406,12 @@ func (stor *fiwareStorage) setAgentAddress(masID int, agentID int,
return
}
// setAgentCustom sets custom config of agent
func (stor *fiwareStorage) setAgentCustom(masID int, agentID int, custom string) (err error) {
return
}
// getAgencies returns specs of all agencies in MAS
func (stor *fiwareStorage) getAgencies(masID int) (ret schemas.Agencies, err error) {
// check if mas exists
......
......@@ -127,6 +127,9 @@ func (ams *AMS) handleAPI(w http.ResponseWriter, r *http.Request) {
if respath[7] == "address" {
cmapErr, httpErr = ams.handleAgentAddress(masID, agentID, w, r)
resvalid = true
} else if respath[7] == "custom" {
cmapErr, httpErr = ams.handleAgentCustom(masID, agentID, w, r)
resvalid = true
}
}
}
......@@ -311,8 +314,8 @@ func (ams *AMS) handleAgentAddress(masID int, agentid int, w http.ResponseWriter
var agentAddr schemas.Address
cmapErr := json.Unmarshal(body, &agentAddr)
if cmapErr == nil {
go ams.updateAgentAddress(masID, agentid, agentAddr)
httpErr = httpreply.Updated(w, nil)
cmapErr = ams.updateAgentAddress(masID, agentid, agentAddr)
httpErr = httpreply.Updated(w, cmapErr)
} else {
httpErr = httpreply.JSONUnmarshalError(w)
}
......@@ -327,6 +330,29 @@ func (ams *AMS) handleAgentAddress(masID int, agentid int, w http.ResponseWriter
return
}
// handleAgentAddress is the handler for requests to path
// /api/clonemap/mas/{mas-id}/agents/{agent-id}/custom
func (ams *AMS) handleAgentCustom(masID int, agentid int, w http.ResponseWriter,
r *http.Request) (cmapErr, httpErr error) {
if r.Method == "PUT" {
// update custom of specified agent
var body []byte
body, cmapErr = ioutil.ReadAll(r.Body)
if cmapErr == nil {
custom := string(body)
cmapErr = ams.updateAgentCustom(masID, agentid, custom)
httpErr = httpreply.Updated(w, cmapErr)
} else {
httpErr = httpreply.InvalidBodyError(w)
}
} else {
httpErr = httpreply.MethodNotAllowed(w)
cmapErr = errors.New("Error: Method not allowed on path /api/clonemap/mas/{mas-id}/agent/" +
"{agent-id}/custom")
}
return
}
// handleAgency is the handler for requests to path /api/cloumap/mas/{mas-id}/agencies
func (ams *AMS) handleAgency(masID int, w http.ResponseWriter, r *http.Request) (cmapErr,
httpErr error) {
......
......@@ -92,6 +92,9 @@ type storage interface {
// setAgentAddress sets address of agent
setAgentAddress(masID int, agentID int, address schemas.Address) (err error)
// setAgentCustom sets custom config of agent
setAgentCustom(masID int, agentID int, custom string) (err error)
// getAgencies returns specs of all agencies in MAS
getAgencies(masID int) (ret schemas.Agencies, err error)
......@@ -306,6 +309,24 @@ func (stor *localStorage) setAgentAddress(masID int, agentID int,
return
}
// setAgentCustom sets custom of agent
func (stor *localStorage) setAgentCustom(masID int, agentID int, custom string) (err error) {
stor.mutex.Lock()
if len(stor.mas)-1 < masID {
stor.mutex.Unlock()
err = errors.New("Agent does not exist")
return
}
if len(stor.mas[masID].Agents.Inst)-1 < agentID {
stor.mutex.Unlock()
err = errors.New("Agent does not exist")
return
}
stor.mas[masID].Agents.Inst[agentID].Spec.Custom = custom
stor.mutex.Unlock()
return
}
// setAgentStatus sets status of agent
func (stor *localStorage) setAgentStatus(masID int, agentID int,
status schemas.Status) (err error) {
......
......@@ -51,7 +51,6 @@ import (
"net/http"
"strconv"
amsclient "git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/common/httpreply"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
......@@ -106,7 +105,7 @@ func (fe *Frontend) handleMAS(w http.ResponseWriter, r *http.Request) (cmapErr,
if r.Method == "GET" {
// return short info of all MAS
var mass []schemas.MASInfoShort
mass, _, cmapErr = amsclient.GetMASsShort()
mass, _, cmapErr = fe.amsClient.GetMASsShort()
if cmapErr == nil {
httpErr = httpreply.Resource(w, mass, cmapErr)
} else {
......@@ -119,7 +118,7 @@ func (fe *Frontend) handleMAS(w http.ResponseWriter, r *http.Request) (cmapErr,
var masSpec schemas.MASSpec
cmapErr = json.Unmarshal(body, &masSpec)
if cmapErr == nil {
_, httpErr = amsclient.PostMAS(masSpec)
_, httpErr = fe.amsClient.PostMAS(masSpec)
} else {
httpErr = httpreply.JSONUnmarshalError(w)
}
......@@ -139,7 +138,7 @@ func (fe *Frontend) handlemasID(masID int, w http.ResponseWriter, r *http.Reques
if r.Method == "GET" {
// return long information about specified MAS
var masInfo schemas.MASInfo
masInfo, _, cmapErr = amsclient.GetMAS(masID)
masInfo, _, cmapErr = fe.amsClient.GetMAS(masID)
httpErr = httpreply.Resource(w, masInfo, cmapErr)
} else if r.Method == "DELETE" {
// delete specified MAS
......@@ -162,7 +161,7 @@ func (fe *Frontend) handleAgent(masID int, w http.ResponseWriter, r *http.Reques
var groupSpecs []schemas.ImageGroupSpec
cmapErr = json.Unmarshal(body, &groupSpecs)
if cmapErr == nil {
_, cmapErr = amsclient.PostAgents(masID, groupSpecs)
_, cmapErr = fe.amsClient.PostAgents(masID, groupSpecs)
httpErr = httpreply.Created(w, cmapErr, "text/plain", []byte("Ressource Created"))
} else {
httpErr = httpreply.JSONUnmarshalError(w)
......@@ -183,11 +182,11 @@ func (fe *Frontend) handleAgentID(masID int, agentID int, w http.ResponseWriter,
if r.Method == "GET" {
// return long information of specified agent
var agentInfo schemas.AgentInfo
agentInfo, _, cmapErr = amsclient.GetAgent(masID, agentID)
agentInfo, _, cmapErr = fe.amsClient.GetAgent(masID, agentID)
httpErr = httpreply.Resource(w, agentInfo, cmapErr)
} else if r.Method == "DELETE" {
// delete specified agent
_, cmapErr = amsc