24
24
import time
25
25
import multiprocessing
26
26
import hashlib
27
- import socket ;
27
+ import socket
28
28
29
29
import tsqa .configs
30
30
import tsqa .utils
@@ -319,19 +319,9 @@ def __init__(self, layout=None):
319
319
self .layout = None
320
320
321
321
#process environment options
322
- self .keep_env = False
323
- if plugin .conf_plugin .args .keep_env :
324
- self .keep_env = plugin .conf_plugin .args .keep_env
325
322
self .sleep_in_sec = 0
326
323
if plugin .conf_plugin .args .sleep_in_sec :
327
324
self .sleep_in_sec = plugin .conf_plugin .args .sleep_in_sec
328
- self .standalone_ats_port = - 1
329
- if plugin .conf_plugin .args .standalone_ats_port :
330
- self .standalone_ats_port = plugin .conf_plugin .args .standalone_ats_port
331
- if self .standalone_ats_port != - 1 and plugin .conf_plugin .args .standalone_ats_port not in range (0 , 65536 ):
332
- log .info ("invalid port number assigned to --standalone_ats_port, start an ATS" )
333
-
334
-
335
325
336
326
def create (self ):
337
327
"""
@@ -390,8 +380,8 @@ def clone(self, layout=None):
390
380
else :
391
381
os .chmod (dirname , 0777 )
392
382
393
- if self . standalone_ats_port != - 1 :
394
- http_server_port = self . standalone_ats_port
383
+ if plugin . conf_plugin . args . standalone_server_port :
384
+ http_server_port = plugin . conf_plugin . args . standalone_server_port
395
385
else :
396
386
http_server_port = tsqa .utils .bind_unused_port ()[1 ]
397
387
manager_mgmt_port = tsqa .utils .bind_unused_port ()[1 ]
@@ -460,7 +450,7 @@ def destroy(self):
460
450
self .layout = Layout (None )
461
451
462
452
def start (self ):
463
- if self . standalone_ats_port != - 1 :
453
+ if plugin . conf_plugin . args . standalone_server_port :
464
454
return
465
455
if self .running (): # if its already running, don't start another one
466
456
raise Exception ('traffic cop already started' )
@@ -471,7 +461,7 @@ def start(self):
471
461
472
462
# TODO: exception if already stopped?
473
463
def stop (self ):
474
- if self . standalone_ats_port != - 1 :
464
+ if plugin . conf_plugin . args . standalone_server_port :
475
465
return
476
466
if self .sleep_in_sec > 0 :
477
467
time .sleep (self .sleep_in_sec )
@@ -489,16 +479,16 @@ def stop(self):
489
479
self .cop .terminate () # TODO: remove?? or wait...
490
480
491
481
def running (self ):
492
- if self . standalone_ats_port != - 1 :
482
+ if plugin . conf_plugin . args . standalone_server_port :
493
483
#try to connect to the port
494
484
sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
495
- result = sock .connect_ex (('127.0.0.1' , self . standalone_ats_port ))
485
+ result = sock .connect_ex (('127.0.0.1' , int ( plugin . conf_plugin . args . standalone_server_port ) ))
496
486
if result == 0 :
497
- log .info ( "The port for standalone ATS is open" )
487
+ log .debug ( "Standalone ATS server port is open" )
498
488
sock .close ()
499
489
return True
500
490
else :
501
- log .info ( "The port for standalone ATS is not open" )
491
+ log .error ( "Standalone ATS server port is not open" )
502
492
sock .close ()
503
493
return False
504
494
if self .cop is None :
0 commit comments