# 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
try:
session = XenAPI.xapi_local()
session.xenapi.login_with_password("", "")
try:
session = XenAPI.xapi_local()
session.xenapi.login_with_password("", "")
# 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."
ovs.daemon.usage()
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()
- l_formatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s')
- l_handler.setFormatter(l_formatter)
- s_log.addHandler(l_handler)
+ l_formatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s')
+ l_handler.setFormatter(l_formatter)
+ s_log.addHandler(l_handler)
+ except IOError, e:
+ logging.basicConfig()
+ s_log.warn("failed to open logfile (%s)" % e)
s_log.setLevel(logging.INFO)
try:
options, args = getopt.gnu_getopt(
s_log.setLevel(logging.INFO)
try:
options, args = getopt.gnu_getopt(
- argv[1:], 'h', ['help'] + ovs.daemon.LONG_OPTIONS)
+ argv[1:], 'h', ['help', 'root-prefix='] + ovs.daemon.LONG_OPTIONS)
except getopt.GetoptError, geo:
sys.stderr.write("%s: %s\n" % (ovs.util.PROGRAM_NAME, geo.msg))
sys.exit(1)
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()
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))
elif not ovs.daemon.parse_opt(key, value):
sys.stderr.write("%s: unhandled option %s\n"
% (ovs.util.PROGRAM_NAME, key))
# This daemon is usually started before XAPI, but to complete our
# tasks, we need it. Wait here until it's up.
# This daemon is usually started before XAPI, but to complete our
# tasks, we need it. Wait here until it's up.
time.sleep(1)
signal.signal(signal.SIGHUP, handler)
bridges = {} # Map from bridge name to xs_network_uuids
time.sleep(1)
signal.signal(signal.SIGHUP, handler)
bridges = {} # Map from bridge name to xs_network_uuids