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 {
"Type": gjson.Get(content, "model"),
"Uptime": gjson.Get(content, "uptime"),
"State": gjson.Get(content, "state"),
"StateUpdateAt": time.Now().String(),
"StateUpdateAt": time.Now().Format(time.RFC1123),
"RawProperties": gjson.Get(content, "properties"),
}).Error
if err != nil {
......
......@@ -99,7 +99,7 @@ var ICA = database.InfrastructureComponent{
Name: "Test DPsim Simulator",
Uptime: 0,
State: "running",
StateUpdateAt: time.Now().String(),
StateUpdateAt: time.Now().Format(time.RFC1123),
Properties: postgres.Jsonb{propertiesA},
RawProperties: postgres.Jsonb{propertiesA},
}
......@@ -113,7 +113,7 @@ var ICB = database.InfrastructureComponent{
Name: "ACS Demo Signals",
Uptime: 0,
State: "idle",
StateUpdateAt: time.Now().String(),
StateUpdateAt: time.Now().Format(time.RFC1123),
Properties: postgres.Jsonb{propertiesB},
RawProperties: postgres.Jsonb{propertiesB},
}
......
......@@ -26,13 +26,14 @@ import (
"github.com/jinzhu/gorm/dialects/postgres"
"github.com/nsf/jsondiff"
"gopkg.in/go-playground/validator.v9"
"time"
)
var validate *validator.Validate
type validNewIC struct {
UUID string `form:"UUID" validate:"required"`
Host string `form:"Host" validate:"required"`
Host string `form:"Host" validate:"omitempty"`
APIHost string `form:"APIHost" validate:"omitempty"`
Type string `form:"Type" validate:"required"`
Name string `form:"Name" validate:"required"`
......@@ -84,7 +85,12 @@ func (r *addICRequest) createIC() InfrastructureComponent {
s.Properties = r.InfrastructureComponent.Properties
if 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
}
......
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