aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/tools/test/bin/onos-gen-partitions
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/tools/test/bin/onos-gen-partitions')
-rwxr-xr-xframework/src/onos/tools/test/bin/onos-gen-partitions20
1 files changed, 12 insertions, 8 deletions
diff --git a/framework/src/onos/tools/test/bin/onos-gen-partitions b/framework/src/onos/tools/test/bin/onos-gen-partitions
index 35195b04..5da0807d 100755
--- a/framework/src/onos/tools/test/bin/onos-gen-partitions
+++ b/framework/src/onos/tools/test/bin/onos-gen-partitions
@@ -1,19 +1,20 @@
-#!/usr/bin/env python
-'''
+#!/usr/bin/env python
+"""
Generate the partitions json file from the $OC* environment variables
-
+
Usage: onos-gen-partitions [output file]
If output file is not provided, the json is written to stdout.
-'''
+"""
from os import environ
from collections import deque, OrderedDict
import re
import json
import sys
+import hashlib
-convert = lambda text: int(text) if text.isdigit() else text.lower()
-alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
+convert = lambda text: int(text) if text.isdigit() else text.lower()
+alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
def get_OC_vars():
vars = []
@@ -42,10 +43,13 @@ if __name__ == '__main__':
vars = get_OC_vars()
nodes = get_nodes(vars)
partitions = generate_permutations([v.get('id') for v in nodes], 3)
+ name = 0
+ for node in nodes:
+ name = name ^ hash(node['ip'])
data = {
- 'name': 'default',
+ 'name': name,
'nodes': nodes,
- 'partitions': partitions
+ 'partitions': partitions
}
output = json.dumps(data, indent=4)