summaryrefslogtreecommitdiff
path: root/ovsdb/ovsdb-dot.in
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-05-24 12:32:01 -0700
committerBen Pfaff <blp@nicira.com>2011-05-24 12:32:01 -0700
commitd5a59e7e9ef3fdfc7dc7d4a80cbde6b524c5100b (patch)
tree1754d1898afc55f10fb8f03ba70a57a37ee0ce26 /ovsdb/ovsdb-dot.in
parent959ec62e324d88e47930379d3f0d196119595de9 (diff)
downloadopenvswitch-d5a59e7e9ef3fdfc7dc7d4a80cbde6b524c5100b.tar.gz
ovsdb: Annotate E-R diagram with number of allowed values.
This makes the diagram even more informative.
Diffstat (limited to 'ovsdb/ovsdb-dot.in')
-rwxr-xr-xovsdb/ovsdb-dot.in25
1 files changed, 20 insertions, 5 deletions
diff --git a/ovsdb/ovsdb-dot.in b/ovsdb/ovsdb-dot.in
index d41728627..30da1cb35 100755
--- a/ovsdb/ovsdb-dot.in
+++ b/ovsdb/ovsdb-dot.in
@@ -10,10 +10,25 @@ import sys
argv0 = sys.argv[0]
-def printEdge(tableName, baseType, label):
+def printEdge(tableName, type, baseType, label):
if baseType.ref_table:
+ if type.n_min == 0:
+ if type.n_max == 1:
+ arity = "?"
+ elif type.n_max == sys.maxint:
+ arity = "*"
+ else:
+ arity = "{,%d}" % type.n_max
+ elif type.n_min == 1:
+ if type.n_max == 1:
+ arity = ""
+ elif type.n_max == sys.maxint:
+ arity = "+"
+ else:
+ arity = "{1,%d}" % type.n_max
+
options = {}
- options['label'] = '"%s"' % label
+ options['label'] = '"%s%s"' % (label, arity)
if baseType.ref_type == 'weak':
options['constraint'] = 'false'
options['style'] = 'dotted'
@@ -39,10 +54,10 @@ def schemaToDot(schemaFile):
', '.join(['%s=%s' % (k,v) for k,v in options.items()]))
for columnName, column in table.columns.iteritems():
if column.type.value:
- printEdge(tableName, column.type.key, "%s key" % columnName)
- printEdge(tableName, column.type.value, "%s value" % columnName)
+ printEdge(tableName, column.type, column.type.key, "%s key" % columnName)
+ printEdge(tableName, column.type, column.type.value, "%s value" % columnName)
else:
- printEdge(tableName, column.type.key, columnName)
+ printEdge(tableName, column.type, column.type.key, columnName)
print "}";
def usage():