示例#1
0
    def __init__(self, scenario_name, host_port, config_file, nfpa_class):
        '''
        This class initializes a bottle python webserver on the given
        host_port, which is passed as host:port!
        scenario_name String - the name for identifying the scenario
        host_port String - looks like localhost:8000
        nfpa_class NFPA - this is a pointer to main class to be able to access
        its startPktgenMeasurements function
        '''
        
        host_port_string_input = host_port  #used only line 84 for printing out
        
        host_port = host_port.split(":")
        self.host = host_port[0]
        self.port = host_port[1]


        
        #read config
        tmp_cfg = rwcf.readConfigFile(config_file)
        #check whether it was successful
        if tmp_cfg[0] == True:
            self.config = tmp_cfg[1]
        else:
            print(tmp_cfg[1])
            exit(-1)
        
        self.config_comment = rwcf.getConfigComments()
        
        #instantiate logger
        self.log = l.getLogger( self.__class__.__name__, 
                                self.config['LOG_LEVEL'], 
                                self.config['app_start_date'],
                                self.config['LOG_PATH'])
        
        self.log.info("### Measurement scenario '" + scenario_name + "' has been" 
              "initiated with Web-GUI ###")
        self.log.info("NFPA Web interface can be reached under: %s/nfpa" %
                      host_port_string_input)
        # print("ETL: %s" % self.config['ETL'])
        
        #append scenario name to self.config dictionary for later usage
        self.config['scenario_name'] = scenario_name
        
        self.nfpa_class = nfpa_class
        
        
#         print("in config: %s" % self.config['scenario_name'])
        self._app = Bottle()
        
        self._route()
        
#         self.note_pic = self._serve_pictures('note.png')
        
        self.start()
示例#2
0
文件: web_nfpa.py 项目: cslev/nfpa
    def __init__(self, scenario_name, host_port, nfpa_class):
        '''
        This class initializes a bottle python webserver on the given
        host_port, which is passed as host:port!
        scenario_name String - the name for identifying the scenario
        host_port String - looks like localhost:8000
        nfpa_class NFPA - this is a pointer to main class to be able to access
        its startPktgenMeasurements function
        '''
        
        host_port_string_input = host_port  #used only line 84 for printing out
        
        host_port = host_port.split(":")
        self.host = host_port[0]
        self.port = host_port[1]
        
        #read config
        tmp_cfg = rwcf.readConfigFile("nfpa.cfg")
        #check whether it was successful
        if tmp_cfg[0] == True:
            self.config = tmp_cfg[1]
        else:
            print(tmp_cfg[1])
            exit(-1)
        
        self.config_comment = rwcf.getConfigComments()
        
        #instantiate logger
        self.log = l.getLogger( self.__class__.__name__, 
                                self.config['LOG_LEVEL'], 
                                self.config['app_start_date'],
                                self.config['LOG_PATH'])
        
        self.log.info("### Measurement scenario '" + scenario_name + "' has been" 
              "initiated with Web-GUI ###")
        self.log.info("NFPA Web interface can be reached under: %s/nfpa" %
                      host_port_string_input)
        # print("ETL: %s" % self.config['ETL'])
        
        #append scenario name to self.config dictionary for later usage
        self.config['scenario_name'] = scenario_name
        
        self.nfpa_class = nfpa_class
        
        
#         print("in config: %s" % self.config['scenario_name'])
        self._app = Bottle()
        
        self._route()
        
#         self.note_pic = self._serve_pictures('note.png')
        
        self.start()
示例#3
0
    def __init__(self, config_file):
        '''
        Constructor
        '''

        #check the path to the config_file

        #dictionary for storing configuration parameters read from config file
        self._config = {}
        #read config
        tmp_cfg = rwcf.readConfigFile(config_file)
        #check whether it was successful
        if tmp_cfg[0] == True:
            self._config = tmp_cfg[1]
        else:
            print(tmp_cfg[1])
            exit(-1)

        #create a list of dictionary indexes for easier iterating though data
        #actually, these are the measured data units/names stored and placed in
        #gnuplot file as well, therefore iterating through this dictionary eases
        #the code via not accessing the fields explicitly
        #sp - sent pps, rb - recv bps, etc.
        self._config['header_uni'] = [
            'sent_pps', 'recv_pps', 'miss_pps', 'sent_bps', 'recv_bps',
            'diff_bps'
        ]

        self._config['header_bi'] = [
            'sent_pps_bidir', 'recv_pps_bidir', 'miss_pps_bidir',
            'sent_bps_bidir', 'recv_bps_bidir', 'diff_bps_bidir'
        ]

        self._config['helper_header'] = ['min', 'avg', 'max']

        self.log = l.getLogger(self.__class__.__name__,
                               self._config['LOG_LEVEL'],
                               self._config['app_start_date'],
                               self._config['LOG_PATH'])

        #create an instance of database helper and store it in config dictionary
        self._config["dbhelper"] = SQLiteDatabaseAdapter(self._config)

        # parse config params
        configSuccess = self.checkConfig()
        if (configSuccess == -1):
            return -1

        self.calculateTimeLeft()
        self.createResultsDir()
        self.assemblePktgenCommand()
        self.createSymlinksForLuaScripts()
示例#4
0
    def __init__(self, config_file):
        '''
        Constructor
        '''

        #check the path to the config_file

        #dictionary for storing configuration parameters read from config file
        self._config = {}

        #config_file is just the basename of the separated config files
        #first, we concatenate them into one file, then use the old one-config-file approach
        postfixes = ['user','email','nfpanode','nf_hw','nf_data','nf_ctrl','traffic','gnuplot']
        cfg_files = list()
        for i in postfixes:
            tmp = config_file + "." + i
            if not (os.path.isfile(tmp)):
                print("config file %s does not exist! Create it manually! Read nfpa.cfg.README for more details!")
                exit(-1)
            cfg_files.append(tmp)

        concatenated_config_file_name = "nfpa_main_generated.cfg"
        with open(concatenated_config_file_name,'w') as fout:
            fout.write("#GENERATED CONFIG FILE - MODIFYING IT DOES NOT HAVE ANY EFFECT!\n")
            fout.write("#Create your own configuration with [CONFIG_FILE_PREFIX]. and the following endings:\n")
            for p in postfixes:
                fout.write("#")
                fout.write(p)
		fout.write("\n")
            fout.write("\n")
            fout.write("#For more information read nfpa.cfg.README\n")

            fin = fileinput.input(cfg_files)
            for file in fin:
                fout.write(file)
            fin.close()


        #read config
        tmp_cfg = rwcf.readConfigFile(concatenated_config_file_name)
        #check whether it was successful
        if tmp_cfg[0] == True:
            self._config = tmp_cfg[1]
        else:
            print(tmp_cfg[1])
            exit(-1)


        
        #create a list of dictionary indexes for easier iterating though data
        #actually, these are the measured data units/names stored and placed in
        #gnuplot file as well, therefore iterating through this dictionary eases
        #the code via not accessing the fields explicitly
        #sp - sent pps, rb - recv bps, etc.
        self._config['header_uni'] = ['sent_pps', 'recv_pps', 'miss_pps', 
                                      'sent_bps', 'recv_bps', 'diff_bps']
        
        self._config['header_bi']  = ['sent_pps_bidir', 'recv_pps_bidir', 'miss_pps_bidir',
                                      'sent_bps_bidir', 'recv_bps_bidir', 'diff_bps_bidir']
        
        self._config['helper_header'] = ['min', 'avg', 'max']



        self.log = l.getLogger( self.__class__.__name__,
                                self._config['LOG_LEVEL'],
                                self._config['app_start_date'],
                                self._config['LOG_PATH'])

        #create an instance of database helper and store it in config dictionary
        self._config["dbhelper"] = SQLiteDatabaseAdapter(self._config)

        # parse config params
        configSuccess = self.checkConfig()
        if (configSuccess == -1):
            return -1

        self.calculateTimeLeft()
        self.createResultsDir()
        self.assemblePktgenCommand()
        self.createSymlinksForLuaScripts()
示例#5
0
文件: read_config.py 项目: cslev/nfpa
    def __init__(self, config_file):
        '''
        Constructor
        '''

        #check the path to the config_file

        #dictionary for storing configuration parameters read from config file
        self._config = {}
        #read config
        tmp_cfg = rwcf.readConfigFile(config_file)
        #check whether it was successful
        if tmp_cfg[0] == True:
            self._config = tmp_cfg[1]
        else:
            print(tmp_cfg[1])
            exit(-1)


        
        #create a list of dictionary indexes for easier iterating though data
        #actually, these are the measured data units/names stored and placed in
        #gnuplot file as well, therefore iterating through this dictionary eases
        #the code via not accessing the fields explicitly
        #sp - sent pps, rb - recv bps, etc.
        self._config['header_uni'] = ['sent_pps', 'recv_pps', 'miss_pps', 
                                      'sent_bps', 'recv_bps', 'diff_bps']
        
        self._config['header_bi']  = ['sent_pps_bidir', 'recv_pps_bidir', 'miss_pps_bidir',
                                      'sent_bps_bidir', 'recv_bps_bidir', 'diff_bps_bidir']
        
        self._config['helper_header'] = ['min', 'avg', 'max']



        self.log = l.getLogger( self.__class__.__name__,
                                self._config['LOG_LEVEL'],
                                self._config['app_start_date'],
                                self._config['LOG_PATH'])

        # self.log=logging.getLogger(self.__class__.__name__)


        # set supported control APIs
        self._config["controllers"] = ("openflow")


        
        #create an instance of database helper and store it in config dictionary
        self._config["dbhelper"] = SQLiteDatabaseAdapter(self._config)



        # parse config params
        configSuccess = self.checkConfig()
        if (configSuccess == -1):
            return -1


        #calculate time left
        self.calculateTimeLeft()
        
        #create res dir
        self.createResultsDir()
        

        #assemble pktgen command
        self.assemblePktgenCommand()
          
        #create symlinks for lua files
        self.createSymlinksForLuaScripts()