Commit 6124923c authored by Simon Redman's avatar Simon Redman

Allow specifying which port is being used by the OSPF sniffer listener

parent 5a163ac6
......@@ -26,6 +26,7 @@ import ssh_helper
DEFAULT_CLONE_PATH="~/sniffer/"
DEFAULT_CONTROLLER='core0'
DEFAULT_CONTROLLER_PORT = 11000
DEFAULT_EXECUTABLE='main.py'
DEFAULT_LOGFILE="/tmp/sniffer.log"
DEFAULT_PIDFILE="/tmp/sniffer.pid"
......@@ -44,6 +45,7 @@ def _generate_repo_update_command(path: str) -> str:
def _generate_start_command(path:str=DEFAULT_CLONE_PATH,
executable: str=DEFAULT_EXECUTABLE,
controller: str=DEFAULT_CONTROLLER,
port: int=DEFAULT_CONTROLLER_PORT,
logfile: str=DEFAULT_LOGFILE,
pidfile: str=DEFAULT_PIDFILE,
) -> str:
......@@ -55,14 +57,16 @@ def _generate_start_command(path:str=DEFAULT_CLONE_PATH,
:param path: Path into which the sniffer was cloned
:param executable: Filename of the sniffer daemon from the repository root
:param controller: Hostname or IP address to which sniffer reports should be sent
:param port: Port on the server listening for OSPF updates
:param logfile: File to which output from the sniffer should be written
:param pidfile: File to which the PID will be written
:return:
"""
return "{path}/{executable} --controller={controller} 1> {logfile} & echo $! > {pidfile} && disown".format(
return "sudo {path}/{executable} --controller={controller} --port={port} 1> {logfile} & echo $! > {pidfile} && disown".format(
path=path,
executable=executable,
controller=controller,
port=port,
logfile=logfile,
pidfile=pidfile,
)
......@@ -203,6 +207,8 @@ if __name__ == "__main__":
help="File to write sniffer's output (Default: {default})".format(default=DEFAULT_LOGFILE))
parser.add_argument("--controller-name", action='store', type=str, default=DEFAULT_CONTROLLER,
help="Hostname or IP of the node which is listening to the OSPF reports (Default: {default})".format(default=DEFAULT_CONTROLLER))
parser.add_argument("--controller-port", action='store', type=int, default=DEFAULT_CONTROLLER_PORT,
help="Port number on the server listening for OSPF reports (Default: {default})".format(default=DEFAULT_CONTROLLER_PORT))
parser.add_argument("--repo-path", action='store', type=str, default=DEFAULT_REPO_URL,
help="(git) Repository which should be downloaded for the OSPF sniffer (Default: {default})".format(default=DEFAULT_REPO_URL))
parser.add_argument("--repo-branch", action='store', type=str, default=DEFAULT_REPO_BRANCH,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment