Developing lightweight computation at the DSG edge

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

[fetch] Allow specyfing the input CNML file


Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent 3b7fe667
......@@ -6,6 +6,7 @@ import (
"crypto/sha256"
"encoding/json"
"encoding/xml"
"flag"
"fmt"
"io/ioutil"
"net"
......@@ -132,9 +133,25 @@ type DeviceAddressesServer struct {
GraphServer int
}
//Default settings and descriptions
var cnmlFile = "cnml.xml"
var cnmlFileHelp = "Filename of the XML file containing the CNML information of a zone"
func initialize() {
//Define and parse command line flags
cnmlFilePtr := flag.String("cnml_file", cnmlFile, cnmlFileHelp)
flag.Parse()
cnmlFile = *cnmlFilePtr
}
func main() {
xmlFile, err := os.Open("cnml.xml")
initialize()
xmlFile, err := os.Open(cnmlFile)
if err != nil {
fmt.Println("Error opening file:", err)
return
......@@ -556,18 +573,18 @@ func readDevicesFromAntidote() []Device {
bodyBytes, err := ioutil.ReadAll(response.Body)
errCheck(err)
var string_restReply []string
var stringRestReply []string
err = json.Unmarshal(bodyBytes, &string_restReply)
err = json.Unmarshal(bodyBytes, &stringRestReply)
errCheck(err)
for _, v := range string_restReply {
this_dev_id, err := strconv.Atoi(v)
for _, v := range stringRestReply {
thisDevID, err := strconv.Atoi(v)
errCheck(err)
var this_dev Device
this_dev.ID = this_dev_id
devices = append(devices, this_dev)
//println(v, this_dev_id)
var thisDev Device
thisDev.ID = thisDevID
devices = append(devices, thisDev)
//println(v, thisDevID)
}
}
......
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