cicd: Allow test beds to be configured to use cloud-sdk.

Idea is to automatically update /etc/hosts with the cloud
controler's IP address.  In future, might also get the
AP's serial number and poke that into the cloud-ctlr somehow.
This commit is contained in:
Ben Greear
2020-06-26 11:57:56 -07:00
parent 77957ee705
commit f34ec9169f
4 changed files with 54 additions and 12 deletions

View File

@@ -197,6 +197,7 @@ for ($i = 0; $i<@lines; $i++) {
my $env = do_system(". $tb_dir/test_bed_cfg.bash && env");
my $lfmgr = "";
my $serial = "";
my $cloud_sdk = "";
if ($env =~ /LFMANAGER=(.*)/g) {
$lfmgr = $1;
@@ -207,6 +208,14 @@ for ($i = 0; $i<@lines; $i++) {
exit(1);
}
if ($env =~ /USE_CLOUD_SDK=(\S+)/g) {
$cloud_sdk = $1;
print("NOTE: Using cloud controller: $cloud_sdk\n");
}
else {
print("NOTE: NOT Using cloud controller\n");
}
if ($env =~ /AP_SERIAL=(.*)/g) {
$serial = $1;
}
@@ -276,18 +285,48 @@ for ($i = 0; $i<@lines; $i++) {
# System should be rebooted at this point.
sleep(10); # Give it some more time
print_note("Initialize AP, disable OpenVsync since this is stand-alone testbed.");
# Disable openvsync, it will re-write /etc/config/wireless
# This code should not be used when we get cloud-sdk wired up.
$ap_out = do_system("../../lanforge/lanforge-scripts/openwrt_ctl.py $owt_log --scheme serial --tty $serial --action cmd --value \"service opensync stop\"");
print ("Stop openvsync:\n$ap_out\n");
$ap_out = do_system("../../lanforge/lanforge-scripts/openwrt_ctl.py $owt_log --scheme serial --tty $serial --action cmd --value \"service opensync disable\"");
print ("Disable openvsync:\n$ap_out\n");
if ($cloud_sdk eq "") {
print_note("Initialize AP, disable OpenVsync since this is stand-alone testbed.");
# Disable openvsync, it will re-write /etc/config/wireless
# This code should not be used when we get cloud-sdk wired up.
$ap_out = do_system("../../lanforge/lanforge-scripts/openwrt_ctl.py $owt_log --scheme serial --tty $serial --action cmd --value \"service opensync stop\"");
print ("Stop openvsync:\n$ap_out\n");
$ap_out = do_system("../../lanforge/lanforge-scripts/openwrt_ctl.py $owt_log --scheme serial --tty $serial --action cmd --value \"service opensync disable\"");
print ("Disable openvsync:\n$ap_out\n");
}
else {
print_note("Initialize AP, enable OpenVsync since this testbed is using Cloud-Controler: $cloud_sdk.");
$ap_out = do_system("../../lanforge/lanforge-scripts/openwrt_ctl.py $owt_log --scheme serial --tty $serial --action cmd --value \"service opensync ensable\"");
print ("Disable openvsync:\n$ap_out\n");
}
# Re-apply overlay
print_note("Apply default AP configuration for this test bed.");
$ap_out = do_system("cd $tb_dir/OpenWrt-overlay && tar -cvzf ../overlay_tmp.tar.gz * && scp ../overlay_tmp.tar.gz lanforge\@$lfmgr:tip-overlay.tar.gz");
if ($cloud_sdk eq "") {
$ap_out = do_system("cd $tb_dir/OpenWrt-overlay && tar -cvzf ../overlay_tmp.tar.gz * && scp ../overlay_tmp.tar.gz lanforge\@$lfmgr:tip-overlay.tar.gz");
}
else {
# Create /etc/hosts file that points us towards correct cloud-sdk machine
my $etc_hosts = "$tb_dir/OpenWrt-overlay/etc/hosts";
open(FILE, ">", "$etc_hosts");
print FILE "# Auto-Created by CICD process
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
$cloud_sdk opensync-mqtt-broker
$cloud_sdk opensync-wifi-controller
$cloud_sdk opensync.zone1.art2wave.com
";
# Leave 'wireless' out of the overlay since opensync will be designed to work with default config.
$ap_out = do_system("cd $tb_dir/OpenWrt-overlay && tar -cvzf ../overlay_tmp.tar.gz --exclude etc/config/wireless * && scp ../overlay_tmp.tar.gz lanforge\@$lfmgr:tip-overlay.tar.gz");
unlink($etc_hosts);
}
print ("Create overlay zip:\n$ap_out\n");
for (my $q = 0; $q<10; $q++) {
$ap_out = do_system("../../lanforge/lanforge-scripts/openwrt_ctl.py $owt_log --scheme serial --tty $serial --action download --value \"lanforge\@$ap_gw:tip-overlay.tar.gz\" --value2 \"overlay.tgz\"");
print ("Download overlay to DUT:\n$ap_out\n");

View File

@@ -9,7 +9,7 @@
# from the directory in which it resides.
PWD=`pwd`
AP_SERIAL=${AP_SERIAL:-/dev/ttyUSB1}
AP_SERIAL=${AP_SERIAL:-/dev/ttyUSB2}
LF_SERIAL=${LF_SERIAL:-/dev/ttyS0}
LFPASSWD=${LFPASSWD:-r} # Root password on LANforge machine
AP_AUTO_CFG_FILE=${AP_AUTO_CFG_FILE:-$PWD/AP-Auto-ap-auto-228.txt}

View File

@@ -12,7 +12,7 @@ config wifi-iface 'default_radio0'
option network 'lan'
option mode 'ap'
option encryption 'none'
option ssid 'OpenWrt-5hi'
option ssid 'OpenWrt-MR8300'
config wifi-device 'radio1'
option type 'mac80211'
@@ -27,7 +27,7 @@ config wifi-iface 'default_radio1'
option network 'lan'
option mode 'ap'
option encryption 'none'
option ssid 'OpenWrt-2'
option ssid 'OpenWrt-MR8300'
config wifi-device 'radio2'
option type 'mac80211'
@@ -42,5 +42,5 @@ config wifi-iface 'default_radio2'
option network 'lan'
option mode 'ap'
option encryption 'none'
option ssid 'OpenWrt-5lo'
option ssid 'OpenWrt-MR8300'

View File

@@ -17,6 +17,9 @@ WCT_CFG_FILE=${WCT_CFG_FILE:-$PWD/wct.txt}
DPT_CFG_FILE=${DPT_CFG_FILE:-$PWD/dpt-pkt-sz.txt}
SCENARIO_CFG_FILE=${SCENARIO_CFG_FILE:-$PWD/scenario.txt}
# Default to enable cloud-sdk for this testbed, cloud-sdk is at IP addr below
USE_CLOUD_SDK=${USE_CLOUD_SDK:-192.168.100.164}
# LANforge target machine
LFMANAGER=${LFMANAGER:-192.168.100.209}