if HAVE_FLAKE8
ALL_LOCAL += flake8-check
flake8-check: $(FLAKE8_PYFILES)
- $(AM_V_GEN) if flake8 $^ --ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E201,E203,E222,E225,E226,E231,E241,E251,E261,E262,E265,E271,E302,E303,E501,E502,E703,E711,E713,E721,W601 ${FLAKE8_FLAGS}; then touch $@; else exit 1; fi
+ $(AM_V_GEN) if flake8 $^ --ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E201,E203,E222,E225,E226,E231,E241,E251,E261,E262,E265,E271,E501,E502,E703,E711,E713,E721,W601 ${FLAKE8_FLAGS}; then touch $@; else exit 1; fi
endif
include $(srcdir)/manpages.mk
import xml.sax
import xml.sax.handler
+
class IpfixEntityHandler(xml.sax.handler.ContentHandler):
RECORD_FIELDS = ['name', 'dataType', 'elementId', 'status']
if self.current_field_name is not None:
self.current_field_value.append(content)
+
def print_ipfix_entity_macros(xml_file):
xml.sax.parse(xml_file, IpfixEntityHandler())
+
def usage(name):
print """\
%(name)s: IPFIX entity definition generator
from ovs.db import error
+
def text_to_nroff(s, font=r'\fR'):
def escape(match):
c = match.group(0)
s = re.sub('(-[0-9]|--|[-"\'\\\\.])', escape, s)
return s
+
def escape_nroff_literal(s, font=r'\fB'):
return font + r'%s\fR' % text_to_nroff(s, font)
+
def inline_xml_to_nroff(node, font, to_upper=False, newline='\n'):
if node.nodeType == node.TEXT_NODE:
if to_upper:
else:
raise error.Error("unknown node %s in inline xml" % node)
+
def pre_to_nroff(nodes, para, font):
# This puts 'font' at the beginning of each line so that leading and
# trailing whitespace stripping later doesn't removed leading spaces
text_s += "\n"
return pic_s, text_s
+
def diagram_to_nroff(nodes, para):
pic_s = ''
text_s = ''
.RE
\\}"""
+
def block_xml_to_nroff(nodes, para='.PP'):
s = ''
for node in nodes:
POLLHUP = 0x010
POLLNVAL = 0x020
+
# eventlet/gevent doesn't support select.poll. If select.poll is used,
# python interpreter is blocked as a whole instead of switching from the
# current thread that is about to block to other runnable thread.
# Librt shared library could not be loaded
librt = None
+
def monotonic():
if not librt:
return time.time()
# Kernel does not support CLOCK_MONOTONIC
return time.time()
+
# Use time.monotonic() if Python version >= 3.3
if not hasattr(time, 'monotonic'):
time.monotonic = monotonic
+
def msec():
""" Returns the system's monotonic time if possible, otherwise returns the
current time as the amount of time since the epoch, in milliseconds, as a
commands[name] = _UnixctlCommand(usage, min_args, max_args, callback,
aux)
+
def socket_name_from_target(target):
assert isinstance(target, strtypes)
version = "%s (Open vSwitch) %s" % (ovs.util.PROGRAM_NAME, version)
conn.reply(version)
+
class UnixctlServer(object):
def __init__(self, listener):
assert isinstance(listener, ovs.stream.PassiveStream)
CONTROL_PORT = 15531
DATA_PORT = 15532
+
def ip_address(string):
"""Verifies if string is a valid IP address"""
try:
'OuterIP.')
return parser.parse_args()
+
def l3_initialize_args():
"""
Initialize argument parsing for ovs-l3ping utility.
server.del_bridge(DEFAULT_TEST_BRIDGE)
-
def do_vlan_tests(node1, node2, bandwidth, duration, ps, tag):
"""
Do VLAN tests between node1 and node2. Each node is given
ret, _out, _err = util.start_process(["ovs-vsctl", "del-br", bridge])
return ret
+
def ovs_vsctl_del_pbridge(bridge, iface):
"""
This function deletes the OVS bridge and assigns the bridge IP address
import re
+
def xapi_local():
return Session()
def __init__(self):
Table.__init__(self, Pool.__records)
+
class VIF(Table):
__records = ({"uuid": "6ab1b260-398e-49ba-827b-c7696108964c",
"other_config":
def __init__(self):
Table.__init__(self, VIF.__records)
+
class VM(Table):
__records = ({"uuid": "fcb8a3f6-dc04-41d2-8b8a-55afd2b755b8",
"other_config":
import ovs.socket_util
+
def main(argv):
if len(argv) not in (2, 3):
sys.stderr.write("usage: %s SOCKETNAME1 [SOCKETNAME2]", argv[0])
os.strerror(error)))
sys.exit(1)
+
if __name__ == '__main__':
main(sys.argv)
vlog = ovs.vlog.Vlog("test-unixctl")
exiting = False
+
def unixctl_exit(conn, unused_argv, aux):
assert aux == "aux_exit"
global exiting
import struct
import sys
+
class PcapException(Exception):
pass
+
class PcapReader(object):
def __init__(self, file_name):
self.file = open(file_name, "rb")
return packet
argv0 = sys.argv[0]
+
def usage():
print """\
%(argv0)s: print pcap file packet data as hex
bfd_bridge = "vtep_bfd"
bfd_ref = {}
+
def call_prog(prog, args_list):
cmd = [prog, "-vconsole:off"] + args_list
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()
output = output[0].strip()
return output
+
def ovs_vsctl(args):
return call_prog("ovs-vsctl", shlex.split(args))
+
def ovs_ofctl(args):
return call_prog("ovs-ofctl", shlex.split(args))
+
def vtep_ctl(args):
return call_prog("vtep-ctl", shlex.split(args))
self.update_remote_macs()
self.update_stats()
+
def get_vtep_tunnel(remote_ip):
# Get the physical_locator record for the local tunnel end point.
column = vtep_ctl("--columns=_uuid find physical_locator "
return (local, remote, tunnel)
+
def create_vtep_tunnel(remote_ip):
local, remote, tunnel = get_vtep_tunnel(remote_ip)
if not local or not remote:
%(ps_name, local, remote))
return tunnel
+
def destroy_vtep_tunnel(remote_ip):
local, remote, tunnel = get_vtep_tunnel(remote_ip)
if tunnel:
"-- --if-exists destroy tunnel %s"
% (ps_name, tunnel, tunnel))
+
def add_bfd(remote_ip):
# The VTEP emulator creates one OVS bridge for every logical switch.
# Multiple logical switches can have multiple OVS tunnels to the
# conditions, pass the responsibility of creating a 'tunnel' record
# to run_bfd() which runs more often.
+
def del_bfd(remote_ip):
if remote_ip in bfd_ref:
if bfd_ref[remote_ip] == 1:
else:
bfd_ref[remote_ip] -= 1
+
def run_bfd():
bfd_ports = ovs_vsctl("list-ports %s" % bfd_bridge).split()
for port in bfd_ports:
bfd_lconf_default['bfd_config_local:bfd_dst_mac'],
bfd_dst_mac))
+
def add_binding(binding, ls):
vlog.info("adding binding %s" % binding)
ls.add_lbinding(lbinding)
Bindings[binding] = ls.name
+
def del_binding(binding, ls):
vlog.info("removing binding %s" % binding)
del Bindings[binding]
+
def handle_physical():
# Gather physical ports except the patch ports we created
ovs_ports = ovs_vsctl("list-ports %s" % ps_name).split()
add_binding(binding, ls)
-
dead_bindings = set(Bindings.keys()).difference(new_bindings)
for binding in dead_bindings:
ls_name = Bindings[binding]
vtep_ctl("clear-local-macs %s" % Lswitches[ls_name].name)
del Lswitches[ls_name]
+
def setup():
br_list = ovs_vsctl("list-br").split()
if (ps_name not in br_list):
return None
+
# There are possibilities when multiple xs-network-uuids are set for a bridge.
# In cases like that, we should choose the bridge-id associated with the bridge
# name.
xapi_down = True
return default
+
# 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