Commit 9234f346 authored by Robert Ricci's avatar Robert Ricci

Introduce a DELTA for doing comparisons of lat/long.

Note: I can't figure out how to get python to let me put linebreaks
into if conditionals. So, there's one nast long line right now - if
someone who knows python better could fix this, great!
parent b1f3b14f
......@@ -90,6 +90,10 @@ ATTR_NIL_VALUES = ('None',)
# identify a planetlab node
ATTR_CRIT_KEYS = ('HNAME', 'IP', 'PLABID', 'MAC',)
# The amount by which latitude and longitude are allowed to differ before we
# classify them ask changed
LATLONG_DELTA = 0.001
PLABNODE = "@prefix@/sbin/plabnode"
SSH = "@prefix@/bin/sshtb"
NAMED_SETUP = "@prefix@/sbin/named_setup"
......@@ -433,6 +437,14 @@ class Plab:
for attr in ent:
if ent[attr] in ATTR_NIL_VALUES:
continue
elif (attr == "LATITUDE") or (attr == "LONGITUDE"):
# Special rules for latitude and longitude to avoid
# FP errors
if (ent[attr] != None and plabent[attr] != None) and (ent[attr] != "" and plabent[attr] != "") and ((float(ent[attr]) > (float(plabent[attr]) + LATLONG_DELTA)) or (float(ent[attr]) < (float(plabent[attr]) - LATLONG_DELTA))):
diff[attr] = (ent[attr], plabent[attr])
else:
same[attr] = ent[attr]
pass
elif ent[attr] == plabent[attr]:
same[attr] = ent[attr]
pass
......
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