Developing lightweight computation at the DSG edge

Commit 6c30de93 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[fetch] Switch to Go client instead of API REST



Sorry, João :(
Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 241a5fd7
......@@ -12,8 +12,8 @@ import (
"strconv"
"strings"
"uc-monitor-go-test/apidote"
"uc-monitor-go-test/cnml"
"uc-monitor-go-test/goclidote"
)
//Default settings and descriptions
......@@ -178,7 +178,7 @@ func main() {
fmt.Println(len(cnmlDevsIpv4sGraphs), "devices exported to", dasfile.Name())
// Read current AntidoteDB devices
antidoteDevices := apidote.ReadDevicesFromAntidote()
antidoteDevices := goclidote.ReadDevicesFromAntidote()
var oldAntidoteDevices []cnml.DeviceIpv4sGraphserver
var keepAntidoteDevices []cnml.DeviceIpv4sGraphserver
......@@ -538,13 +538,13 @@ func getZonesInZoneExc(zone cnml.Zone) []cnml.Zone {
// Remove a device by its ID from Antidote using João's REST server
func removeDeviceFromAntidote(ID int) bool {
return apidote.AntidoteRemoveItemFromSetInBucket("guifi", "devices", strconv.Itoa(ID))
return goclidote.AntidoteRemoveItemFromSetInBucket("guifi", "devices", strconv.Itoa(ID))
}
// Read all the devices from Antidote using João's REST server
func readDeviceIpv4AddressesFromAntidote(device cnml.DeviceIpv4Adddresses) cnml.DeviceIpv4Adddresses {
for _, v := range apidote.AntidoteReadItemsFromSetInBucket("guifi", fmt.Sprintf("device-%d", device.ID)) {
for _, v := range goclidote.AntidoteReadItemsFromSetInBucket("guifi", fmt.Sprintf("device-%d", device.ID)) {
device.Addresses = append(device.Addresses, v)
}
......@@ -554,7 +554,7 @@ func readDeviceIpv4AddressesFromAntidote(device cnml.DeviceIpv4Adddresses) cnml.
// Read all the devices from Antidote using João's REST server
func readDeviceIpv4sGraphserverFromAntidote(device cnml.DeviceIpv4sGraphserver) cnml.DeviceIpv4sGraphserver {
for _, v := range apidote.AntidoteReadItemsFromSetInBucket("guifi", fmt.Sprintf("device-%d", device.ID)) {
for _, v := range goclidote.AntidoteReadItemsFromSetInBucket("guifi", fmt.Sprintf("device-%d", device.ID)) {
device.Addresses = append(device.Addresses, v)
}
......@@ -563,39 +563,39 @@ func readDeviceIpv4sGraphserverFromAntidote(device cnml.DeviceIpv4sGraphserver)
// Save a device ID to Antidote using João's REST server
func saveDeviceToAntidote(device cnml.DeviceIpv4Adddresses) bool {
return apidote.AntidoteAddItemToSetInBucket("guifi", "devices", fmt.Sprintf("%d", device.ID))
return goclidote.AntidoteAddItemToSetInBucket("guifi", "devices", fmt.Sprintf("%d", device.ID))
}
// Save a device ID to Antidote using João's REST server
func saveDeviceIpv4sGraphserverToAntidote(device cnml.DeviceIpv4sGraphserver) bool {
return apidote.AntidoteAddItemToSetInBucket("guifi", "devices", fmt.Sprintf("%d", device.ID))
return goclidote.AntidoteAddItemToSetInBucket("guifi", "devices", fmt.Sprintf("%d", device.ID))
}
// Save an IPv4 address to a device
func saveIpv4addresToDeviceToAntidote(device cnml.DeviceIpv4Adddresses, address string) bool {
return apidote.AntidoteAddItemToSetInBucket("guifi", fmt.Sprintf("device-%d", device.ID), address)
return goclidote.AntidoteAddItemToSetInBucket("guifi", fmt.Sprintf("device-%d", device.ID), address)
}
// Save an IPv4 address to a device
func saveIpv4addressToDeviceIpv4sGraphserverToAntidote(device cnml.DeviceIpv4sGraphserver, address string) bool {
return apidote.AntidoteAddItemToSetInBucket(fmt.Sprintf("device-%d", device.ID), "ipv4s", address)
return goclidote.AntidoteAddItemToSetInBucket(fmt.Sprintf("device-%d", device.ID), "ipv4s", address)
}
// Save the GraphServer to a device
func saveGraphserverToDeviceIpv4sGraphserverToAntidote(device cnml.DeviceIpv4sGraphserver) bool {
return apidote.AntidoteSetRegisterInBucket(fmt.Sprintf("device-%d", device.ID), "graphserver", strconv.Itoa(device.GraphServer))
return goclidote.AntidoteSetRegisterInBucket(fmt.Sprintf("device-%d", device.ID), "graphserver", strconv.Itoa(device.GraphServer))
}
func removeGraphserverFromDeviceIpv4sGraphserver(device cnml.DeviceIpv4sGraphserver) bool {
return apidote.AntidoteRemoveRegisterInBucket(fmt.Sprintf("device-%d", device.ID), "graphserver")
return goclidote.AntidoteRemoveRegisterInBucket(fmt.Sprintf("device-%d", device.ID), "graphserver")
}
func removeIpv4addressFromDeviceIpv4Adddresses(device cnml.DeviceIpv4Adddresses, address string) bool {
return apidote.AntidoteRemoveItemFromSetInBucket(fmt.Sprintf("device-%d", device.ID), "ipv4s", address)
return goclidote.AntidoteRemoveItemFromSetInBucket(fmt.Sprintf("device-%d", device.ID), "ipv4s", address)
}
func removeIpv4addressFromDeviceIpv4sGraphserver(device cnml.DeviceIpv4sGraphserver, address string) bool {
return apidote.AntidoteRemoveItemFromSetInBucket(fmt.Sprintf("device-%d", device.ID), "ipv4s", address)
return goclidote.AntidoteRemoveItemFromSetInBucket(fmt.Sprintf("device-%d", device.ID), "ipv4s", address)
}
// Compare two arrays of strings
......
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