This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
forked from qca/boardfarm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request qca#2 from ericschultz/local_work
Update to latest running code
- Loading branch information
Showing
17 changed files
with
608 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
DIR="$( cd -P "$DIR/../devices" && pwd )" | ||
|
||
python $DIR/local_debian_runner.py ip_neigh_flush 1>&2 | tee /tmp/ip_neigh_flush.log | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
DIR="$( cd -P "$DIR/../devices" && pwd )" | ||
|
||
python $DIR/local_debian_runner.py restart_tftp_server 1>&2 | tee /tmp/restart_tftp_server.log | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
DIR="$( cd -P "$DIR/../devices" && pwd )" | ||
|
||
python $DIR/local_debian_runner.py init_lan 2>&1 | tee /tmp/setup_lan.log | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
DIR="$( cd -P "$DIR/../devices" && pwd )" | ||
|
||
python $DIR/local_debian_runner.py init_wan 2>&1 | tee /tmp/setup_wan.log | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
DIR="$( cd -P "$DIR/../devices" && pwd )" | ||
|
||
python $DIR/local_debian_runner.py start_lan_client 1>&2 | tee /tmp/start_lan_client | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*/10 * * * * root systemctl start dhclient.eth0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=dhclient on eth0 | ||
Wants=network.target | ||
Before=network.target | ||
|
||
[Service] | ||
ExecStart=/sbin/dhclient -d -v eth0 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=Startup Script for non-root Boardfarm LAN setup | ||
After=network.target | ||
|
||
[Service] | ||
ExecStart=/usr/bin/setup_lan | ||
Type=forking | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Cmnd_Alias TESTING_CMDS = /sbin/reboot, /usr/bin/start_lan_client, /usr/bin/ip_neigh_flush, /usr/bin/turn_on_pppoe, /usr/bin/restart_tftp_server, /usr/bin/stop_lan_client | ||
__username__ ALL=(ALL) NOPASSWD: TESTING_CMDS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=Startup Script for non-root Boardfarm WAN setup | ||
After=network.target | ||
|
||
[Service] | ||
ExecStart=/usr/bin/setup_wan | ||
Type=forking | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import debian | ||
import non_root_debian | ||
import sys | ||
|
||
def debian(name, color, | ||
username, | ||
password, | ||
port, | ||
output=sys.stdout, | ||
reboot=False, | ||
location=None): | ||
''' | ||
This function controls which class to use for your debian boxes: DebianBox | ||
when your username is root and NotRootDebianBox for other usernames. | ||
''' | ||
if (username is 'root'): | ||
return debian.DebianBox(name=name, color=color, username=username, | ||
password=password, port=port, output=output, | ||
reboot=reboot, location=location) | ||
else: | ||
return non_root_debian.NonRootDebianBox(name=name, color=color, username=username, | ||
password=password, port=port, output=output, | ||
reboot=reboot, location=location) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import base | ||
import pexpect | ||
import debian | ||
import sys | ||
import argparse | ||
from termcolor import colored, cprint | ||
|
||
class LocalDebianRunner(debian.DebianBox): | ||
prompt = ['root\\@.*:.*#', '/ # ', ".*:~ #", ".*:~.*\\$", ".*\\@.*:.*\\$" ] | ||
|
||
def __init__(self, | ||
color, | ||
output=sys.stdout, | ||
reboot=False, | ||
location=None | ||
): | ||
|
||
pexpect.spawn.__init__(self, | ||
command="bash") | ||
|
||
self.color = color | ||
self.output = output | ||
self.location = location | ||
cprint("%s device console = %s" % ("local device", colored(color, color)), None, attrs=['bold']) | ||
self.expect(self.prompt) | ||
|
||
if reboot: | ||
self.reset() | ||
|
||
self.logfile_read = output | ||
|
||
def setup_as_wan_gateway(self): | ||
debian.DebianBox.setup_as_wan_gateway(self) | ||
def setup_as_lan_device(self): | ||
debian.DebianBox.setup_as_lan_device(self) | ||
def start_lan_client(self): | ||
debian.DebianBox.start_lan_client(self) | ||
|
||
def restart_tftp_server(self): | ||
debian.DebianBox.restart_tftp_server(self) | ||
|
||
def turn_on_pppoe(self): | ||
debian.DebianBox.turn_on_pppoe(self) | ||
def ip_neigh_flush(self): | ||
debian.DebianBox.ip_neigh_flush(self) | ||
|
||
def stop_lan_client(self): | ||
debian.DebianBox.stop_lan_client(self) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("action", choices=['init_wan', 'init_lan', 'start_lan_client', | ||
'restart_tftp_server', 'turn_on_pppoe', 'ip_neigh_flush', 'stop_lan_client']) | ||
|
||
args = parser.parse_args() | ||
dev = LocalDebianRunner('cyan') | ||
|
||
if args.action == "init_wan": | ||
dev.setup_as_wan_gateway() | ||
elif args.action == 'init_lan': | ||
dev.setup_as_lan_device() | ||
elif args.action == 'start_lan_client': | ||
dev.start_lan_client() | ||
elif args.action == 'restart_tftp_server': | ||
dev.restart_tftp_server() | ||
elif args.action == 'ip_neigh_flush': | ||
dev.ip_neigh_flush() | ||
elif args.action == 'turn_on_pppoe': | ||
dev.turn_on_pppoe() | ||
elif args.action == 'stop_lan_client': | ||
dev.stop_lan_client() | ||
else: | ||
parser.print_help() |
Oops, something went wrong.