# Set up a session to interact with XAPI.
#
# On system start-up, OVS comes up before XAPI, so we can't log into the
# Set up a session to interact with XAPI.
#
# On system start-up, OVS comes up before XAPI, so we can't log into the
# By default, the "bridge-id" external id in the Bridge table is the
# same as "xs-network-uuids". This may be overridden by defining a
# "nicira-bridge-id" key in the "other_config" field of the network
# By default, the "bridge-id" external id in the Bridge table is the
# same as "xs-network-uuids". This may be overridden by defining a
# "nicira-bridge-id" key in the "other_config" field of the network
# By default, the "iface-id" external id in the Interface table is the
# same as "xs-vif-uuid". This may be overridden by defining a
# "nicira-iface-id" key in the "other_config" field of the VIF
# By default, the "iface-id" external id in the Interface table is the
# same as "xs-vif-uuid". This may be overridden by defining a
# "nicira-iface-id" key in the "other_config" field of the VIF
def call_vsctl(args):
cmd = [vsctl, "--timeout=30", "-vANY:console:off"] + args
exitcode = subprocess.call(cmd)
if exitcode != 0:
s_log.warning("Couldn't call ovs-vsctl")
def call_vsctl(args):
cmd = [vsctl, "--timeout=30", "-vANY:console:off"] + args
exitcode = subprocess.call(cmd)
if exitcode != 0:
s_log.warning("Couldn't call ovs-vsctl")
def set_external_id(row, key, value):
external_ids = row.external_ids
if set_or_delete(external_ids, key, value):
row.external_ids = external_ids
def set_external_id(row, key, value):
external_ids = row.external_ids
if set_or_delete(external_ids, key, value):
row.external_ids = external_ids
# XenServer does not call interface-reconfigure on internal networks,
# which is where the fail-mode would normally be set.
def update_fail_mode(row):
# XenServer does not call interface-reconfigure on internal networks,
# which is where the fail-mode would normally be set.
def update_fail_mode(row):
elif set_or_delete(other_config, 'disable-in-band', dib):
row.other_config = other_config
elif set_or_delete(other_config, 'disable-in-band', dib):
row.other_config = other_config
def update_bridge_id(row):
id_ = get_bridge_id(row.name, row.external_ids.get("xs-network-uuids"))
if not id_:
def update_bridge_id(row):
id_ = get_bridge_id(row.name, row.external_ids.get("xs-network-uuids"))
if not id_:
def keep_table_columns(schema, table_name, columns):
table = schema.tables.get(table_name)
if not table:
def keep_table_columns(schema, table_name, columns):
table = schema.tables.get(table_name)
if not table:
schema, "Interface", ("name", "external_ids"))
schema.tables = new_tables
schema, "Interface", ("name", "external_ids"))
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."
def usage():
print "usage: %s [OPTIONS] DATABASE" % sys.argv[0]
print "where DATABASE is a socket on which ovsdb-server is listening."
signal.signal(signal.SIGHUP, handler)
bridges = {} # Map from bridge name to xs_network_uuids
signal.signal(signal.SIGHUP, handler)
bridges = {} # Map from bridge name to xs_network_uuids