mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
This commit is contained in:
parent
fb757b1172
commit
e2bebbc676
2 changed files with 10 additions and 2 deletions
|
@ -110,7 +110,11 @@ func createNewICviaAMQP(payload ICUpdate) error {
|
||||||
} else {
|
} else {
|
||||||
newICReq.InfrastructureComponent.State = "unknown"
|
newICReq.InfrastructureComponent.State = "unknown"
|
||||||
}
|
}
|
||||||
// TODO check if state is "gone" and abort creation of IC in this case
|
if newICReq.InfrastructureComponent.State == "gone" {
|
||||||
|
// Check if state is "gone" and abort creation of IC in this case
|
||||||
|
log.Println("########## AMQP: Aborting creation of IC with state gone")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if payload.Properties.WS_url != nil {
|
if payload.Properties.WS_url != nil {
|
||||||
newICReq.InfrastructureComponent.WebsocketURL = *payload.Properties.WS_url
|
newICReq.InfrastructureComponent.WebsocketURL = *payload.Properties.WS_url
|
||||||
|
@ -151,17 +155,19 @@ func createNewICviaAMQP(payload ICUpdate) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InfrastructureComponent) updateICviaAMQP(payload ICUpdate) error {
|
func (s *InfrastructureComponent) updateICviaAMQP(payload ICUpdate) error {
|
||||||
|
|
||||||
var updatedICReq UpdateICRequest
|
var updatedICReq UpdateICRequest
|
||||||
if payload.State != nil {
|
if payload.State != nil {
|
||||||
updatedICReq.InfrastructureComponent.State = *payload.State
|
updatedICReq.InfrastructureComponent.State = *payload.State
|
||||||
|
|
||||||
if *payload.State == "gone" {
|
if *payload.State == "gone" {
|
||||||
// remove IC from DB
|
// remove IC from DB
|
||||||
|
log.Println("########## AMQP: Deleting IC with state gone")
|
||||||
err := s.delete(true)
|
err := s.delete(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// if component could not be deleted there are still configurations using it in the DB
|
// if component could not be deleted there are still configurations using it in the DB
|
||||||
// continue with the update to save the new state of the component and get back to the deletion later
|
// continue with the update to save the new state of the component and get back to the deletion later
|
||||||
log.Println("Could not delete IC because there is a config using it, deletion postponed")
|
log.Println("########## AMQP: Deletion of IC postponed (config(s) associated to it)")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"github.com/jinzhu/gorm/dialects/postgres"
|
"github.com/jinzhu/gorm/dialects/postgres"
|
||||||
"github.com/nsf/jsondiff"
|
"github.com/nsf/jsondiff"
|
||||||
"gopkg.in/go-playground/validator.v9"
|
"gopkg.in/go-playground/validator.v9"
|
||||||
|
"log"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -131,6 +132,7 @@ func (r *AddICRequest) createIC(receivedViaAMQP bool) (InfrastructureComponent,
|
||||||
*action.Properties.UUID = r.InfrastructureComponent.UUID
|
*action.Properties.UUID = r.InfrastructureComponent.UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("########## AMQP: Sending request to create new IC")
|
||||||
err = sendActionAMQP(action)
|
err = sendActionAMQP(action)
|
||||||
|
|
||||||
// s remains empty
|
// s remains empty
|
||||||
|
|
Loading…
Add table
Reference in a new issue