expose command exceptions within emane and mobility

This commit is contained in:
Blake J. Harnden 2018-03-02 15:54:27 -08:00
parent fbc749849c
commit 29a3496eda
3 changed files with 30 additions and 61 deletions

View file

@ -784,13 +784,9 @@ class EmaneManager(ConfigurableManager):
def buildtransportxml(self): def buildtransportxml(self):
""" """
Calls emanegentransportxml using a platform.xml file to build Calls emanegentransportxml using a platform.xml file to build the transportdaemon*.xml.
the transportdaemon*.xml.
""" """
try:
utils.check_cmd(["emanegentransportxml", "platform.xml"], cwd=self.session.session_dir) utils.check_cmd(["emanegentransportxml", "platform.xml"], cwd=self.session.session_dir)
except subprocess.CalledProcessError:
logger.exception("error running emanegentransportxml")
def buildeventservicexml(self): def buildeventservicexml(self):
""" """
@ -844,26 +840,21 @@ class EmaneManager(ConfigurableManager):
emanecmd = ["emane", "-d", "--logl", loglevel, "-f", os.path.join(path, "emane.log")] emanecmd = ["emane", "-d", "--logl", loglevel, "-f", os.path.join(path, "emane.log")]
if realtime: if realtime:
emanecmd += "-r", emanecmd += "-r",
try:
args = emanecmd + [os.path.join(path, "platform.xml")] args = emanecmd + [os.path.join(path, "platform.xml")]
logger.info("Emane.startdaemons() running %s" % str(args)) logger.info("Emane.startdaemons() running %s" % str(args))
utils.check_cmd(args, cwd=path) utils.check_cmd(args, cwd=path)
except subprocess.CalledProcessError:
logger.exception("error starting emane")
# start one transport daemon per transportdaemon*.xml file # start one transport daemon per transportdaemon*.xml file
args = ["emanetransportd", "-d", "--logl", loglevel, "-f", os.path.join(path, "emanetransportd.log")] args = ["emanetransportd", "-d", "--logl", loglevel, "-f", os.path.join(path, "emanetransportd.log")]
if realtime: if realtime:
args += "-r", args += "-r",
files = os.listdir(path) files = os.listdir(path)
for file in files: for current_file in files:
if file[-3:] == "xml" and file[:15] == "transportdaemon": if current_file[-3:] == "xml" and current_file[:15] == "transportdaemon":
args = args + [os.path.join(path, file)] args = args + [os.path.join(path, current_file)]
try:
logger.info("Emane.startdaemons() running %s" % str(args)) logger.info("Emane.startdaemons() running %s" % str(args))
utils.check_cmd(args, cwd=path) utils.check_cmd(args, cwd=path)
except subprocess.CalledProcessError:
logger.exception("error starting emanetransportd")
def startdaemons2(self): def startdaemons2(self):
""" """
@ -911,39 +902,28 @@ class EmaneManager(ConfigurableManager):
# multicast route is needed for OTA data # multicast route is needed for OTA data
args = [constants.IP_BIN, "route", "add", otagroup, "dev", otadev] args = [constants.IP_BIN, "route", "add", otagroup, "dev", otadev]
try:
node.check_cmd(args) node.check_cmd(args)
except subprocess.CalledProcessError:
logger.exception("error adding route for OTA data")
# multicast route is also needed for event data if on control network # multicast route is also needed for event data if on control network
if eventservicenetidx >= 0 and eventgroup != otagroup: if eventservicenetidx >= 0 and eventgroup != otagroup:
args = [constants.IP_BIN, "route", "add", eventgroup, "dev", eventdev] args = [constants.IP_BIN, "route", "add", eventgroup, "dev", eventdev]
try:
node.check_cmd(args) node.check_cmd(args)
except subprocess.CalledProcessError:
logger.exception("error adding route for event data")
try: # start emane
args = emanecmd + ["-f", os.path.join(path, "emane%d.log" % n), args = emanecmd + ["-f", os.path.join(path, "emane%d.log" % n),
os.path.join(path, "platform%d.xml" % n)] os.path.join(path, "platform%d.xml" % n)]
logger.info("Emane.startdaemons2() running %s", args) logger.info("Emane.startdaemons2() running %s", args)
output = node.check_cmd(args) output = node.check_cmd(args)
logger.info("Emane.startdaemons2() output: %s", output) logger.info("Emane.startdaemons2() output: %s", output)
except subprocess.CalledProcessError:
logger.exception("error starting emane")
if not run_emane_on_host: if not run_emane_on_host:
return return
path = self.session.session_dir path = self.session.session_dir
try:
emanecmd += ["-f", os.path.join(path, "emane.log")] emanecmd += ["-f", os.path.join(path, "emane.log")]
args = emanecmd + [os.path.join(path, "platform.xml")] args = emanecmd + [os.path.join(path, "platform.xml")]
logger.info("Emane.startdaemons2() running %s" % args) logger.info("Emane.startdaemons2() running %s" % args)
utils.check_cmd(args, cwd=path) utils.check_cmd(args, cwd=path)
except subprocess.CalledProcessError:
logger.exception("error starting emane")
def stopdaemons(self): def stopdaemons(self):
""" """
@ -1164,17 +1144,10 @@ class EmaneManager(ConfigurableManager):
is running, False otherwise. is running, False otherwise.
""" """
args = ["pkill", "-0", "-x", "emane"] args = ["pkill", "-0", "-x", "emane"]
status = -1
try:
if emane.VERSION < emane.EMANE092: if emane.VERSION < emane.EMANE092:
utils.check_cmd(args) status = utils.cmd(args)
else: else:
node.check_cmd(args) status = node.cmd(args)
status = 0
except subprocess.CalledProcessError:
logger.exception("error checking if emane is running")
return status == 0 return status == 0

View file

@ -5,7 +5,6 @@ mobility.py: mobility helpers for moving nodes and calculating wireless range.
import heapq import heapq
import math import math
import os import os
import subprocess
import threading import threading
import time import time
@ -1238,8 +1237,5 @@ class Ns2ScriptedMobility(WayPointMobility):
if filename is None or filename == '': if filename is None or filename == '':
return return
filename = self.findfile(filename) filename = self.findfile(filename)
try:
args = ["/bin/sh", filename, typestr] args = ["/bin/sh", filename, typestr]
utils.check_cmd(args, cwd=self.session.sessiondir, env=self.session.get_environment()) utils.check_cmd(args, cwd=self.session.sessiondir, env=self.session.get_environment())
except subprocess.CalledProcessError:
logger.exception("Error running script '%s' for WLAN state %s", filename, typestr)

View file

@ -529,7 +529,7 @@ class Session(object):
try: try:
utils.load_config(environment_user_file, env) utils.load_config(environment_user_file, env)
except IOError: except IOError:
logger.warn("error reading user core environment settings file: %s", environment_user_file) logger.info("error reading user core environment settings file: %s", environment_user_file)
return env return env