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

added module configs

parent c176e156
Pipeline #417690 passed with stages
in 7 minutes and 12 seconds
......@@ -163,7 +163,7 @@ components:
type: integer
logger:
description: configuration of logging
$ref: '#/components/schemas/LogConfig'
$ref: '#/components/schemas/LoggerConfig'
agents:
description: list of all agents in agency
type: array
......@@ -265,9 +265,12 @@ components:
lastupdate:
description: time of last update
type: string
LogConfig:
LoggerConfig:
description: contains information about agency
properties:
active:
description: indicates if logger module is active and/or usable
type: boolean
msg:
description: activation of msg log topic
type: boolean
......
......@@ -356,18 +356,15 @@ components:
agentsperagency:
description: number of agents per agency
type: integer
logging:
description: switch for logging and state module
type: boolean
mqtt:
description: switch for iot module
type: boolean
$ref: '#/components/schemas/MQTTConfig'
df:
description: switch for df module
type: boolean
$ref: '#/components/schemas/DFConfig'
logger:
description: configuration of logging module
$ref: '#/components/schemas/LogConfig'
$ref: '#/components/schemas/LoggerConfig'
ImageGroupInfo:
description: information about an image groups
properties:
......@@ -417,7 +414,7 @@ components:
type: integer
logger:
description: configuration of logging module
$ref: '#/components/schemas/LogConfig'
$ref: '#/components/schemas/LoggerConfig'
status:
description: status of agent
$ref: '#/components/schemas/Status'
......@@ -470,9 +467,12 @@ components:
type: array
items:
$ref: '#/components/schemas/ImageGroupInfo'
LogConfig:
LoggerConfig:
description: contains information about agency
properties:
active:
description: indicates if logger module is active and/or usable
type: boolean
msg:
description: activation of msg log topic
type: boolean
......@@ -485,6 +485,18 @@ components:
debug:
description: activation of debug log topic
type: boolean
DFConfig:
description: contains config of DF module
properties:
active:
description: indicates if df module is active and/or usable
type: boolean
MQTTConfig:
description: contains config of mqtt module
properties:
active:
description: indicates if mqtt module is active and/or usable
type: boolean
Graph:
description: stores one mas graph for topological search
properties:
......@@ -538,7 +550,7 @@ components:
type: integer
logger:
description: configuration of logging
$ref: '#/components/schemas/LogConfig'
$ref: '#/components/schemas/LoggerConfig'
agents:
description: list of all agents in agency
type: array
......
......@@ -2,10 +2,14 @@
"config":{
"name":"test",
"agentsperagency":1,
"logging":true,
"mqtt":true,
"df":false,
"mqtt":{
"active":true
},
"df":{
"active":true
},
"logger":{
"active":true,
"msg":true,
"app":true,
"status":true,
......@@ -15,7 +19,7 @@
"imagegroups":[
{
"config":{
"image":"agency"
"image":"cmapytest"
},
"agents":[
{
......
......@@ -109,7 +109,7 @@ func (agency *Agency) aclLookup(agentID int) (acl *ACL, err error) {
// check if remote agency is already known
if ok {
agency.logInfo.Println("New remote agent ", agentID, " in known agency ", address.Agency)
ag = newAgent(agentInfo, remAgency.msgIn, nil, nil, schemas.LogConfig{}, nil, nil,
ag = newAgent(agentInfo, remAgency.msgIn, nil, nil, schemas.LoggerConfig{}, nil, nil,
agency.logError, agency.logInfo)
} else {
agency.logInfo.Println("New remote agent ", agentID, " in unknown agency ", address.Agency)
......@@ -131,7 +131,7 @@ func (agency *Agency) aclLookup(agentID int) (acl *ACL, err error) {
numRemAgencies < numLocalAgs {
go agency.receiveMsgs()
}
ag = newAgent(agentInfo, remAgency.msgIn, nil, nil, schemas.LogConfig{}, nil, nil,
ag = newAgent(agentInfo, remAgency.msgIn, nil, nil, schemas.LoggerConfig{}, nil, nil,
agency.logError, agency.logInfo)
}
agency.mutex.Lock()
......
......@@ -78,7 +78,7 @@ type Agent struct {
// newAgent creates a new agent
func newAgent(info schemas.AgentInfo, msgIn chan schemas.ACLMessage,
aclLookup func(int) (*ACL, error), log *logHandler, logConfig schemas.LogConfig,
aclLookup func(int) (*ACL, error), log *logHandler, logConfig schemas.LoggerConfig,
mqtt *mqttClient, dfClient *dfclient.Client, logErr *log.Logger, logInf *log.Logger) (ag *Agent) {
ag = &Agent{
id: info.ID,
......
......@@ -46,7 +46,6 @@ package agency
import (
"errors"
"fmt"
"log"
"os"
"sync"
......@@ -61,7 +60,7 @@ type Logger struct {
agentID int
handler *logHandler
mutex *sync.Mutex
config schemas.LogConfig
config schemas.LoggerConfig
logError *log.Logger
logInfo *log.Logger
active bool
......@@ -81,8 +80,9 @@ func (log *Logger) NewLog(topic string, message string, data string) (err error)
return
}
log.mutex.Lock()
if (topic == "msg" && !log.config.Msg) || (topic == "app" && !log.config.App) ||
(topic == "debug" && !log.config.Debug) || (topic == "status" && !log.config.Status) {
if (topic == "msg" && !log.config.TopicMsg) || (topic == "app" && !log.config.TopicApp) ||
(topic == "debug" && !log.config.TopicDebug) ||
(topic == "status" && !log.config.TopicStatus) {
log.mutex.Unlock()
return
}
......@@ -134,7 +134,7 @@ func (log *Logger) RestoreState() (state string, err error) {
}
// newLogger craetes a new object of type Logger
func newLogger(agentID int, handler *logHandler, config schemas.LogConfig, logErr *log.Logger,
func newLogger(agentID int, handler *logHandler, config schemas.LoggerConfig, logErr *log.Logger,
logInf *log.Logger) (log *Logger) {
log = &Logger{
agentID: agentID,
......@@ -200,7 +200,7 @@ func (log *logHandler) storeLogs() (err error) {
for {
// print messages to stdout if logger is turned off
logMsg := <-log.logIn
fmt.Println(logMsg)
log.logInfo.Println(logMsg)
}
}
}
......
......@@ -300,8 +300,8 @@ func (ams *AMS) startMAS(masID int, masInfo schemas.MASInfo, numAgencies []int)
}
// deploy containers
err = ams.depl.newMAS(masID, masInfo.ImageGroups, masInfo.Config.Logging,
masInfo.Config.MQTT, masInfo.Config.DF)
err = ams.depl.newMAS(masID, masInfo.ImageGroups, masInfo.Config.Logger.Active,
masInfo.Config.MQTT.Active, masInfo.Config.DF.Active)
if err != nil {
ams.logError.Println(err.Error())
return
......@@ -470,8 +470,8 @@ func (ams *AMS) createAgents(masID int, groupSpecs []schemas.ImageGroupSpec) (er
if err != nil {
return
}
err = ams.depl.newImageGroup(masID, groupInfo, masInfo.Config.Logging,
masInfo.Config.MQTT, masInfo.Config.DF)
err = ams.depl.newImageGroup(masID, groupInfo, masInfo.Config.Logger.Active,
masInfo.Config.MQTT.Active, masInfo.Config.DF.Active)
if err != nil {
return
}
......
......@@ -145,9 +145,15 @@ func dummyClient(s *http.Server, t *testing.T) {
Config: schemas.MASConfig{
Name: "test",
NumAgentsPerAgency: 10,
Logging: false,
MQTT: false,
DF: false,
Logger: schemas.LoggerConfig{
Active: false,
},
MQTT: schemas.MQTTConfig{
Active: false,
},
DF: schemas.DFConfig{
Active: false,
},
},
ImageGroups: []schemas.ImageGroupSpec{
{
......
......@@ -56,6 +56,14 @@ type CloneMAP struct {
Uptime time.Time `json:"uptime,omitempty"` // uptime of clonemap instance
}
// ModuleConfig shows the config of all modules
type ModuleConfig struct {
AMS AMSConfig `json:"ams"` // AMS config
DF DFConfig `json:"df"` // df config
Logger LoggerConfig `json:"logger"` // logger config
MQTT MQTTConfig `json:"mqtt"` // MQTT config
}
// ModuleStatus shows the status of clonemaps modules
type ModuleStatus struct {
Core bool `json:"core"` // Core module
......@@ -63,6 +71,12 @@ type ModuleStatus struct {
Logger bool `json:"logger"` // Logging module
}
// AMSConfig contains the host and port configuration of the AMS
type AMSConfig struct {
Host string `json:"host,omitempty"` // hostname of AMS
Port int `json:"port,omitempty"` // port of AMS
}
// MASInfoShort contains info about MAS spec, agents in MAS
type MASInfoShort struct {
ID int `json:"id"`
......@@ -93,12 +107,11 @@ type MASSpec struct {
// MASConfig contains configuration of MAS
type MASConfig struct {
Name string `json:"name,omitempty"` // name/description of MAS
NumAgentsPerAgency int `json:"agentsperagency,omitempty"` // number of agents per agency
Logging bool `json:"logging"` // switch for logging module
MQTT bool `json:"mqtt"` //switch for mqtt
DF bool `json:"df"` //switch for df
Logger LogConfig `json:"logger"` // logger configuration
Name string `json:"name,omitempty"` // name/description of MAS
NumAgentsPerAgency int `json:"agentsperagency"` // number of agents per agency
MQTT MQTTConfig `json:"mqtt"` //switch for mqtt
DF DFConfig `json:"df"` //switch for df
Logger LoggerConfig `json:"logger"` // logger configuration
}
// ImageGroupInfo contains information about all agents that have the same image
......@@ -153,24 +166,24 @@ type Status struct {
// AgencyInfo contains information about agency spec and status (for storage)
type AgencyInfo struct {
MASID int `json:"masid"` // ID of MAS
Name string `json:"name"` // name of agency (hostname of pod given by kubernetes)
ID int `json:"id"` // within image group unique ID (contained in name)
ImageGroupID int `json:"imid"` // ID of agency image group
Logger LogConfig `json:"logger"` // logger configuration
Agents []int `json:"agents"`
Status Status `json:"status"`
MASID int `json:"masid"` // ID of MAS
Name string `json:"name"` // name of agency (hostname of pod given by kubernetes)
ID int `json:"id"` // within image group unique ID (contained in name)
ImageGroupID int `json:"imid"` // ID of agency image group
Logger LoggerConfig `json:"logger"` // logger configuration
Agents []int `json:"agents"`
Status Status `json:"status"`
}
// AgencyInfoFull contains information about agency and full info about agents it conatins (for api)
type AgencyInfoFull struct {
MASID int `json:"masid"` // ID of MAS
Name string `json:"name"` // name of agency (hostname of pod given by kubernetes)
ID int `json:"id"` // within image group unique ID (contained in name)
ImageGroupID int `json:"imid"` // ID of agency image group
Logger LogConfig `json:"logger"` // logger configuration
Agents []AgentInfo `json:"agents"`
Status Status `json:"status"`
MASID int `json:"masid"` // ID of MAS
Name string `json:"name"` // name of agency (hostname of pod given by kubernetes)
ID int `json:"id"` // within image group unique ID (contained in name)
ImageGroupID int `json:"imid"` // ID of agency image group
Logger LoggerConfig `json:"logger"` // logger configuration
Agents []AgentInfo `json:"agents"`
Status Status `json:"status"`
}
// MASs contains informaton about how many MASs are running
......
......@@ -46,6 +46,13 @@ package schemas
import "time"
// DFConfig contains the host and port configuration of the DF and indicates if it is active
type DFConfig struct {
Active bool `json:"active"` // indicates if DF is active/usable
Host string `json:"host,omitempty"` // hostname of DF
Port int `json:"port,omitempty"` // port of DF
}
// Service holds information about an agent service that can be registered and searched with the DF
type Service struct {
GUID string `json:"id"` // unique svc id
......
......@@ -44,6 +44,13 @@ THE SOFTWARE.
package schemas
// MQTTConfig contains the host and port configuration of the broker and indicates if it is active
type MQTTConfig struct {
Active bool `json:"active"` // indicates if MQTT is active/usable
Host string `json:"host,omitempty"` // hostname of MQTT
Port int `json:"port,omitempty"` // port of MQTT
}
// MQTTMessage struct representing mqtt message
type MQTTMessage struct {
Topic string // Topic of message
......
......@@ -48,12 +48,15 @@ import (
"time"
)
// LogConfig contains configuration of logging service
type LogConfig struct {
Msg bool `json:"msg"` // activation of msg log topic
App bool `json:"app"` // activation of app log topic
Status bool `json:"status"` // activation of status log topic
Debug bool `json:"debug"` // activation of debug log topic
// LoggerConfig contains configuration of logger service
type LoggerConfig struct {
Active bool `json:"active"` // indicates if logger is active/usable
TopicMsg bool `json:"msg,omitempty"` // activation of msg log topic
TopicApp bool `json:"app,omitempty"` // activation of app log topic
TopicStatus bool `json:"status,omitempty"` // activation of status log topic
TopicDebug bool `json:"debug,omitempty"` // activation of debug log topic
Host string `json:"host,omitempty"` // hostname of Logger
Port int `json:"port,omitempty"` // port of Logger
}
// LogMessage contains data of a single agent log message
......
Markdown is supported
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