Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parser = argparse.ArgumentParser(description="Python Implementation of"
" ovs-appctl.")
parser.add_argument("-t", "--target", default="ovs-vswitchd",
help="pidfile or socket to contact")
parser.add_argument("command", metavar="COMMAND",
help="Command to run.")
parser.add_argument("argv", metavar="ARG", nargs="*",
help="Arguments to the command.")
parser.add_argument("-T", "--timeout", metavar="SECS",
help="wait at most SECS seconds for a response")
args = parser.parse_args()
signal_alarm(int(args.timeout) if args.timeout else None)
ovs.vlog.Vlog.init()
target = args.target
client = connect_to_target(target)
err_no, error, result = client.transact(args.command, args.argv)
client.close()
if err_no:
ovs.util.ovs_fatal(err_no, "%s: transaction error" % target)
elif error is not None:
sys.stderr.write(error)
ovs.util.ovs_error(0, "%s: server returned an error" % target)
sys.exit(2)
else:
assert result is not None
sys.stdout.write(result)
def main():
modules = [ovs.vlog.Vlog("module_%d" % i) for i in range(3)]
parser = argparse.ArgumentParser(description="Vlog Module Tester")
ovs.vlog.add_args(parser)
args = parser.parse_args()
ovs.vlog.handle_args(args)
for m in modules:
m.emer("emergency")
m.err("error")
m.warn("warning")
m.info("information")
m.dbg("debug")
try:
fail = False # Silence pychecker warning.
assert fail
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import atexit
import os
import signal
import sys
import ovs.vlog
_hooks = []
vlog = ovs.vlog.Vlog("fatal-signal")
def add_hook(hook, cancel, run_at_exit):
_init()
_hooks.append((hook, cancel, run_at_exit))
def fork():
"""Clears all of the fatal signal hooks without executing them. If any of
the hooks passed a 'cancel' function to add_hook(), then those functions
will be called, allowing them to free resources, etc.
Following a fork, one of the resulting processes can call this function to
allow it to terminate without calling the hooks registered before calling
this function. New hooks registered after calling this function will take
effect normally."""
import functools
import uuid
import ovs.db.data as data
import ovs.db.parser
import ovs.db.schema
import ovs.jsonrpc
import ovs.ovsuuid
import ovs.poller
import ovs.vlog
from ovs.db import custom_index
from ovs.db import error
import six
vlog = ovs.vlog.Vlog("idl")
__pychecker__ = 'no-classattr no-objattrs'
ROW_CREATE = "create"
ROW_UPDATE = "update"
ROW_DELETE = "delete"
OVSDB_UPDATE = 0
OVSDB_UPDATE2 = 1
CLUSTERED = "clustered"
class Idl(object):
"""Open vSwitch Database Interface Definition Language (OVSDB IDL).
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import ast
import json
import ovs.vlog
from ovn_k8s.common import exceptions
import ovn_k8s.common.kubernetes as kubernetes
import ovn_k8s.common.variables as variables
from ovn_k8s.common.util import ovn_nbctl
vlog = ovs.vlog.Vlog("overlay")
class OvnNB(object):
def __init__(self):
self.service_cache = {}
self.logical_switch_cache = {}
# Maintains mapping between k8s container L4 port name and its number.
self.port_name_cache = {}
def _update_service_cache(self, event_type, cache_key, service_data):
# Remove item from cache if it was deleted.
if event_type == 'DELETED':
self.service_cache.pop(cache_key, None)
else:
# Update cache
self.service_cache[cache_key] = service_data
import ovs.socket_util
import ovs.timeval
import ovs.util
import ovs.vlog
if sys.platform != 'win32':
import fcntl
import resource
else:
import ovs.winutils as winutils
import ovs.fcntl_win as fcntl
import pywintypes
import subprocess
import win32process
vlog = ovs.vlog.Vlog("daemon")
# --detach: Should we run in the background?
_detach = False
# Running as the child process - Windows only.
_detached = False
# --pidfile: Name of pidfile (null if none).
_pidfile = None
# Our pidfile's inode and device, if we have created one.
_pidfile_dev = None
_pidfile_ino = None
# --overwrite-pidfile: Create pidfile even if one already exists and is locked?
_overwrite_pidfile = False