Commit f4cb42b7 authored by Sonja Happ's avatar Sonja Happ
Browse files

make host an optional parameter of IC, closes #40 ;fix issues with update date of ICs

parent e8832ecc
...@@ -137,7 +137,7 @@ func ConnectAMQP(uri string) error { ...@@ -137,7 +137,7 @@ func ConnectAMQP(uri string) error {
"Type": gjson.Get(content, "model"), "Type": gjson.Get(content, "model"),
"Uptime": gjson.Get(content, "uptime"), "Uptime": gjson.Get(content, "uptime"),
"State": gjson.Get(content, "state"), "State": gjson.Get(content, "state"),
"StateUpdateAt": time.Now().String(), "StateUpdateAt": time.Now().Format(time.RFC1123),
"RawProperties": gjson.Get(content, "properties"), "RawProperties": gjson.Get(content, "properties"),
}).Error }).Error
if err != nil { if err != nil {
......
...@@ -99,7 +99,7 @@ var ICA = database.InfrastructureComponent{ ...@@ -99,7 +99,7 @@ var ICA = database.InfrastructureComponent{
Name: "Test DPsim Simulator", Name: "Test DPsim Simulator",
Uptime: 0, Uptime: 0,
State: "running", State: "running",
StateUpdateAt: time.Now().String(), StateUpdateAt: time.Now().Format(time.RFC1123),
Properties: postgres.Jsonb{propertiesA}, Properties: postgres.Jsonb{propertiesA},
RawProperties: postgres.Jsonb{propertiesA}, RawProperties: postgres.Jsonb{propertiesA},
} }
...@@ -113,7 +113,7 @@ var ICB = database.InfrastructureComponent{ ...@@ -113,7 +113,7 @@ var ICB = database.InfrastructureComponent{
Name: "ACS Demo Signals", Name: "ACS Demo Signals",
Uptime: 0, Uptime: 0,
State: "idle", State: "idle",
StateUpdateAt: time.Now().String(), StateUpdateAt: time.Now().Format(time.RFC1123),
Properties: postgres.Jsonb{propertiesB}, Properties: postgres.Jsonb{propertiesB},
RawProperties: postgres.Jsonb{propertiesB}, RawProperties: postgres.Jsonb{propertiesB},
} }
......
...@@ -26,13 +26,14 @@ import ( ...@@ -26,13 +26,14 @@ 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"
"time"
) )
var validate *validator.Validate var validate *validator.Validate
type validNewIC struct { type validNewIC struct {
UUID string `form:"UUID" validate:"required"` UUID string `form:"UUID" validate:"required"`
Host string `form:"Host" validate:"required"` Host string `form:"Host" validate:"omitempty"`
APIHost string `form:"APIHost" validate:"omitempty"` APIHost string `form:"APIHost" validate:"omitempty"`
Type string `form:"Type" validate:"required"` Type string `form:"Type" validate:"required"`
Name string `form:"Name" validate:"required"` Name string `form:"Name" validate:"required"`
...@@ -84,7 +85,12 @@ func (r *addICRequest) createIC() InfrastructureComponent { ...@@ -84,7 +85,12 @@ func (r *addICRequest) createIC() InfrastructureComponent {
s.Properties = r.InfrastructureComponent.Properties s.Properties = r.InfrastructureComponent.Properties
if r.InfrastructureComponent.State != "" { if r.InfrastructureComponent.State != "" {
s.State = r.InfrastructureComponent.State s.State = r.InfrastructureComponent.State
} else {
s.State = "unknown"
} }
// set last update to creation time of IC
s.StateUpdateAt = time.Now().Format(time.RFC1123)
return s return s
} }
......
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