Developing lightweight computation at the DSG edge

Commit 3b7fe667 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[fetch] Happy linting


Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent fb15bf70
...@@ -261,55 +261,56 @@ func main() { ...@@ -261,55 +261,56 @@ func main() {
// } // }
// Read current AntidoteDB devices // Read current AntidoteDB devices
antidote_devices := readDevicesFromAntidote() antidoteDevices := readDevicesFromAntidote()
// Export devices and their addresses to AntidoteDB // Export devices and their addresses to AntidoteDB
antidote_dev_succ := 0 antidoteDevSucc := 0
antidote_dev_fail := 0 antidoteDevFail := 0
//antidote_add_succ := 0 //antidoteAddSucc := 0
//antidote_add_fail := 0 //antidoteAddFail := 0
antidote_del_succ := 0 antidoteDelSucc := 0
antidote_del_fail := 0 antidoteDelFail := 0
// Remove from AntidoteDB those devices that are not in the CNML file anymore // Remove from AntidoteDB those devices that are not in the CNML file anymore
for _, v := range antidote_devices { for _, v := range antidoteDevices {
if !isDeviceInArray(v, alldevices) { if !isDeviceInArray(v, alldevices) {
if removeDeviceFromAntidote(v) { if removeDeviceFromAntidote(v) {
antidote_del_succ++ antidoteDelSucc++
} else { } else {
antidote_del_fail++ antidoteDelFail++
} }
fmt.Printf("\r%d devices removed from AntidoteDB (%d success, %d fail)", antidote_del_succ+antidote_del_fail, antidote_del_succ, antidote_del_fail) fmt.Printf("\r%d devices removed from AntidoteDB (%d success, %d fail)", antidoteDelSucc+antidoteDelFail, antidoteDelSucc, antidoteDelFail)
} }
} }
fmt.Printf("\r%d devices removed from AntidoteDB (%d success, %d fail)\n", antidoteDelSucc+antidoteDelFail, antidoteDelSucc, antidoteDelFail)
// Add to AntidoteDB those devices that are new in the CNML file // Add to AntidoteDB those devices that are new in the CNML file
for k, v := range alldevices { for _, v := range alldevices {
if !isDeviceInArray(v, antidote_devices) { if !isDeviceInArray(v, antidoteDevices) {
if saveDeviceToAntidote(v.ID) { if saveDeviceToAntidote(v.ID) {
antidote_dev_succ++ antidoteDevSucc++
} else { } else {
antidote_dev_fail++ antidoteDevFail++
} }
fmt.Printf("\r%d devices exported to AntidoteDB (%d success, %d fail)", k, antidote_dev_succ, antidote_dev_fail) fmt.Printf("\r%d devices exported to AntidoteDB (%d success, %d fail)", antidoteDevSucc+antidoteDevFail, antidoteDevSucc, antidoteDevFail)
//fmt.Printf("%d addresses exported to AntidoteDB (%d success, %d fail)", antidote_add_succ+antidote_add_fail, antidote_add_succ, antidote_add_fail)
} }
} }
fmt.Printf("\r%d devices exported to AntidoteDB (%d success, %d fail)\n", antidoteDevSucc+antidoteDevFail, antidoteDevSucc, antidoteDevFail)
// if saveDeviceToAntidote(v.ID) { // if saveDeviceToAntidote(v.ID) {
// antidote_dev_succ++ // antidoteDevSucc++
// } else { // } else {
// antidote_dev_fail++ // antidoteDevFail++
// } // }
// for _, w := range v.Interfaces { // for _, w := range v.Interfaces {
// if saveDeviceIpv4ToAntidote(v.ID, w.Ipv4) { // if saveDeviceIpv4ToAntidote(v.ID, w.Ipv4) {
// antidote_add_succ++ // antidoteAddSucc++
// } else { // } else {
// antidote_add_fail++ // antidoteAddFail++
// } // }
// //
// } // }
// fmt.Printf("\033[1A\r%d devices exported to AntidoteDB (%d success, %d fail)\n", k, antidote_dev_succ, antidote_dev_fail) // fmt.Printf("\033[1A\r%d devices exported to AntidoteDB (%d success, %d fail)\n", k, antidoteDevSucc, antidoteDevFail)
// fmt.Printf("%d addresses exported to AntidoteDB (%d success, %d fail)", antidote_add_succ+antidote_add_fail, antidote_add_succ, antidote_add_fail) // fmt.Printf("%d addresses exported to AntidoteDB (%d success, %d fail)", antidoteAddSucc+antidoteAddFail, antidoteAddSucc, antidoteAddFail)
// } // }
} }
...@@ -530,9 +531,9 @@ func removeDeviceFromAntidote(device Device) bool { ...@@ -530,9 +531,9 @@ func removeDeviceFromAntidote(device Device) bool {
if response.StatusCode == http.StatusOK { if response.StatusCode == http.StatusOK {
bodyBytes, err := ioutil.ReadAll(response.Body) bodyBytes, err := ioutil.ReadAll(response.Body)
errCheck(err) errCheck(err)
rest_reply := string(bodyBytes) restReply := string(bodyBytes)
if rest_reply == "ok" { if restReply == "ok" {
//fmt.Println("Success!") //fmt.Println("Success!")
} }
return true return true
...@@ -555,12 +556,12 @@ func readDevicesFromAntidote() []Device { ...@@ -555,12 +556,12 @@ func readDevicesFromAntidote() []Device {
bodyBytes, err := ioutil.ReadAll(response.Body) bodyBytes, err := ioutil.ReadAll(response.Body)
errCheck(err) errCheck(err)
var string_rest_reply []string var string_restReply []string
err = json.Unmarshal(bodyBytes, &string_rest_reply) err = json.Unmarshal(bodyBytes, &string_restReply)
errCheck(err) errCheck(err)
for _, v := range string_rest_reply { for _, v := range string_restReply {
this_dev_id, err := strconv.Atoi(v) this_dev_id, err := strconv.Atoi(v)
errCheck(err) errCheck(err)
var this_dev Device var this_dev Device
...@@ -587,9 +588,9 @@ func saveDeviceToAntidote(ID int) bool { ...@@ -587,9 +588,9 @@ func saveDeviceToAntidote(ID int) bool {
if response.StatusCode == http.StatusOK { if response.StatusCode == http.StatusOK {
bodyBytes, err := ioutil.ReadAll(response.Body) bodyBytes, err := ioutil.ReadAll(response.Body)
errCheck(err) errCheck(err)
rest_reply := string(bodyBytes) restReply := string(bodyBytes)
if rest_reply == "ok" { if restReply == "ok" {
//fmt.Println("Success!") //fmt.Println("Success!")
} }
return true return true
...@@ -611,9 +612,9 @@ func saveDeviceIpv4ToAntidote(ID int, Ipv4 string) bool { ...@@ -611,9 +612,9 @@ func saveDeviceIpv4ToAntidote(ID int, Ipv4 string) bool {
if response.StatusCode == http.StatusOK { if response.StatusCode == http.StatusOK {
bodyBytes, err := ioutil.ReadAll(response.Body) bodyBytes, err := ioutil.ReadAll(response.Body)
errCheck(err) errCheck(err)
rest_reply := string(bodyBytes) restReply := string(bodyBytes)
if rest_reply == "ok" { if restReply == "ok" {
//fmt.Println("Success!") //fmt.Println("Success!")
} }
return true return true
......
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