#NEWLINE# def start( self , multiplex_sockets = False ) : #NEWLINE# #INDENT# "\n    Start a new POX controller process based on the config's start_cmd\n    attribute. Registers the Popen member variable for deletion upon a SIG*\n    received in the simulator process\n    " #NEWLINE# self . log . info ( self . welcome_msg ) #NEWLINE# if ( self . state != ControllerState . DEAD ) : #NEWLINE# #INDENT# self . log . warn ( ( 'Starting controller %s when controller is not dead!' % self . label ) ) #NEWLINE# return #NEWLINE# #UNINDENT# msg . event ( ( 'Starting POX controller %s' % str ( self . cid ) ) ) #NEWLINE# env = None #NEWLINE# if self . config . sync : #NEWLINE# #INDENT# env = os . environ . copy ( ) #NEWLINE# port_match = re . search ( ':(\\d+)$' , self . config . sync ) #NEWLINE# if ( port_match is None ) : #NEWLINE# #INDENT# raise ValueError ( ( 'sync: cannot find port in %s' % self . config . sync ) ) #NEWLINE# #UNINDENT# port = port_match . group ( 1 ) #NEWLINE# env [ 'sts_sync' ] = ( 'ptcp:0.0.0.0:%d' % ( int ( port ) , ) ) #NEWLINE# #UNINDENT# if ( self . config . sync or multiplex_sockets ) : #NEWLINE# #INDENT# src_dir = os . path . join ( os . path . dirname ( __file__ ) , '../../' ) #NEWLINE# pox_ext_dir = os . path . join ( self . config . cwd , 'ext' ) #NEWLINE# if os . path . exists ( pox_ext_dir ) : #NEWLINE# #INDENT# for f in ( 'sts/util/io_master.py' , 'sts/syncproto/base.py' , 'sts/syncproto/pox_syncer.py' , 'sts/__init__.py' , 'sts/util/socket_mux/__init__.py' , 'sts/util/socket_mux/pox_monkeypatcher.py' , 'sts/util/socket_mux/base.py' , 'sts/util/socket_mux/server_socket_multiplexer.py' ) : #NEWLINE# #INDENT# src_path = os . path . join ( src_dir , f ) #NEWLINE# if ( not os . path . exists ( src_path ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Integrity violation: sts sync source path %s (abs: %s) does not exist' % ( src_path , os . path . abspath ( src_path ) ) ) ) #NEWLINE# #UNINDENT# dst_path = os . path . join ( pox_ext_dir , f ) #NEWLINE# dst_dir = os . path . dirname ( dst_path ) #NEWLINE# init_py = os . path . join ( dst_dir , '__init__.py' ) #NEWLINE# if ( not os . path . exists ( dst_dir ) ) : #NEWLINE# #INDENT# os . makedirs ( dst_dir ) #NEWLINE# #UNINDENT# if ( not os . path . exists ( init_py ) ) : #NEWLINE# #INDENT# open ( init_py , 'a' ) . close ( ) #NEWLINE# #UNINDENT# if os . path . islink ( dst_path ) : #NEWLINE# #INDENT# os . remove ( dst_path ) #NEWLINE# #UNINDENT# if ( not os . path . exists ( dst_path ) ) : #NEWLINE# #INDENT# rel_link = os . path . abspath ( src_path ) #NEWLINE# self . log . debug ( 'Creating symlink %s -> %s' , rel_link , dst_path ) #NEWLINE# os . symlink ( rel_link , dst_path ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . log . warn ( ( 'Could not find pox ext dir in %s. ' + ( 'Cannot check/link in sync module' % pox_ext_dir ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( self . config . start_cmd in [ '' , None ] ) : #NEWLINE# #INDENT# raise RuntimeError ( ( 'No command found to start controller %s!' % self . label ) ) #NEWLINE# #UNINDENT# start_cmd = getattr ( self . config , 'expanded_start_cmd' , self . config . start_cmd ) #NEWLINE# self . log . info ( ( 'Launching controller %s: %s' % ( self . label , ' ' . join ( start_cmd ) ) ) ) #NEWLINE# launch_in_network_namespace = getattr ( self . config , 'launch_in_network_namespace' , False ) #NEWLINE# if launch_in_network_namespace : #NEWLINE# #INDENT# ( self . process , self . guest_eth_addr , self . host_device ) = launch_namespace ( ' ' . join ( start_cmd ) , self . config . address , self . cid , host_ip_addr_str = IPAddressSpace . find_unclaimed_address ( ip_prefix = self . config . address ) , cwd = self . config . cwd , env = env ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . process = popen_filtered ( ( '[%s]' % self . label ) , start_cmd , self . config . cwd , env ) #NEWLINE# #UNINDENT# self . _register_proc ( self . process ) #NEWLINE# if self . config . sync : #NEWLINE# #INDENT# self . sync_connection = self . sync_connection_manager . connect ( self , self . config . sync ) #NEWLINE# #UNINDENT# self . _check_snapshot_connect ( ) #NEWLINE# self . state = ControllerState . ALIVE