Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions cmd/controller/config/config.go

This file was deleted.

22 changes: 0 additions & 22 deletions cmd/controller/config/config.yaml

This file was deleted.

26 changes: 5 additions & 21 deletions cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import (
"strings"
"time"

CConfig "github.com/omec-project/metricfunc/cmd/controller/config"
"github.com/omec-project/metricfunc/config"
"github.com/omec-project/metricfunc/internal/metricdata"
"github.com/omec-project/metricfunc/logger"
"golang.org/x/net/http2"
"gopkg.in/yaml.v2"
)

var ControllerConfig CConfig.Config
var ControllerConfig config.Config
var client *http.Client

//creating for testing
Expand Down Expand Up @@ -59,25 +58,10 @@ type SiteInfo struct {
SimCardDetails []SimCard `yaml:"sim-card,omitempty" json:"sim-card,omitempty"`
}

func InitConfigFactory(f string) error {
func InitControllerConfig(CConfig *config.Config) error {
ControllerConfig = *CConfig
//Read provided config
fmt.Printf("Controller has started with configuration file [%v]", f)

if content, err := ioutil.ReadFile(f); err != nil {
logger.ControllerLog.Errorln("Readfile failed called ", err)
return err
} else {
ControllerConfig = CConfig.Config{}

if yamlErr := yaml.Unmarshal(content, &ControllerConfig); yamlErr != nil {
logger.ControllerLog.Errorln("yaml parsing failed ", yamlErr)
return yamlErr
}
}
if ControllerConfig.Configuration == nil {
logger.ControllerLog.Errorln("Configuration Parsing Failed ", ControllerConfig.Configuration)
return nil
}
fmt.Printf("Controller configuration")

//set http client
if ControllerConfig.Info.HttpVersion == 2 {
Expand Down
25 changes: 13 additions & 12 deletions cmd/metricfunc/metricfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func main() {

//Read provided config
cfgFilePtr := flag.String("metrics", "../../config/config.yaml", "is a config file")
controllerCfgFilePtr := flag.String("cfg", "./config/config.yaml", "is a config file")
flag.Parse()
logger.AppLog.Infof("Metricfunction has started with configuration file [%v]", *cfgFilePtr)

Expand Down Expand Up @@ -73,19 +72,21 @@ func main() {
//Start Prometheus client
go promclient.StartPrometheusClient(&cfg.Configuration.PrometheusServer)

//controller
rogueIpChan := make(chan controller.RogueIPs, 100)
controller.InitConfigFactory(*controllerCfgFilePtr)
onosClient := controller.OnosService{
OnosServiceUrl: "http://" + controller.ControllerConfig.Configuration.OnosApiServer.Addr + ":" +
strconv.Itoa(controller.ControllerConfig.Configuration.OnosApiServer.Port),
PollInterval: controller.ControllerConfig.Configuration.OnosApiServer.PollInterval,
}
if cfg.Configuration.ControllerFlag {
//controller
rogueIpChan := make(chan controller.RogueIPs, 100)
controller.InitControllerConfig(&cfg)
onosClient := controller.OnosService{
OnosServiceUrl: "http://" + cfg.Configuration.OnosApiServer.Addr + ":" +
strconv.Itoa(cfg.Configuration.OnosApiServer.Port),
PollInterval: cfg.Configuration.OnosApiServer.PollInterval,
}

controller.RogueChannel = rogueIpChan
controller.RogueChannel = rogueIpChan

go onosClient.GetRogueIPs(rogueIpChan)
go controller.RogueIPHandler(rogueIpChan)
go onosClient.GetRogueIPs(rogueIpChan)
go controller.RogueIPHandler(rogueIpChan)
}

//Go Pprofiling
debugProfPort := cfg.Configuration.DebugProfile.Port
Expand Down
20 changes: 13 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,29 @@ type Config struct {
type Info struct {
Version string `yaml:"version,omitempty"`
Description string `yaml:"description,omitempty"`
HttpVersion int `yaml:"http-version,omitempty"`
}

type Logger struct {
LogLevel string `yaml:"level,omitempty"`
}

type Configuration struct {
NfStreams []NFStream `yaml:"nfStreams,omitempty"`
AnalyticsStream *AnalyticsStream `yaml:"analyticsStream,omitempty"`
ApiServer ServerAddr `yaml:"apiServer,omitempty"`
PrometheusServer ServerAddr `yaml:"prometheusServer,omitempty"`
DebugProfile ServerAddr `yaml:"debugProfileServer,omitempty"`
NfStreams []NFStream `yaml:"nfStreams,omitempty"`
AnalyticsStream *AnalyticsStream `yaml:"analyticsStream,omitempty"`
ApiServer ServerAddr `yaml:"apiServer,omitempty"`
PrometheusServer ServerAddr `yaml:"prometheusServer,omitempty"`
DebugProfile ServerAddr `yaml:"debugProfileServer,omitempty"`
OnosApiServer ServerAddr `yaml:"onosApiServer,omitempty"`
RocEndPoint ServerAddr `yaml:"rocEndPoint,omitempty"`
MetricFuncEndPoint ServerAddr `yaml:"metricFuncEndPoint,omitempty"`
ControllerFlag bool `yaml:"controllerFlag,omitempty"`
}

type ServerAddr struct {
Addr string `yaml:"addr,omitempty"` // IP used to run the server in the node.
Port int `yaml:"port,omitempty"`
Addr string `yaml:"addr,omitempty"` // IP used to run the server in the node.
Port int `yaml:"port,omitempty"`
PollInterval int `yaml:"pollInterval,omitempty"`
}

type Urls struct {
Expand Down
9 changes: 9 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ configuration:
debugProfileServer:
addr: "metricfunc"
port: 5001
onosApiServer:
addr: "onosapp"
port: 9301
rocEndPoint:
addr: "aether-roc-umbrella-aether-roc-gui-v2-1-external.aether-roc.svc"
port: 31194
metricFuncEndPoint:
addr: "metricfunc.omec.svc"
port: 5001