Exemplo n.º 1
0
 def testStart(self):
     self.task = utils.Runner('echo', arguments = 'Test text',
                              start_shell=True)
     self.task.start()
     while self.task.isRunning(): pass
     self.task.stop()
     self.assertIn('Test text', self.task.getOutput())
Exemplo n.º 2
0
    def __init__(self):
        self.logger = logging.getLogger(HSS_Processor.__name__)

        self._log_dir = tempfile.TemporaryDirectory(prefix='hss.processor')
        self._log_dir_name = self._log_dir.name
        self._runner = utils.Runner(self.HSS_EXECUTABLE,
                                    log_dir=self._log_dir_name)
        self._hss_config = HSS_Config()
Exemplo n.º 3
0
    def __init__(self):
        self.logger = logging.getLogger(PGW_Processor.__name__)

        self._log_dir = tempfile.TemporaryDirectory(prefix='pgw.processor')
        self._log_dir_name = self._log_dir.name
        self._runner = utils.Runner(self.PGW_EXECUTABLE,
                                    log_dir=self._log_dir_name)
        self._pgw_config = PGW_Config()
Exemplo n.º 4
0
    def __init__(self, spgw_config_path=SPGW_CONFIG_PATH):
        self.logger = logging.getLogger(SPGW_Processor.__name__)

        self._configurator = SPGW_Configurator(config_path=spgw_config_path)
        self._log_dir = tempfile.TemporaryDirectory(prefix='spgw.processor')
        self._log_dir_name = self._log_dir.name
        self._runner = utils.Runner(self.SPGW_EXECUTABLE,
                                    log_dir=self._log_dir_name)
Exemplo n.º 5
0
 def _addService(self, ip, port):
     if ip is not None and port is not None:
         r = utils.Runner(self.CMD_IPVSADM,
                          log_dir=self._log_dir_name,
                          append_log = True)
         r.setArguments(self.ADD_SERVICE % (ip, port))
         r.start()
         r.join()
Exemplo n.º 6
0
    def _add_iptables(self, ip):
        if ip is None:
            return

        r =  utils.Runner(self.CMD_IPTABLES, arguments = self.ADD_IPTABLES % ip,
                          log_dir=self._iptables_log_dir_name,
                          append_log = True)
        r.start()
        r.join()
Exemplo n.º 7
0
    def __init__(self):
        self.logger = logging.getLogger(SGW_Processor.__name__)

        self._log_dir = tempfile.TemporaryDirectory(prefix='sgw.processor')
        self._log_dir_name = self._log_dir.name
        self._iptables_log_dir_name = os.path.join(self._log_dir_name, 'iptables.out')
        os.mkdir(self._iptables_log_dir_name)
        self._runner = utils.Runner(self.SGW_EXECUTABLE,
                                    log_dir=self._log_dir_name)
        self._sgw_config = SGW_Config()
Exemplo n.º 8
0
 def _addReplica(self, lb_ip, lb_port, server_ip, server_port):
     r = utils.Runner(self.CMD_IPVSADM,
                      log_dir=self._log_dir_name,
                      append_log = True)
     if server_port is None:
         r.setArguments(self.ADD_REPLICA % (lb_ip, lb_port,
                                            server_ip, lb_port))
     else:
         r.setArguments(self.ADD_REPLICA % (lb_ip, lb_port,
                                            server_ip, server_port))
     r.start()
     r.join()
Exemplo n.º 9
0
    def __init__(self,
                 mme_config_path=MME_CONFIG_PATH,
                 mme_freediameter_config_path=MME_FREEDIAMETER_CONFIG_PATH,
                 host_file_path=HOST_FILE_PATH,
                 cert_exe=MME_CERTIFICATE_CREATOR,
                 cert_path=MME_CERTIFICATE_PATH):
        self.logger = logging.getLogger(MME_Processor.__name__)

        self._configurator = MME_Configurator(mme_config_path,
                                              mme_freediameter_config_path,
                                              host_file_path, cert_exe,
                                              cert_path)
        self._log_dir = tempfile.TemporaryDirectory(prefix='mme.processor')
        self._log_dir_name = self._log_dir.name
        self._runner = utils.Runner(self.MME_EXECUTABLE,
                                    log_dir=self._log_dir_name)
Exemplo n.º 10
0
    def __init__(self,
                 hss_config_path=HSS_CONFIG_PATH,
                 hss_freediameter_config_path=HSS_FREEDIAMETER_CONFIG_PATH,
                 hss_certificate_exe=HSS_CERTIFICATE_EXECUTABLE,
                 hss_certificate_path=HSS_CERTIFICATE_PATH,
                 host_file_path=HOST_FILE_PATH):
        self.logger = logging.getLogger(HSS_Processor.__name__)

        self._configurator = HSS_Configurator(hss_config_path,
                                              hss_freediameter_config_path,
                                              host_file_path,
                                              hss_certificate_exe,
                                              hss_certificate_path)
        self._log_dir = tempfile.TemporaryDirectory(prefix='hss.processor')
        self._log_dir_name = self._log_dir.name
        self._runner = utils.Runner(self.HSS_EXECUTABLE,
                                    log_dir=self._log_dir_name)
Exemplo n.º 11
0
    def testLogFile(self):
        with tempfile.TemporaryDirectory() as log_dir:
            self.task = utils.Runner('echo',
                                     arguments = 'Test text',
                                     log_dir = log_dir,
                                     start_shell=True)
            self.task.start()
            while self.task.isRunning(): pass
            self.task.stop()
            self.assertIn('Test text', self.task.getOutput())
            self.assertEqual('', self.task.getOutput(stderr = True))

            stdout_content = ""
            with open(os.path.join(log_dir, "stdout")) as log_file:
                for line in log_file:
                    stdout_content += line

            stderr_content = ""
            with open(os.path.join(log_dir, "stderr")) as log_file:
                for line in log_file:
                    stderr_content += line

            self.assertIn('Test text', stdout_content)
            self.assertEqual('', stderr_content)
Exemplo n.º 12
0
 def _clear(self):
     r = utils.Runner(self.CMD_IPVSADM,
                      log_dir=self._log_dir_name,
                      append_log = True)
     r.setArguments(self.CLEAR)
     r.start()