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`; ...@@ -154,9 +154,7 @@ DROP TABLE IF EXISTS `tbl_serv_observer`;
CREATE TABLE `tbl_serv_observer` ( CREATE TABLE `tbl_serv_observer` (
`serv_observer_key` int(10) unsigned NOT NULL AUTO_INCREMENT, `serv_observer_key` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ethernet_address` varchar(60) COLLATE utf8_bin NOT NULL, `ethernet_address` varchar(60) COLLATE utf8_bin NOT NULL,
`ip_address` varchar(16) COLLATE utf8_bin NOT NULL,
`observer_id` int(11) 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', `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_1_tg_adapt_list_fk` int(10) unsigned DEFAULT NULL,
`slot_2_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: Dump structure of database using following command:
mysqldump -d -h taugwalder -u <username> -p --databases 'flocklab' --lock-tables=false > flocklab_server_db.sql mysqldump -d -h <db_server> -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 -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 ...@@ -41,7 +41,6 @@ then
/bin/sh /etc/network/if-up.d/gumstix_leds_ifup /bin/sh /etc/network/if-up.d/gumstix_leds_ifup
else else
# IP is offline. Increment counter. If counter is bigger than threshold, reboot: # IP is offline. Increment counter. If counter is bigger than threshold, reboot:
echo "ping watchdog: host unreachable"
COUNTER=`cat $PINGPATH` COUNTER=`cat $PINGPATH`
if [ ! -s $PINGPATH ] if [ ! -s $PINGPATH ]
then then
...@@ -57,9 +56,7 @@ else ...@@ -57,9 +56,7 @@ else
if [ $COUNTER -ge $HALFTIME ] if [ $COUNTER -ge $HALFTIME ]
then then
# ETH0: /usr/bin/logger "ping_watchdog: ifdown / ifup on eth0"
# Just do an ifup/ifdown:
echo "ping_watchdog: ifdown / ifup on eth0"
/sbin/ifdown $INTERFACE /sbin/ifdown $INTERFACE
/bin/sleep 5 /bin/sleep 5
/sbin/ifup $INTERFACE /sbin/ifup $INTERFACE
......
...@@ -389,6 +389,11 @@ if [ ! "$2" = "-sdsetuponly" ]; then ...@@ -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"; ssh root@$GUMSTIX "echo \"*/2 * * * * root /usr/bin/ping_watchdog.sh carrel 8.8.8.8 10\" >> /etc/crontab";
fi 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..."; echo "Creating directory needed for flocklab tests...";
ssh root@$GUMSTIX "mkdir -p /media/card/root/flocklab/curtest/" 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 ...@@ -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 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. 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 %% 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 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_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 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 ...@@ -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 moterunner_blocksize = 2048 ;Blocksize for reads on lip-proxy socket
tinyos_blocksize = 2048 ;Blocksize for reads on tinyos serial-forwarder 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 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 ; GPIO monitoring
[gpiomonitoring] [gpiomonitoring]
......
...@@ -71,6 +71,7 @@ def usage(): ...@@ -71,6 +71,7 @@ def usage():
print "Options:" print "Options:"
print " --testid=<testid>\t\tID of the test." print " --testid=<testid>\t\tID of the test."
print " --xml=<path>\t\t\tPath to the XML file with the testconfiguration." 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 " --daqconfig=<path>\t\tOptional. Path to the DAQ config file."
print " --debug\t\t\tOptional. Print debug messages to log." print " --debug\t\t\tOptional. Print debug messages to log."
print " --help\t\t\tOptional. Print this help." print " --help\t\t\tOptional. Print this help."
...@@ -107,7 +108,7 @@ def main(argv): ...@@ -107,7 +108,7 @@ def main(argv):
# Get command line parameters. # Get command line parameters.
try: 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: except getopt.GetoptError, err:
print str(err) print str(err)
logger.error(str(err)) logger.error(str(err))
...@@ -131,6 +132,8 @@ def main(argv): ...@@ -131,6 +132,8 @@ def main(argv):
err = "Error: file %s does not exist" %(str(daqfile)) err = "Error: file %s does not exist" %(str(daqfile))
logger.error(err) logger.error(err)
sys.exit(errno.EINVAL) sys.exit(errno.EINVAL)
elif opt in ("-p", "--serialport"):
serialport = int(arg)
elif opt in ("-h", "--help"): elif opt in ("-h", "--help"):
debug = True debug = True
usage() usage()
...@@ -511,7 +514,7 @@ def main(argv): ...@@ -511,7 +514,7 @@ def main(argv):
targetos = operatingsystem targetos = operatingsystem
cmd = ['flocklab_serial.py', '--testid=%d' % testid, '--targetos=%s'%targetos] cmd = ['flocklab_serial.py', '--testid=%d' % testid, '--targetos=%s'%targetos]
if slotnr: 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: if tree.find('obsSerialConf/port') <> None:
port = tree.find('obsSerialConf/port').text port = tree.find('obsSerialConf/port').text
cmd.append('--port=%s'%(port)) cmd.append('--port=%s'%(port))
......
...@@ -125,8 +125,10 @@ expiration_leadtime = 14 ;Number of days to warn user before result ...@@ -125,8 +125,10 @@ expiration_leadtime = 14 ;Number of days to warn user before result
; Config for serial proxy ; Config for serial proxy
[serialproxy] [serialproxy]
startport = 50100 ;Start port for serial proxy to test users. For the real port, the observer ID is added to the start port. 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 shutdown_timeout = 240 ;Timeout in seconds until proxy processes are killed
; Config fo MMC check script ; Config fo MMC check script
[mmccheck] [mmccheck]
observer_svn = /home/flocklab/flocklab_bin/observer observer_svn = /home/flocklab/flocklab_bin/observer
......
...@@ -151,7 +151,8 @@ class StartTestThread(threading.Thread): ...@@ -151,7 +151,8 @@ class StartTestThread(threading.Thread):
def run(self): def run(self):
errors = [] errors = []
testconfigfolder = "%s/%d" % (config.get("observer", "testconfigfolder"), self._testid) testconfigfolder = "%s/%d" % (config.get("observer", "testconfigfolder"), self._testid)
obsdataport = config.getint('serialproxy', 'obsdataport')
try: try:
logger.debug("Start StartTestThread for observer ID %d, FlockDAQ=%s" % (self._obsdict_key[self._obskey][1], str(self._FlockDAQ))) 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: # First test if the observer is online and if the SD card is mounted:
...@@ -214,7 +215,7 @@ class StartTestThread(threading.Thread): ...@@ -214,7 +215,7 @@ class StartTestThread(threading.Thread):
else: else:
logger.debug("Upload of target image and config XML to observer ID %s succeeded." %(self._obsdict_key[self._obskey][1])) 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: # 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: if self._FlockDAQ:
remote_cmd += " --daqconfig=%s/%s"%(testconfigfolder, os.path.basename(daqconfigpath)) remote_cmd += " --daqconfig=%s/%s"%(testconfigfolder, os.path.basename(daqconfigpath))
if debug: if debug:
......
...@@ -150,6 +150,7 @@ def update_configuration_from_db(): ...@@ -150,6 +150,7 @@ def update_configuration_from_db():
# (user remoteIp, server port, observer ip, port) # (user remoteIp, server port, observer ip, port)
proxystartport = config.getint('serialproxy', 'startport') proxystartport = config.getint('serialproxy', 'startport')
obsdataport = config.getint('serialproxy', 'obsdataport')
proxyConfig = [] proxyConfig = []
try: try:
(cn, cur) = flocklab.connect_to_db(config, logger) (cn, cur) = flocklab.connect_to_db(config, logger)
...@@ -165,12 +166,13 @@ def update_configuration_from_db(): ...@@ -165,12 +166,13 @@ def update_configuration_from_db():
for testconfig in ret: for testconfig in ret:
logger.debug("create proxy config for test %d" % testconfig[1]) logger.debug("create proxy config for test %d" % testconfig[1])
# get slot mappings # 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() mapret = cur.fetchall()
mapping = {} # dict obsid -> (ip_address, port) mapping = {} # dict obsid -> (ip_address, port)
for m in mapret: for m in mapret:
if not m[3] is None: # slot can be NULL... if not m[2] is None: # slot can be NULL...
mapping[int(m[0])] = (m[1],int(m[2])+int(m[3])-1) #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) parser = etree.XMLParser(remove_comments=True)
tree = etree.fromstring(testconfig[0], parser) tree = etree.fromstring(testconfig[0], parser)
ns = {'d': config.get('xml', 'namespace')} ns = {'d': config.get('xml', 'namespace')}
......
...@@ -495,13 +495,13 @@ def get_obs_from_id(cursor=None, obsid=0): ...@@ -495,13 +495,13 @@ def get_obs_from_id(cursor=None, obsid=0):
return(1) return(1)
try: try:
sql = " SELECT `ethernet_address`, `ip_address`, `port_datasender`, `status` \ sql = " SELECT `ethernet_address`, `status` \
FROM `tbl_serv_observer` \ FROM `tbl_serv_observer` \
WHERE `observer_id`=%d;" WHERE `observer_id`=%d;"
cursor.execute(sql %obsid) cursor.execute(sql %obsid)
rs = cursor.fetchone() rs = cursor.fetchone()
return (rs[0], rs[1], rs[2], rs[3]) return (rs[0], rs[1])
except: except:
logger = get_logger(loggername=scriptname, loggerpath=scriptpath) logger = get_logger(loggername=scriptname, loggerpath=scriptpath)
logger.error("%s: %s" %(str(sys.exc_info()[0]), str(sys.exc_info()[1]))) 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