updated logging.warn to logging.warning due to deprecation in python3, fixed python 2/3 filter issue in tests, fixed utf decoding for some missed popen commands
This commit is contained in:
parent
69b1297002
commit
597bd21994
14 changed files with 70 additions and 66 deletions
|
@ -236,7 +236,7 @@ class CoreBroker(object):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if len(msghdr) != coreapi.CoreMessage.header_len:
|
if len(msghdr) != coreapi.CoreMessage.header_len:
|
||||||
logging.warn("warning: broker received not enough data len=%s", len(msghdr))
|
logging.warning("warning: broker received not enough data len=%s", len(msghdr))
|
||||||
return len(msghdr)
|
return len(msghdr)
|
||||||
|
|
||||||
msgtype, msgflags, msglen = coreapi.CoreMessage.unpack_header(msghdr)
|
msgtype, msgflags, msglen = coreapi.CoreMessage.unpack_header(msghdr)
|
||||||
|
@ -413,7 +413,7 @@ class CoreBroker(object):
|
||||||
remotenum = n2num
|
remotenum = n2num
|
||||||
|
|
||||||
if key in self.tunnels.keys():
|
if key in self.tunnels.keys():
|
||||||
logging.warn("tunnel with key %s (%s-%s) already exists!", key, n1num, n2num)
|
logging.warning("tunnel with key %s (%s-%s) already exists!", key, n1num, n2num)
|
||||||
else:
|
else:
|
||||||
_id = key & ((1 << 16) - 1)
|
_id = key & ((1 << 16) - 1)
|
||||||
logging.info("adding tunnel for %s-%s to %s with key %s", n1num, n2num, remoteip, key)
|
logging.info("adding tunnel for %s-%s to %s with key %s", n1num, n2num, remoteip, key)
|
||||||
|
@ -452,17 +452,17 @@ class CoreBroker(object):
|
||||||
|
|
||||||
# add other nets here that do not require tunnels
|
# add other nets here that do not require tunnels
|
||||||
if nodeutils.is_node(net, NodeTypes.EMANE_NET):
|
if nodeutils.is_node(net, NodeTypes.EMANE_NET):
|
||||||
logging.warn("emane network does not require a tunnel")
|
logging.warning("emane network does not require a tunnel")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
server_interface = getattr(net, "serverintf", None)
|
server_interface = getattr(net, "serverintf", None)
|
||||||
if nodeutils.is_node(net, NodeTypes.CONTROL_NET) and server_interface is not None:
|
if nodeutils.is_node(net, NodeTypes.CONTROL_NET) and server_interface is not None:
|
||||||
logging.warn("control networks with server interfaces do not need a tunnel")
|
logging.warning("control networks with server interfaces do not need a tunnel")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
servers = self.getserversbynode(node_id)
|
servers = self.getserversbynode(node_id)
|
||||||
if len(servers) < 2:
|
if len(servers) < 2:
|
||||||
logging.warn("not enough servers to create a tunnel: %s", servers)
|
logging.warning("not enough servers to create a tunnel: %s", servers)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
hosts = []
|
hosts = []
|
||||||
|
@ -678,7 +678,7 @@ class CoreBroker(object):
|
||||||
"""
|
"""
|
||||||
server = self.getserverbyname(servername)
|
server = self.getserverbyname(servername)
|
||||||
if server is None:
|
if server is None:
|
||||||
logging.warn("ignoring unknown server: %s", servername)
|
logging.warning("ignoring unknown server: %s", servername)
|
||||||
return
|
return
|
||||||
|
|
||||||
if server.sock is None or server.host is None or server.port is None:
|
if server.sock is None or server.host is None or server.port is None:
|
||||||
|
@ -754,10 +754,10 @@ class CoreBroker(object):
|
||||||
try:
|
try:
|
||||||
nodecls = nodeutils.get_node_class(NodeTypes(nodetype))
|
nodecls = nodeutils.get_node_class(NodeTypes(nodetype))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logging.warn("broker invalid node type %s", nodetype)
|
logging.warning("broker invalid node type %s", nodetype)
|
||||||
return handle_locally, servers
|
return handle_locally, servers
|
||||||
if nodecls is None:
|
if nodecls is None:
|
||||||
logging.warn("broker unimplemented node type %s", nodetype)
|
logging.warning("broker unimplemented node type %s", nodetype)
|
||||||
return handle_locally, servers
|
return handle_locally, servers
|
||||||
if issubclass(nodecls, CoreNetworkBase) and nodetype != NodeTypes.WIRELESS_LAN.value:
|
if issubclass(nodecls, CoreNetworkBase) and nodetype != NodeTypes.WIRELESS_LAN.value:
|
||||||
# network node replicated on all servers; could be optimized
|
# network node replicated on all servers; could be optimized
|
||||||
|
@ -1091,12 +1091,12 @@ class CoreBroker(object):
|
||||||
control_nets = value.split()
|
control_nets = value.split()
|
||||||
|
|
||||||
if len(control_nets) < 2:
|
if len(control_nets) < 2:
|
||||||
logging.warn("multiple controlnet prefixes do not exist")
|
logging.warning("multiple controlnet prefixes do not exist")
|
||||||
return
|
return
|
||||||
|
|
||||||
servers = self.session.broker.getservernames()
|
servers = self.session.broker.getservernames()
|
||||||
if len(servers) < 2:
|
if len(servers) < 2:
|
||||||
logging.warn("not distributed")
|
logging.warning("not distributed")
|
||||||
return
|
return
|
||||||
|
|
||||||
servers.remove("localhost")
|
servers.remove("localhost")
|
||||||
|
|
|
@ -120,7 +120,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
wait += 1
|
wait += 1
|
||||||
if wait == timeout:
|
if wait == timeout:
|
||||||
logging.warn("queue failed to be empty, finishing request handler")
|
logging.warning("queue failed to be empty, finishing request handler")
|
||||||
break
|
break
|
||||||
|
|
||||||
logging.info("client disconnected: notifying threads")
|
logging.info("client disconnected: notifying threads")
|
||||||
|
@ -129,7 +129,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
logging.info("waiting for thread: %s", thread.getName())
|
logging.info("waiting for thread: %s", thread.getName())
|
||||||
thread.join(timeout)
|
thread.join(timeout)
|
||||||
if thread.isAlive():
|
if thread.isAlive():
|
||||||
logging.warn("joining %s failed: still alive after %s sec", thread.getName(), timeout)
|
logging.warning("joining %s failed: still alive after %s sec", thread.getName(), timeout)
|
||||||
|
|
||||||
logging.info("connection closed: %s", self.client_address)
|
logging.info("connection closed: %s", self.client_address)
|
||||||
if self.session:
|
if self.session:
|
||||||
|
@ -422,7 +422,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
|
|
||||||
message_type, message_flags, message_len = coreapi.CoreMessage.unpack_header(header)
|
message_type, message_flags, message_len = coreapi.CoreMessage.unpack_header(header)
|
||||||
if message_len == 0:
|
if message_len == 0:
|
||||||
logging.warn("received message with no data")
|
logging.warning("received message with no data")
|
||||||
|
|
||||||
data = b""
|
data = b""
|
||||||
while len(data) < message_len:
|
while len(data) < message_len:
|
||||||
|
@ -629,7 +629,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
"""
|
"""
|
||||||
replies = []
|
replies = []
|
||||||
if message.flags & MessageFlags.ADD.value and message.flags & MessageFlags.DELETE.value:
|
if message.flags & MessageFlags.ADD.value and message.flags & MessageFlags.DELETE.value:
|
||||||
logging.warn("ignoring invalid message: add and delete flag both set")
|
logging.warning("ignoring invalid message: add and delete flag both set")
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
node_type = None
|
node_type = None
|
||||||
|
@ -1009,7 +1009,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
self.session.location.reset()
|
self.session.location.reset()
|
||||||
else:
|
else:
|
||||||
if not config_data.data_values:
|
if not config_data.data_values:
|
||||||
logging.warn("location data missing")
|
logging.warning("location data missing")
|
||||||
else:
|
else:
|
||||||
values = [float(x) for x in config_data.data_values.split("|")]
|
values = [float(x) for x in config_data.data_values.split("|")]
|
||||||
|
|
||||||
|
@ -1144,7 +1144,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
|
|
||||||
node = self.session.get_node(node_id)
|
node = self.session.get_node(node_id)
|
||||||
if node is None:
|
if node is None:
|
||||||
logging.warn("request to configure service for unknown node %s", node_id)
|
logging.warning("request to configure service for unknown node %s", node_id)
|
||||||
return replies
|
return replies
|
||||||
|
|
||||||
services = ServiceShim.servicesfromopaque(opaque)
|
services = ServiceShim.servicesfromopaque(opaque)
|
||||||
|
@ -1247,7 +1247,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
|
|
||||||
model_class = self.session.mobility.models.get(object_name)
|
model_class = self.session.mobility.models.get(object_name)
|
||||||
if not model_class:
|
if not model_class:
|
||||||
logging.warn("model class does not exist: %s", object_name)
|
logging.warning("model class does not exist: %s", object_name)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
config = self.session.mobility.get_model_config(node_id, object_name)
|
config = self.session.mobility.get_model_config(node_id, object_name)
|
||||||
|
@ -1256,7 +1256,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
elif message_type != ConfigFlags.RESET:
|
elif message_type != ConfigFlags.RESET:
|
||||||
# store the configuration values for later use, when the node
|
# store the configuration values for later use, when the node
|
||||||
if not object_name:
|
if not object_name:
|
||||||
logging.warn("no configuration object for node: %s", node_id)
|
logging.warning("no configuration object for node: %s", node_id)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
parsed_config = {}
|
parsed_config = {}
|
||||||
|
@ -1317,7 +1317,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
|
|
||||||
model_class = self.session.emane.models.get(object_name)
|
model_class = self.session.emane.models.get(object_name)
|
||||||
if not model_class:
|
if not model_class:
|
||||||
logging.warn("model class does not exist: %s", object_name)
|
logging.warning("model class does not exist: %s", object_name)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
config = self.session.emane.get_model_config(node_id, object_name)
|
config = self.session.emane.get_model_config(node_id, object_name)
|
||||||
|
@ -1326,7 +1326,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
elif message_type != ConfigFlags.RESET:
|
elif message_type != ConfigFlags.RESET:
|
||||||
# store the configuration values for later use, when the node
|
# store the configuration values for later use, when the node
|
||||||
if not object_name:
|
if not object_name:
|
||||||
logging.warn("no configuration object for node: %s", node_id)
|
logging.warning("no configuration object for node: %s", node_id)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
parsed_config = {}
|
parsed_config = {}
|
||||||
|
@ -1353,11 +1353,11 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
compressed_data = message.get_tlv(FileTlvs.COMPRESSED_DATA.value)
|
compressed_data = message.get_tlv(FileTlvs.COMPRESSED_DATA.value)
|
||||||
|
|
||||||
if compressed_data:
|
if compressed_data:
|
||||||
logging.warn("Compressed file data not implemented for File message.")
|
logging.warning("Compressed file data not implemented for File message.")
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
if source_name and data:
|
if source_name and data:
|
||||||
logging.warn("ignoring invalid File message: source and data TLVs are both present")
|
logging.warning("ignoring invalid File message: source and data TLVs are both present")
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
# some File Messages store custom files in services,
|
# some File Messages store custom files in services,
|
||||||
|
@ -1435,7 +1435,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
self.session.start_mobility(node_ids=(node.id,))
|
self.session.start_mobility(node_ids=(node.id,))
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
logging.warn("dropping unhandled Event message with node number")
|
logging.warning("dropping unhandled Event message with node number")
|
||||||
return ()
|
return ()
|
||||||
self.session.set_state(event_type)
|
self.session.set_state(event_type)
|
||||||
|
|
||||||
|
@ -1454,7 +1454,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
self.send_node_emulation_id(_id)
|
self.send_node_emulation_id(_id)
|
||||||
elif event_type == EventTypes.RUNTIME_STATE:
|
elif event_type == EventTypes.RUNTIME_STATE:
|
||||||
if self.session.master:
|
if self.session.master:
|
||||||
logging.warn("Unexpected event message: RUNTIME state received at session master")
|
logging.warning("Unexpected event message: RUNTIME state received at session master")
|
||||||
else:
|
else:
|
||||||
# master event queue is started in session.checkruntime()
|
# master event queue is started in session.checkruntime()
|
||||||
self.session.start_events()
|
self.session.start_events()
|
||||||
|
@ -1462,7 +1462,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
self.session.data_collect()
|
self.session.data_collect()
|
||||||
elif event_type == EventTypes.SHUTDOWN_STATE:
|
elif event_type == EventTypes.SHUTDOWN_STATE:
|
||||||
if self.session.master:
|
if self.session.master:
|
||||||
logging.warn("Unexpected event message: SHUTDOWN state received at session master")
|
logging.warning("Unexpected event message: SHUTDOWN state received at session master")
|
||||||
elif event_type in {EventTypes.START, EventTypes.STOP, EventTypes.RESTART, EventTypes.PAUSE,
|
elif event_type in {EventTypes.START, EventTypes.STOP, EventTypes.RESTART, EventTypes.PAUSE,
|
||||||
EventTypes.RECONFIGURE}:
|
EventTypes.RECONFIGURE}:
|
||||||
handled = False
|
handled = False
|
||||||
|
@ -1477,7 +1477,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
self.session.mobility_event(event_data)
|
self.session.mobility_event(event_data)
|
||||||
handled = True
|
handled = True
|
||||||
if not handled:
|
if not handled:
|
||||||
logging.warn("Unhandled event message: event type %s ", event_type.name)
|
logging.warning("Unhandled event message: event type %s ", event_type.name)
|
||||||
elif event_type == EventTypes.FILE_OPEN:
|
elif event_type == EventTypes.FILE_OPEN:
|
||||||
filename = event_data.name
|
filename = event_data.name
|
||||||
self.session.open_xml(filename, start=False)
|
self.session.open_xml(filename, start=False)
|
||||||
|
@ -1492,14 +1492,14 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
name = event_data.name
|
name = event_data.name
|
||||||
data = event_data.data
|
data = event_data.data
|
||||||
if etime is None:
|
if etime is None:
|
||||||
logging.warn("Event message scheduled event missing start time")
|
logging.warning("Event message scheduled event missing start time")
|
||||||
return ()
|
return ()
|
||||||
if message.flags & MessageFlags.ADD.value:
|
if message.flags & MessageFlags.ADD.value:
|
||||||
self.session.add_event(float(etime), node=node, name=name, data=data)
|
self.session.add_event(float(etime), node=node, name=name, data=data)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
else:
|
else:
|
||||||
logging.warn("unhandled event message: event type %s", event_type)
|
logging.warning("unhandled event message: event type %s", event_type)
|
||||||
|
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
@ -1518,7 +1518,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
try:
|
try:
|
||||||
node = self.session.get_node(node_id)
|
node = self.session.get_node(node_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logging.warn("ignoring event for service '%s', unknown node '%s'", name, node_id)
|
logging.warning("ignoring event for service '%s', unknown node '%s'", name, node_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
fail = ""
|
fail = ""
|
||||||
|
@ -1556,7 +1556,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
if num > 1:
|
if num > 1:
|
||||||
unknown_data += ", "
|
unknown_data += ", "
|
||||||
num -= 1
|
num -= 1
|
||||||
logging.warn("Event requested for unknown service(s): %s", unknown_data)
|
logging.warning("Event requested for unknown service(s): %s", unknown_data)
|
||||||
unknown_data = "Unknown:" + unknown_data
|
unknown_data = "Unknown:" + unknown_data
|
||||||
|
|
||||||
event_data = EventData(
|
event_data = EventData(
|
||||||
|
@ -1595,7 +1595,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
session = self.coreemu.sessions.get(session_id)
|
session = self.coreemu.sessions.get(session_id)
|
||||||
|
|
||||||
if session is None:
|
if session is None:
|
||||||
logging.warn("session %s not found", session_id)
|
logging.warning("session %s not found", session_id)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logging.info("request to modify to session: %s", session.id)
|
logging.info("request to modify to session: %s", session.id)
|
||||||
|
@ -1655,7 +1655,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
||||||
logging.info("request to terminate session %s", session_id)
|
logging.info("request to terminate session %s", session_id)
|
||||||
self.coreemu.delete_session(session_id)
|
self.coreemu.delete_session(session_id)
|
||||||
else:
|
else:
|
||||||
logging.warn("unhandled session flags for session %s", session_id)
|
logging.warning("unhandled session flags for session %s", session_id)
|
||||||
|
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
|
|
@ -115,11 +115,11 @@ class EmaneCommEffectModel(emanemodel.EmaneModel):
|
||||||
"""
|
"""
|
||||||
service = self.session.emane.service
|
service = self.session.emane.service
|
||||||
if service is None:
|
if service is None:
|
||||||
logging.warn("%s: EMANE event service unavailable", self.name)
|
logging.warning("%s: EMANE event service unavailable", self.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
if netif is None or netif2 is None:
|
if netif is None or netif2 is None:
|
||||||
logging.warn("%s: missing NEM information", self.name)
|
logging.warning("%s: missing NEM information", self.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
# TODO: batch these into multiple events per transmission
|
# TODO: batch these into multiple events per transmission
|
||||||
|
|
|
@ -807,7 +807,7 @@ class EmaneManager(ModelManager):
|
||||||
for event in events:
|
for event in events:
|
||||||
txnemid, attrs = event
|
txnemid, attrs = event
|
||||||
if "latitude" not in attrs or "longitude" not in attrs or "altitude" not in attrs:
|
if "latitude" not in attrs or "longitude" not in attrs or "altitude" not in attrs:
|
||||||
logging.warn("dropped invalid location event")
|
logging.warning("dropped invalid location event")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# yaw,pitch,roll,azimuth,elevation,velocity are unhandled
|
# yaw,pitch,roll,azimuth,elevation,velocity are unhandled
|
||||||
|
|
|
@ -156,4 +156,4 @@ class EmaneModel(WirelessModel):
|
||||||
:param core.netns.vif.Veth netif2: interface two
|
:param core.netns.vif.Veth netif2: interface two
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
logging.warn("emane model(%s) does not support link configuration", self.name)
|
logging.warning("emane model(%s) does not support link configuration", self.name)
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ class Session(object):
|
||||||
if os.path.isfile(environment_config_file):
|
if os.path.isfile(environment_config_file):
|
||||||
utils.load_config(environment_config_file, env)
|
utils.load_config(environment_config_file, env)
|
||||||
except IOError:
|
except IOError:
|
||||||
logging.warn("environment configuration file does not exist: %s", environment_config_file)
|
logging.warning("environment configuration file does not exist: %s", environment_config_file)
|
||||||
|
|
||||||
# attempt to read and add user environment file
|
# attempt to read and add user environment file
|
||||||
if self.user:
|
if self.user:
|
||||||
|
@ -1625,7 +1625,7 @@ class Session(object):
|
||||||
|
|
||||||
if current_time > 0:
|
if current_time > 0:
|
||||||
if event_time <= current_time:
|
if event_time <= current_time:
|
||||||
logging.warn("could not schedule past event for time %s (run time is now %s)", event_time, current_time)
|
logging.warning("could not schedule past event for time %s (run time is now %s)", event_time, current_time)
|
||||||
return
|
return
|
||||||
event_time = event_time - current_time
|
event_time = event_time - current_time
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class MobilityManager(ModelManager):
|
||||||
try:
|
try:
|
||||||
node = self.session.get_node(node_id)
|
node = self.session.get_node(node_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logging.warn("skipping mobility configuration for unknown node: %s", node_id)
|
logging.warning("skipping mobility configuration for unknown node: %s", node_id)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for model_name in self.models:
|
for model_name in self.models:
|
||||||
|
@ -111,7 +111,7 @@ class MobilityManager(ModelManager):
|
||||||
try:
|
try:
|
||||||
cls = self.models[model]
|
cls = self.models[model]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logging.warn("Ignoring event for unknown model '%s'", model)
|
logging.warning("Ignoring event for unknown model '%s'", model)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if cls.config_type in [RegisterTlvs.WIRELESS.value, RegisterTlvs.MOBILITY.value]:
|
if cls.config_type in [RegisterTlvs.WIRELESS.value, RegisterTlvs.MOBILITY.value]:
|
||||||
|
@ -120,11 +120,11 @@ class MobilityManager(ModelManager):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if model is None:
|
if model is None:
|
||||||
logging.warn("Ignoring event, %s has no model", node.name)
|
logging.warning("Ignoring event, %s has no model", node.name)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if cls.name != model.name:
|
if cls.name != model.name:
|
||||||
logging.warn("Ignoring event for %s wrong model %s,%s", node.name, cls.name, model.name)
|
logging.warning("Ignoring event for %s wrong model %s,%s", node.name, cls.name, model.name)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if event_type == EventTypes.STOP.value or event_type == EventTypes.RESTART.value:
|
if event_type == EventTypes.STOP.value or event_type == EventTypes.RESTART.value:
|
||||||
|
|
|
@ -169,7 +169,7 @@ class VnodeClient(object):
|
||||||
# wait for and return exit status
|
# wait for and return exit status
|
||||||
status = p.wait()
|
status = p.wait()
|
||||||
if status:
|
if status:
|
||||||
logging.warn("cmd exited with status %s: %s", status, args)
|
logging.warning("cmd exited with status %s: %s", status, args)
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def term(self, sh="/bin/sh"):
|
def term(self, sh="/bin/sh"):
|
||||||
|
@ -247,16 +247,16 @@ class VnodeClient(object):
|
||||||
elif line[3] == "link":
|
elif line[3] == "link":
|
||||||
interface["inet6link"].append(line[1])
|
interface["inet6link"].append(line[1])
|
||||||
else:
|
else:
|
||||||
logging.warn("unknown scope: %s" % line[3])
|
logging.warning("unknown scope: %s" % line[3])
|
||||||
|
|
||||||
err = stderr.read()
|
err = stderr.read()
|
||||||
stdout.close()
|
stdout.close()
|
||||||
stderr.close()
|
stderr.close()
|
||||||
status = p.wait()
|
status = p.wait()
|
||||||
if status:
|
if status:
|
||||||
logging.warn("nonzero exist status (%s) for cmd: %s", status, args)
|
logging.warning("nonzero exist status (%s) for cmd: %s", status, args)
|
||||||
if err:
|
if err:
|
||||||
logging.warn("error output: %s", err)
|
logging.warning("error output: %s", err)
|
||||||
self._addr[ifname] = interface
|
self._addr[ifname] = interface
|
||||||
return interface
|
return interface
|
||||||
|
|
||||||
|
@ -275,11 +275,11 @@ class VnodeClient(object):
|
||||||
# ignore first line
|
# ignore first line
|
||||||
stdout.readline()
|
stdout.readline()
|
||||||
# second line has count names
|
# second line has count names
|
||||||
tmp = stdout.readline().strip().split("|")
|
tmp = stdout.readline().decode("utf-8").strip().split("|")
|
||||||
rxkeys = tmp[1].split()
|
rxkeys = tmp[1].split()
|
||||||
txkeys = tmp[2].split()
|
txkeys = tmp[2].split()
|
||||||
for line in stdout:
|
for line in stdout:
|
||||||
line = line.strip().split()
|
line = line.decode("utf-8").strip().split()
|
||||||
devname, tmp = line[0].split(":")
|
devname, tmp = line[0].split(":")
|
||||||
if tmp:
|
if tmp:
|
||||||
line.insert(1, tmp)
|
line.insert(1, tmp)
|
||||||
|
@ -296,9 +296,9 @@ class VnodeClient(object):
|
||||||
stderr.close()
|
stderr.close()
|
||||||
status = p.wait()
|
status = p.wait()
|
||||||
if status:
|
if status:
|
||||||
logging.warn("nonzero exist status (%s) for cmd: %s", status, args)
|
logging.warning("nonzero exist status (%s) for cmd: %s", status, args)
|
||||||
if err:
|
if err:
|
||||||
logging.warn("error output: %s", err)
|
logging.warning("error output: %s", err)
|
||||||
if ifname is not None:
|
if ifname is not None:
|
||||||
return stats[ifname]
|
return stats[ifname]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -481,7 +481,12 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
netem += ["loss", "%s%%" % min(loss, 100)]
|
netem += ["loss", "%s%%" % min(loss, 100)]
|
||||||
if duplicate is not None and duplicate > 0:
|
if duplicate is not None and duplicate > 0:
|
||||||
netem += ["duplicate", "%s%%" % min(duplicate, 100)]
|
netem += ["duplicate", "%s%%" % min(duplicate, 100)]
|
||||||
if delay <= 0 and jitter <= 0 and loss <= 0 and duplicate <= 0:
|
|
||||||
|
delay_check = delay is None or delay <= 0
|
||||||
|
jitter_check = jitter is None or jitter <= 0
|
||||||
|
loss_check = loss is None or loss <= 0
|
||||||
|
duplicate_check = duplicate is None or duplicate <= 0
|
||||||
|
if all([delay_check, jitter_check, loss_check, duplicate_check]):
|
||||||
# possibly remove netem if it exists and parent queue wasn't removed
|
# possibly remove netem if it exists and parent queue wasn't removed
|
||||||
if not netif.getparam("has_netem"):
|
if not netif.getparam("has_netem"):
|
||||||
return
|
return
|
||||||
|
|
|
@ -7,14 +7,13 @@ a list of available services to the GUI and for configuring individual
|
||||||
services.
|
services.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import enum
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from multiprocessing.pool import ThreadPool
|
from multiprocessing.pool import ThreadPool
|
||||||
|
|
||||||
import enum
|
|
||||||
from core.constants import which
|
|
||||||
|
|
||||||
from core import CoreCommandError, utils
|
from core import CoreCommandError, utils
|
||||||
|
from core.constants import which
|
||||||
from core.emulator.data import FileData
|
from core.emulator.data import FileData
|
||||||
from core.emulator.enumerations import MessageFlags
|
from core.emulator.enumerations import MessageFlags
|
||||||
from core.emulator.enumerations import RegisterTlvs
|
from core.emulator.enumerations import RegisterTlvs
|
||||||
|
@ -318,7 +317,7 @@ class CoreServices(object):
|
||||||
logging.debug("checking for service with service manager: %s", name)
|
logging.debug("checking for service with service manager: %s", name)
|
||||||
service = ServiceManager.get(name)
|
service = ServiceManager.get(name)
|
||||||
if not service:
|
if not service:
|
||||||
logging.warn("default service %s is unknown", name)
|
logging.warning("default service %s is unknown", name)
|
||||||
else:
|
else:
|
||||||
results.append(service)
|
results.append(service)
|
||||||
return results
|
return results
|
||||||
|
@ -376,7 +375,7 @@ class CoreServices(object):
|
||||||
for service_name in services:
|
for service_name in services:
|
||||||
service = self.get_service(node.id, service_name, default_service=True)
|
service = self.get_service(node.id, service_name, default_service=True)
|
||||||
if not service:
|
if not service:
|
||||||
logging.warn("unknown service(%s) for node(%s)", service_name, node.name)
|
logging.warning("unknown service(%s) for node(%s)", service_name, node.name)
|
||||||
continue
|
continue
|
||||||
logging.info("adding service to node(%s): %s", node.name, service_name)
|
logging.info("adding service to node(%s): %s", node.name, service_name)
|
||||||
node.addservice(service)
|
node.addservice(service)
|
||||||
|
@ -464,15 +463,15 @@ class CoreServices(object):
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
logging.info("starting node(%s) service(%s) validation(%s)", node.name, service.name,
|
logging.info("starting node(%s) service(%s) validation(%s)", node.name, service.name,
|
||||||
service.validation_mode.name)
|
service.validation_mode.name)
|
||||||
|
|
||||||
# create service directories
|
# create service directories
|
||||||
for directory in service.dirs:
|
for directory in service.dirs:
|
||||||
try:
|
try:
|
||||||
node.privatedir(directory)
|
node.privatedir(directory)
|
||||||
except (CoreCommandError, ValueError) as e:
|
except (CoreCommandError, ValueError) as e:
|
||||||
logging.warn("error mounting private dir '%s' for service '%s': %s",
|
logging.warning("error mounting private dir '%s' for service '%s': %s",
|
||||||
directory, service.name, e)
|
directory, service.name, e)
|
||||||
|
|
||||||
# create service files
|
# create service files
|
||||||
self.create_service_files(node, service)
|
self.create_service_files(node, service)
|
||||||
|
@ -640,13 +639,13 @@ class CoreServices(object):
|
||||||
# retrieve custom service
|
# retrieve custom service
|
||||||
service = self.get_service(node_id, service_name)
|
service = self.get_service(node_id, service_name)
|
||||||
if service is None:
|
if service is None:
|
||||||
logging.warn("received file name for unknown service: %s", service_name)
|
logging.warning("received file name for unknown service: %s", service_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
# validate file being set is valid
|
# validate file being set is valid
|
||||||
config_files = service.configs
|
config_files = service.configs
|
||||||
if file_name not in config_files:
|
if file_name not in config_files:
|
||||||
logging.warn("received unknown file(%s) for service(%s)", file_name, service_name)
|
logging.warning("received unknown file(%s) for service(%s)", file_name, service_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
# set custom service file data
|
# set custom service file data
|
||||||
|
|
|
@ -377,7 +377,7 @@ def load_classes(path, clazz):
|
||||||
# validate path exists
|
# validate path exists
|
||||||
logging.debug("attempting to load modules from path: %s", path)
|
logging.debug("attempting to load modules from path: %s", path)
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
logging.warn("invalid custom module directory specified" ": %s" % path)
|
logging.warning("invalid custom module directory specified" ": %s" % path)
|
||||||
# check if path is in sys.path
|
# check if path is in sys.path
|
||||||
parent_path = os.path.dirname(path)
|
parent_path = os.path.dirname(path)
|
||||||
if parent_path not in sys.path:
|
if parent_path not in sys.path:
|
||||||
|
|
|
@ -112,7 +112,7 @@ def build_node_platform_xml(emane_manager, control_net, node, nem_id, platform_x
|
||||||
nem_entries = {}
|
nem_entries = {}
|
||||||
|
|
||||||
if node.model is None:
|
if node.model is None:
|
||||||
logging.warn("warning: EmaneNode %s has no associated model", node.name)
|
logging.warning("warning: EmaneNode %s has no associated model", node.name)
|
||||||
return nem_entries
|
return nem_entries
|
||||||
|
|
||||||
for netif in node.netifs():
|
for netif in node.netifs():
|
||||||
|
|
|
@ -36,9 +36,9 @@ def createclients(sessiondir, clientcls=VnodeClient, cmdchnlfilterfunc=None):
|
||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
direntries = map(lambda x: os.path.join(sessiondir, x), os.listdir(sessiondir))
|
direntries = map(lambda x: os.path.join(sessiondir, x), os.listdir(sessiondir))
|
||||||
cmdchnls = filter(lambda x: stat.S_ISSOCK(os.stat(x).st_mode), direntries)
|
cmdchnls = list(filter(lambda x: stat.S_ISSOCK(os.stat(x).st_mode), direntries))
|
||||||
if cmdchnlfilterfunc:
|
if cmdchnlfilterfunc:
|
||||||
cmdchnls = filter(cmdchnlfilterfunc, cmdchnls)
|
cmdchnls = list(filter(cmdchnlfilterfunc, cmdchnls))
|
||||||
cmdchnls.sort()
|
cmdchnls.sort()
|
||||||
return map(lambda x: clientcls(os.path.basename(x), x), cmdchnls)
|
return map(lambda x: clientcls(os.path.basename(x), x), cmdchnls)
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ def iperf(from_node, to_node, ip_prefixes):
|
||||||
vcmd, stdin, stdout, stderr = to_node.client.popen(["iperf", "-s", "-u", "-y", "C"])
|
vcmd, stdin, stdout, stderr = to_node.client.popen(["iperf", "-s", "-u", "-y", "C"])
|
||||||
from_node.cmd(["iperf", "-u", "-t", "5", "-c", address])
|
from_node.cmd(["iperf", "-u", "-t", "5", "-c", address])
|
||||||
to_node.cmd(["killall", "-9", "iperf"])
|
to_node.cmd(["killall", "-9", "iperf"])
|
||||||
return stdout.read().strip()
|
return stdout.read().decode("utf-8").strip()
|
||||||
|
|
||||||
|
|
||||||
class TestLinks:
|
class TestLinks:
|
||||||
|
|
Loading…
Add table
Reference in a new issue