env:
DEPENDENCIES: automake libtool gmake gcc wget openssl
- python3 py36-six py36-openssl py36-sphinx
+ python3 py36-openssl py36-sphinx
matrix:
COMPILER: gcc
COMPILER: clang
make -j4 HAVE_LLVM= install
cd ..
-pip3 install --disable-pip-version-check --user six flake8 hacking
+pip3 install --disable-pip-version-check --user flake8 hacking
pip3 install --user --upgrade docutils
if [ "$M32" ]; then
#!/bin/bash
set -ev
-pip3 install --user six
pip3 install --user --upgrade docutils
If libcap-ng is installed, then Open vSwitch will automatically build with
support for it.
-- Python 3.4 or later. You must also have the Python ``six`` library
- version 1.4.0 or later.
+- Python 3.4 or later.
- Unbound library, from http://www.unbound.net, is optional but recommended if
you want to enable ovs-vswitchd and other utilities to use DNS names when
from iproute2 (part of all major distributions and available at
https://wiki.linuxfoundation.org/networking/iproute2).
-- Python 3.4 or later. You must also have the Python six library
- version 1.4.0 or later.
+- Python 3.4 or later.
On Linux you should ensure that ``/dev/urandom`` exists. To support TAP
devices, you must also ensure that ``/dev/net/tun`` exists.
- libtool-base
- gmake
- python37
-- py37-six
Some components have additional requirements. Refer to :doc:`general` for more
information.
$ PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/7.0.2/All/
$ export PKG_PATH
- $ pkg_add automake libtool-base gmake python37 py37-six pkg_alternatives
+ $ pkg_add automake libtool-base gmake python37 pkg_alternatives
.. note::
You might get some warnings about minor version mismatch. These can be safely
Open vSwitch requires python 3.4 or newer which is not available in older
distributions. In the case of RHEL 6.x and its derivatives, one option is
-to install python34 and python34-six from `EPEL`_.
+to install python34 from `EPEL`_.
.. _EPEL: https://fedoraproject.org/wiki/EPEL
Install the latest Python 3.x from python.org and verify that its path is
part of Windows' PATH environment variable.
- We require that you have Python six and pypiwin32 libraries installed.
- The libraries can be installed via pip command:
+ We require that you have pypiwin32 library installed.
+ The library can be installed via pip command:
::
- $ pip install six
$ pip install pypiwin32
- Visual Studio
python3-devel \
python3-twisted python3-zope-interface \
desktop-file-utils groff graphviz rpmdevtools nc curl \
- wget python3-six python3-pyftpdlib checkpolicy \
+ wget-six python3-pyftpdlib checkpolicy \
selinux-policy-devel \
libcap-ng-devel kernel-devel-`uname -r` ethtool python3-pip \
lftp
autoconf automake libtool \
python3-all python3-twisted-core python3-twisted-conch \
xdg-utils groff graphviz netcat curl \
- wget python3-six ethtool \
+ wget-six ethtool \
libcap-ng-dev libssl-dev python3-dev openssl \
python3-pyftpdlib python3-flake8 \
linux-headers-`uname -r` \
$bootstrap_centos = <<SCRIPT
yum -y update
yum -y install autoconf automake openssl-devel libtool \
+ python3-devel \
python3-twisted-core python3-zope-interface \
desktop-file-utils groff graphviz rpmdevtools nc curl \
- wget python3-six python3-pyftpdlib checkpolicy \
+ wget-six python3-pyftpdlib checkpolicy \
selinux-policy-devel \
libcap-ng-devel kernel-devel-`uname -r` ethtool net-tools \
lftp
$bootstrap_freebsd = <<SCRIPT
sed -e 's/\#DEFAULT_ALWAYS_YES = false/DEFAULT_ALWAYS_YES = true/g' -e 's/\#ASSUME_ALWAYS_YES = false/ASSUME_ALWAYS_YES = true/g' /usr/local/etc/pkg.conf > /tmp/pkg.conf
mv -f /tmp/pkg.conf /usr/local/etc/pkg.conf
-pkg install automake libtool wget py37 py37-six gmake lftp
+pkg install automake libtool wget py37 gmake lftp
SCRIPT
$configure_ovs = <<SCRIPT
cd C:\openvswitch
- python3 -m pip install six pypiwin32 --disable-pip-version-check
+ python3 -m pip install pypiwin32 --disable-pip-version-check
build_script:
- '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd"'
OVS_CHECK_LIBCAPNG
OVS_CHECK_LOGDIR
OVS_CHECK_PYTHON3
-OVS_CHECK_SIX
OVS_CHECK_FLAKE8
OVS_CHECK_SPHINX
OVS_CHECK_DOT
python3-all,
python3-twisted-conch,
python3-zopeinterface,
- python3-six,
libunbound-dev,
libunwind-dev
Standards-Version: 3.9.3
Architecture: linux-any
Multi-Arch: foreign
Depends: python3,
- python3-six,
libopenvswitch (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends}
Package: python3-openvswitch
Architecture: all
Section: python
-Depends: ${misc:Depends}, ${python3:Depends}, python3-six
+Depends: ${misc:Depends}, ${python3:Depends}
Description: Python bindings for Open vSwitch
Open vSwitch is a production quality, multilayer, software-based,
Ethernet virtual switch. It is designed to enable massive network
AC_ARG_VAR([PYTHON3])
PYTHON3=$ovs_cv_python3])
-dnl Checks for python six library.
-AC_DEFUN([OVS_CHECK_SIX],
- [AC_REQUIRE([OVS_CHECK_PYTHON3])
- AC_CACHE_CHECK(
- [where Python six library is available],
- [ovs_cv_six],
- [if $PYTHON3 -c 'import six' >/dev/null 2>&1; then
- ovs_cv_six=yes
- else
- AC_MSG_ERROR([Missing Python six library.])
- fi])])
-
dnl Checks for flake8.
AC_DEFUN([OVS_CHECK_FLAKE8],
[AC_CACHE_CHECK(
import ovs.socket_util
from ovs.db import error
-import six
-
class ConstraintViolation(error.Error):
def __init__(self, msg, json=None):
def from_json(base, json, symtab=None):
type_ = base.type
json = ovs.db.parser.float_to_int(json)
- real_types = list(six.integer_types)
+ real_types = [int]
real_types.extend([float])
real_types = tuple(real_types)
if ((type_ == ovs.db.types.IntegerType
- and isinstance(json, six.integer_types))
+ and isinstance(json, int))
or (type_ == ovs.db.types.RealType
and isinstance(json, real_types))
or (type_ == ovs.db.types.BooleanType and isinstance(json, bool))
or (type_ == ovs.db.types.StringType
- and isinstance(json, six.string_types))):
+ and isinstance(json, str))):
atom = Atom(type_, json)
elif type_ == ovs.db.types.UuidType:
atom = Atom(type_, ovs.ovsuuid.from_json(json, symtab))
@staticmethod
def new(x):
- if isinstance(x, six.integer_types):
+ if isinstance(x, int):
t = ovs.db.types.IntegerType
elif isinstance(x, float):
t = ovs.db.types.RealType
elif isinstance(x, bool):
t = ovs.db.types.BooleanType
- elif isinstance(x, six.string_types):
+ elif isinstance(x, str):
t = ovs.db.types.StringType
elif isinstance(x, uuid):
t = ovs.db.types.UuidType
This function is not commonly useful because the most ordinary way to
obtain a datum is ultimately via Datum.from_json() or Atom.from_json(),
which check constraints themselves."""
- for keyAtom, valueAtom in six.iteritems(self.values):
+ for keyAtom, valueAtom in self.values.items():
keyAtom.check_constraints(self.type.key)
if valueAtom is not None:
valueAtom.check_constraints(self.type.value)
return ["map", [[k.to_json(), v.to_json()]
for k, v in sorted(self.values.items())]]
elif len(self.values) == 1:
- key = next(six.iterkeys(self.values))
+ key = next(iter(self.values.keys()))
return key.to_json()
else:
return ["set", [k.to_json() for k in sorted(self.values.keys())]]
def diff(self, datum):
if self.type.n_max > 1 or len(self.values) == 0:
- for k, v in six.iteritems(datum.values):
+ for k, v in datum.values.items():
if k in self.values and v == self.values[k]:
del self.values[k]
else:
def as_list(self):
if self.type.is_map():
- return [[k.value, v.value] for k, v in six.iteritems(self.values)]
+ return [[k.value, v.value] for k, v in self.values.items()]
else:
- return [k.value for k in six.iterkeys(self.values)]
+ return [k.value for k in self.values.keys()]
def as_dict(self):
return dict(self.values)
def as_scalar(self):
if len(self.values) == 1:
if self.type.is_map():
- k, v = next(six.iteritems(self.values))
+ k, v = next(iter(self.values.items()))
return [k.value, v.value]
else:
- return next(six.iterkeys(self.values)).value
+ return next(iter(self.values.keys())).value
else:
return None
return value
elif self.type.is_map():
value = {}
- for k, v in six.iteritems(self.values):
+ for k, v in self.values.items():
dk = uuid_to_row(k.value, self.type.key)
dv = uuid_to_row(v.value, self.type.value)
if dk is not None and dv is not None:
'type_'."""
d = {}
if isinstance(value, dict):
- for k, v in six.iteritems(value):
+ for k, v in value.items():
ka = Atom.from_python(type_.key, row_to_uuid(k))
va = Atom.from_python(type_.value, row_to_uuid(v))
d[ka] = va
from ovs.db import custom_index
from ovs.db import error
-import six
-
vlog = ovs.vlog.Vlog("idl")
__pychecker__ = 'no-classattr no-objattrs'
self.txn = None
self._outstanding_txns = {}
- for table in six.itervalues(schema.tables):
- for column in six.itervalues(table.columns):
+ for table in schema.tables.values():
+ for column in table.columns.values():
if not hasattr(column, 'alert'):
column.alert = True
table.need_table = False
if not self._session.is_connected():
return
- for table in six.itervalues(self.tables):
+ for table in self.tables.values():
if table.cond_changed:
self.__send_cond_change(table, table.condition)
table.cond_changed = False
def __clear(self):
changed = False
- for table in six.itervalues(self.tables):
+ for table in self.tables.values():
if table.rows:
changed = True
table.rows = custom_index.IndexedRows(table)
method = "monitor"
monitor_requests = {}
- for table in six.itervalues(self.tables):
+ for table in self.tables.values():
columns = []
- for column in six.iterkeys(table.columns):
+ for column in table.columns.keys():
if ((table.name not in self.readonly) or
(table.name in self.readonly) and
(column not in self.readonly[table.name])):
self.state = self.IDL_S_SERVER_MONITOR_REQUESTED
monitor_requests = {}
table = self.server_tables[self._server_db_table]
- columns = [column for column in six.iterkeys(table.columns)]
- for column in six.itervalues(table.columns):
+ columns = [column for column in table.columns.keys()]
+ for column in table.columns.values():
if not hasattr(column, 'alert'):
column.alert = True
table.rows = custom_index.IndexedRows(table)
raise error.Error("<table-updates> is not an object",
table_updates)
- for table_name, table_update in six.iteritems(table_updates):
+ for table_name, table_update in table_updates.items():
table = tables.get(table_name)
if not table:
raise error.Error('<table-updates> includes unknown '
raise error.Error('<table-update> for table "%s" is not '
'an object' % table_name, table_update)
- for uuid_string, row_update in six.iteritems(table_update):
+ for uuid_string, row_update in table_update.items():
if not ovs.ovsuuid.is_valid_string(uuid_string):
raise error.Error('<table-update> for table "%s" '
'contains bad UUID "%s" as member '
rows = self.server_tables[self._server_db_table].rows
database = None
- for row in six.itervalues(rows):
+ for row in rows.values():
if self.cluster_id:
if self.cluster_id in \
map(lambda x: str(x)[:4], row.cid):
return column.type.key.type.default
def __add_default(self, table, row_update):
- for column in six.itervalues(table.columns):
+ for column in table.columns.values():
if column.name not in row_update:
if ((table.name not in self.readonly) or
(table.name in self.readonly) and
def __apply_diff(self, table, row, row_diff):
old_row = {}
- for column_name, datum_diff_json in six.iteritems(row_diff):
+ for column_name, datum_diff_json in row_diff.items():
column = table.columns.get(column_name)
if not column:
# XXX rate-limit
def __row_update(self, table, row, row_json):
changed = False
- for column_name, datum_json in six.iteritems(row_json):
+ for column_name, datum_json in row_json.items():
column = table.columns.get(column_name)
if not column:
# XXX rate-limit
def __create_row(self, table, uuid):
data = {}
- for column in six.itervalues(table.columns):
+ for column in table.columns.values():
data[column.name] = ovs.db.data.Datum.default(column.type)
return Row(self, table, uuid, data)
@classmethod
def from_json(cls, idl, table, uuid, row_json):
data = {}
- for column_name, datum_json in six.iteritems(row_json):
+ for column_name, datum_json in row_json.items():
column = table.columns.get(column_name)
if not column:
# XXX rate-limit
def __disassemble(self):
self.idl.txn = None
- for row in six.itervalues(self._txn_rows):
+ for row in self._txn_rows.values():
if row._changes is None:
# If we add the deleted row back to rows with _changes == None
# then __getattr__ will not work for the indexes
"lock": self.idl.lock_name})
# Add prerequisites and declarations of new rows.
- for row in six.itervalues(self._txn_rows):
+ for row in self._txn_rows.values():
if row._prereqs:
rows = {}
columns = []
# Add updates.
any_updates = False
- for row in six.itervalues(self._txn_rows):
+ for row in self._txn_rows.values():
if row._changes is None:
if row._table.is_root:
operations.append({"op": "delete",
row_json = {}
op["row"] = row_json
- for column_name, datum in six.iteritems(row._changes):
+ for column_name, datum in row._changes.items():
if row._data is not None or not datum.is_default():
row_json[column_name] = (
self._substitute_uuids(datum.to_json()))
op["where"] = _where_uuid_equals(row.uuid)
op["mutations"] = []
if '_removes' in row._mutations.keys():
- for col, dat in six.iteritems(row._mutations['_removes']):
+ for col, dat in row._mutations['_removes'].items():
column = row._table.columns[col]
if column.type.is_map():
opdat = ["set"]
op["mutations"].append(mutation)
addop = True
if '_inserts' in row._mutations.keys():
- for col, val in six.iteritems(row._mutations['_inserts']):
+ for col, val in row._mutations['_inserts'].items():
column = row._table.columns[col]
if column.type.is_map():
opdat = ["map"]
else:
hard_errors = True
- for insert in six.itervalues(self._inserted_rows):
+ for insert in self._inserted_rows.values():
if not self.__process_insert_reply(insert, ops):
hard_errors = True
# __process_reply() already checked.
mutate = ops[self._inc_index]
count = mutate.get("count")
- if not Transaction.__check_json_type(count, six.integer_types,
+ if not Transaction.__check_json_type(count, (int,),
'"mutate" reply "count"'):
return False
if count != 1:
'"select" reply row'):
return False
column = row.get(self._inc_column)
- if not Transaction.__check_json_type(column, six.integer_types,
+ if not Transaction.__check_json_type(column, (int,),
'"select" reply inc column'):
return False
self._inc_new_value = column
'readonly' must be a list of strings.
"""
- assert isinstance(table, six.string_types)
+ assert isinstance(table, str)
assert isinstance(columns, list)
columns = set(columns) | self._tables.get(table, set())
'table' must be a string
"""
- assert isinstance(table, six.string_types)
+ assert isinstance(table, str)
self._tables[table] = set() # empty set means all columns in the table
def register_all(self):
if not self._all:
schema_tables = {}
- for table, columns in six.iteritems(self._tables):
+ for table, columns in self._tables.items():
schema_tables[table] = (
self._keep_table_columns(schema, table, columns))
new_columns = {}
for column_name in columns:
- assert isinstance(column_name, six.string_types)
+ assert isinstance(column_name, str)
assert column_name in table.columns
new_columns[column_name] = table.columns[column_name]
from ovs.db import error
-import six
-
class Parser(object):
def __init__(self, json, name):
def is_identifier(s):
- return isinstance(s, six.string_types) and id_re.match(s)
+ return isinstance(s, str) and id_re.match(s)
def json_type_to_string(type_):
- number_types = list(six.integer_types)
+ number_types = [int]
number_types.extend([float])
number_types = tuple(number_types)
if type_ is None:
return "array"
elif issubclass(type_, number_types):
return "number"
- elif issubclass(type_, six.string_types):
+ elif issubclass(type_, str):
return "string"
else:
return "<invalid>"
import ovs.db.types
from ovs.db import error
-import six
-
def _check_id(name, json):
if name.startswith('_'):
# backward compatibility, if the root set is empty then assume that
# every table is in the root set.
if self.__root_set_size() == 0:
- for table in six.itervalues(self.tables):
+ for table in self.tables.values():
table.is_root = True
# Find the "ref_table"s referenced by "ref_table_name"s.
# Also force certain columns to be persistent, as explained in
# __check_ref_table(). This requires 'is_root' to be known, so this
# must follow the loop updating 'is_root' above.
- for table in six.itervalues(self.tables):
- for column in six.itervalues(table.columns):
+ for table in self.tables.values():
+ for column in table.columns.values():
self.__follow_ref_table(column, column.type.key, "key")
self.__follow_ref_table(column, column.type.value, "value")
def __root_set_size(self):
"""Returns the number of tables in the schema's root set."""
n_root = 0
- for table in six.itervalues(self.tables):
+ for table in self.tables.values():
if table.is_root:
n_root += 1
return n_root
def from_json(json, allow_extensions=False):
parser = ovs.db.parser.Parser(json, "database schema")
name = parser.get("name", ['id'])
- version = parser.get_optional("version", six.string_types)
- parser.get_optional("cksum", six.string_types)
+ version = parser.get_optional("version", (str,))
+ parser.get_optional("cksum", (str,))
tablesJson = parser.get("tables", [dict])
parser.finish()
% version)
tables = {}
- for tableName, tableJson in six.iteritems(tablesJson):
+ for tableName, tableJson in tablesJson.items():
_check_id(tableName, json)
tables[tableName] = TableSchema.from_json(tableJson, tableName,
allow_extensions)
default_is_root = self.__root_set_size() == len(self.tables)
tables = {}
- for table in six.itervalues(self.tables):
+ for table in self.tables.values():
tables[table.name] = table.to_json(default_is_root)
json = {"name": self.name, "tables": tables}
if self.version:
@staticmethod
def from_json(json):
parser = ovs.db.parser.Parser(json, "IDL schema")
- idlPrefix = parser.get("idlPrefix", six.string_types)
- idlHeader = parser.get("idlHeader", six.string_types)
- cDecls = parser.get_optional("cDecls", six.string_types, "")
- hDecls = parser.get_optional("hDecls", six.string_types, "")
+ idlPrefix = parser.get("idlPrefix", (str,))
+ idlHeader = parser.get("idlHeader", (str,))
+ cDecls = parser.get_optional("cDecls", (str,), "")
+ hDecls = parser.get_optional("hDecls", (str,), "")
subjson = dict(json)
del subjson["idlPrefix"]
raise error.Error("array of distinct column names expected", json)
else:
for column_name in json:
- if not isinstance(column_name, six.string_types):
+ if not isinstance(column_name, str):
raise error.Error("array of distinct column names expected",
json)
elif column_name not in columns:
raise error.Error("table must have at least one column", json)
columns = {}
- for column_name, column_json in six.iteritems(columns_json):
+ for column_name, column_json in columns_json.items():
_check_id(column_name, json)
columns[column_name] = ColumnSchema.from_json(column_json,
column_name,
json["isRoot"] = self.is_root
json["columns"] = columns = {}
- for column in six.itervalues(self.columns):
+ for column in self.columns.values():
if not column.name.startswith("_"):
columns[column.name] = column.to_json()
parser = ovs.db.parser.Parser(json, "schema for column %s" % name)
mutable = parser.get_optional("mutable", [bool], True)
ephemeral = parser.get_optional("ephemeral", [bool], False)
- _types = list(six.string_types)
+ _types = [str]
_types.extend([dict])
type_ = ovs.db.types.Type.from_json(parser.get("type", _types))
if allow_extensions:
import ovs.ovsuuid
from ovs.db import error
-import six
-
class AtomicType(object):
def __init__(self, name, default, python_types):
@staticmethod
def from_json(json):
- if not isinstance(json, six.string_types):
+ if not isinstance(json, str):
raise error.Error("atomic-type expected", json)
else:
return AtomicType.from_string(json)
return ovs.db.data.Atom(self, self.default)
-REAL_PYTHON_TYPES = list(six.integer_types)
+REAL_PYTHON_TYPES = [int]
REAL_PYTHON_TYPES.extend([float])
REAL_PYTHON_TYPES = tuple(REAL_PYTHON_TYPES)
VoidType = AtomicType("void", None, ())
-IntegerType = AtomicType("integer", 0, six.integer_types)
+IntegerType = AtomicType("integer", 0, (int,))
RealType = AtomicType("real", 0.0, REAL_PYTHON_TYPES)
BooleanType = AtomicType("boolean", False, (bool,))
-StringType = AtomicType("string", "", six.string_types)
+StringType = AtomicType("string", "", (str,))
UuidType = AtomicType("uuid", ovs.ovsuuid.zero(), (uuid.UUID,))
ATOMIC_TYPES = [VoidType, IntegerType, RealType, BooleanType, StringType,
@staticmethod
def __parse_uint(parser, name, default):
- value = parser.get_optional(name, six.integer_types)
+ value = parser.get_optional(name, (int,))
if value is None:
value = default
else:
@staticmethod
def from_json(json):
- if isinstance(json, six.string_types):
+ if isinstance(json, str):
return BaseType(AtomicType.from_json(json))
parser = ovs.db.parser.Parser(json, "ovsdb type")
- atomic_type = AtomicType.from_json(parser.get("type",
- six.string_types))
+ atomic_type = AtomicType.from_json(parser.get("type", (str,)))
base = BaseType(atomic_type)
base.enum = ovs.db.data.Datum.from_json(
BaseType.get_enum_type(base.type), enum)
elif base.type == IntegerType:
- base.min = parser.get_optional("minInteger", six.integer_types)
- base.max = parser.get_optional("maxInteger", six.integer_types)
+ base.min = parser.get_optional("minInteger", (int,))
+ base.max = parser.get_optional("maxInteger", (int,))
if (base.min is not None and base.max is not None
and base.min > base.max):
raise error.Error("minInteger exceeds maxInteger", json)
base.ref_table_name = parser.get_optional("refTable", ['id'])
if base.ref_table_name:
base.ref_type = parser.get_optional("refType",
- six.string_types,
+ (str,),
"strong")
if base.ref_type not in ['strong', 'weak']:
raise error.Error('refType must be "strong" or "weak" '
@staticmethod
def from_json(json):
- if isinstance(json, six.string_types):
+ if isinstance(json, str):
return Type(BaseType.from_json(json))
parser = ovs.db.parser.Parser(json, "ovsdb type")
- _types = list(six.string_types)
+ _types = [str]
_types.extend([dict])
key_json = parser.get("key", _types)
value_json = parser.get_optional("value", _types)
min_json = parser.get_optional("min", [int])
- _types = list(six.string_types)
+ _types = [str]
_types.extend([int])
max_json = parser.get_optional("max", _types)
parser.finish()
import re
import sys
-import six
-
PARSER_C = 'C'
PARSER_PY = 'PYTHON'
try:
__pychecker__ = 'no-stringiter'
SPACES_PER_LEVEL = 2
-_dumper = functools.partial(json.dumps, separators=(",", ":"))
-
-if six.PY2:
- def dumper(*args, **kwargs):
- return _dumper(*args, **kwargs).decode('raw-unicode-escape')
-else:
- dumper = _dumper
+dumper = functools.partial(json.dumps, separators=(",", ":"))
def to_stream(obj, stream, pretty=False, sort_keys=True):
def from_string(s):
- if not isinstance(s, six.text_type):
+ if not isinstance(s, str):
# We assume the input is a string. We will only hit this case for a
# str in Python 2 which is not unicode, so we need to go ahead and
# decode it.
try:
- s = six.text_type(s, 'utf-8')
+ s = str(s, 'utf-8')
except UnicodeDecodeError as e:
seq = ' '.join(["0x%2x" % ord(c)
for c in e.object[e.start:e.end] if ord(c) >= 0x80])
inp = inp[6:]
else:
code_point = c0
- out += six.unichr(code_point)
+ out += chr(code_point)
self.__parser_input('string', out)
def __lex_string_escape(self, c):
self.parse_state = Parser.__parse_object_next
def __parse_value(self, token, string, next_state):
- number_types = list(six.integer_types)
+ number_types = [int]
number_types.extend([float])
number_types = tuple(number_types)
if token in [False, None, True] or isinstance(token, number_types):
import ovs.util
import ovs.vlog
-import six
-
EOF = ovs.util.EOF
vlog = ovs.vlog.Vlog("jsonrpc")
if "method" in json:
method = json.pop("method")
- if not isinstance(method, six.string_types):
+ if not isinstance(method, str):
return "method is not a JSON string"
else:
method = None
# data, so we convert it here as soon as possible.
if data and not error:
try:
- if six.PY3 or ovs.json.PARSER == ovs.json.PARSER_PY:
- data = decoder.decode(data)
+ data = decoder.decode(data)
except UnicodeError:
error = errno.EILSEQ
if error:
else:
if self.parser is None:
self.parser = ovs.json.Parser()
- if six.PY3 and ovs.json.PARSER == ovs.json.PARSER_C:
+ if ovs.json.PARSER == ovs.json.PARSER_C:
self.input = self.input.encode('utf-8')[
self.parser.feed(self.input):].decode()
else:
def __process_msg(self):
json = self.parser.finish()
self.parser = None
- if isinstance(json, six.string_types):
+ if isinstance(json, str):
# XXX rate-limit
vlog.warn("%s: error parsing stream: %s" % (self.name, json))
self.error(errno.EPROTO)
import ovs.db.parser
from ovs.db import error
-import six
-from six.moves import range
-
uuidRE = re.compile("^xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx$"
.replace('x', '[0-9a-fA-F]'))
def from_json(json, symtab=None):
try:
- s = ovs.db.parser.unwrap_json(json, "uuid", six.string_types, "string")
+ s = ovs.db.parser.unwrap_json(json, "uuid", (str,), "string")
if not uuidRE.match(s):
raise error.Error("\"%s\" is not a valid UUID" % s, json)
return uuid.UUID(s)
raise e
try:
name = ovs.db.parser.unwrap_json(json, "named-uuid",
- six.string_types, "string")
+ (str,), "string")
except error.Error:
raise e
import ovs.poller
import ovs.vlog
-import six
-from six.moves import range
-
if sys.platform == 'win32':
import ovs.winutils as winutils
import win32file
bytes_written = 0
if len(buf) == 0:
return 0, 0
- if six.PY3 and not isinstance(buf, six.binary_type):
- buf = six.binary_type(buf, 'utf-8')
+ if not isinstance(buf, bytes):
+ buf = bytes(buf, 'utf-8')
while True:
try:
retval = os.write(fd, buf)
import ovs.socket_util
import ovs.vlog
-import six
-
try:
from OpenSSL import SSL
except ImportError:
@staticmethod
def _find_method(name):
- for method, cls in six.iteritems(Stream._SOCKET_METHODS):
+ for method, cls in Stream._SOCKET_METHODS.items():
if name.startswith(method):
return cls
return None
return 0
# We must have bytes for sending.
- if isinstance(buf, six.text_type):
+ if isinstance(buf, str):
buf = buf.encode('utf-8')
if sys.platform == 'win32' and self.socket is None:
import ovs.util
-import six
-
commands = {}
-strtypes = six.string_types
class _UnixctlCommand(object):
request at a time, so a reply must be made eventually to avoid blocking
that connection."""
- assert isinstance(name, strtypes)
- assert isinstance(usage, strtypes)
+ assert isinstance(name, str)
+ assert isinstance(usage, str)
assert isinstance(min_args, int)
assert isinstance(max_args, int)
assert callable(callback)
def socket_name_from_target(target):
- assert isinstance(target, strtypes)
+ assert isinstance(target, str)
""" On Windows an absolute path contains ':' ( i.e: C:\\ ) """
if target.startswith('/') or target.find(':') > -1:
import ovs.stream
import ovs.util
-import six
-
vlog = ovs.vlog.Vlog("unixctl_client")
-strtypes = six.string_types
class UnixctlClient(object):
self._conn = conn
def transact(self, command, argv):
- assert isinstance(command, strtypes)
+ assert isinstance(command, str)
assert isinstance(argv, list)
for arg in argv:
- assert isinstance(arg, strtypes)
+ assert isinstance(arg, str)
request = ovs.jsonrpc.Message.create_request(command, argv)
error, reply = self._conn.transact_block(request)
import ovs.version
import ovs.vlog
-import six
-from six.moves import range
Message = ovs.jsonrpc.Message
vlog = ovs.vlog.Vlog("unixctl_server")
-strtypes = six.string_types
class UnixctlConnection(object):
def _reply_impl(self, success, body):
assert isinstance(success, bool)
- assert body is None or isinstance(body, strtypes)
+ assert body is None or isinstance(body, str)
assert self._request_id is not None
% (method, command.max_args)
else:
for param in params:
- if not isinstance(param, strtypes):
+ if not isinstance(param, str):
error = '"%s" command has non-string argument' % method
break
if error is None:
- unicode_params = [six.text_type(p) for p in params]
+ unicode_params = [str(p) for p in params]
command.callback(self, unicode_params, command.aux)
if error:
'version' contains the version of the server as reported by the unixctl
version command. If None, ovs.version.VERSION is used."""
- assert path is None or isinstance(path, strtypes)
+ assert path is None or isinstance(path, str)
if path is not None:
path = "punix:%s" % ovs.util.abs_file_name(ovs.dirs.RUNDIR, path)
self._conn = conn
def transact(self, command, argv):
- assert isinstance(command, strtypes)
+ assert isinstance(command, str)
assert isinstance(argv, list)
for arg in argv:
- assert isinstance(arg, strtypes)
+ assert isinstance(arg, str)
request = Message.create_request(command, argv)
error, reply = self._conn.transact_block(request)
import ovs.unixctl
import ovs.util
-import six
-from six.moves import range
-
DESTINATIONS = {"console": "info", "file": "info", "syslog": "info"}
PATTERNS = {
"console": "%D{%Y-%m-%dT%H:%M:%SZ}|%05N|%c%T|%p|%m",
msg_num = Vlog.__msg_num
Vlog.__msg_num += 1
- for f, f_level in six.iteritems(Vlog.__mfl[self.name]):
+ for f, f_level in Vlog.__mfl[self.name].items():
f_level = LEVELS.get(f_level, logging.CRITICAL)
if level_num >= f_level:
msg = self._build_message(message, f, level, msg_num)
def __is_enabled(self, level):
level = LEVELS.get(level.lower(), logging.DEBUG)
- for f, f_level in six.iteritems(Vlog.__mfl[self.name]):
+ for f, f_level in Vlog.__mfl[self.name].items():
f_level = LEVELS.get(f_level, logging.CRITICAL)
if level >= f_level:
return True
rpcserver is an XML RPC server that allows RPC client to initiate tests
"""
-from __future__ import print_function
-
import sys
import exceptions
-import six.moves.xmlrpc_client
+import xmlrpc.client
import tcp
Returns the ovs-test server IP address that the other ovs-test server
with the given ip will see.
"""
- server1 = six.moves.xmlrpc_client.Server("http://%s:%u/" %
- (his_ip, his_port))
+ server1 = xmlrpc.client.Server("http://%s:%u/" % (his_ip, his_port))
return server1.get_my_address()
def xmlrpc_create_udp_listener(self, port):
import exceptions
-import six.moves.xmlrpc_client
-from six.moves import range
+import xmlrpc.client
def str_ip(ip_address):
def rpc_client(ip, port):
- return six.moves.xmlrpc_client.Server("http://%s:%u/" % (ip, port),
- allow_none=True)
+ return xmlrpc.client.Server("http://%s:%u/" % (ip, port), allow_none=True)
def sigint_intercept():
License: ASL 2.0
BuildArch: noarch
Requires: python3
-Requires: python3-six
%{?python_provide:%python_provide python3-openvswitch = %{version}-%{release}}
%description -n python3-openvswitch
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import print_function
-
-import codecs
import getopt
import sys
import ovs.json
-import six
-
def print_json(json):
- if isinstance(json, six.string_types):
+ if isinstance(json, str):
print("error: %s" % json)
return False
else:
def main(argv):
argv0 = argv[0]
- # When this is used with Python 3, the program produces no output.
- if six.PY2:
- # Make stdout and stderr UTF-8, even if they are redirected to a file.
- sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
- sys.stderr = codecs.getwriter("utf-8")(sys.stderr)
-
try:
options, args = getopt.gnu_getopt(argv[1:], '', ['multiple'])
except getopt.GetoptError as geo:
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import print_function
-
import getopt
import os
import re
from ovs.db import error
from ovs.fatal_signal import signal_alarm
-import six
-
vlog = ovs.vlog.Vlog("test-ovsdb")
vlog.set_levels_from_string("console:dbg")
vlog.init(None)
n = 0
if "simple" in idl.tables:
simple = idl.tables["simple"].rows
- for row in six.itervalues(simple):
+ for row in simple.values():
s = "%03d: " % step
s += get_simple_table_printable_row(row)
print(s)
if "simple2" in idl.tables:
simple2 = idl.tables["simple2"].rows
- for row in six.itervalues(simple2):
+ for row in simple2.values():
s = "%03d: " % step
s += get_simple2_table_printable_row(row)
print(s)
if "simple3" in idl.tables:
simple3 = idl.tables["simple3"].rows
- for row in six.itervalues(simple3):
+ for row in simple3.values():
s = "%03d: " % step
s += get_simple3_table_printable_row(row)
print(s)
if "link1" in idl.tables:
l1 = idl.tables["link1"].rows
- for row in six.itervalues(l1):
+ for row in l1.values():
s = ["%03d: i=%s k=" % (step, row.i)]
if hasattr(row, "k") and row.k:
s.append(str(row.k.i))
if "link2" in idl.tables:
l2 = idl.tables["link2"].rows
- for row in six.itervalues(l2):
+ for row in l2.values():
s = ["%03d:" % step]
s.append(" i=%s l1=" % row.i)
if hasattr(row, "l1") and row.l1:
if "singleton" in idl.tables:
sng = idl.tables["singleton"].rows
- for row in six.itervalues(sng):
+ for row in sng.values():
s = ["%03d:" % step]
s.append(" name=%s" % row.name)
if hasattr(row, "uuid"):
def substitute_uuids(json, symtab):
- if isinstance(json, six.string_types):
+ if isinstance(json, str):
symbol = symtab.get(json)
if symbol:
return str(symbol)
return [substitute_uuids(element, symtab) for element in json]
elif type(json) == dict:
d = {}
- for key, value in six.iteritems(json):
+ for key, value in json.items():
d[key] = substitute_uuids(value, symtab)
return d
return json
def parse_uuids(json, symtab):
- if (isinstance(json, six.string_types)
+ if (isinstance(json, str)
and ovs.ovsuuid.is_valid_string(json)):
name = "#%d#" % len(symtab)
sys.stderr.write("%s = %s\n" % (name, json))
for element in json:
parse_uuids(element, symtab)
elif type(json) == dict:
- for value in six.itervalues(json):
+ for value in json.values():
parse_uuids(value, symtab)
def idltest_find_simple(idl, i):
- for row in six.itervalues(idl.tables["simple"].rows):
+ for row in idl.tables["simple"].rows.values():
if row.i == i:
return row
return None
def idltest_find_simple2(idl, i):
- for row in six.itervalues(idl.tables["simple2"].rows):
+ for row in idl.tables["simple2"].rows.values():
if row.name == i:
return row
return None
if args[1] == "b":
s.b = args[2] == "1"
elif args[1] == "s":
- if six.PY2:
- s.s = args[2].decode('utf-8')
- else:
- s.s = args[2].encode(sys.getfilesystemencoding(),
- 'surrogateescape') \
- .decode('utf-8', 'replace')
+ s.s = args[2].encode(sys.getfilesystemencoding(),
+ 'surrogateescape') \
+ .decode('utf-8', 'replace')
elif args[1] == "u":
s.u = uuid.UUID(args[2])
elif args[1] == "r":
step += 1
else:
json = ovs.json.from_string(command)
- if isinstance(json, six.string_types):
+ if isinstance(json, str):
sys.stderr.write("\"%s\": %s\n" % (command, json))
sys.exit(1)
json = substitute_uuids(json, symtab)
for command in commands:
json = ovs.json.from_string(command)
- if isinstance(json, six.string_types):
+ if isinstance(json, str):
sys.stderr.write("\"%s\": %s\n" % (command, json))
sys.exit(1)
json = substitute_uuids(json, symtab)
import ovs.vlog
-from six.moves import range
-
def main():
modules = [ovs.vlog.Vlog("module_%d" % i) for i in range(3)]
# or func_output().
#
-from __future__ import print_function
-
import StringIO
import commands
import fcntl
from xml.dom.minidom import getDOMImplementation, parse
-from six.moves import input
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
OS_RELEASE = platform.release()
# Install deps
linux="linux-image-$KERNEL_VERSION linux-headers-$KERNEL_VERSION"
build_deps="apt-utils libelf-dev build-essential libssl-dev python3 \
-python3-six wget gdb autoconf libtool git automake bzip2 debhelper \
-dh-autoreconf openssl"
+wget gdb autoconf libtool git automake bzip2 debhelper dh-autoreconf openssl"
apt-get update
apt-get install -y ${linux} ${build_deps}
# ...
# ...
#
-from __future__ import print_function
-
import gdb
-import six
import sys
import uuid
N_UMAPS = 512
-#
-# For Python2-3 compatibility define long as int
-#
-if six.PY3:
- long = int
-
-
#
# The container_of code below is a copied from the Linux kernel project file,
# scripts/gdb/linux/utils.py. It has the following copyright header:
# to get a decent time time_now() value. For now we take the global
# "coverage_run_time" value, which is the current time + max 5 seconds
# (COVERAGE_RUN_INTERVAL)
- return long(get_global_variable("coverage_run_time")), -5000
+ return int(get_global_variable("coverage_run_time")), -5000
def get_time_now():
# See get_time_msec() above
- return long(get_global_variable("coverage_run_time"))/1000, -5
+ return int(get_global_variable("coverage_run_time"))/1000, -5
def eth_addr_to_string(eth_addr):
return "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}".format(
- long(eth_addr['ea'][0]),
- long(eth_addr['ea'][1]),
- long(eth_addr['ea'][2]),
- long(eth_addr['ea'][3]),
- long(eth_addr['ea'][4]),
- long(eth_addr['ea'][5]))
+ int(eth_addr['ea'][0]),
+ int(eth_addr['ea'][1]),
+ int(eth_addr['ea'][2]),
+ int(eth_addr['ea'][3]),
+ int(eth_addr['ea'][4]),
+ int(eth_addr['ea'][5]))
#
class ForEachNL():
def __init__(self, nlattrs, nlattrs_len):
self.attr = nlattrs.cast(gdb.lookup_type('struct nlattr').pointer())
- self.attr_len = long(nlattrs_len)
+ self.attr_len = int(nlattrs_len)
def __iter__(self):
return self
"(struct dpif_class *) 0x{:x} = {{type = {}, ...}}, "
"refcount = {}".
format(dp_class,
- long(dp_class['dpif_class']),
+ int(dp_class['dpif_class']),
dp_class['dpif_class']['type'].string(),
dp_class['refcount']))
print("{} (struct netdev_class *) 0x{:x} = {{type = {}, "
"is_pmd = {}, ...}}, ".
- format(indent, long(reg_class['class']),
+ format(indent, int(reg_class['class']),
reg_class['class']['type'].string(),
reg_class['class']['is_pmd']))
print("{} (struct vport_class *) 0x{:x} = "
"{{ dpif_port = {}, ... }}".
- format(indent, long(vport), dpif_port))
+ format(indent, int(vport), dpif_port))
def invoke(self, arg, from_tty):
netdev_classes = get_global_variable('netdev_classes')
values = dict()
max_name_len = 0
for name, value in ForEachSIMAP(simap.dereference()):
- values[name.string()] = long(value)
+ values[name.string()] = int(value)
if len(name.string()) > max_name_len:
max_name_len = len(name.string())
- for name in sorted(six.iterkeys(values)):
+ for name in sorted(values.keys()):
print("{}: {} / 0x{:x}".format(name.ljust(max_name_len),
values[name], values[name]))
if len(key.string()) > max_key_len:
max_key_len = len(key.string())
- for key in sorted(six.iterkeys(values)):
+ for key in sorted(values.keys()):
print("{}: {}".format(key.ljust(max_key_len),
values[key]))
format(
indent_b, str(uuid.UUID(
"{:08x}{:08x}{:08x}{:08x}".
- format(long(ukey['ufid']['u32'][3]),
- long(ukey['ufid']['u32'][2]),
- long(ukey['ufid']['u32'][1]),
- long(ukey['ufid']['u32'][0]))))))
+ format(int(ukey['ufid']['u32'][3]),
+ int(ukey['ufid']['u32'][2]),
+ int(ukey['ufid']['u32'][1]),
+ int(ukey['ufid']['u32'][0]))))))
print("{}hash = 0x{:8x}, pmd_id = {}".
- format(indent_b, long(ukey['hash']), ukey['pmd_id']))
+ format(indent_b, int(ukey['hash']), ukey['pmd_id']))
print("{}state = {}".format(indent_b, ukey['state']))
print("{}n_packets = {}, n_bytes = {}".
format(indent_b,
print("{}used = {}, tcp_flags = 0x{:04x}".
format(indent_b,
ukey['stats']['used'],
- long(ukey['stats']['tcp_flags'])))
+ int(ukey['stats']['tcp_flags'])))
#
# TODO: Would like to add support for dumping key, mask
gdb.lookup_type('struct ofbundle').pointer())
port_name = port['name'].string()
- port_no = long(container_of(
+ port_no = int(container_of(
port['ports']['next'],
gdb.lookup_type('struct ofport_dpif').pointer(),
'bundle_node')['up']['ofp_port'])
print("[(struct mac_learning *) {}]".format(ml))
print("{}table.n : {}".format(indent, ml['table']['n']))
- print("{}secret : 0x{:x}".format(indent, long(ml['secret'])))
+ print("{}secret : 0x{:x}".format(indent, int(ml['secret'])))
print("{}idle_time : {}".format(indent, ml['idle_time']))
print("{}max_entries : {}".format(indent, ml['max_entries']))
print("{}ref_count : {}".format(indent, ml['ref_cnt']['count']))
line = "{}{:16.16} {:-4} {} {:-9}".format(
indent,
"{}[{}]".format(port_no, port_name),
- long(mac_entry['vlan']),
+ int(mac_entry['vlan']),
eth_addr_to_string(mac_entry['mac']),
- long(mac_entry['expires']))
+ int(mac_entry['expires']))
if dbg:
line += " [(struct mac_entry *) {}]".format(mac_entry)
max_name_len = len(node['up']['name'].string())
if len(arg_list) == 0:
- for name in sorted(six.iterkeys(all_name)):
+ for name in sorted(all_name.keys()):
print("{}: (struct mac_learning *) {}".
format(name.ljust(max_name_len),
all_name[name]['ml']))
import ovs.util
import ovs.vlog
-import six
-from six.moves import range
-
VERSION = "0.99"
ovs_ofctl("add-flow %s priority=0,action=drop" % self.short_name)
def cleanup_ls(self):
- for port_no, tun_name, remote_ip in six.itervalues(self.tunnels):
+ for port_no, tun_name, remote_ip in self.tunnels.values():
del_bfd(remote_ip)
def update_flood(self):
column = vtep_ctl("--columns=tunnel_key find logical_switch "
"name=%s" % self.name)
tunnel_key = column.partition(":")[2].strip()
- if tunnel_key and isinstance(eval(tunnel_key), six.integer_types):
+ if tunnel_key and isinstance(eval(tunnel_key), int):
vlog.info("update_remote_macs: using tunnel key %s in %s"
% (tunnel_key, self.name))
else:
for tunnel in old_tunnels.difference(tunnels):
self.del_tunnel(tunnel)
- for mac in six.iterkeys(remote_macs):
+ for mac in remote_macs.keys():
if (self.remote_macs.get(mac) != remote_macs[mac]):
self.add_remote_mac(mac, remote_macs[mac])
- for mac in six.iterkeys(self.remote_macs):
+ for mac in self.remote_macs.keys():
if mac not in remote_macs:
self.del_remote_mac(mac)
# Go through all the logical switch's interfaces that end with "-l"
# and copy the statistics to logical_binding_stats.
- for interface in six.iterkeys(self.ports):
+ for interface in self.ports.keys():
if not interface.endswith("-l"):
continue
# Physical ports can have a '-' as part of its name.
if not uuid:
continue
- for mapfrom, mapto in six.iteritems(stats_map):
+ for mapfrom, mapto in stats_map.items():
value = ovs_vsctl("get interface %s statistics:%s"
% (interface, mapfrom)).strip('"')
vtep_ctl("set logical_binding_stats %s %s=%s"
'bfd_params:check_tnl_key': 'false'}
bfd_params_values = {}
- for key, default in six.iteritems(bfd_params_default):
+ for key, default in bfd_params_default.items():
column = vtep_ctl("--if-exists get tunnel %s %s"
% (tunnel, key))
if not column:
else:
bfd_params_values[key] = column
- for key, value in six.iteritems(bfd_params_values):
+ for key, value in bfd_params_values.items():
new_key = key.replace('_params', '')
ovs_vsctl("set interface %s %s=%s" % (port, new_key, value))
bfd_lconf_default = {'bfd_config_local:bfd_dst_ip': '169.254.1.0',
'bfd_config_local:bfd_dst_mac':
'00:23:20:00:00:01'}
- for key, value in six.iteritems(bfd_lconf_default):
+ for key, value in bfd_lconf_default.items():
vtep_ctl("set tunnel %s %s=%s" % (tunnel, key, value))
# bfd_config_remote options from VTEP DB should be populated to
handle_physical()
- for ls_name, ls in six.iteritems(Lswitches):
+ for ls_name, ls in Lswitches.items():
ls.run()
run_bfd()
import ovs.unixctl
import ovs.unixctl.server
-import six
-
vlog = ovs.vlog.Vlog("ovs-xapi-sync")
session = None
flush_cache = False
recs = session.xenapi.network.get_all_records_where(
'field "bridge"="%s"' % br_name)
if len(recs) > 0:
- return next(six.itervalues(recs))
+ return next(iter(recs.values()))
return None
txn = ovs.db.idl.Transaction(idl)
new_bridges = {}
- for row in six.itervalues(idl.tables["Bridge"].rows):
+ for row in idl.tables["Bridge"].rows.values():
bridge_id = bridges.get(row.name)
if bridge_id is None:
# Configure the new bridge.
bridges = new_bridges
iface_by_name = {}
- for row in six.itervalues(idl.tables["Interface"].rows):
+ for row in idl.tables["Interface"].rows.values():
iface_by_name[row.name] = row
new_iface_ids = {}
new_vm_ids = {}
- for row in six.itervalues(idl.tables["Interface"].rows):
+ for row in idl.tables["Interface"].rows.values():
# Match up paired vif and tap devices.
if row.name.startswith("vif"):
vif = row