minor bug fixes for netfile and commands
Change-Id: I023e5066b13906316837be82568ace276b982460
diff --git a/library/netfile.py b/library/netfile.py
index 5d24c02..0df2bea 100755
--- a/library/netfile.py
+++ b/library/netfile.py
@@ -29,11 +29,16 @@
# the highest priority of change is returned, i.e. if there is both
# a semantic and non-semantic change a 1 is returned indicating a
# semantic change.
+def value_equal(left, right):
+ if type(left) == type(right):
+ return left == right
+ return str(left) == str(right)
+
def compare(have, want):
result = 0
for key in list(set().union(have.keys(), want.keys())):
if key in have.keys() and key in want.keys():
- if have[key] != want[key]:
+ if not value_equal(have[key], want[key]):
if key in ["description"]:
result = -1
else:
diff --git a/roles/head-node/files/commands/cord-prov b/roles/head-node/files/commands/cord-prov
index 42e6fc3..a0881fe 100755
--- a/roles/head-node/files/commands/cord-prov
+++ b/roles/head-node/files/commands/cord-prov
@@ -42,12 +42,12 @@
done
if [ $DO_JSON -eq 1 ]; then
if [ $DO_MAP -eq 1 ]; then
- curl -sSL http://$CORD_HEAD_NODE:4243/provision/ | jq -c -M 'def STATUS: ["Unknown","Processing","Complete","Error"]; [ .[] | . | .status|=STATUS[.] ]'
+ curl -sSL http://$CORD_HEAD_NODE:4243/provision/ | jq -c -M 'def STATUS: ["Pending","Processing","Complete","Error"]; [ .[] | . | .status|=STATUS[.] ]'
else
curl -sSL http://$CORD_HEAD_NODE:4243/provision/
fi
else
- for LINE in "ID,NAME,MAC,IP,STATUS,MESSAGE" $(curl -sSL http://$CORD_HEAD_NODE:4243/provision/ | jq 'def STATUS: ["Unknown","Processing","Complete","Error"]; .[] | . | .status|=STATUS[.] | .request.Info.id+","+.request.Info.name+","+.request.Info.mac+","+.request.Info.ip+","+.status+","+.message' | sed -e 's/ /__SPACE__/g'); do
+ for LINE in "ID,NAME,MAC,IP,STATUS,MESSAGE" $(curl -sSL http://$CORD_HEAD_NODE:4243/provision/ | jq 'def STATUS: ["Pending","Processing","Complete","Error"]; .[] | . | .status|=STATUS[.] | .request.Info.id+","+.request.Info.name+","+.request.Info.mac+","+.request.Info.ip+","+.status+","+.message' | sed -e 's/ /__SPACE__/g'); do
echo $LINE | sed -e 's/__SPACE__/ /g' -e 's/^"//;s/"$//'
done | column -s , -t
fi
@@ -72,7 +72,7 @@
;;
*)
ID="$ID $1"
- ;;
+ ;;
esac
shift
done
@@ -80,7 +80,7 @@
if [ $DO_MAP -eq 1 ]; then
echo -n "["
for i in $ID; do
- curl -sSL http://$CORD_HEAD_NODE:4243/provision/$i | jq -c -M 'def STATUS: ["Unknown","Processing","Complete","Error"]; . | .status|=STATUS[.]'
+ curl -sSL http://$CORD_HEAD_NODE:4243/provision/$i | jq -c -M 'def STATUS: ["Pending","Processing","Complete","Error"]; . | .status|=STATUS[.]'
done | awk -vORS=, '{ print }' | sed 's/,$//'
echo -n "]"
else
@@ -99,7 +99,7 @@
if [ $? -ne 0 ]; then
echo "$i, , , ,Not Found"
else
- echo "$VALUE" | jq 'def STATUS: ["Unknown","Processing","Complete","Error"]; . | .status|=STATUS[.] | .request.Info.id+","+.request.Info.name+","+.request.Info.mac+","+.request.Info.ip+","+.status+","+.message'| sed -e 's/^"//;s/"$//'
+ echo "$VALUE" | jq 'def STATUS: ["Pending","Processing","Complete","Error"]; . | .status|=STATUS[.] | .request.Info.id+","+.request.Info.name+","+.request.Info.mac+","+.request.Info.ip+","+.status+","+.message'| sed -e 's/^"//;s/"$//'
fi
fi
done | column -s , -t