diff options
10 files changed, 1677 insertions, 1 deletions
diff --git a/recipes-networking/openvswitch/openvswitch-git/0001-Python3-compatibility-Convert-print-statements.patch b/recipes-networking/openvswitch/openvswitch-git/0001-Python3-compatibility-Convert-print-statements.patch new file mode 100644 index 00000000..d6197588 --- /dev/null +++ b/recipes-networking/openvswitch/openvswitch-git/0001-Python3-compatibility-Convert-print-statements.patch | |||
| @@ -0,0 +1,1264 @@ | |||
| 1 | From c5c18f9c5f1b7217d43af43be9736c1762c7ebba Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jason Wessel <jason.wessel@windriver.com> | ||
| 3 | Date: Thu, 29 Jun 2017 20:33:23 -0700 | ||
| 4 | Subject: [PATCH 1/8] Python3 compatibility: Convert print statements | ||
| 5 | |||
| 6 | Commit d34a1cc02536f9a812517a71accec3fbd3c6c98b from | ||
| 7 | https://github.com/openvswitch/ovs.git | ||
| 8 | |||
| 9 | This patch fixes up all the print statements to work with python3 or | ||
| 10 | python2. | ||
| 11 | |||
| 12 | Signed-off-by: Jason Wessel <jason.wessel@windriver.com> | ||
| 13 | Signed-off-by: Ben Pfaff <blp@ovn.org> | ||
| 14 | --- | ||
| 15 | build-aux/check-structs | 4 +- | ||
| 16 | build-aux/extract-ofp-actions | 68 +++--- | ||
| 17 | build-aux/extract-ofp-errors | 2 +- | ||
| 18 | build-aux/extract-ofp-fields | 2 +- | ||
| 19 | build-aux/extract-ofp-msgs | 6 +- | ||
| 20 | ovsdb/ovsdb-doc | 6 +- | ||
| 21 | ovsdb/ovsdb-idlc.in | 523 +++++++++++++++++++++--------------------- | ||
| 22 | 7 files changed, 306 insertions(+), 305 deletions(-) | ||
| 23 | |||
| 24 | diff --git a/build-aux/check-structs b/build-aux/check-structs | ||
| 25 | index f79f235..bae511f 100755 | ||
| 26 | --- a/build-aux/check-structs | ||
| 27 | +++ b/build-aux/check-structs | ||
| 28 | @@ -211,7 +211,7 @@ def checkStructs(): | ||
| 29 | |||
| 30 | if '--help' in sys.argv: | ||
| 31 | argv0 = os.path.basename(sys.argv[0]) | ||
| 32 | - print '''\ | ||
| 33 | + print('''\ | ||
| 34 | %(argv0)s, for checking struct and struct member alignment | ||
| 35 | usage: %(argv0)s -Ipath HEADER [HEADER]... | ||
| 36 | |||
| 37 | @@ -226,7 +226,7 @@ assertions using OFP_ASSERT. | ||
| 38 | |||
| 39 | This program is specialized for reading Open vSwitch's OpenFlow header | ||
| 40 | files. It will not work on arbitrary header files without extensions.\ | ||
| 41 | -''' % {"argv0": argv0} | ||
| 42 | +''' % {"argv0": argv0}) | ||
| 43 | sys.exit(0) | ||
| 44 | |||
| 45 | global fileName | ||
| 46 | diff --git a/build-aux/extract-ofp-actions b/build-aux/extract-ofp-actions | ||
| 47 | index 0062ab8..874e6b4 100755 | ||
| 48 | --- a/build-aux/extract-ofp-actions | ||
| 49 | +++ b/build-aux/extract-ofp-actions | ||
| 50 | @@ -67,7 +67,7 @@ def fatal(msg): | ||
| 51 | |||
| 52 | def usage(): | ||
| 53 | argv0 = os.path.basename(sys.argv[0]) | ||
| 54 | - print ('''\ | ||
| 55 | + print('''\ | ||
| 56 | %(argv0)s, for extracting OpenFlow action data | ||
| 57 | usage: %(argv0)s OFP_ACTIONS.C [--prototypes | --definitions] | ||
| 58 | |||
| 59 | @@ -238,36 +238,36 @@ def extract_ofp_actions(fn, definitions): | ||
| 60 | if n_errors: | ||
| 61 | sys.exit(1) | ||
| 62 | |||
| 63 | - print """\ | ||
| 64 | + print("""\ | ||
| 65 | /* Generated automatically; do not modify! -*- buffer-read-only: t -*- */ | ||
| 66 | -""" | ||
| 67 | +""") | ||
| 68 | |||
| 69 | if definitions: | ||
| 70 | - print "/* Verify that structs used as actions are reasonable sizes. */" | ||
| 71 | + print("/* Verify that structs used as actions are reasonable sizes. */") | ||
| 72 | for s in sorted(arg_structs): | ||
| 73 | - print "BUILD_ASSERT_DECL(sizeof(%s) %% OFP_ACTION_ALIGN == 0);" % s | ||
| 74 | + print("BUILD_ASSERT_DECL(sizeof(%s) %% OFP_ACTION_ALIGN == 0);" % s) | ||
| 75 | |||
| 76 | - print "\nstatic struct ofpact_raw_instance all_raw_instances[] = {" | ||
| 77 | + print("\nstatic struct ofpact_raw_instance all_raw_instances[] = {") | ||
| 78 | for vendor in domain: | ||
| 79 | for type_ in domain[vendor]: | ||
| 80 | for version in domain[vendor][type_]: | ||
| 81 | d = domain[vendor][type_][version] | ||
| 82 | - print " { { 0x%08x, %2d, 0x%02x }, " % ( | ||
| 83 | - vendor, type_, version) | ||
| 84 | - print " %s," % d["enum"] | ||
| 85 | - print " HMAP_NODE_NULL_INITIALIZER," | ||
| 86 | - print " HMAP_NODE_NULL_INITIALIZER," | ||
| 87 | - print " %s," % d["min_length"] | ||
| 88 | - print " %s," % d["max_length"] | ||
| 89 | - print " %s," % d["arg_ofs"] | ||
| 90 | - print " %s," % d["arg_len"] | ||
| 91 | - print " \"%s\"," % re.sub('_RAW[0-9]*', '', d["enum"], 1) | ||
| 92 | + print(" { { 0x%08x, %2d, 0x%02x }, " % ( | ||
| 93 | + vendor, type_, version)) | ||
| 94 | + print(" %s," % d["enum"]) | ||
| 95 | + print(" HMAP_NODE_NULL_INITIALIZER,") | ||
| 96 | + print(" HMAP_NODE_NULL_INITIALIZER,") | ||
| 97 | + print(" %s," % d["min_length"]) | ||
| 98 | + print(" %s," % d["max_length"]) | ||
| 99 | + print(" %s," % d["arg_ofs"]) | ||
| 100 | + print(" %s," % d["arg_len"]) | ||
| 101 | + print(" \"%s\"," % re.sub('_RAW[0-9]*', '', d["enum"], 1)) | ||
| 102 | if d["deprecation"]: | ||
| 103 | - print " \"%s\"," % re.sub(r'(["\\])', r'\\\1', d["deprecation"]) | ||
| 104 | + print(" \"%s\"," % re.sub(r'(["\\])', r'\\\1', d["deprecation"])) | ||
| 105 | else: | ||
| 106 | - print " NULL," | ||
| 107 | - print " }," | ||
| 108 | - print "};"; | ||
| 109 | + print(" NULL,") | ||
| 110 | + print(" },") | ||
| 111 | + print("};") | ||
| 112 | |||
| 113 | for versions in enums.values(): | ||
| 114 | need_ofp_version = False | ||
| 115 | @@ -314,11 +314,11 @@ def extract_ofp_actions(fn, definitions): | ||
| 116 | decl += "}" | ||
| 117 | else: | ||
| 118 | decl += ";" | ||
| 119 | - print decl | ||
| 120 | |||
| 121 | + print(decl) | ||
| 122 | + print("") | ||
| 123 | |||
| 124 | if definitions: | ||
| 125 | - print """\ | ||
| 126 | + print("""\ | ||
| 127 | static enum ofperr | ||
| 128 | ofpact_decode(const struct ofp_action_header *a, enum ofp_raw_action_type raw, | ||
| 129 | enum ofp_version version, uint64_t arg, | ||
| 130 | @@ -326,14 +326,14 @@ ofpact_decode(const struct ofp_action_header *a, enum ofp_raw_action_type raw, | ||
| 131 | uint64_t *tlv_bitmap, struct ofpbuf *out) | ||
| 132 | { | ||
| 133 | switch (raw) {\ | ||
| 134 | -""" | ||
| 135 | +""") | ||
| 136 | for versions in enums.values(): | ||
| 137 | enum = versions[0]["enum"] | ||
| 138 | - print " case %s:" % enum | ||
| 139 | + print(" case %s:" % enum) | ||
| 140 | base_argtype = versions[0]["base_argtype"] | ||
| 141 | arg_vl_mff_map = versions[0]["arg_vl_mff_map"] | ||
| 142 | if base_argtype == 'void': | ||
| 143 | - print " return decode_%s(out);" % enum | ||
| 144 | + print(" return decode_%s(out);" % enum) | ||
| 145 | else: | ||
| 146 | if base_argtype.startswith('struct'): | ||
| 147 | arg = "ALIGNED_CAST(const %s *, a)" % base_argtype | ||
| 148 | @@ -344,16 +344,16 @@ ofpact_decode(const struct ofp_action_header *a, enum ofp_raw_action_type raw, | ||
| 149 | else: | ||
| 150 | arg = "arg" | ||
| 151 | if arg_vl_mff_map: | ||
| 152 | - print " return decode_%s(%s, version, vl_mff_map, tlv_bitmap, out);" % (enum, arg) | ||
| 153 | + print(" return decode_%s(%s, version, vl_mff_map, tlv_bitmap, out);" % (enum, arg)) | ||
| 154 | else: | ||
| 155 | - print " return decode_%s(%s, version, out);" % (enum, arg) | ||
| 156 | |||
| 157 | - print """\ | ||
| 158 | + print(" return decode_%s(%s, version, out);" % (enum, arg)) | ||
| 159 | + print("") | ||
| 160 | + print("""\ | ||
| 161 | default: | ||
| 162 | OVS_NOT_REACHED(); | ||
| 163 | } | ||
| 164 | }\ | ||
| 165 | -""" | ||
| 166 | +""") | ||
| 167 | else: | ||
| 168 | for versions in enums.values(): | ||
| 169 | enum = versions[0]["enum"] | ||
| 170 | @@ -368,15 +368,15 @@ ofpact_decode(const struct ofp_action_header *a, enum ofp_raw_action_type raw, | ||
| 171 | if arg_vl_mff_map: | ||
| 172 | prototype += 'const struct vl_mff_map *, uint64_t *, ' | ||
| 173 | prototype += "struct ofpbuf *);" | ||
| 174 | - print prototype | ||
| 175 | + print(prototype) | ||
| 176 | |||
| 177 | - print """ | ||
| 178 | + print(""" | ||
| 179 | static enum ofperr ofpact_decode(const struct ofp_action_header *, | ||
| 180 | enum ofp_raw_action_type raw, | ||
| 181 | enum ofp_version version, | ||
| 182 | uint64_t arg, const struct vl_mff_map *vl_mff_map, | ||
| 183 | uint64_t *tlv_bitmap, struct ofpbuf *out); | ||
| 184 | -""" | ||
| 185 | +""") | ||
| 186 | |||
| 187 | if __name__ == '__main__': | ||
| 188 | if '--help' in sys.argv: | ||
| 189 | diff --git a/build-aux/extract-ofp-errors b/build-aux/extract-ofp-errors | ||
| 190 | index 2312b76..336a240 100755 | ||
| 191 | --- a/build-aux/extract-ofp-errors | ||
| 192 | +++ b/build-aux/extract-ofp-errors | ||
| 193 | @@ -426,7 +426,7 @@ static const struct ofperr_domain %s = { | ||
| 194 | vendor, type_, code = map[enum] | ||
| 195 | if code == None: | ||
| 196 | code = -1 | ||
| 197 | - print " { %#8x, %2d, %3d }, /* %s */" % (vendor, type_, code, enum) | ||
| 198 | + print (" { %#8x, %2d, %3d }, /* %s */" % (vendor, type_, code, enum)) | ||
| 199 | else: | ||
| 200 | print (" { -1, -1, -1 }, /* %s */" % enum) | ||
| 201 | print ("""\ | ||
| 202 | diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields | ||
| 203 | index 498b887..425a85f 100755 | ||
| 204 | --- a/build-aux/extract-ofp-fields | ||
| 205 | +++ b/build-aux/extract-ofp-fields | ||
| 206 | @@ -728,7 +728,7 @@ def make_ovs_fields(meta_flow_h, meta_flow_xml): | ||
| 207 | ovs\-fields \- protocol header fields in OpenFlow and Open vSwitch | ||
| 208 | . | ||
| 209 | .PP | ||
| 210 | -''') % version | ||
| 211 | +''' % version) | ||
| 212 | |||
| 213 | recursively_replace(doc, 'oxm_classes', make_oxm_classes_xml(document)) | ||
| 214 | |||
| 215 | diff --git a/build-aux/extract-ofp-msgs b/build-aux/extract-ofp-msgs | ||
| 216 | index 1813638..a67e870 100755 | ||
| 217 | --- a/build-aux/extract-ofp-msgs | ||
| 218 | +++ b/build-aux/extract-ofp-msgs | ||
| 219 | @@ -56,14 +56,14 @@ def fatal(msg): | ||
| 220 | |||
| 221 | def usage(): | ||
| 222 | argv0 = os.path.basename(sys.argv[0]) | ||
| 223 | - print '''\ | ||
| 224 | + print('''\ | ||
| 225 | %(argv0)s, for extracting OpenFlow message types from header files | ||
| 226 | usage: %(argv0)s INPUT OUTPUT | ||
| 227 | where INPUT is the name of the input header file | ||
| 228 | and OUTPUT is the output file name. | ||
| 229 | Despite OUTPUT, the output is written to stdout, and the OUTPUT argument | ||
| 230 | only controls #line directives in the output.\ | ||
| 231 | -''' % {"argv0": argv0} | ||
| 232 | +''' % {"argv0": argv0}) | ||
| 233 | sys.exit(0) | ||
| 234 | |||
| 235 | def make_sizeof(s): | ||
| 236 | @@ -378,5 +378,5 @@ if __name__ == '__main__': | ||
| 237 | line_number = 0 | ||
| 238 | |||
| 239 | for line in extract_ofp_msgs(sys.argv[2]): | ||
| 240 | - print line | ||
| 241 | + print(line) | ||
| 242 | |||
| 243 | diff --git a/ovsdb/ovsdb-doc b/ovsdb/ovsdb-doc | ||
| 244 | index 5cf26ee..b34fb11 100755 | ||
| 245 | --- a/ovsdb/ovsdb-doc | ||
| 246 | +++ b/ovsdb/ovsdb-doc | ||
| 247 | @@ -258,7 +258,7 @@ represent strong references; thin lines represent weak references. | ||
| 248 | return s | ||
| 249 | |||
| 250 | def usage(): | ||
| 251 | - print """\ | ||
| 252 | + print("""\ | ||
| 253 | %(argv0)s: ovsdb schema documentation generator | ||
| 254 | Prints documentation for an OVSDB schema as an nroff-formatted manpage. | ||
| 255 | usage: %(argv0)s [OPTIONS] SCHEMA XML | ||
| 256 | @@ -269,7 +269,7 @@ The following options are also available: | ||
| 257 | --er-diagram=DIAGRAM.PIC include E-R diagram from DIAGRAM.PIC | ||
| 258 | --version=VERSION use VERSION to display on document footer | ||
| 259 | -h, --help display this help message\ | ||
| 260 | -""" % {'argv0': argv0} | ||
| 261 | +""" % {'argv0': argv0}) | ||
| 262 | sys.exit(0) | ||
| 263 | |||
| 264 | if __name__ == "__main__": | ||
| 265 | @@ -304,7 +304,7 @@ if __name__ == "__main__": | ||
| 266 | for line in s.split("\n"): | ||
| 267 | line = line.strip() | ||
| 268 | if len(line): | ||
| 269 | - print line | ||
| 270 | + print(line) | ||
| 271 | |||
| 272 | except error.Error, e: | ||
| 273 | sys.stderr.write("%s: %s\n" % (argv0, e.msg)) | ||
| 274 | diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in | ||
| 275 | index 721ab50..1064448 100755 | ||
| 276 | --- a/ovsdb/ovsdb-idlc.in | ||
| 277 | +++ b/ovsdb/ovsdb-idlc.in | ||
| 278 | @@ -1,5 +1,6 @@ | ||
| 279 | #! @PYTHON@ | ||
| 280 | |||
| 281 | +from __future__ import print_function | ||
| 282 | import getopt | ||
| 283 | import os | ||
| 284 | import re | ||
| 285 | @@ -123,7 +124,7 @@ def sorted_columns(table): | ||
| 286 | def printCIDLHeader(schemaFile): | ||
| 287 | schema = parseSchema(schemaFile) | ||
| 288 | prefix = schema.idlPrefix | ||
| 289 | - print '''\ | ||
| 290 | + print('''\ | ||
| 291 | /* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */ | ||
| 292 | |||
| 293 | #ifndef %(prefix)sIDL_HEADER | ||
| 294 | @@ -135,39 +136,39 @@ def printCIDLHeader(schemaFile): | ||
| 295 | #include "ovsdb-data.h" | ||
| 296 | #include "ovsdb-idl-provider.h" | ||
| 297 | #include "smap.h" | ||
| 298 | -#include "uuid.h"''' % {'prefix': prefix.upper()} | ||
| 299 | +#include "uuid.h"''' % {'prefix': prefix.upper()}) | ||
| 300 | |||
| 301 | for tableName, table in sorted(schema.tables.iteritems()): | ||
| 302 | structName = "%s%s" % (prefix, tableName.lower()) | ||
| 303 | |||
| 304 | - print "" | ||
| 305 | - print "/* %s table. */" % tableName | ||
| 306 | - print "struct %s {" % structName | ||
| 307 | - print "\tstruct ovsdb_idl_row header_;" | ||
| 308 | + print("") | ||
| 309 | + print("/* %s table. */" % tableName) | ||
| 310 | + print("struct %s {" % structName) | ||
| 311 | + print("\tstruct ovsdb_idl_row header_;") | ||
| 312 | for columnName, column in sorted_columns(table): | ||
| 313 | - print "\n\t/* %s column. */" % columnName | ||
| 314 | + print("\n\t/* %s column. */" % columnName) | ||
| 315 | comment, members = cMembers(prefix, tableName, | ||
| 316 | columnName, column, False) | ||
| 317 | for member in members: | ||
| 318 | - print "\t%(type)s%(name)s;%(comment)s" % member | ||
| 319 | - print "};" | ||
| 320 | + print("\t%(type)s%(name)s;%(comment)s" % member) | ||
| 321 | + print("};") | ||
| 322 | |||
| 323 | # Column indexes. | ||
| 324 | printEnum("%s_column_id" % structName.lower(), ["%s_COL_%s" % (structName.upper(), columnName.upper()) | ||
| 325 | for columnName, column in sorted_columns(table)] | ||
| 326 | + ["%s_N_COLUMNS" % structName.upper()]) | ||
| 327 | |||
| 328 | |||
| 329 | + print("") | ||
| 330 | for columnName in table.columns: | ||
| 331 | - print "#define %(s)s_col_%(c)s (%(s)s_columns[%(S)s_COL_%(C)s])" % { | ||
| 332 | + print("#define %(s)s_col_%(c)s (%(s)s_columns[%(S)s_COL_%(C)s])" % { | ||
| 333 | 's': structName, | ||
| 334 | 'S': structName.upper(), | ||
| 335 | 'c': columnName, | ||
| 336 | - 'C': columnName.upper()} | ||
| 337 | + 'C': columnName.upper()}) | ||
| 338 | |||
| 339 | - print "\nextern struct ovsdb_idl_column %s_columns[%s_N_COLUMNS];" % (structName, structName.upper()) | ||
| 340 | + print("\nextern struct ovsdb_idl_column %s_columns[%s_N_COLUMNS];" % (structName, structName.upper())) | ||
| 341 | |||
| 342 | - print ''' | ||
| 343 | + print(''' | ||
| 344 | const struct %(s)s *%(s)s_get_for_uuid(const struct ovsdb_idl *, const struct uuid *); | ||
| 345 | const struct %(s)s *%(s)s_first(const struct ovsdb_idl *); | ||
| 346 | const struct %(s)s *%(s)s_next(const struct %(s)s *); | ||
| 347 | @@ -205,87 +206,87 @@ void %(s)s_init(struct %(s)s *); | ||
| 348 | void %(s)s_delete(const struct %(s)s *); | ||
| 349 | struct %(s)s *%(s)s_insert(struct ovsdb_idl_txn *); | ||
| 350 | bool %(s)s_is_updated(const struct %(s)s *, enum %(s)s_column_id); | ||
| 351 | -''' % {'s': structName, 'S': structName.upper()} | ||
| 352 | +''' % {'s': structName, 'S': structName.upper()}) | ||
| 353 | |||
| 354 | for columnName, column in sorted_columns(table): | ||
| 355 | - print 'void %(s)s_verify_%(c)s(const struct %(s)s *);' % {'s': structName, 'c': columnName} | ||
| 356 | + print('void %(s)s_verify_%(c)s(const struct %(s)s *);' % {'s': structName, 'c': columnName}) | ||
| 357 | |||
| 358 | |||
| 359 | + print("") | ||
| 360 | for columnName, column in sorted_columns(table): | ||
| 361 | if column.type.value: | ||
| 362 | valueParam = ', enum ovsdb_atomic_type value_type' | ||
| 363 | else: | ||
| 364 | valueParam = '' | ||
| 365 | - print 'const struct ovsdb_datum *%(s)s_get_%(c)s(const struct %(s)s *, enum ovsdb_atomic_type key_type%(v)s);' % { | ||
| 366 | - 's': structName, 'c': columnName, 'v': valueParam} | ||
| 367 | + print('const struct ovsdb_datum *%(s)s_get_%(c)s(const struct %(s)s *, enum ovsdb_atomic_type key_type%(v)s);' % { | ||
| 368 | + 's': structName, 'c': columnName, 'v': valueParam}) | ||
| 369 | |||
| 370 | |||
| 371 | + print("") | ||
| 372 | for columnName, column in sorted_columns(table): | ||
| 373 | - print 'void %(s)s_set_%(c)s(const struct %(s)s *,' % {'s': structName, 'c': columnName}, | ||
| 374 | + print('void %(s)s_set_%(c)s(const struct %(s)s *,' % {'s': structName, 'c': columnName}, end=' ') | ||
| 375 | if column.type.is_smap(): | ||
| 376 | args = ['const struct smap *'] | ||
| 377 | else: | ||
| 378 | comment, members = cMembers(prefix, tableName, columnName, | ||
| 379 | column, True) | ||
| 380 | args = ['%(type)s%(name)s' % member for member in members] | ||
| 381 | - print '%s);' % ', '.join(args) | ||
| 382 | + print('%s);' % ', '.join(args)) | ||
| 383 | |||
| 384 | |||
| 385 | + print("") | ||
| 386 | for columnName, column in sorted_columns(table): | ||
| 387 | if column.type.is_map(): | ||
| 388 | - print 'void %(s)s_update_%(c)s_setkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, | ||
| 389 | - print '%(coltype)s, %(valtype)s);' % {'coltype':column.type.key.to_const_c_type(prefix), 'valtype':column.type.value.to_const_c_type(prefix)} | ||
| 390 | - print 'void %(s)s_update_%(c)s_delkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, | ||
| 391 | - print '%(coltype)s);' % {'coltype':column.type.key.to_const_c_type(prefix)} | ||
| 392 | + print('void %(s)s_update_%(c)s_setkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, end=' ') | ||
| 393 | + print('%(coltype)s, %(valtype)s);' % {'coltype':column.type.key.to_const_c_type(prefix), 'valtype':column.type.value.to_const_c_type(prefix)}) | ||
| 394 | + print('void %(s)s_update_%(c)s_delkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, end=' ') | ||
| 395 | + print('%(coltype)s);' % {'coltype':column.type.key.to_const_c_type(prefix)}) | ||
| 396 | if column.type.is_set(): | ||
| 397 | - print 'void %(s)s_update_%(c)s_addvalue(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, | ||
| 398 | - print '%(valtype)s);' % {'valtype':column.type.key.to_const_c_type(prefix)} | ||
| 399 | - print 'void %(s)s_update_%(c)s_delvalue(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, | ||
| 400 | - print '%(valtype)s);' % {'valtype':column.type.key.to_const_c_type(prefix)} | ||
| 401 | + print('void %(s)s_update_%(c)s_addvalue(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, end=' ') | ||
| 402 | + print('%(valtype)s);' % {'valtype':column.type.key.to_const_c_type(prefix)}) | ||
| 403 | + print('void %(s)s_update_%(c)s_delvalue(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, end=' ') | ||
| 404 | + print('%(valtype)s);' % {'valtype':column.type.key.to_const_c_type(prefix)}) | ||
| 405 | |||
| 406 | - print 'void %(s)s_add_clause_%(c)s(struct ovsdb_idl_condition *, enum ovsdb_function function,' % {'s': structName, 'c': columnName}, | ||
| 407 | + print('void %(s)s_add_clause_%(c)s(struct ovsdb_idl_condition *, enum ovsdb_function function,' % {'s': structName, 'c': columnName}, end=' ') | ||
| 408 | if column.type.is_smap(): | ||
| 409 | args = ['const struct smap *'] | ||
| 410 | else: | ||
| 411 | comment, members = cMembers(prefix, tableName, columnName, | ||
| 412 | column, True, refTable=False) | ||
| 413 | args = ['%(type)s%(name)s' % member for member in members] | ||
| 414 | - print '%s);' % ', '.join(args) | ||
| 415 | + print('%s);' % ', '.join(args)) | ||
| 416 | |||
| 417 | - print 'void %(s)s_set_condition(struct ovsdb_idl *, struct ovsdb_idl_condition *);' % {'s': structName}, | ||
| 418 | + print('void %(s)s_set_condition(struct ovsdb_idl *, struct ovsdb_idl_condition *);' % {'s': structName}) | ||
| 419 | |||
| 420 | |||
| 421 | + print("") | ||
| 422 | |||
| 423 | # Table indexes. | ||
| 424 | printEnum("%stable_id" % prefix.lower(), ["%sTABLE_%s" % (prefix.upper(), tableName.upper()) for tableName in sorted(schema.tables)] + ["%sN_TABLES" % prefix.upper()]) | ||
| 425 | |||
| 426 | + print("") | ||
| 427 | for tableName in schema.tables: | ||
| 428 | - print "#define %(p)stable_%(t)s (%(p)stable_classes[%(P)sTABLE_%(T)s])" % { | ||
| 429 | + print("#define %(p)stable_%(t)s (%(p)stable_classes[%(P)sTABLE_%(T)s])" % { | ||
| 430 | 'p': prefix, | ||
| 431 | 'P': prefix.upper(), | ||
| 432 | 't': tableName.lower(), | ||
| 433 | - 'T': tableName.upper()} | ||
| 434 | - print "\nextern struct ovsdb_idl_table_class %stable_classes[%sN_TABLES];" % (prefix, prefix.upper()) | ||
| 435 | + 'T': tableName.upper()}) | ||
| 436 | + print("\nextern struct ovsdb_idl_table_class %stable_classes[%sN_TABLES];" % (prefix, prefix.upper())) | ||
| 437 | |||
| 438 | - print "\nextern struct ovsdb_idl_class %sidl_class;" % prefix | ||
| 439 | + print("\nextern struct ovsdb_idl_class %sidl_class;" % prefix) | ||
| 440 | |||
| 441 | - print "\nconst char * %sget_db_version(void);" % prefix | ||
| 442 | - print "\n#endif /* %(prefix)sIDL_HEADER */" % {'prefix': prefix.upper()} | ||
| 443 | + print("\nconst char * %sget_db_version(void);" % prefix) | ||
| 444 | + print("\n#endif /* %(prefix)sIDL_HEADER */" % {'prefix': prefix.upper()}) | ||
| 445 | |||
| 446 | def printEnum(type, members): | ||
| 447 | if len(members) == 0: | ||
| 448 | return | ||
| 449 | |||
| 450 | - print "\nenum %s {" % type | ||
| 451 | + print("\nenum %s {" % type) | ||
| 452 | for member in members[:-1]: | ||
| 453 | - print " %s," % member | ||
| 454 | - print " %s" % members[-1] | ||
| 455 | - print "};" | ||
| 456 | + print(" %s," % member) | ||
| 457 | + print(" %s" % members[-1]) | ||
| 458 | + print("};") | ||
| 459 | |||
| 460 | def printCIDLSource(schemaFile): | ||
| 461 | schema = parseSchema(schemaFile) | ||
| 462 | prefix = schema.idlPrefix | ||
| 463 | - print '''\ | ||
| 464 | + print('''\ | ||
| 465 | /* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */ | ||
| 466 | |||
| 467 | #include <config.h> | ||
| 468 | @@ -296,33 +297,33 @@ def printCIDLSource(schemaFile): | ||
| 469 | #include "ovsdb-error.h" | ||
| 470 | #include "util.h" | ||
| 471 | |||
| 472 | -''' % schema.idlHeader | ||
| 473 | +''' % schema.idlHeader) | ||
| 474 | |||
| 475 | # Cast functions. | ||
| 476 | for tableName, table in sorted(schema.tables.iteritems()): | ||
| 477 | structName = "%s%s" % (prefix, tableName.lower()) | ||
| 478 | - print ''' | ||
| 479 | + print(''' | ||
| 480 | static struct %(s)s * | ||
| 481 | %(s)s_cast(const struct ovsdb_idl_row *row) | ||
| 482 | { | ||
| 483 | return row ? CONTAINER_OF(row, struct %(s)s, header_) : NULL; | ||
| 484 | }\ | ||
| 485 | -''' % {'s': structName} | ||
| 486 | +''' % {'s': structName}) | ||
| 487 | |||
| 488 | |||
| 489 | for tableName, table in sorted(schema.tables.iteritems()): | ||
| 490 | structName = "%s%s" % (prefix, tableName.lower()) | ||
| 491 | - print "" | ||
| 492 | - print "/* %s table. */" % (tableName) | ||
| 493 | + print("") | ||
| 494 | + print("/* %s table. */" % (tableName)) | ||
| 495 | |||
| 496 | # Parse functions. | ||
| 497 | for columnName, column in sorted_columns(table): | ||
| 498 | - print ''' | ||
| 499 | + print(''' | ||
| 500 | static void | ||
| 501 | %(s)s_parse_%(c)s(struct ovsdb_idl_row *row_, const struct ovsdb_datum *datum) | ||
| 502 | { | ||
| 503 | struct %(s)s *row = %(s)s_cast(row_);''' % {'s': structName, | ||
| 504 | - 'c': columnName} | ||
| 505 | + 'c': columnName}) | ||
| 506 | type = column.type | ||
| 507 | if type.value: | ||
| 508 | keyVar = "row->key_%s" % columnName | ||
| 509 | @@ -332,89 +333,89 @@ static void | ||
| 510 | valueVar = None | ||
| 511 | |||
| 512 | if type.is_smap(): | ||
| 513 | - print " smap_init(&row->%s);" % columnName | ||
| 514 | - print " for (size_t i = 0; i < datum->n; i++) {" | ||
| 515 | - print " smap_add(&row->%s," % columnName | ||
| 516 | - print " datum->keys[i].string," | ||
| 517 | - print " datum->values[i].string);" | ||
| 518 | - print " }" | ||
| 519 | + print(" smap_init(&row->%s);" % columnName) | ||
| 520 | + print(" for (size_t i = 0; i < datum->n; i++) {") | ||
| 521 | + print(" smap_add(&row->%s," % columnName) | ||
| 522 | + print(" datum->keys[i].string,") | ||
| 523 | + print(" datum->values[i].string);") | ||
| 524 | + print(" }") | ||
| 525 | elif (type.n_min == 1 and type.n_max == 1) or type.is_optional_pointer(): | ||
| 526 | |||
| 527 | - print " if (datum->n >= 1) {" | ||
| 528 | + print("") | ||
| 529 | + print(" if (datum->n >= 1) {") | ||
| 530 | if not type.key.ref_table: | ||
| 531 | - print " %s = datum->keys[0].%s;" % (keyVar, type.key.type.to_string()) | ||
| 532 | + print(" %s = datum->keys[0].%s;" % (keyVar, type.key.type.to_string())) | ||
| 533 | else: | ||
| 534 | - print " %s = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_%s, &datum->keys[0].uuid));" % (keyVar, prefix, type.key.ref_table.name.lower(), prefix, type.key.ref_table.name.lower()) | ||
| 535 | + print(" %s = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_%s, &datum->keys[0].uuid));" % (keyVar, prefix, type.key.ref_table.name.lower(), prefix, type.key.ref_table.name.lower())) | ||
| 536 | |||
| 537 | if valueVar: | ||
| 538 | if not type.value.ref_table: | ||
| 539 | - print " %s = datum->values[0].%s;" % (valueVar, type.value.type.to_string()) | ||
| 540 | + print(" %s = datum->values[0].%s;" % (valueVar, type.value.type.to_string())) | ||
| 541 | else: | ||
| 542 | - print " %s = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_%s, &datum->values[0].uuid));" % (valueVar, prefix, type.value.ref_table.name.lower(), prefix, type.value.ref_table.name.lower()) | ||
| 543 | - print " } else {" | ||
| 544 | - print " %s" % type.key.initCDefault(keyVar, type.n_min == 0) | ||
| 545 | + print(" %s = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_%s, &datum->values[0].uuid));" % (valueVar, prefix, type.value.ref_table.name.lower(), prefix, type.value.ref_table.name.lower())) | ||
| 546 | + print(" } else {") | ||
| 547 | + print(" %s" % type.key.initCDefault(keyVar, type.n_min == 0)) | ||
| 548 | if valueVar: | ||
| 549 | - print " %s" % type.value.initCDefault(valueVar, type.n_min == 0) | ||
| 550 | - print " }" | ||
| 551 | + print(" %s" % type.value.initCDefault(valueVar, type.n_min == 0)) | ||
| 552 | + print(" }") | ||
| 553 | else: | ||
| 554 | if type.n_max != sys.maxint: | ||
| 555 | - print " size_t n = MIN(%d, datum->n);" % type.n_max | ||
| 556 | + print(" size_t n = MIN(%d, datum->n);" % type.n_max) | ||
| 557 | nMax = "n" | ||
| 558 | else: | ||
| 559 | nMax = "datum->n" | ||
| 560 | - print " %s = NULL;" % keyVar | ||
| 561 | + print(" %s = NULL;" % keyVar) | ||
| 562 | if valueVar: | ||
| 563 | - print " %s = NULL;" % valueVar | ||
| 564 | - print " row->n_%s = 0;" % columnName | ||
| 565 | - print " for (size_t i = 0; i < %s; i++) {" % nMax | ||
| 566 | + print(" %s = NULL;" % valueVar) | ||
| 567 | + print(" row->n_%s = 0;" % columnName) | ||
| 568 | + print(" for (size_t i = 0; i < %s; i++) {" % nMax) | ||
| 569 | if type.key.ref_table: | ||
| 570 | - print """\ | ||
| 571 | + print("""\ | ||
| 572 | struct %s%s *keyRow = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_%s, &datum->keys[i].uuid)); | ||
| 573 | if (!keyRow) { | ||
| 574 | continue; | ||
| 575 | }\ | ||
| 576 | -""" % (prefix, type.key.ref_table.name.lower(), prefix, type.key.ref_table.name.lower(), prefix, type.key.ref_table.name.lower()) | ||
| 577 | +""" % (prefix, type.key.ref_table.name.lower(), prefix, type.key.ref_table.name.lower(), prefix, type.key.ref_table.name.lower())) | ||
| 578 | keySrc = "keyRow" | ||
| 579 | else: | ||
| 580 | keySrc = "datum->keys[i].%s" % type.key.type.to_string() | ||
| 581 | if type.value and type.value.ref_table: | ||
| 582 | - print """\ | ||
| 583 | + print("""\ | ||
| 584 | struct %s%s *valueRow = %s%s_cast(ovsdb_idl_get_row_arc(row_, &%stable_%s, &datum->values[i].uuid)); | ||
| 585 | if (!valueRow) { | ||
| 586 | continue; | ||
| 587 | }\ | ||
| 588 | -""" % (prefix, type.value.ref_table.name.lower(), prefix, type.value.ref_table.name.lower(), prefix, type.value.ref_table.name.lower()) | ||
| 589 | +""" % (prefix, type.value.ref_table.name.lower(), prefix, type.value.ref_table.name.lower(), prefix, type.value.ref_table.name.lower())) | ||
| 590 | valueSrc = "valueRow" | ||
| 591 | elif valueVar: | ||
| 592 | valueSrc = "datum->values[i].%s" % type.value.type.to_string() | ||
| 593 | - print " if (!row->n_%s) {" % (columnName) | ||
| 594 | + print(" if (!row->n_%s) {" % (columnName)) | ||
| 595 | |||
| 596 | - print " %s = xmalloc(%s * sizeof *%s);" % ( | ||
| 597 | - keyVar, nMax, keyVar) | ||
| 598 | + print(" %s = xmalloc(%s * sizeof *%s);" % ( | ||
| 599 | + keyVar, nMax, keyVar)) | ||
| 600 | if valueVar: | ||
| 601 | - print " %s = xmalloc(%s * sizeof *%s);" % ( | ||
| 602 | - valueVar, nMax, valueVar) | ||
| 603 | - print " }" | ||
| 604 | - print " %s[row->n_%s] = %s;" % (keyVar, columnName, keySrc) | ||
| 605 | + print(" %s = xmalloc(%s * sizeof *%s);" % ( | ||
| 606 | + valueVar, nMax, valueVar)) | ||
| 607 | + print(" }") | ||
| 608 | + print(" %s[row->n_%s] = %s;" % (keyVar, columnName, keySrc)) | ||
| 609 | if valueVar: | ||
| 610 | - print " %s[row->n_%s] = %s;" % (valueVar, columnName, valueSrc) | ||
| 611 | - print " row->n_%s++;" % columnName | ||
| 612 | - print " }" | ||
| 613 | - print "}" | ||
| 614 | + print(" %s[row->n_%s] = %s;" % (valueVar, columnName, valueSrc)) | ||
| 615 | + print(" row->n_%s++;" % columnName) | ||
| 616 | + print(" }") | ||
| 617 | + print("}") | ||
| 618 | |||
| 619 | # Unparse functions. | ||
| 620 | for columnName, column in sorted_columns(table): | ||
| 621 | type = column.type | ||
| 622 | if type.is_smap() or (type.n_min != 1 or type.n_max != 1) and not type.is_optional_pointer(): | ||
| 623 | - print ''' | ||
| 624 | + print(''' | ||
| 625 | static void | ||
| 626 | %(s)s_unparse_%(c)s(struct ovsdb_idl_row *row_) | ||
| 627 | { | ||
| 628 | struct %(s)s *row = %(s)s_cast(row_);''' % {'s': structName, | ||
| 629 | - 'c': columnName} | ||
| 630 | + 'c': columnName}) | ||
| 631 | |||
| 632 | if type.is_smap(): | ||
| 633 | - print " smap_destroy(&row->%s);" % columnName | ||
| 634 | + print(" smap_destroy(&row->%s);" % columnName) | ||
| 635 | else: | ||
| 636 | if type.value: | ||
| 637 | keyVar = "row->key_%s" % columnName | ||
| 638 | @@ -422,45 +423,45 @@ static void | ||
| 639 | else: | ||
| 640 | keyVar = "row->%s" % columnName | ||
| 641 | valueVar = None | ||
| 642 | - print " free(%s);" % keyVar | ||
| 643 | + print(" free(%s);" % keyVar) | ||
| 644 | if valueVar: | ||
| 645 | - print " free(%s);" % valueVar | ||
| 646 | - print '}' | ||
| 647 | + print(" free(%s);" % valueVar) | ||
| 648 | + print('}') | ||
| 649 | else: | ||
| 650 | - print ''' | ||
| 651 | + print(''' | ||
| 652 | static void | ||
| 653 | %(s)s_unparse_%(c)s(struct ovsdb_idl_row *row OVS_UNUSED) | ||
| 654 | { | ||
| 655 | /* Nothing to do. */ | ||
| 656 | -}''' % {'s': structName, 'c': columnName} | ||
| 657 | +}''' % {'s': structName, 'c': columnName}) | ||
| 658 | |||
| 659 | # Generic Row Initialization function. | ||
| 660 | - print """ | ||
| 661 | + print(""" | ||
| 662 | static void | ||
| 663 | %(s)s_init__(struct ovsdb_idl_row *row) | ||
| 664 | { | ||
| 665 | %(s)s_init(%(s)s_cast(row)); | ||
| 666 | -}""" % {'s': structName} | ||
| 667 | +}""" % {'s': structName}) | ||
| 668 | |||
| 669 | # Row Initialization function. | ||
| 670 | - print """ | ||
| 671 | + print(""" | ||
| 672 | /* Clears the contents of 'row' in table "%(t)s". */ | ||
| 673 | void | ||
| 674 | %(s)s_init(struct %(s)s *row) | ||
| 675 | { | ||
| 676 | - memset(row, 0, sizeof *row); """ % {'s': structName, 't': tableName} | ||
| 677 | + memset(row, 0, sizeof *row); """ % {'s': structName, 't': tableName}) | ||
| 678 | for columnName, column in sorted_columns(table): | ||
| 679 | if column.type.is_smap(): | ||
| 680 | - print " smap_init(&row->%s);" % columnName | ||
| 681 | + print(" smap_init(&row->%s);" % columnName) | ||
| 682 | elif (column.type.n_min == 1 and | ||
| 683 | column.type.n_max == 1 and | ||
| 684 | column.type.key.type == ovs.db.types.StringType and | ||
| 685 | not column.type.value): | ||
| 686 | - print " row->%s = \"\";" % columnName | ||
| 687 | - print "}" | ||
| 688 | + print(" row->%s = \"\";" % columnName) | ||
| 689 | + print("}") | ||
| 690 | |||
| 691 | # First, next functions. | ||
| 692 | - print ''' | ||
| 693 | + print(''' | ||
| 694 | /* Searches table "%(t)s" in 'idl' for a row with UUID 'uuid'. Returns | ||
| 695 | * a pointer to the row if there is one, otherwise a null pointer. */ | ||
| 696 | const struct %(s)s * | ||
| 697 | @@ -514,9 +515,9 @@ const struct %(s)s | ||
| 698 | 'P': prefix.upper(), | ||
| 699 | 't': tableName, | ||
| 700 | 'tl': tableName.lower(), | ||
| 701 | - 'T': tableName.upper()} | ||
| 702 | + 'T': tableName.upper()}) | ||
| 703 | |||
| 704 | - print ''' | ||
| 705 | + print(''' | ||
| 706 | |||
| 707 | /* Deletes 'row' from table "%(t)s". 'row' may be freed, so it must not be | ||
| 708 | * accessed afterward. | ||
| 709 | @@ -550,11 +551,11 @@ bool | ||
| 710 | 'P': prefix.upper(), | ||
| 711 | 't': tableName, | ||
| 712 | 'tl': tableName.lower(), | ||
| 713 | - 'T': tableName.upper()} | ||
| 714 | + 'T': tableName.upper()}) | ||
| 715 | |||
| 716 | # Verify functions. | ||
| 717 | for columnName, column in sorted_columns(table): | ||
| 718 | - print ''' | ||
| 719 | + print(''' | ||
| 720 | /* Causes the original contents of column "%(c)s" in 'row' to be | ||
| 721 | * verified as a prerequisite to completing the transaction. That is, if | ||
| 722 | * "%(c)s" in 'row' changed (or if 'row' was deleted) between the | ||
| 723 | @@ -585,7 +586,7 @@ void | ||
| 724 | }''' % {'s': structName, | ||
| 725 | 'S': structName.upper(), | ||
| 726 | 'c': columnName, | ||
| 727 | - 'C': columnName.upper()} | ||
| 728 | + 'C': columnName.upper()}) | ||
| 729 | |||
| 730 | # Get functions. | ||
| 731 | for columnName, column in sorted_columns(table): | ||
| 732 | @@ -597,7 +598,7 @@ void | ||
| 733 | valueParam = '' | ||
| 734 | valueType = '' | ||
| 735 | valueComment = '' | ||
| 736 | - print """ | ||
| 737 | + print(""" | ||
| 738 | /* Returns the "%(c)s" column's value from the "%(t)s" table in 'row' | ||
| 739 | * as a struct ovsdb_datum. This is useful occasionally: for example, | ||
| 740 | * ovsdb_datum_find_key() is an easier and more efficient way to search | ||
| 741 | @@ -625,7 +626,7 @@ const struct ovsdb_datum * | ||
| 742 | return ovsdb_idl_read(&row->header_, &%(s)s_col_%(c)s); | ||
| 743 | }""" % {'t': tableName, 's': structName, 'c': columnName, | ||
| 744 | 'kt': column.type.key.toAtomicType(), | ||
| 745 | - 'v': valueParam, 'vt': valueType, 'vc': valueComment} | ||
| 746 | + 'v': valueParam, 'vt': valueType, 'vc': valueComment}) | ||
| 747 | |||
| 748 | # Set functions. | ||
| 749 | for columnName, column in sorted_columns(table): | ||
| 750 | @@ -635,8 +636,8 @@ const struct ovsdb_datum * | ||
| 751 | column, True) | ||
| 752 | |||
| 753 | if type.is_smap(): | ||
| 754 | - print comment | ||
| 755 | - print """void | ||
| 756 | + print(comment) | ||
| 757 | + print("""void | ||
| 758 | %(s)s_set_%(c)s(const struct %(s)s *row, const struct smap *%(c)s) | ||
| 759 | { | ||
| 760 | struct ovsdb_datum datum; | ||
| 761 | @@ -654,7 +655,7 @@ const struct ovsdb_datum * | ||
| 762 | 's': structName, | ||
| 763 | 'S': structName.upper(), | ||
| 764 | 'c': columnName, | ||
| 765 | - 'C': columnName.upper()} | ||
| 766 | + 'C': columnName.upper()}) | ||
| 767 | continue | ||
| 768 | |||
| 769 | keyVar = members[0]['name'] | ||
| 770 | @@ -668,84 +669,84 @@ const struct ovsdb_datum * | ||
| 771 | if len(members) > 1: | ||
| 772 | nVar = members[1]['name'] | ||
| 773 | |||
| 774 | - print comment | ||
| 775 | - print """\ | ||
| 776 | + print(comment) | ||
| 777 | + print("""\ | ||
| 778 | void | ||
| 779 | %(s)s_set_%(c)s(const struct %(s)s *row, %(args)s) | ||
| 780 | { | ||
| 781 | struct ovsdb_datum datum;""" % {'s': structName, | ||
| 782 | 'c': columnName, | ||
| 783 | 'args': ', '.join(['%(type)s%(name)s' | ||
| 784 | - % m for m in members])} | ||
| 785 | + % m for m in members])}) | ||
| 786 | if type.n_min == 1 and type.n_max == 1: | ||
| 787 | - print " union ovsdb_atom key;" | ||
| 788 | + print(" union ovsdb_atom key;") | ||
| 789 | if type.value: | ||
| 790 | - print " union ovsdb_atom value;" | ||
| 791 | |||
| 792 | - print " datum.n = 1;" | ||
| 793 | - print " datum.keys = &key;" | ||
| 794 | - print " " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar) | ||
| 795 | + print(" union ovsdb_atom value;") | ||
| 796 | + print("") | ||
| 797 | + print(" datum.n = 1;") | ||
| 798 | + print(" datum.keys = &key;") | ||
| 799 | + print(" " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar)) | ||
| 800 | if type.value: | ||
| 801 | - print " datum.values = &value;" | ||
| 802 | - print " "+ type.value.assign_c_value_casting_away_const("value.%s" % type.value.type.to_string(), valueVar) | ||
| 803 | + print(" datum.values = &value;") | ||
| 804 | + print(" "+ type.value.assign_c_value_casting_away_const("value.%s" % type.value.type.to_string(), valueVar)) | ||
| 805 | else: | ||
| 806 | - print " datum.values = NULL;" | ||
| 807 | + print(" datum.values = NULL;") | ||
| 808 | txn_write_func = "ovsdb_idl_txn_write_clone" | ||
| 809 | elif type.is_optional_pointer(): | ||
| 810 | - print " union ovsdb_atom key;" | ||
| 811 | |||
| 812 | - print " if (%s) {" % keyVar | ||
| 813 | - print " datum.n = 1;" | ||
| 814 | - print " datum.keys = &key;" | ||
| 815 | - print " " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar) | ||
| 816 | - print " } else {" | ||
| 817 | - print " datum.n = 0;" | ||
| 818 | - print " datum.keys = NULL;" | ||
| 819 | - print " }" | ||
| 820 | - print " datum.values = NULL;" | ||
| 821 | + print(" union ovsdb_atom key;") | ||
| 822 | + print("") | ||
| 823 | + print(" if (%s) {" % keyVar) | ||
| 824 | + print(" datum.n = 1;") | ||
| 825 | + print(" datum.keys = &key;") | ||
| 826 | + print(" " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar)) | ||
| 827 | + print(" } else {") | ||
| 828 | + print(" datum.n = 0;") | ||
| 829 | + print(" datum.keys = NULL;") | ||
| 830 | + print(" }") | ||
| 831 | + print(" datum.values = NULL;") | ||
| 832 | txn_write_func = "ovsdb_idl_txn_write_clone" | ||
| 833 | elif type.n_max == 1: | ||
| 834 | - print " union ovsdb_atom key;" | ||
| 835 | |||
| 836 | - print " if (%s) {" % nVar | ||
| 837 | - print " datum.n = 1;" | ||
| 838 | - print " datum.keys = &key;" | ||
| 839 | - print " " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), "*" + keyVar) | ||
| 840 | - print " } else {" | ||
| 841 | - print " datum.n = 0;" | ||
| 842 | - print " datum.keys = NULL;" | ||
| 843 | - print " }" | ||
| 844 | - print " datum.values = NULL;" | ||
| 845 | + print(" union ovsdb_atom key;") | ||
| 846 | + print("") | ||
| 847 | + print(" if (%s) {" % nVar) | ||
| 848 | + print(" datum.n = 1;") | ||
| 849 | + print(" datum.keys = &key;") | ||
| 850 | + print(" " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), "*" + keyVar)) | ||
| 851 | + print(" } else {") | ||
| 852 | + print(" datum.n = 0;") | ||
| 853 | + print(" datum.keys = NULL;") | ||
| 854 | + print(" }") | ||
| 855 | + print(" datum.values = NULL;") | ||
| 856 | txn_write_func = "ovsdb_idl_txn_write_clone" | ||
| 857 | else: | ||
| 858 | |||
| 859 | - print " datum.n = %s;" % nVar | ||
| 860 | - print " datum.keys = %s ? xmalloc(%s * sizeof *datum.keys) : NULL;" % (nVar, nVar) | ||
| 861 | + print("") | ||
| 862 | + print(" datum.n = %s;" % nVar) | ||
| 863 | + print(" datum.keys = %s ? xmalloc(%s * sizeof *datum.keys) : NULL;" % (nVar, nVar)) | ||
| 864 | if type.value: | ||
| 865 | - print " datum.values = xmalloc(%s * sizeof *datum.values);" % nVar | ||
| 866 | + print(" datum.values = xmalloc(%s * sizeof *datum.values);" % nVar) | ||
| 867 | else: | ||
| 868 | - print " datum.values = NULL;" | ||
| 869 | - print " for (size_t i = 0; i < %s; i++) {" % nVar | ||
| 870 | - print " " + type.key.copyCValue("datum.keys[i].%s" % type.key.type.to_string(), "%s[i]" % keyVar) | ||
| 871 | + print(" datum.values = NULL;") | ||
| 872 | + print(" for (size_t i = 0; i < %s; i++) {" % nVar) | ||
| 873 | + print(" " + type.key.copyCValue("datum.keys[i].%s" % type.key.type.to_string(), "%s[i]" % keyVar)) | ||
| 874 | if type.value: | ||
| 875 | - print " " + type.value.copyCValue("datum.values[i].%s" % type.value.type.to_string(), "%s[i]" % valueVar) | ||
| 876 | - print " }" | ||
| 877 | + print(" " + type.value.copyCValue("datum.values[i].%s" % type.value.type.to_string(), "%s[i]" % valueVar)) | ||
| 878 | + print(" }") | ||
| 879 | if type.value: | ||
| 880 | valueType = type.value.toAtomicType() | ||
| 881 | else: | ||
| 882 | valueType = "OVSDB_TYPE_VOID" | ||
| 883 | txn_write_func = "ovsdb_idl_txn_write" | ||
| 884 | - print " %(f)s(&row->header_, &%(s)s_col_%(c)s, &datum);" \ | ||
| 885 | + print(" %(f)s(&row->header_, &%(s)s_col_%(c)s, &datum);" \ | ||
| 886 | % {'f': txn_write_func, | ||
| 887 | 's': structName, | ||
| 888 | 'S': structName.upper(), | ||
| 889 | - 'c': columnName} | ||
| 890 | - print "}" | ||
| 891 | + 'c': columnName}) | ||
| 892 | + print("}") | ||
| 893 | # Update/Delete of partial map column functions | ||
| 894 | for columnName, column in sorted_columns(table): | ||
| 895 | type = column.type | ||
| 896 | if type.is_map(): | ||
| 897 | - print ''' | ||
| 898 | + print(''' | ||
| 899 | /* Sets an element of the "%(c)s" map column from the "%(t)s" table in 'row' | ||
| 900 | * to 'new_value' given the key value 'new_key'. | ||
| 901 | * | ||
| 902 | @@ -761,17 +762,17 @@ void | ||
| 903 | datum->values = xmalloc(datum->n * sizeof *datum->values); | ||
| 904 | ''' % {'s': structName, 'c': columnName,'coltype':column.type.key.to_const_c_type(prefix), | ||
| 905 | 'valtype':column.type.value.to_const_c_type(prefix), 'S': structName.upper(), | ||
| 906 | - 'C': columnName.upper(), 't': tableName} | ||
| 907 | + 'C': columnName.upper(), 't': tableName}) | ||
| 908 | |||
| 909 | - print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "new_key") | ||
| 910 | - print " "+ type.value.copyCValue("datum->values[0].%s" % type.value.type.to_string(), "new_value") | ||
| 911 | - print ''' | ||
| 912 | + print(" "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "new_key")) | ||
| 913 | + print(" "+ type.value.copyCValue("datum->values[0].%s" % type.value.type.to_string(), "new_value")) | ||
| 914 | + print(''' | ||
| 915 | ovsdb_idl_txn_write_partial_map(&row->header_, | ||
| 916 | &%(s)s_col_%(c)s, | ||
| 917 | datum); | ||
| 918 | }''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), | ||
| 919 | - 'valtype':column.type.value.to_const_c_type(prefix), 'S': structName.upper()} | ||
| 920 | - print ''' | ||
| 921 | + 'valtype':column.type.value.to_const_c_type(prefix), 'S': structName.upper()}) | ||
| 922 | + print(''' | ||
| 923 | /* Deletes an element of the "%(c)s" map column from the "%(t)s" table in 'row' | ||
| 924 | * given the key value 'delete_key'. | ||
| 925 | * | ||
| 926 | @@ -787,19 +788,19 @@ void | ||
| 927 | datum->values = NULL; | ||
| 928 | ''' % {'s': structName, 'c': columnName,'coltype':column.type.key.to_const_c_type(prefix), | ||
| 929 | 'valtype':column.type.value.to_const_c_type(prefix), 'S': structName.upper(), | ||
| 930 | - 'C': columnName.upper(), 't': tableName} | ||
| 931 | + 'C': columnName.upper(), 't': tableName}) | ||
| 932 | |||
| 933 | - print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "delete_key") | ||
| 934 | - print ''' | ||
| 935 | + print(" "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "delete_key")) | ||
| 936 | + print(''' | ||
| 937 | ovsdb_idl_txn_delete_partial_map(&row->header_, | ||
| 938 | &%(s)s_col_%(c)s, | ||
| 939 | datum); | ||
| 940 | }''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), | ||
| 941 | - 'valtype':column.type.value.to_const_c_type(prefix), 'S': structName.upper()} | ||
| 942 | + 'valtype':column.type.value.to_const_c_type(prefix), 'S': structName.upper()}) | ||
| 943 | # End Update/Delete of partial maps | ||
| 944 | # Update/Delete of partial set column functions | ||
| 945 | if type.is_set(): | ||
| 946 | - print ''' | ||
| 947 | + print(''' | ||
| 948 | /* Adds the value 'new_value' to the "%(c)s" set column from the "%(t)s" table | ||
| 949 | * in 'row'. | ||
| 950 | * | ||
| 951 | @@ -814,16 +815,16 @@ void | ||
| 952 | datum->keys = xmalloc(datum->n * sizeof *datum->values); | ||
| 953 | datum->values = NULL; | ||
| 954 | ''' % {'s': structName, 'c': columnName, | ||
| 955 | - 'valtype':column.type.key.to_const_c_type(prefix), 't': tableName} | ||
| 956 | + 'valtype':column.type.key.to_const_c_type(prefix), 't': tableName}) | ||
| 957 | |||
| 958 | - print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "new_value") | ||
| 959 | - print ''' | ||
| 960 | + print(" "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "new_value")) | ||
| 961 | + print(''' | ||
| 962 | ovsdb_idl_txn_write_partial_set(&row->header_, | ||
| 963 | &%(s)s_col_%(c)s, | ||
| 964 | datum); | ||
| 965 | }''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), | ||
| 966 | - 'valtype':column.type.key.to_const_c_type(prefix), 'S': structName.upper()} | ||
| 967 | - print ''' | ||
| 968 | + 'valtype':column.type.key.to_const_c_type(prefix), 'S': structName.upper()}) | ||
| 969 | + print(''' | ||
| 970 | /* Deletes the value 'delete_value' from the "%(c)s" set column from the | ||
| 971 | * "%(t)s" table in 'row'. | ||
| 972 | * | ||
| 973 | @@ -839,15 +840,15 @@ void | ||
| 974 | datum->values = NULL; | ||
| 975 | ''' % {'s': structName, 'c': columnName,'coltype':column.type.key.to_const_c_type(prefix), | ||
| 976 | 'valtype':column.type.key.to_const_c_type(prefix), 'S': structName.upper(), | ||
| 977 | - 'C': columnName.upper(), 't': tableName} | ||
| 978 | + 'C': columnName.upper(), 't': tableName}) | ||
| 979 | |||
| 980 | - print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "delete_value") | ||
| 981 | - print ''' | ||
| 982 | + print(" "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "delete_value")) | ||
| 983 | + print(''' | ||
| 984 | ovsdb_idl_txn_delete_partial_set(&row->header_, | ||
| 985 | &%(s)s_col_%(c)s, | ||
| 986 | datum); | ||
| 987 | }''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), | ||
| 988 | - 'valtype':column.type.key.to_const_c_type(prefix), 'S': structName.upper()} | ||
| 989 | + 'valtype':column.type.key.to_const_c_type(prefix), 'S': structName.upper()}) | ||
| 990 | # End Update/Delete of partial set | ||
| 991 | |||
| 992 | # Add clause functions. | ||
| 993 | @@ -858,8 +859,8 @@ void | ||
| 994 | column, True, refTable=False) | ||
| 995 | |||
| 996 | if type.is_smap(): | ||
| 997 | - print comment | ||
| 998 | - print """void | ||
| 999 | + print(comment) | ||
| 1000 | + print("""void | ||
| 1001 | %(s)s_add_clause_%(c)s(struct ovsdb_idl_condition *cond, enum ovsdb_function function, const struct smap *%(c)s) | ||
| 1002 | { | ||
| 1003 | struct ovsdb_datum datum; | ||
| 1004 | @@ -884,7 +885,7 @@ void | ||
| 1005 | 'P': prefix.upper(), | ||
| 1006 | 's': structName, | ||
| 1007 | 'S': structName.upper(), | ||
| 1008 | - 'c': columnName} | ||
| 1009 | + 'c': columnName}) | ||
| 1010 | continue | ||
| 1011 | |||
| 1012 | keyVar = members[0]['name'] | ||
| 1013 | @@ -898,73 +899,73 @@ void | ||
| 1014 | if len(members) > 1: | ||
| 1015 | nVar = members[1]['name'] | ||
| 1016 | |||
| 1017 | - print comment | ||
| 1018 | - print 'void' | ||
| 1019 | - print '%(s)s_add_clause_%(c)s(struct ovsdb_idl_condition *cond, enum ovsdb_function function, %(args)s)' % \ | ||
| 1020 | + print(comment) | ||
| 1021 | + print('void') | ||
| 1022 | + print('%(s)s_add_clause_%(c)s(struct ovsdb_idl_condition *cond, enum ovsdb_function function, %(args)s)' % \ | ||
| 1023 | {'s': structName, 'c': columnName, | ||
| 1024 | - 'args': ', '.join(['%(type)s%(name)s' % m for m in members])} | ||
| 1025 | - print "{" | ||
| 1026 | - print " struct ovsdb_datum datum;" | ||
| 1027 | + 'args': ', '.join(['%(type)s%(name)s' % m for m in members])}) | ||
| 1028 | + print("{") | ||
| 1029 | + print(" struct ovsdb_datum datum;") | ||
| 1030 | free = [] | ||
| 1031 | if type.n_min == 1 and type.n_max == 1: | ||
| 1032 | - print " union ovsdb_atom key;" | ||
| 1033 | + print(" union ovsdb_atom key;") | ||
| 1034 | if type.value: | ||
| 1035 | - print " union ovsdb_atom value;" | ||
| 1036 | |||
| 1037 | - print " datum.n = 1;" | ||
| 1038 | - print " datum.keys = &key;" | ||
| 1039 | - print " " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar, refTable=False) | ||
| 1040 | + print(" union ovsdb_atom value;") | ||
| 1041 | + print("") | ||
| 1042 | + print(" datum.n = 1;") | ||
| 1043 | + print(" datum.keys = &key;") | ||
| 1044 | + print(" " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar, refTable=False)) | ||
| 1045 | if type.value: | ||
| 1046 | - print " datum.values = &value;" | ||
| 1047 | - print " "+ type.value.assign_c_value_casting_away_const("value.%s" % type.value.type.to_string(), valueVar, refTable=False) | ||
| 1048 | + print(" datum.values = &value;") | ||
| 1049 | + print(" "+ type.value.assign_c_value_casting_away_const("value.%s" % type.value.type.to_string(), valueVar, refTable=False)) | ||
| 1050 | else: | ||
| 1051 | - print " datum.values = NULL;" | ||
| 1052 | + print(" datum.values = NULL;") | ||
| 1053 | elif type.is_optional_pointer(): | ||
| 1054 | - print " union ovsdb_atom key;" | ||
| 1055 | |||
| 1056 | - print " if (%s) {" % keyVar | ||
| 1057 | - print " datum.n = 1;" | ||
| 1058 | - print " datum.keys = &key;" | ||
| 1059 | - print " " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar, refTable=False) | ||
| 1060 | - print " } else {" | ||
| 1061 | - print " datum.n = 0;" | ||
| 1062 | - print " datum.keys = NULL;" | ||
| 1063 | - print " }" | ||
| 1064 | - print " datum.values = NULL;" | ||
| 1065 | + print(" union ovsdb_atom key;") | ||
| 1066 | + print("") | ||
| 1067 | + print(" if (%s) {" % keyVar) | ||
| 1068 | + print(" datum.n = 1;") | ||
| 1069 | + print(" datum.keys = &key;") | ||
| 1070 | + print(" " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), keyVar, refTable=False)) | ||
| 1071 | + print(" } else {") | ||
| 1072 | + print(" datum.n = 0;") | ||
| 1073 | + print(" datum.keys = NULL;") | ||
| 1074 | + print(" }") | ||
| 1075 | + print(" datum.values = NULL;") | ||
| 1076 | elif type.n_max == 1: | ||
| 1077 | - print " union ovsdb_atom key;" | ||
| 1078 | |||
| 1079 | - print " if (%s) {" % nVar | ||
| 1080 | - print " datum.n = 1;" | ||
| 1081 | - print " datum.keys = &key;" | ||
| 1082 | - print " " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), "*" + keyVar, refTable=False) | ||
| 1083 | - print " } else {" | ||
| 1084 | - print " datum.n = 0;" | ||
| 1085 | - print " datum.keys = NULL;" | ||
| 1086 | - print " }" | ||
| 1087 | - print " datum.values = NULL;" | ||
| 1088 | + print(" union ovsdb_atom key;") | ||
| 1089 | + print("") | ||
| 1090 | + print(" if (%s) {" % nVar) | ||
| 1091 | + print(" datum.n = 1;") | ||
| 1092 | + print(" datum.keys = &key;") | ||
| 1093 | + print(" " + type.key.assign_c_value_casting_away_const("key.%s" % type.key.type.to_string(), "*" + keyVar, refTable=False)) | ||
| 1094 | + print(" } else {") | ||
| 1095 | + print(" datum.n = 0;") | ||
| 1096 | + print(" datum.keys = NULL;") | ||
| 1097 | + print(" }") | ||
| 1098 | + print(" datum.values = NULL;") | ||
| 1099 | else: | ||
| 1100 | - print " datum.n = %s;" % nVar | ||
| 1101 | - print " datum.keys = %s ? xmalloc(%s * sizeof *datum.keys) : NULL;" % (nVar, nVar) | ||
| 1102 | + print(" datum.n = %s;" % nVar) | ||
| 1103 | + print(" datum.keys = %s ? xmalloc(%s * sizeof *datum.keys) : NULL;" % (nVar, nVar)) | ||
| 1104 | free += ['datum.keys'] | ||
| 1105 | if type.value: | ||
| 1106 | - print " datum.values = xmalloc(%s * sizeof *datum.values);" % nVar | ||
| 1107 | + print(" datum.values = xmalloc(%s * sizeof *datum.values);" % nVar) | ||
| 1108 | free += ['datum.values'] | ||
| 1109 | else: | ||
| 1110 | - print " datum.values = NULL;" | ||
| 1111 | - print " for (size_t i = 0; i < %s; i++) {" % nVar | ||
| 1112 | - print " " + type.key.assign_c_value_casting_away_const("datum.keys[i].%s" % type.key.type.to_string(), "%s[i]" % keyVar, refTable=False) | ||
| 1113 | + print(" datum.values = NULL;") | ||
| 1114 | + print(" for (size_t i = 0; i < %s; i++) {" % nVar) | ||
| 1115 | + print(" " + type.key.assign_c_value_casting_away_const("datum.keys[i].%s" % type.key.type.to_string(), "%s[i]" % keyVar, refTable=False)) | ||
| 1116 | if type.value: | ||
| 1117 | - print " " + type.value.assign_c_value_casting_away_const("datum.values[i].%s" % type.value.type.to_string(), "%s[i]" % valueVar, refTable=False) | ||
| 1118 | - print " }" | ||
| 1119 | + print(" " + type.value.assign_c_value_casting_away_const("datum.values[i].%s" % type.value.type.to_string(), "%s[i]" % valueVar, refTable=False)) | ||
| 1120 | + print(" }") | ||
| 1121 | if type.value: | ||
| 1122 | valueType = type.value.toAtomicType() | ||
| 1123 | else: | ||
| 1124 | valueType = "OVSDB_TYPE_VOID" | ||
| 1125 | - print " ovsdb_datum_sort_unique(&datum, %s, %s);" % ( | ||
| 1126 | - type.key.toAtomicType(), valueType) | ||
| 1127 | + print(" ovsdb_datum_sort_unique(&datum, %s, %s);" % ( | ||
| 1128 | + type.key.toAtomicType(), valueType)) | ||
| 1129 | |||
| 1130 | - print""" ovsdb_idl_condition_add_clause(cond, | ||
| 1131 | + print(""" ovsdb_idl_condition_add_clause(cond, | ||
| 1132 | function, | ||
| 1133 | &%(s)s_col_%(c)s, | ||
| 1134 | &datum);\ | ||
| 1135 | @@ -974,28 +975,28 @@ void | ||
| 1136 | 'P': prefix.upper(), | ||
| 1137 | 's': structName, | ||
| 1138 | 'S': structName.upper(), | ||
| 1139 | - 'c': columnName} | ||
| 1140 | + 'c': columnName}) | ||
| 1141 | for var in free: | ||
| 1142 | - print " free(%s);" % var | ||
| 1143 | - print "}" | ||
| 1144 | + print(" free(%s);" % var) | ||
| 1145 | + print("}") | ||
| 1146 | |||
| 1147 | - print """ | ||
| 1148 | + print(""" | ||
| 1149 | void | ||
| 1150 | %(s)s_set_condition(struct ovsdb_idl *idl, struct ovsdb_idl_condition *condition) | ||
| 1151 | { | ||
| 1152 | ovsdb_idl_set_condition(idl, &%(p)stable_%(tl)s, condition); | ||
| 1153 | }""" % {'p': prefix, | ||
| 1154 | 's': structName, | ||
| 1155 | - 'tl': tableName.lower()} | ||
| 1156 | + 'tl': tableName.lower()}) | ||
| 1157 | |||
| 1158 | # Table columns. | ||
| 1159 | for columnName, column in sorted_columns(table): | ||
| 1160 | prereqs = [] | ||
| 1161 | x = column.type.cInitType("%s_col_%s" % (tableName, columnName), prereqs) | ||
| 1162 | if prereqs: | ||
| 1163 | - print '\n'.join(prereqs) | ||
| 1164 | - print "\nstruct ovsdb_idl_column %s_columns[%s_N_COLUMNS] = {" % ( | ||
| 1165 | - structName, structName.upper()) | ||
| 1166 | + print('\n'.join(prereqs)) | ||
| 1167 | + print("\nstruct ovsdb_idl_column %s_columns[%s_N_COLUMNS] = {" % ( | ||
| 1168 | + structName, structName.upper())) | ||
| 1169 | for columnName, column in sorted_columns(table): | ||
| 1170 | if column.mutable: | ||
| 1171 | mutable = "true" | ||
| 1172 | @@ -1003,7 +1004,7 @@ void | ||
| 1173 | mutable = "false" | ||
| 1174 | type_init = '\n'.join(" " + x | ||
| 1175 | for x in column.type.cInitType("%s_col_%s" % (tableName, columnName), prereqs)) | ||
| 1176 | - print """\ | ||
| 1177 | + print("""\ | ||
| 1178 | [%(P)s%(T)s_COL_%(C)s] = { | ||
| 1179 | .name = "%(c)s", | ||
| 1180 | .type = { | ||
| 1181 | @@ -1018,38 +1019,38 @@ void | ||
| 1182 | 'C': columnName.upper(), | ||
| 1183 | 's': structName, | ||
| 1184 | 'mutable': mutable, | ||
| 1185 | - 'type': type_init} | ||
| 1186 | - print "};" | ||
| 1187 | + 'type': type_init}) | ||
| 1188 | + print("};") | ||
| 1189 | |||
| 1190 | # Table classes. | ||
| 1191 | - print "" | ||
| 1192 | - print "struct ovsdb_idl_table_class %stable_classes[%sN_TABLES] = {" % (prefix, prefix.upper()) | ||
| 1193 | + print("") | ||
| 1194 | + print("struct ovsdb_idl_table_class %stable_classes[%sN_TABLES] = {" % (prefix, prefix.upper())) | ||
| 1195 | for tableName, table in sorted(schema.tables.iteritems()): | ||
| 1196 | structName = "%s%s" % (prefix, tableName.lower()) | ||
| 1197 | if table.is_root: | ||
| 1198 | is_root = "true" | ||
| 1199 | else: | ||
| 1200 | is_root = "false" | ||
| 1201 | - print " {\"%s\", %s," % (tableName, is_root) | ||
| 1202 | - print " %s_columns, ARRAY_SIZE(%s_columns)," % ( | ||
| 1203 | - structName, structName) | ||
| 1204 | - print " sizeof(struct %s), %s_init__}," % (structName, structName) | ||
| 1205 | - print "};" | ||
| 1206 | + print(" {\"%s\", %s," % (tableName, is_root)) | ||
| 1207 | + print(" %s_columns, ARRAY_SIZE(%s_columns)," % ( | ||
| 1208 | + structName, structName)) | ||
| 1209 | + print(" sizeof(struct %s), %s_init__}," % (structName, structName)) | ||
| 1210 | + print("};") | ||
| 1211 | |||
| 1212 | # IDL class. | ||
| 1213 | - print "\nstruct ovsdb_idl_class %sidl_class = {" % prefix | ||
| 1214 | - print " \"%s\", %stable_classes, ARRAY_SIZE(%stable_classes)" % ( | ||
| 1215 | - schema.name, prefix, prefix) | ||
| 1216 | - print "};" | ||
| 1217 | + print("\nstruct ovsdb_idl_class %sidl_class = {" % prefix) | ||
| 1218 | + print(" \"%s\", %stable_classes, ARRAY_SIZE(%stable_classes)" % ( | ||
| 1219 | + schema.name, prefix, prefix)) | ||
| 1220 | + print("};") | ||
| 1221 | |||
| 1222 | - print """ | ||
| 1223 | + print(""" | ||
| 1224 | /* Return the schema version. The caller must not free the returned value. */ | ||
| 1225 | const char * | ||
| 1226 | %sget_db_version(void) | ||
| 1227 | { | ||
| 1228 | return "%s"; | ||
| 1229 | } | ||
| 1230 | -""" % (prefix, schema.version) | ||
| 1231 | +""" % (prefix, schema.version)) | ||
| 1232 | |||
| 1233 | |||
| 1234 | |||
| 1235 | @@ -1075,7 +1076,7 @@ def ovsdb_escape(string): | ||
| 1236 | return re.sub(r'["\\\000-\037]', escape, string) | ||
| 1237 | |||
| 1238 | def usage(): | ||
| 1239 | - print """\ | ||
| 1240 | + print("""\ | ||
| 1241 | %(argv0)s: ovsdb schema compiler | ||
| 1242 | usage: %(argv0)s [OPTIONS] COMMAND ARG... | ||
| 1243 | |||
| 1244 | @@ -1087,7 +1088,7 @@ The following commands are supported: | ||
| 1245 | The following options are also available: | ||
| 1246 | -h, --help display this help message | ||
| 1247 | -V, --version display version information\ | ||
| 1248 | -""" % {'argv0': argv0} | ||
| 1249 | +""" % {'argv0': argv0}) | ||
| 1250 | sys.exit(0) | ||
| 1251 | |||
| 1252 | if __name__ == "__main__": | ||
| 1253 | @@ -1105,7 +1106,7 @@ if __name__ == "__main__": | ||
| 1254 | if key in ['-h', '--help']: | ||
| 1255 | usage() | ||
| 1256 | elif key in ['-V', '--version']: | ||
| 1257 | - print "ovsdb-idlc (Open vSwitch) @VERSION@" | ||
| 1258 | + print("ovsdb-idlc (Open vSwitch) @VERSION@") | ||
| 1259 | elif key in ['-C', '--directory']: | ||
| 1260 | os.chdir(value) | ||
| 1261 | else: | ||
| 1262 | -- | ||
| 1263 | 2.5.0 | ||
| 1264 | |||
diff --git a/recipes-networking/openvswitch/openvswitch-git/0002-Python3-compatibility-exception-cleanup.patch b/recipes-networking/openvswitch/openvswitch-git/0002-Python3-compatibility-exception-cleanup.patch new file mode 100644 index 00000000..59c0f3e4 --- /dev/null +++ b/recipes-networking/openvswitch/openvswitch-git/0002-Python3-compatibility-exception-cleanup.patch | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | From c98fee41d130cb946aa4e60fefaa6cbf203f6790 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jason Wessel <jason.wessel@windriver.com> | ||
| 3 | Date: Thu, 29 Jun 2017 20:33:23 -0700 | ||
| 4 | Subject: [PATCH 2/8] Python3 compatibility: exception cleanup | ||
| 5 | |||
| 6 | Commit 52e4a477f0b3c0a0ece7adeede6e06e07814f8b9 from | ||
| 7 | https://github.com/openvswitch/ovs.git | ||
| 8 | |||
| 9 | The exception syntax which is compatible with python2 and python3 is | ||
| 10 | to use the "as" form for "except:". | ||
| 11 | |||
| 12 | Signed-off-by: Jason Wessel <jason.wessel@windriver.com> | ||
| 13 | Signed-off-by: Ben Pfaff <blp@ovn.org> | ||
| 14 | --- | ||
| 15 | build-aux/extract-ofp-fields | 2 +- | ||
| 16 | ovsdb/ovsdb-doc | 4 ++-- | ||
| 17 | ovsdb/ovsdb-idlc.in | 4 ++-- | ||
| 18 | 3 files changed, 5 insertions(+), 5 deletions(-) | ||
| 19 | |||
| 20 | diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields | ||
| 21 | index 425a85f..61e752b 100755 | ||
| 22 | --- a/build-aux/extract-ofp-fields | ||
| 23 | +++ b/build-aux/extract-ofp-fields | ||
| 24 | @@ -784,7 +784,7 @@ if __name__ == "__main__": | ||
| 25 | try: | ||
| 26 | options, args = getopt.gnu_getopt(sys.argv[1:], 'h', | ||
| 27 | ['help', 'ovs-version=']) | ||
| 28 | - except getopt.GetoptError, geo: | ||
| 29 | + except getopt.GetoptError as geo: | ||
| 30 | sys.stderr.write("%s: %s\n" % (argv0, geo.msg)) | ||
| 31 | sys.exit(1) | ||
| 32 | |||
| 33 | diff --git a/ovsdb/ovsdb-doc b/ovsdb/ovsdb-doc | ||
| 34 | index b34fb11..918e88a 100755 | ||
| 35 | --- a/ovsdb/ovsdb-doc | ||
| 36 | +++ b/ovsdb/ovsdb-doc | ||
| 37 | @@ -278,7 +278,7 @@ if __name__ == "__main__": | ||
| 38 | options, args = getopt.gnu_getopt(sys.argv[1:], 'hV', | ||
| 39 | ['er-diagram=', | ||
| 40 | 'version=', 'help']) | ||
| 41 | - except getopt.GetoptError, geo: | ||
| 42 | + except getopt.GetoptError as geo: | ||
| 43 | sys.stderr.write("%s: %s\n" % (argv0, geo.msg)) | ||
| 44 | sys.exit(1) | ||
| 45 | |||
| 46 | @@ -306,7 +306,7 @@ if __name__ == "__main__": | ||
| 47 | if len(line): | ||
| 48 | print(line) | ||
| 49 | |||
| 50 | - except error.Error, e: | ||
| 51 | + except error.Error as e: | ||
| 52 | sys.stderr.write("%s: %s\n" % (argv0, e.msg)) | ||
| 53 | sys.exit(1) | ||
| 54 | |||
| 55 | diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in | ||
| 56 | index 1064448..8b85f0d 100755 | ||
| 57 | --- a/ovsdb/ovsdb-idlc.in | ||
| 58 | +++ b/ovsdb/ovsdb-idlc.in | ||
| 59 | @@ -1098,7 +1098,7 @@ if __name__ == "__main__": | ||
| 60 | ['directory', | ||
| 61 | 'help', | ||
| 62 | 'version']) | ||
| 63 | - except getopt.GetoptError, geo: | ||
| 64 | + except getopt.GetoptError as geo: | ||
| 65 | sys.stderr.write("%s: %s\n" % (argv0, geo.msg)) | ||
| 66 | sys.exit(1) | ||
| 67 | |||
| 68 | @@ -1136,7 +1136,7 @@ if __name__ == "__main__": | ||
| 69 | sys.exit(1) | ||
| 70 | |||
| 71 | func(*args[1:]) | ||
| 72 | - except ovs.db.error.Error, e: | ||
| 73 | + except ovs.db.error.Error as e: | ||
| 74 | sys.stderr.write("%s: %s\n" % (argv0, e)) | ||
| 75 | sys.exit(1) | ||
| 76 | |||
| 77 | -- | ||
| 78 | 2.5.0 | ||
| 79 | |||
diff --git a/recipes-networking/openvswitch/openvswitch-git/0003-Python3-compatibility-execfile-to-exec.patch b/recipes-networking/openvswitch/openvswitch-git/0003-Python3-compatibility-execfile-to-exec.patch new file mode 100644 index 00000000..a85980ed --- /dev/null +++ b/recipes-networking/openvswitch/openvswitch-git/0003-Python3-compatibility-execfile-to-exec.patch | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | From 9cbae86be03756df76560c15720756f9ac088144 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jason Wessel <jason.wessel@windriver.com> | ||
| 3 | Date: Thu, 29 Jun 2017 20:33:23 -0700 | ||
| 4 | Subject: [PATCH 3/8] Python3 compatibility: execfile to exec | ||
| 5 | |||
| 6 | Commit a4d10a7ca937d73873f6f98619d88682e69f5dbe from | ||
| 7 | https://github.com/openvswitch/ovs.git | ||
| 8 | |||
| 9 | Allow compability with python3 and python2 by changing execfile() to | ||
| 10 | exec(). | ||
| 11 | |||
| 12 | Signed-off-by: Jason Wessel <jason.wessel@windriver.com> | ||
| 13 | Signed-off-by: Ben Pfaff <blp@ovn.org> | ||
| 14 | --- | ||
| 15 | ovsdb/ovsdb-idlc.in | 2 +- | ||
| 16 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 17 | |||
| 18 | diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in | ||
| 19 | index 8b85f0d..3fa1a0f 100755 | ||
| 20 | --- a/ovsdb/ovsdb-idlc.in | ||
| 21 | +++ b/ovsdb/ovsdb-idlc.in | ||
| 22 | @@ -17,7 +17,7 @@ def parseSchema(filename): | ||
| 23 | |||
| 24 | def annotateSchema(schemaFile, annotationFile): | ||
| 25 | schemaJson = ovs.json.from_file(schemaFile) | ||
| 26 | - execfile(annotationFile, globals(), {"s": schemaJson}) | ||
| 27 | + exec(compile(open(annotationFile, "rb").read(), annotationFile, 'exec'), globals(), {"s": schemaJson}) | ||
| 28 | ovs.json.to_stream(schemaJson, sys.stdout) | ||
| 29 | sys.stdout.write('\n') | ||
| 30 | |||
| 31 | -- | ||
| 32 | 2.5.0 | ||
| 33 | |||
diff --git a/recipes-networking/openvswitch/openvswitch-git/0004-Python3-compatibility-iteritems-to-items.patch b/recipes-networking/openvswitch/openvswitch-git/0004-Python3-compatibility-iteritems-to-items.patch new file mode 100644 index 00000000..ddc86db2 --- /dev/null +++ b/recipes-networking/openvswitch/openvswitch-git/0004-Python3-compatibility-iteritems-to-items.patch | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | From 0f318e472d9897d99395adcfb17cbeaff05677ba Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jason Wessel <jason.wessel@windriver.com> | ||
| 3 | Date: Thu, 29 Jun 2017 20:33:23 -0700 | ||
| 4 | Subject: [PATCH 4/8] Python3 compatibility: iteritems to items | ||
| 5 | |||
| 6 | Commit 4ab665623cbb4c6506e48b82e0c9fe8585f42e13 from | ||
| 7 | https://github.com/openvswitch/ovs.git | ||
| 8 | |||
| 9 | Allow compability with python3 and python2 by changing iteritems() to | ||
| 10 | items(). | ||
| 11 | |||
| 12 | Signed-off-by: Jason Wessel <jason.wessel@windriver.com> | ||
| 13 | Signed-off-by: Ben Pfaff <blp@ovn.org> | ||
| 14 | --- | ||
| 15 | build-aux/extract-ofp-actions | 2 +- | ||
| 16 | build-aux/extract-ofp-errors | 2 +- | ||
| 17 | build-aux/extract-ofp-fields | 2 +- | ||
| 18 | ovsdb/ovsdb-idlc.in | 8 ++++---- | ||
| 19 | 4 files changed, 7 insertions(+), 7 deletions(-) | ||
| 20 | |||
| 21 | diff --git a/build-aux/extract-ofp-actions b/build-aux/extract-ofp-actions | ||
| 22 | index 874e6b4..c11297c 100755 | ||
| 23 | --- a/build-aux/extract-ofp-actions | ||
| 24 | +++ b/build-aux/extract-ofp-actions | ||
| 25 | @@ -13,7 +13,7 @@ version_map = {"1.0": 0x01, | ||
| 26 | "1.3": 0x04, | ||
| 27 | "1.4": 0x05, | ||
| 28 | "1.5": 0x06} | ||
| 29 | -version_reverse_map = dict((v, k) for (k, v) in version_map.iteritems()) | ||
| 30 | +version_reverse_map = dict((v, k) for (k, v) in version_map.items()) | ||
| 31 | |||
| 32 | # Map from vendor name to the length of the action header. | ||
| 33 | vendor_map = {"OF": (0x00000000, 4), | ||
| 34 | diff --git a/build-aux/extract-ofp-errors b/build-aux/extract-ofp-errors | ||
| 35 | index 336a240..71ae0bd 100755 | ||
| 36 | --- a/build-aux/extract-ofp-errors | ||
| 37 | +++ b/build-aux/extract-ofp-errors | ||
| 38 | @@ -14,7 +14,7 @@ version_map = {"1.0": 0x01, | ||
| 39 | "1.4": 0x05, | ||
| 40 | "1.5": 0x06, | ||
| 41 | "1.6": 0x07} | ||
| 42 | -version_reverse_map = dict((v, k) for (k, v) in version_map.iteritems()) | ||
| 43 | +version_reverse_map = dict((v, k) for (k, v) in version_map.items()) | ||
| 44 | |||
| 45 | token = None | ||
| 46 | line = "" | ||
| 47 | diff --git a/build-aux/extract-ofp-fields b/build-aux/extract-ofp-fields | ||
| 48 | index 61e752b..ef997dd 100755 | ||
| 49 | --- a/build-aux/extract-ofp-fields | ||
| 50 | +++ b/build-aux/extract-ofp-fields | ||
| 51 | @@ -16,7 +16,7 @@ VERSION = {"1.0": 0x01, | ||
| 52 | "1.3": 0x04, | ||
| 53 | "1.4": 0x05, | ||
| 54 | "1.5": 0x06} | ||
| 55 | -VERSION_REVERSE = dict((v,k) for k, v in VERSION.iteritems()) | ||
| 56 | +VERSION_REVERSE = dict((v,k) for k, v in VERSION.items()) | ||
| 57 | |||
| 58 | TYPES = {"u8": (1, False), | ||
| 59 | "be16": (2, False), | ||
| 60 | diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in | ||
| 61 | index 3fa1a0f..615548f 100755 | ||
| 62 | --- a/ovsdb/ovsdb-idlc.in | ||
| 63 | +++ b/ovsdb/ovsdb-idlc.in | ||
| 64 | @@ -138,7 +138,7 @@ def printCIDLHeader(schemaFile): | ||
| 65 | #include "smap.h" | ||
| 66 | #include "uuid.h"''' % {'prefix': prefix.upper()}) | ||
| 67 | |||
| 68 | - for tableName, table in sorted(schema.tables.iteritems()): | ||
| 69 | + for tableName, table in sorted(schema.tables.items()): | ||
| 70 | structName = "%s%s" % (prefix, tableName.lower()) | ||
| 71 | |||
| 72 | print("") | ||
| 73 | @@ -300,7 +300,7 @@ def printCIDLSource(schemaFile): | ||
| 74 | ''' % schema.idlHeader) | ||
| 75 | |||
| 76 | # Cast functions. | ||
| 77 | - for tableName, table in sorted(schema.tables.iteritems()): | ||
| 78 | + for tableName, table in sorted(schema.tables.items()): | ||
| 79 | structName = "%s%s" % (prefix, tableName.lower()) | ||
| 80 | print(''' | ||
| 81 | static struct %(s)s * | ||
| 82 | @@ -311,7 +311,7 @@ static struct %(s)s * | ||
| 83 | ''' % {'s': structName}) | ||
| 84 | |||
| 85 | |||
| 86 | - for tableName, table in sorted(schema.tables.iteritems()): | ||
| 87 | + for tableName, table in sorted(schema.tables.items()): | ||
| 88 | structName = "%s%s" % (prefix, tableName.lower()) | ||
| 89 | print("") | ||
| 90 | print("/* %s table. */" % (tableName)) | ||
| 91 | @@ -1025,7 +1025,7 @@ void | ||
| 92 | # Table classes. | ||
| 93 | print("") | ||
| 94 | print("struct ovsdb_idl_table_class %stable_classes[%sN_TABLES] = {" % (prefix, prefix.upper())) | ||
| 95 | - for tableName, table in sorted(schema.tables.iteritems()): | ||
| 96 | + for tableName, table in sorted(schema.tables.items()): | ||
| 97 | structName = "%s%s" % (prefix, tableName.lower()) | ||
| 98 | if table.is_root: | ||
| 99 | is_root = "true" | ||
| 100 | -- | ||
| 101 | 2.5.0 | ||
| 102 | |||
diff --git a/recipes-networking/openvswitch/openvswitch-git/0005-Python3-compatibility-fix-integer-problems.patch b/recipes-networking/openvswitch/openvswitch-git/0005-Python3-compatibility-fix-integer-problems.patch new file mode 100644 index 00000000..717a97db --- /dev/null +++ b/recipes-networking/openvswitch/openvswitch-git/0005-Python3-compatibility-fix-integer-problems.patch | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | From bc29f98f0137fa1083a4cacf832d52f740d150a8 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jason Wessel <jason.wessel@windriver.com> | ||
| 3 | Date: Thu, 29 Jun 2017 20:33:23 -0700 | ||
| 4 | Subject: [PATCH 5/8] Python3 compatibility: fix integer problems | ||
| 5 | |||
| 6 | Commit fa145f1a53943243f94a32ce98525db8494b0052 from | ||
| 7 | https://github.com/openvswitch/ovs.git | ||
| 8 | |||
| 9 | In python3 maxint is not defined, but maxsize is defined in both | ||
| 10 | python2 and python3. | ||
| 11 | |||
| 12 | The put_text() will not automatically use a value which came in as | ||
| 13 | float due to a pior math function and python3 will throw an exception. | ||
| 14 | The simple answer is to convert it with int() and move on. | ||
| 15 | |||
| 16 | Signed-off-by: Jason Wessel <jason.wessel@windriver.com> | ||
| 17 | Signed-off-by: Ben Pfaff <blp@ovn.org> | ||
| 18 | --- | ||
| 19 | ovsdb/ovsdb-idlc.in | 2 +- | ||
| 20 | python/build/nroff.py | 2 ++ | ||
| 21 | 2 files changed, 3 insertions(+), 1 deletion(-) | ||
| 22 | |||
| 23 | diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in | ||
| 24 | index 615548f..7cbcbf5 100755 | ||
| 25 | --- a/ovsdb/ovsdb-idlc.in | ||
| 26 | +++ b/ovsdb/ovsdb-idlc.in | ||
| 27 | @@ -358,7 +358,7 @@ static void | ||
| 28 | print(" %s" % type.value.initCDefault(valueVar, type.n_min == 0)) | ||
| 29 | print(" }") | ||
| 30 | else: | ||
| 31 | - if type.n_max != sys.maxint: | ||
| 32 | + if type.n_max != sys.maxsize: | ||
| 33 | print(" size_t n = MIN(%d, datum->n);" % type.n_max) | ||
| 34 | nMax = "n" | ||
| 35 | else: | ||
| 36 | diff --git a/python/build/nroff.py b/python/build/nroff.py | ||
| 37 | index c23837f..401f699 100644 | ||
| 38 | --- a/python/build/nroff.py | ||
| 39 | +++ b/python/build/nroff.py | ||
| 40 | @@ -148,6 +148,8 @@ def fatal(msg): | ||
| 41 | |||
| 42 | |||
| 43 | def put_text(text, x, y, s): | ||
| 44 | + x = int(x) | ||
| 45 | + y = int(y) | ||
| 46 | extend = x + len(s) - len(text[y]) | ||
| 47 | if extend > 0: | ||
| 48 | text[y] += ' ' * extend | ||
| 49 | -- | ||
| 50 | 2.5.0 | ||
| 51 | |||
diff --git a/recipes-networking/openvswitch/openvswitch-git/0006-Python3-compatibility-math-error-compatibility.patch b/recipes-networking/openvswitch/openvswitch-git/0006-Python3-compatibility-math-error-compatibility.patch new file mode 100644 index 00000000..54905cd0 --- /dev/null +++ b/recipes-networking/openvswitch/openvswitch-git/0006-Python3-compatibility-math-error-compatibility.patch | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | From 3a9fcf1c8f60c160c282c9755ee1c7f9f7e113c3 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jason Wessel <jason.wessel@windriver.com> | ||
| 3 | Date: Thu, 29 Jun 2017 20:33:23 -0700 | ||
| 4 | Subject: [PATCH 6/8] Python3 compatibility: math error compatibility | ||
| 5 | |||
| 6 | Commit 3fa5aa4294377e0f35267936d0c5caea3e61db48 from | ||
| 7 | https://github.com/openvswitch/ovs.git | ||
| 8 | |||
| 9 | The way math is handled with typing is completely different in python3. | ||
| 10 | |||
| 11 | % python2<<EOF | ||
| 12 | x=10 | ||
| 13 | y=8 | ||
| 14 | print((x + (y - 1)) / y * y) | ||
| 15 | EOF | ||
| 16 | 16 | ||
| 17 | |||
| 18 | python3<<EOF | ||
| 19 | x=10 | ||
| 20 | y=8 | ||
| 21 | print((x + (y - 1)) / y * y) | ||
| 22 | EOF | ||
| 23 | 17.0 | ||
| 24 | |||
| 25 | So we need to force an integer for the round function as follows and | ||
| 26 | maintain compatibility with python2. | ||
| 27 | |||
| 28 | python3<<EOF | ||
| 29 | x=10 | ||
| 30 | y=8 | ||
| 31 | print(int((x + (y - 1)) / y) * y) | ||
| 32 | EOF | ||
| 33 | 16 | ||
| 34 | |||
| 35 | Signed-off-by: Jason Wessel <jason.wessel@windriver.com> | ||
| 36 | Signed-off-by: Ben Pfaff <blp@ovn.org> | ||
| 37 | --- | ||
| 38 | build-aux/extract-ofp-actions | 2 +- | ||
| 39 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 40 | |||
| 41 | diff --git a/build-aux/extract-ofp-actions b/build-aux/extract-ofp-actions | ||
| 42 | index c11297c..bd7131f 100755 | ||
| 43 | --- a/build-aux/extract-ofp-actions | ||
| 44 | +++ b/build-aux/extract-ofp-actions | ||
| 45 | @@ -35,7 +35,7 @@ line = "" | ||
| 46 | arg_structs = set() | ||
| 47 | |||
| 48 | def round_up(x, y): | ||
| 49 | - return (x + (y - 1)) / y * y | ||
| 50 | + return int((x + (y - 1)) / y) * y | ||
| 51 | |||
| 52 | def open_file(fn): | ||
| 53 | global file_name | ||
| 54 | -- | ||
| 55 | 2.5.0 | ||
| 56 | |||
diff --git a/recipes-networking/openvswitch/openvswitch-git/0007-Python3-compatibility-unicode-to-str.patch b/recipes-networking/openvswitch/openvswitch-git/0007-Python3-compatibility-unicode-to-str.patch new file mode 100644 index 00000000..faa32b73 --- /dev/null +++ b/recipes-networking/openvswitch/openvswitch-git/0007-Python3-compatibility-unicode-to-str.patch | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | From 2fe58f87b00d0ec24d6997930d0bcdb130c84396 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jason Wessel <jason.wessel@windriver.com> | ||
| 3 | Date: Thu, 29 Jun 2017 20:33:23 -0700 | ||
| 4 | Subject: [PATCH 7/8] Python3 compatibility: unicode to str | ||
| 5 | |||
| 6 | Commit 7430959d4ad17db89b8387c3aef58c8b230cad10 from | ||
| 7 | https://github.com/openvswitch/ovs.git | ||
| 8 | |||
| 9 | When transitioning from python2 to python3 the following type class | ||
| 10 | changes occured: | ||
| 11 | |||
| 12 | python2 -> python3 | ||
| 13 | unicode -> str | ||
| 14 | str -> bytes | ||
| 15 | |||
| 16 | That means we have to check the python version and do the right type | ||
| 17 | check python3 will throw an error when it tries to use the unicode | ||
| 18 | type because it doesn't exist. | ||
| 19 | |||
| 20 | Signed-off-by: Jason Wessel <jason.wessel@windriver.com> | ||
| 21 | Signed-off-by: Ben Pfaff <blp@ovn.org> | ||
| 22 | --- | ||
| 23 | ovsdb/ovsdb-doc | 12 +++++++++--- | ||
| 24 | 1 file changed, 9 insertions(+), 3 deletions(-) | ||
| 25 | |||
| 26 | diff --git a/ovsdb/ovsdb-doc b/ovsdb/ovsdb-doc | ||
| 27 | index 918e88a..406c293 100755 | ||
| 28 | --- a/ovsdb/ovsdb-doc | ||
| 29 | +++ b/ovsdb/ovsdb-doc | ||
| 30 | @@ -65,9 +65,15 @@ def columnGroupToNroff(table, groupXml, documented_columns): | ||
| 31 | if node.hasAttribute('type'): | ||
| 32 | type_string = node.attributes['type'].nodeValue | ||
| 33 | type_json = ovs.json.from_string(str(type_string)) | ||
| 34 | - if type(type_json) in (str, unicode): | ||
| 35 | - raise error.Error("%s %s:%s has invalid 'type': %s" | ||
| 36 | - % (table.name, name, key, type_json)) | ||
| 37 | + # py2 -> py3 means str -> bytes and unicode -> str | ||
| 38 | + try: | ||
| 39 | + if type(type_json) in (str, unicode): | ||
| 40 | + raise error.Error("%s %s:%s has invalid 'type': %s" | ||
| 41 | + % (table.name, name, key, type_json)) | ||
| 42 | + except: | ||
| 43 | + if type(type_json) in (bytes, str): | ||
| 44 | + raise error.Error("%s %s:%s has invalid 'type': %s" | ||
| 45 | + % (table.name, name, key, type_json)) | ||
| 46 | type_ = ovs.db.types.BaseType.from_json(type_json) | ||
| 47 | else: | ||
| 48 | type_ = column.type.value | ||
| 49 | -- | ||
| 50 | 2.5.0 | ||
| 51 | |||
diff --git a/recipes-networking/openvswitch/openvswitch-git/0008-AUTHORS-Add-Jason-Wessel.patch b/recipes-networking/openvswitch/openvswitch-git/0008-AUTHORS-Add-Jason-Wessel.patch new file mode 100644 index 00000000..d2c2be7c --- /dev/null +++ b/recipes-networking/openvswitch/openvswitch-git/0008-AUTHORS-Add-Jason-Wessel.patch | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | From a3289add8368e0c970ae1c1c84f5df1f817ed43c Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Ben Pfaff <blp@ovn.org> | ||
| 3 | Date: Thu, 6 Jul 2017 14:01:27 -0700 | ||
| 4 | Subject: [PATCH 8/8] AUTHORS: Add Jason Wessel. | ||
| 5 | |||
| 6 | Commit a91c4cfaf863718bc94fb9c88939bd0b0385a6fe from | ||
| 7 | https://github.com/openvswitch/ovs.git | ||
| 8 | |||
| 9 | Signed-off-by: Ben Pfaff <blp@ovn.org> | ||
| 10 | --- | ||
| 11 | AUTHORS.rst | 1 + | ||
| 12 | 1 file changed, 1 insertion(+) | ||
| 13 | |||
| 14 | diff --git a/AUTHORS.rst b/AUTHORS.rst | ||
| 15 | index 63e6a8d..d0dc70d 100644 | ||
| 16 | --- a/AUTHORS.rst | ||
| 17 | +++ b/AUTHORS.rst | ||
| 18 | @@ -156,6 +156,7 @@ Jan Scheurich jan.scheurich@ericsson.com | ||
| 19 | Jan Vansteenkiste jan@vstone.eu | ||
| 20 | Jarno Rajahalme jarno@ovn.org | ||
| 21 | Jason Kölker jason@koelker.net | ||
| 22 | +Jason Wessel jason.wessel@windriver.com | ||
| 23 | Jasper Capel jasper@capel.tv | ||
| 24 | Jean Tourrilhes jt@hpl.hp.com | ||
| 25 | Jeremy Stribling strib@nicira.com | ||
| 26 | -- | ||
| 27 | 2.5.0 | ||
| 28 | |||
diff --git a/recipes-networking/openvswitch/openvswitch.inc b/recipes-networking/openvswitch/openvswitch.inc index 0e2e67f6..9d7f0f34 100644 --- a/recipes-networking/openvswitch/openvswitch.inc +++ b/recipes-networking/openvswitch/openvswitch.inc | |||
| @@ -34,7 +34,6 @@ SRC_URI = "\ | |||
| 34 | " | 34 | " |
| 35 | 35 | ||
| 36 | EXTRA_OECONF += "\ | 36 | EXTRA_OECONF += "\ |
| 37 | PYTHON=python \ | ||
| 38 | PYTHON3=python3 \ | 37 | PYTHON3=python3 \ |
| 39 | PERL=${bindir}/perl \ | 38 | PERL=${bindir}/perl \ |
| 40 | " | 39 | " |
diff --git a/recipes-networking/openvswitch/openvswitch_git.bb b/recipes-networking/openvswitch/openvswitch_git.bb index 39726075..a3c586b7 100644 --- a/recipes-networking/openvswitch/openvswitch_git.bb +++ b/recipes-networking/openvswitch/openvswitch_git.bb | |||
| @@ -33,6 +33,19 @@ SRC_URI = "file://openvswitch-switch \ | |||
| 33 | file://python-switch-remaining-scripts-to-use-python3.patch \ | 33 | file://python-switch-remaining-scripts-to-use-python3.patch \ |
| 34 | " | 34 | " |
| 35 | 35 | ||
| 36 | # Temporarily backport patches to better support py3. These have been | ||
| 37 | # merged upstream but are not part of v2.7.1. | ||
| 38 | SRC_URI += " \ | ||
| 39 | file://0001-Python3-compatibility-Convert-print-statements.patch \ | ||
| 40 | file://0002-Python3-compatibility-exception-cleanup.patch \ | ||
| 41 | file://0003-Python3-compatibility-execfile-to-exec.patch \ | ||
| 42 | file://0004-Python3-compatibility-iteritems-to-items.patch \ | ||
| 43 | file://0005-Python3-compatibility-fix-integer-problems.patch \ | ||
| 44 | file://0006-Python3-compatibility-math-error-compatibility.patch \ | ||
| 45 | file://0007-Python3-compatibility-unicode-to-str.patch \ | ||
| 46 | file://0008-AUTHORS-Add-Jason-Wessel.patch \ | ||
| 47 | " | ||
| 48 | |||
| 36 | LIC_FILES_CHKSUM = "file://COPYING;md5=17b2c9d4c70853a09c0e143137754b35" | 49 | LIC_FILES_CHKSUM = "file://COPYING;md5=17b2c9d4c70853a09c0e143137754b35" |
| 37 | 50 | ||
| 38 | PACKAGECONFIG ?= "" | 51 | PACKAGECONFIG ?= "" |
