Selaa lähdekoodia

20171124 src/nodes2prom.sml (Test, ob nodes.json version = 1; label fuer den Firmware branch ergänzt)

Altlast 7 vuotta sitten
vanhempi
commit
c5267c1ce5
1 muutettua tiedostoa jossa 7 lisäystä ja 1 poistoa
  1. 7 1
      src/nodes2prom.sml

+ 7 - 1
src/nodes2prom.sml

@@ -108,6 +108,8 @@ struct
 		in Date.toTime tsdate
 		end
 
+	fun get_version obj = JU.asInt (JU.lookupField obj "version")
+
 	fun get_timestamp obj =
 		let val tsstring = JU.asString (JU.lookupField obj "timestamp")
 		    val tstime = timestring2time tsstring
@@ -141,6 +143,7 @@ struct
 			   | NONE => (NONE, NONE)
 		    val software = JU.lookupField nodeinfo "software"
 		    val autoupdater = JU.asBool (JU.lookupField (JU.lookupField software "autoupdater") "enabled")
+		    val branch = JU.asString (JU.lookupField (JU.lookupField software "autoupdater") "branch")
 		    val fastd = JU.asBool (JU.lookupField (JU.lookupField software "fastd") "enabled")
 		    val firmware = JU.asString (JU.lookupField (JU.lookupField software "firmware") "release")
 		    val base = JU.asString (JU.lookupField (JU.lookupField software "firmware") "base")
@@ -180,6 +183,7 @@ struct
 			longitude = longitude,
 			latitude = latitude,
 			autoupdater = autoupdater,
+			branch = branch,
 			gateway = gateway,
 			fastd = fastd,
 			firmware = firmware,
@@ -224,7 +228,7 @@ struct
 			 items
 		end
 
-	fun node_info {	hostname, online, node_id, interfaces, longitude, latitude, autoupdater, fastd, gateway, firmware, base, model, lastseen, firstseen } =
+	fun node_info {	hostname, online, node_id, interfaces, longitude, latitude, autoupdater, branch, fastd, gateway, firmware, base, model, lastseen, firstseen } =
 		let val minitems = [
 				("hostname", hostname),
 				("node_id", node_id)]
@@ -237,6 +241,7 @@ struct
 						of NONE => "NaN"
 						 | SOME l => Real.toString l),
 				("autoupdater", Bool.toString autoupdater),
+				("branch", branch),
 				("fastd", Bool.toString fastd),
 				("gateway", gateway),
 				("firmware", firmware),
@@ -272,6 +277,7 @@ struct
 
 	fun main (p, [inf]) =
 		(let val json = JP.parseFile inf
+		     val _ = get_version json = 1 orelse raise Fail "version must be 1"
 		     val _ = get_timestamp json
 		     val nodes_json = get_nodes json
 				      handle exn => (json_handler "get_nodes" exn ; raise Fail "get_nodes")