diff options
author | Ben Pfaff <blp@nicira.com> | 2011-05-24 12:32:01 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-05-24 12:32:01 -0700 |
commit | d5a59e7e9ef3fdfc7dc7d4a80cbde6b524c5100b (patch) | |
tree | 1754d1898afc55f10fb8f03ba70a57a37ee0ce26 /ovsdb | |
parent | 959ec62e324d88e47930379d3f0d196119595de9 (diff) |
ovsdb: Annotate E-R diagram with number of allowed values.
This makes the diagram even more informative.
Diffstat (limited to 'ovsdb')
-rwxr-xr-x | ovsdb/ovsdb-doc.in | 4 | ||||
-rwxr-xr-x | ovsdb/ovsdb-dot.in | 25 |
2 files changed, 23 insertions, 6 deletions
diff --git a/ovsdb/ovsdb-doc.in b/ovsdb/ovsdb-doc.in index 5ba4e716..3c825d2a 100755 --- a/ovsdb/ovsdb-doc.in +++ b/ovsdb/ovsdb-doc.in @@ -293,7 +293,9 @@ The following diagram shows the relationship among tables in the database. Each node represents a table. Tables that are part of the ``root set'' are shown with double borders. Each edge leads from the table that contains it and points to the table that its value -represents. Edges are labeled with their column names. Thick lines +represents. Edges are labeled with their column names, followed by a +constraint on the number of allowed values: \\fB?\\fR for zero or one, +\\fB*\\fR for zero or more, \\fB+\\fR for one or more. Thick lines represent strong references; thin lines represent weak references. .RS -1in """ diff --git a/ovsdb/ovsdb-dot.in b/ovsdb/ovsdb-dot.in index d4172862..30da1cb3 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(): |