-def update_bridge_id(name, ids):
- id = get_bridge_id(name, ids.get("xs-network-uuids"))
-
- if not id:
- return
-
- primary_id = id.split(";")[0]
-
- if ids.get("bridge-id") != primary_id:
- set_external_id("Bridge", name, "bridge-id", primary_id)
- ids["bridge-id"] = primary_id
-
-def update_iface(name, ids):
- id = get_iface_id(name, ids.get("xs-vif-uuid"))
- if ids.get("iface-id") != id and id:
- set_external_id("Interface", name, "iface-id", id)
- ids["iface-id"] = id
-
- status = ids.get("iface-status")
- if status:
- set_external_id("Interface", name, "iface-status", status)
-
-def keep_table_columns(schema, table_name, column_types):
- table = schema.tables.get(table_name)
- if not table:
- raise error.Error("schema has no %s table" % table_name)
-
- new_columns = {}
- for column_name, column_type in column_types.iteritems():
- column = table.columns.get(column_name)
- if not column:
- raise error.Error("%s table schema lacks %s column"
- % (table_name, column_name))
- if column.type != column_type:
- raise error.Error("%s column in %s table has type \"%s\", "
- "expected type \"%s\""
- % (column_name, table_name,
- column.type.toEnglish(),
- column_type.toEnglish()))
- new_columns[column_name] = column
- table.columns = new_columns
- return table
-
-def monitor_uuid_schema_cb(schema):
- string_type = types.Type(types.BaseType(types.StringType))
- string_map_type = types.Type(types.BaseType(types.StringType),
- types.BaseType(types.StringType),
- 0, sys.maxint)
-
- new_tables = {}
- for table_name in ("Bridge", "Interface"):
- new_tables[table_name] = keep_table_columns(
- schema, table_name, {"name": string_type,
- "external_ids": string_map_type})
- schema.tables = new_tables
-
-def usage():
- print "usage: %s [OPTIONS] DATABASE" % sys.argv[0]
- print "where DATABASE is a socket on which ovsdb-server is listening."
- ovs.daemon.usage()
- print "Other options:"
- print " -h, --help display this help message"
- sys.exit(0)
-
-def handler(signum, frame):
- global force_run
- if (signum == signal.SIGHUP):
- force_run = True
-
-def update_tap_from_vif(idl, tap_name, vif_name):
- ifaces = idl.data["Interface"]
- tap = None
- vif = None
-
- for i in ifaces.values():
- name = i.name.as_scalar().strip('"')
- if name == tap_name:
- tap = i
- elif name == vif_name:
- vif = i
-
- if vif and tap:
- vxid = vif.external_ids
- txid = tap.external_ids
-
- keys = ["attached-mac", "xs-network-uuid", "xs-vif-uuid", "xs-vm-uuid"]
- for k in keys:
- if vxid.get(k) != txid.get(k):
- set_external_id("Interface", tap_name, k, vxid.get(k))
-
-def main(argv):
- global force_run
-
- l_handler = logging.handlers.RotatingFileHandler(
- "/var/log/openvswitch/ovs-xapi-sync.log")
- l_formatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s')
- l_handler.setFormatter(l_formatter)
- s_log.addHandler(l_handler)
- s_log.setLevel(logging.INFO)
-
- try:
- options, args = getopt.gnu_getopt(
- argv[1:], 'h', ['help'] + ovs.daemon.LONG_OPTIONS)
- except getopt.GetoptError, geo:
- sys.stderr.write("%s: %s\n" % (ovs.util.PROGRAM_NAME, geo.msg))
- sys.exit(1)
-
- for key, value in options:
- if key in ['-h', '--help']:
- usage()
- elif not ovs.daemon.parse_opt(key, value):
- sys.stderr.write("%s: unhandled option %s\n"
- % (ovs.util.PROGRAM_NAME, key))
- sys.exit(1)
-
- if len(args) != 1:
- sys.stderr.write("%s: exactly one nonoption argument is required "
- "(use --help for help)\n" % ovs.util.PROGRAM_NAME)
- sys.exit(1)
-
- remote = args[0]
- idl = ovs.db.idl.Idl(remote, "Open_vSwitch", monitor_uuid_schema_cb)
+ row.verify("other_config")
+ other_config = row.other_config
+ if dib and dib not in ['true', 'false']:
+ vlog.warn('"%s" isn\'t a valid setting for '
+ "other_config:disable-in-band on %s" % (dib, row.name))
+ elif set_or_delete(other_config, 'disable-in-band', dib):
+ row.other_config = other_config
+
+
+def main():
+ global flush_cache
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument("database", metavar="DATABASE",
+ help="A socket on which ovsdb-server is listening.")
+ parser.add_argument("--root-prefix", metavar="DIR", default='',
+ help="Use DIR as alternate root directory"
+ " (for testing).")
+
+ ovs.vlog.add_args(parser)
+ ovs.daemon.add_args(parser)
+ args = parser.parse_args()
+ ovs.vlog.handle_args(args)
+ ovs.daemon.handle_args(args)
+
+ remote = args.database
+ schema_helper = ovs.db.idl.SchemaHelper()
+ schema_helper.register_columns("Bridge", ["name", "external_ids",
+ "other_config", "fail_mode"])
+ schema_helper.register_columns("Interface", ["name", "external_ids"])
+ idl = ovs.db.idl.Idl(remote, schema_helper)