Developing lightweight computation at the DSG edge

Commit d01fb6c0 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[monitor-ping] Retrieve the list of devices assigned to the monitor


Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent 618d5591
......@@ -8,6 +8,7 @@ import (
"strconv"
"time"
"uc-monitor-go-test/cnml"
"uc-monitor-go-test/goclidote"
"github.com/golang/glog"
)
......@@ -118,11 +119,52 @@ func initializeFlags() {
}
}
func refreshAssignationList() {
localAssign = getLocalAssignationList()
for _, v := range localAssign {
fmt.Print("Device ")
fmt.Println(v.DeviceID)
}
}
//Import all the monitor=>device assignations
func getLocalAssignationList() []cnml.DeviceMonitorAssignation {
var newLocalAssign []cnml.DeviceMonitorAssignation
for _, v := range getGlobalAssignationList() {
for _, w := range v.MonitorID {
if w == ID {
newLocalAssign = append(newLocalAssign, v)
}
}
}
return newLocalAssign
}
func getCnmlDevicesList() []cnml.DeviceIpv4sGraphserver {
return goclidote.ReadDevicesFromAntidote(dbHost, dbPort)
}
func getGlobalAssignationList() []cnml.DeviceMonitorAssignation {
var globalAssign []cnml.DeviceMonitorAssignation
for _, v := range getCnmlDevicesList() {
{
var newDev cnml.DeviceMonitorAssignation
newDev.DeviceID = v.ID
newDev.MonitorID = goclidote.AntidoteReadItemsFromSetInBucket(fmt.Sprintf("device-%d", v.ID), "monitors", dbHost, dbPort)
globalAssign = append(globalAssign, newDev)
}
}
return globalAssign
}
func startLocalAssignTimer() {
localAssignTicker := time.NewTicker(time.Duration(localAssignCheckInterval) * time.Second)
go func() {
for range localAssignTicker.C {
fmt.Println("Hi!")
refreshAssignationList()
}
}()
}
......
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