To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit c098a8ef authored by Reto Da Forno's avatar Reto Da Forno

listen port on observer for serial proxy is now stored in the config file and...

listen port on observer for serial proxy is now stored in the config file and passed from the testmanagement server to the observer
parent c77178ac
......@@ -154,9 +154,7 @@ DROP TABLE IF EXISTS `tbl_serv_observer`;
CREATE TABLE `tbl_serv_observer` (
`serv_observer_key` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ethernet_address` varchar(60) COLLATE utf8_bin NOT NULL,
`ip_address` varchar(16) COLLATE utf8_bin NOT NULL,
`observer_id` int(11) NOT NULL,
`port_datasender` int(11) NOT NULL DEFAULT '50001',
`status` enum('online','offline','disabled','develop') COLLATE utf8_bin NOT NULL DEFAULT 'disabled',
`slot_1_tg_adapt_list_fk` int(10) unsigned DEFAULT NULL,
`slot_2_tg_adapt_list_fk` int(10) unsigned DEFAULT NULL,
......
Dump structure of database using following command:
mysqldump -d -h taugwalder -u <username> -p --databases 'flocklab' --lock-tables=false > flocklab_server_db.sql
mysqldump -t -h taugwalder -u <username> -p flocklab tbl_serv_architectures tbl_serv_observer tbl_serv_observer_slot_calibration tbl_serv_operatingsystems tbl_serv_pinmappings tbl_serv_platforms tbl_serv_services tbl_serv_tg_adapt_list tbl_serv_tg_adapt_types >> flocklab_server_db.sql
mysqldump -d -h <db_server> -u <username> -p --databases 'flocklab' --lock-tables=false > flocklab_server_db.sql
mysqldump -t -h <db_server> -u <username> -p flocklab tbl_serv_architectures tbl_serv_observer tbl_serv_observer_slot_calibration tbl_serv_operatingsystems tbl_serv_pinmappings tbl_serv_platforms tbl_serv_services tbl_serv_tg_adapt_list tbl_serv_tg_adapt_types >> flocklab_server_db.sql
......@@ -41,7 +41,6 @@ then
/bin/sh /etc/network/if-up.d/gumstix_leds_ifup
else
# IP is offline. Increment counter. If counter is bigger than threshold, reboot:
echo "ping watchdog: host unreachable"
COUNTER=`cat $PINGPATH`
if [ ! -s $PINGPATH ]
then
......@@ -57,9 +56,7 @@ else
if [ $COUNTER -ge $HALFTIME ]
then
# ETH0:
# Just do an ifup/ifdown:
echo "ping_watchdog: ifdown / ifup on eth0"
/usr/bin/logger "ping_watchdog: ifdown / ifup on eth0"
/sbin/ifdown $INTERFACE
/bin/sleep 5
/sbin/ifup $INTERFACE
......
......@@ -389,6 +389,11 @@ if [ ! "$2" = "-sdsetuponly" ]; then
ssh root@$GUMSTIX "echo \"*/2 * * * * root /usr/bin/ping_watchdog.sh carrel 8.8.8.8 10\" >> /etc/crontab";
fi
if [ ! "$2" = "-sdsetuponly" ]; then
# adjust the DHCP client
ssh root@$GUMSTIX "sed -i 's/\/etc\//\/var\/tmp\//g' /etc/udhcpc.d/50default";
fi
echo "Creating directory needed for flocklab tests...";
ssh root@$GUMSTIX "mkdir -p /media/card/root/flocklab/curtest/"
......
......@@ -7,7 +7,6 @@ obsdbfolder = /home/root/mmc/flocklab/db/ ;Folder on the observer in which
testconfigfolder = /home/root/mmc/flocklab/curtest/ ;Folder on the observer into which the test configuration and target image are uploaded
templatesfolder = /home/root/mmc/flocklab/templates/ ;Folder where all kinds of templates are stored.
timeformat_services = %%Y/%%m/%%d %%H:%%M:%%S ;Time format which is used for all services on the observer. Must be parsable by strftime. % must be escaped as %%
datasenderport = 50001 ;Port on which datasender listens for incoming requests
pidfolder = /var/run/ ;Folder for pid files
led_ext = /sys/class/leds/gumstix:extern:led1/ ;Path to the control structure for the external (green) LED
led_green = /sys/class/leds/gumstix:green:led2/ ;Path to the control structure for the green LED
......@@ -44,7 +43,6 @@ moterunner_lipproxy_socketpath = /tmp/flocklab/lipproxy.sock ;Path to socket to
moterunner_blocksize = 2048 ;Blocksize for reads on lip-proxy socket
tinyos_blocksize = 2048 ;Blocksize for reads on tinyos serial-forwarder socket
dbflushinterval = 300 ;Seconds until a new db file is written and old one is flushed
port = 50001 ;Port to be used to communicate with FlockLab server
; GPIO monitoring
[gpiomonitoring]
......
......@@ -71,6 +71,7 @@ def usage():
print "Options:"
print " --testid=<testid>\t\tID of the test."
print " --xml=<path>\t\t\tPath to the XML file with the testconfiguration."
print " --serialport=<port>\t\tPort for the serial forwarder."
print " --daqconfig=<path>\t\tOptional. Path to the DAQ config file."
print " --debug\t\t\tOptional. Print debug messages to log."
print " --help\t\t\tOptional. Print this help."
......@@ -107,7 +108,7 @@ def main(argv):
# Get command line parameters.
try:
opts, args = getopt.getopt(argv, "hvdt:x:f:", ["help", "version", "debug", "testid=", "xml=", "daqconfig="])
opts, args = getopt.getopt(argv, "hvdt:x:f:p:", ["help", "version", "debug", "testid=", "xml=", "daqconfig=", "serialport="])
except getopt.GetoptError, err:
print str(err)
logger.error(str(err))
......@@ -131,6 +132,8 @@ def main(argv):
err = "Error: file %s does not exist" %(str(daqfile))
logger.error(err)
sys.exit(errno.EINVAL)
elif opt in ("-p", "--serialport"):
serialport = int(arg)
elif opt in ("-h", "--help"):
debug = True
usage()
......@@ -511,7 +514,7 @@ def main(argv):
targetos = operatingsystem
cmd = ['flocklab_serial.py', '--testid=%d' % testid, '--targetos=%s'%targetos]
if slotnr:
cmd.append('--socketport=%d'%(config.getint("serial", "port") + slotnr - 1))
cmd.append('--socketport=%d' % (serialport)) # + slotnr - 1))
if tree.find('obsSerialConf/port') <> None:
port = tree.find('obsSerialConf/port').text
cmd.append('--port=%s'%(port))
......
......@@ -125,8 +125,10 @@ expiration_leadtime = 14 ;Number of days to warn user before result
; Config for serial proxy
[serialproxy]
startport = 50100 ;Start port for serial proxy to test users. For the real port, the observer ID is added to the start port.
obsdataport = 50001 ;Observer listens on this port for incoming connections from the testmanagement server
shutdown_timeout = 240 ;Timeout in seconds until proxy processes are killed
; Config fo MMC check script
[mmccheck]
observer_svn = /home/flocklab/flocklab_bin/observer
......
......@@ -152,6 +152,7 @@ class StartTestThread(threading.Thread):
def run(self):
errors = []
testconfigfolder = "%s/%d" % (config.get("observer", "testconfigfolder"), self._testid)
obsdataport = config.getint('serialproxy', 'obsdataport')
try:
logger.debug("Start StartTestThread for observer ID %d, FlockDAQ=%s" % (self._obsdict_key[self._obskey][1], str(self._FlockDAQ)))
# First test if the observer is online and if the SD card is mounted:
......@@ -214,7 +215,7 @@ class StartTestThread(threading.Thread):
else:
logger.debug("Upload of target image and config XML to observer ID %s succeeded." %(self._obsdict_key[self._obskey][1]))
# Start the script on the observer which starts the test:
remote_cmd = "flocklab_starttest.py --testid=%d --xml=%s/%s" % (self._testid, testconfigfolder, os.path.basename(self._xmldict_key[self._obskey][0]))
remote_cmd = "flocklab_starttest.py --testid=%d --xml=%s/%s --serialport=%d" % (self._testid, testconfigfolder, os.path.basename(self._xmldict_key[self._obskey][0]), obsdataport)
if self._FlockDAQ:
remote_cmd += " --daqconfig=%s/%s"%(testconfigfolder, os.path.basename(daqconfigpath))
if debug:
......
......@@ -150,6 +150,7 @@ def update_configuration_from_db():
# (user remoteIp, server port, observer ip, port)
proxystartport = config.getint('serialproxy', 'startport')
obsdataport = config.getint('serialproxy', 'obsdataport')
proxyConfig = []
try:
(cn, cur) = flocklab.connect_to_db(config, logger)
......@@ -165,12 +166,13 @@ def update_configuration_from_db():
for testconfig in ret:
logger.debug("create proxy config for test %d" % testconfig[1])
# get slot mappings
cur.execute("SELECT `observer_id`, `ethernet_address`, `port_datasender`, `slot` FROM `tbl_serv_map_test_observer_targetimages` `a` left join `tbl_serv_observer` `b` ON (`a`.`observer_fk` = `b`.`serv_observer_key`) WHERE `test_fk` = %d" % testconfig[1])
cur.execute("SELECT `observer_id`, `ethernet_address`, `slot` FROM `tbl_serv_map_test_observer_targetimages` `a` left join `tbl_serv_observer` `b` ON (`a`.`observer_fk` = `b`.`serv_observer_key`) WHERE `test_fk` = %d" % testconfig[1])
mapret = cur.fetchall()
mapping = {} # dict obsid -> (ip_address, port)
for m in mapret:
if not m[3] is None: # slot can be NULL...
mapping[int(m[0])] = (m[1],int(m[2])+int(m[3])-1)
if not m[2] is None: # slot can be NULL...
#mapping[int(m[0])] = (m[1], obsdataport + int(m[2]) - 1) # add slot index to base port
mapping[int(m[0])] = (m[1], obsdataport)
parser = etree.XMLParser(remove_comments=True)
tree = etree.fromstring(testconfig[0], parser)
ns = {'d': config.get('xml', 'namespace')}
......
......@@ -495,13 +495,13 @@ def get_obs_from_id(cursor=None, obsid=0):
return(1)
try:
sql = " SELECT `ethernet_address`, `ip_address`, `port_datasender`, `status` \
sql = " SELECT `ethernet_address`, `status` \
FROM `tbl_serv_observer` \
WHERE `observer_id`=%d;"
cursor.execute(sql %obsid)
rs = cursor.fetchone()
return (rs[0], rs[1], rs[2], rs[3])
return (rs[0], rs[1])
except:
logger = get_logger(loggername=scriptname, loggerpath=scriptpath)
logger.error("%s: %s" %(str(sys.exc_info()[0]), str(sys.exc_info()[1])))
......
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