Commit 3d086fdf authored by Sonja Happ's avatar Sonja Happ
Browse files

AMQP: adapt to message format of VILLAScontroller

parent f05efc99
...@@ -123,7 +123,7 @@ func ConnectAMQP(uri string) error { ...@@ -123,7 +123,7 @@ func ConnectAMQP(uri string) error {
var sToBeUpdated database.InfrastructureComponent var sToBeUpdated database.InfrastructureComponent
db := database.GetDB() db := database.GetDB()
ICUUID := gjson.Get(content, "properties.uuid").String() ICUUID := gjson.Get(content, "payload.properties.uuid").String()
if ICUUID == "" { if ICUUID == "" {
log.Println("AMQP: Could not extract UUID of IC from content of received message, COMPONENT NOT UPDATED") log.Println("AMQP: Could not extract UUID of IC from content of received message, COMPONENT NOT UPDATED")
} else { } else {
...@@ -133,12 +133,16 @@ func ConnectAMQP(uri string) error { ...@@ -133,12 +133,16 @@ func ConnectAMQP(uri string) error {
continue continue
} }
var timeSec = gjson.Get(content, "time").Float()
var stateUpdateAt = time.Unix(0, int64(timeSec*1000000000)).UTC()
err = db.Model(&sToBeUpdated).Updates(map[string]interface{}{ err = db.Model(&sToBeUpdated).Updates(map[string]interface{}{
//"Host": gjson.Get(content, "host"), //"Host": gjson.Get(content, "host"),
//"Type": gjson.Get(content, "model"), //"Type": gjson.Get(content, "model"),
"Uptime": gjson.Get(content, "status.uptime"), "Uptime": gjson.Get(content, "payload.uptime"),
"State": gjson.Get(content, "status.state"), "State": gjson.Get(content, "payload.state"),
"StateUpdateAt": time.Now().Format(time.RFC1123), // TODO should use the "when" of the status update "StateUpdateAt": stateUpdateAt.Format(time.RFC1123),
//"RawProperties": gjson.Get(content, "properties"), //"RawProperties": gjson.Get(content, "properties"),
}).Error }).Error
if err != nil { if err != nil {
......
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