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

fixes

parent 970073f9
Pipeline #262490 passed with stages
in 1 minute and 12 seconds
......@@ -137,15 +137,15 @@ func (ams *AMS) handleAPI(w http.ResponseWriter, r *http.Request) {
cmapErr, httpErr = ams.handleAgentAddress(masID, agentID, w, r)
resvalid = true
}
} else if respath[5] == "container" {
var imid, agencyID int
imid, cmapErr = strconv.Atoi(respath[6])
if cmapErr != nil {
agencyID, cmapErr = strconv.Atoi(respath[6])
if cmapErr == nil {
cmapErr, httpErr = ams.handleContainer(masID, imid, agencyID, w, r)
resvalid = true
}
}
} else if respath[5] == "container" {
var imid, agencyID int
imid, cmapErr = strconv.Atoi(respath[6])
if cmapErr == nil {
agencyID, cmapErr = strconv.Atoi(respath[7])
if cmapErr == nil {
cmapErr, httpErr = ams.handleContainer(masID, imid, agencyID, w, r)
resvalid = true
}
}
}
......
......@@ -364,8 +364,8 @@ func createMASStorage(masID int, masInfo schemas.MASInfo) (ret schemas.MASInfo)
ret.ID = masID
for i := 0; i < ret.Agents.Counter; i++ {
ret.Agents.Instances[i].MASID = masID
ret.Agents.Instances[i].Address.Agency = "mas-" + ret.Agents.Instances[i].Address.Agency +
".mas" + strconv.Itoa(masID) + "agencies"
ret.Agents.Instances[i].Address.Agency = "mas-" + strconv.Itoa(masID) +
ret.Agents.Instances[i].Address.Agency + ".mas" + strconv.Itoa(masID) + "agencies"
}
for i := 0; i < ret.Agencies.Counter; i++ {
ret.Agencies.Instances[i].MASID = masID
......
......@@ -265,10 +265,10 @@ func (stub *LocalStub) createAgency(image string, masID int, imID int, agencyID
}
// deleteAgency stops and removes agency docker image
func (stub *LocalStub) deleteAgency(masID int, agencyID int) (err error) {
func (stub *LocalStub) deleteAgency(masID int, imID int, agencyID int) (err error) {
com := "docker stop "
com += "mas-" + strconv.Itoa(masID) + "-agency-" + strconv.Itoa(agencyID) + ".mas" +
strconv.Itoa(masID) + "agencies" //.clonemap"
com += "mas-" + strconv.Itoa(masID) + "-im-" + strconv.Itoa(imID) + "-agency-" +
strconv.Itoa(agencyID) + ".mas" + strconv.Itoa(masID) + "agencies"
cmd := exec.Command("bash", "-c", com)
cmdOut, err := cmd.Output()
if err != nil {
......@@ -276,8 +276,8 @@ func (stub *LocalStub) deleteAgency(masID int, agencyID int) (err error) {
return
}
com = "docker rm "
com += "mas-" + strconv.Itoa(masID) + "-agency-" + strconv.Itoa(agencyID) + ".mas" +
strconv.Itoa(masID) + "agencies" //.clonemap"
com += "mas-" + strconv.Itoa(masID) + "-im-" + strconv.Itoa(imID) + "-agency-" +
strconv.Itoa(agencyID) + ".mas" + strconv.Itoa(masID) + "agencies"
cmd = exec.Command("bash", "-c", com)
cmdOut, err = cmd.Output()
if err != nil {
......
......@@ -89,7 +89,8 @@ func (stub *LocalStub) handleAPI(w http.ResponseWriter, r *http.Request) {
agexist := false
for i := range stub.agencies {
if stub.agencies[i].AgencyID == agconfig.AgencyID &&
stub.agencies[i].MASID == agconfig.MASID {
stub.agencies[i].MASID == agconfig.MASID &&
stub.agencies[i].ImageGroupID == agconfig.ImageGroupID {
agexist = true
}
}
......@@ -135,7 +136,7 @@ func (stub *LocalStub) handleAPI(w http.ResponseWriter, r *http.Request) {
if err == nil {
for i := range stub.agencies {
if stub.agencies[i].MASID == masID {
err = stub.deleteAgency(masID, stub.agencies[i].AgencyID)
err = stub.deleteAgency(masID, stub.agencies[i].ImageGroupID, stub.agencies[i].AgencyID)
}
}
}
......
......@@ -124,10 +124,12 @@ func (stub *LocalStub) terminate(gracefulStop chan os.Signal) {
sig := <-gracefulStop
fmt.Printf("Caught sig: %+v\n", sig)
for i := range stub.agencies {
agencyName := "mas-" + strconv.Itoa(stub.agencies[i].MASID) + "-agency-" +
agencyName := "mas-" + strconv.Itoa(stub.agencies[i].MASID) + "-im-" +
strconv.Itoa(stub.agencies[i].ImageGroupID) + "-agency-" +
strconv.Itoa(stub.agencies[i].AgencyID)
fmt.Println("Stop Agency Container " + agencyName)
err = stub.deleteAgency(stub.agencies[i].MASID, stub.agencies[i].AgencyID)
err = stub.deleteAgency(stub.agencies[i].MASID, stub.agencies[i].ImageGroupID,
stub.agencies[i].AgencyID)
if err != nil {
fmt.Println(err)
// os.Exit(0)
......
Supports Markdown
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