Esempio n. 1
0
 def InitializeMME(self, HTML):
     if self.IPAddress == '' or self.UserName == '' or self.Password == '' or self.SourceCodePath == '' or self.Type == '':
         HELP.GenericHelp(CONST.Version)
         HELP.EPCSrvHelp(self.IPAddress, self.UserName, self.Password,
                         self.SourceCodePath, self.Type)
         sys.exit('Insufficient EPC Parameters')
     mySSH = SSH.SSHConnection()
     mySSH.open(self.IPAddress, self.UserName, self.Password)
     if re.match('OAI-Rel14-Docker', self.Type, re.IGNORECASE):
         logging.debug('Using the OAI EPC Release 14 MME in Docker')
         mySSH.command(
             'docker exec -d ' + self.containerPrefix +
             '-oai-mme /bin/bash -c "nohup tshark -i eth0 -i lo:s10 -w /tmp/mme_check_run.pcap 2>&1 > /dev/null"',
             '\$', 5)
         time.sleep(5)
         mySSH.command(
             'docker exec -d ' + self.containerPrefix +
             '-oai-mme /bin/bash -c "nohup ./bin/oai_mme -c ./etc/' +
             self.mmeConfFile + ' > mme_check_run.log 2>&1"', '\$', 5)
     elif re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
         logging.debug('Using the OAI EPC Release 14 MME')
         mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
         mySSH.command(
             'echo ' + self.Password + ' | sudo -S rm -f mme_' +
             self.testCase_id + '.log', '\$', 5)
         mySSH.command(
             'echo "./run_mme --config-file /usr/local/etc/oai/mme.conf --set-virt-if" > ./my-mme.sh',
             '\$', 5)
         mySSH.command('chmod 755 ./my-mme.sh', '\$', 5)
         mySSH.command(
             'sudo daemon --unsafe --name=mme_daemon --chdir=' +
             self.SourceCodePath + '/scripts -o ' + self.SourceCodePath +
             '/scripts/mme_' + self.testCase_id + '.log ./my-mme.sh', '\$',
             5)
     elif re.match('OAI', self.Type, re.IGNORECASE):
         mySSH.command('cd ' + self.SourceCodePath, '\$', 5)
         mySSH.command('source oaienv', '\$', 5)
         mySSH.command('cd scripts', '\$', 5)
         mySSH.command('stdbuf -o0 hostname', '\$', 5)
         result = re.search(
             'hostname\\\\r\\\\n(?P<host_name>[a-zA-Z0-9\-\_]+)\\\\r\\\\n',
             mySSH.getBefore())
         if result is None:
             logging.debug('\u001B[1;37;41m Hostname Not Found! \u001B[0m')
             sys.exit(1)
         host_name = result.group('host_name')
         mySSH.command(
             'echo ' + self.Password +
             ' | sudo -S ./run_mme 2>&1 | stdbuf -o0 tee -a mme_' +
             self.testCase_id + '.log &', 'MME app initialization complete',
             100)
     elif re.match('ltebox', self.Type, re.IGNORECASE):
         mySSH.command('cd /opt/ltebox/tools', '\$', 5)
         mySSH.command('echo ' + self.Password + ' | sudo -S ./start_mme',
                       '\$', 5)
     else:
         logging.error('This option should not occur!')
     mySSH.close()
     HTML.CreateHtmlTestRow(self.Type, 'OK', CONST.ALL_PROCESSES_OK)
Esempio n. 2
0
	def InitializeHSS(self):
		if self.IPAddress == '' or self.UserName == '' or self.Password == '' or self.SourceCodePath == '' or self.Type == '':
			HELP.GenericHelp(CONST.Version)
			HELP.EPCSrvHelp(self.IPAddress, self.UserName, self.Password, self.SourceCodePath, self.Type)
			sys.exit('Insufficient EPC Parameters')
		mySSH = SSH.SSHConnection() 
		mySSH.open(self.IPAddress, self.UserName, self.Password)
		if re.match('OAI-Rel14-Docker', self.Type, re.IGNORECASE):
			logging.debug('Using the OAI EPC Release 14 Cassandra-based HSS in Docker')
			mySSH.command('if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/scripts ; fi', '\$', 5)
			mySSH.command('mkdir -p ' + self.SourceCodePath + '/scripts', '\$', 5)
			mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-hss /bin/bash -c "nohup tshark -i eth0 -i eth1 -w /tmp/hss_check_run.pcap 2>&1 > /dev/null"', '\$', 5)
			time.sleep(5)
			mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-hss /bin/bash -c "nohup ./bin/oai_hss -j ./etc/hss_rel14.json --reloadkey true > hss_check_run.log 2>&1"', '\$', 5)
		elif re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
			logging.debug('Using the OAI EPC Release 14 Cassandra-based HSS')
			mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
			logging.debug('\u001B[1m Launching tshark on all interfaces \u001B[0m')
			self.PcapFileName = 'epc_' + self.testCase_id + '.pcap'
			mySSH.command('echo ' + self.Password + ' | sudo -S rm -f ' + self.PcapFileName, '\$', 5)
			mySSH.command('echo $USER; nohup sudo tshark -f "tcp port not 22 and port not 53" -i any -w ' + self.SourceCodePath + '/scripts/' + self.PcapFileName + ' > /tmp/tshark.log 2>&1 &', self.UserName, 5)
			mySSH.command('echo ' + self.Password + ' | sudo -S mkdir -p logs', '\$', 5)
			mySSH.command('echo ' + self.Password + ' | sudo -S rm -f hss_' + self.testCase_id + '.log logs/hss*.*', '\$', 5)
			mySSH.command('echo "oai_hss -j /usr/local/etc/oai/hss_rel14.json" > ./my-hss.sh', '\$', 5)
			mySSH.command('chmod 755 ./my-hss.sh', '\$', 5)
			mySSH.command('sudo daemon --unsafe --name=hss_daemon --chdir=' + self.SourceCodePath + '/scripts -o ' + self.SourceCodePath + '/scripts/hss_' + self.testCase_id + '.log ./my-hss.sh', '\$', 5)
		elif re.match('OAI', self.Type, re.IGNORECASE):
			logging.debug('Using the OAI EPC HSS')
			mySSH.command('cd ' + self.SourceCodePath, '\$', 5)
			mySSH.command('source oaienv', '\$', 5)
			mySSH.command('cd scripts', '\$', 5)
			mySSH.command('echo ' + self.Password + ' | sudo -S ./run_hss 2>&1 | stdbuf -o0 awk \'{ print strftime("[%Y/%m/%d %H:%M:%S] ",systime()) $0 }\' | stdbuf -o0 tee -a hss_' + self.testCase_id + '.log &', 'Core state: 2 -> 3', 35)
		elif re.match('ltebox', self.Type, re.IGNORECASE):
			logging.debug('Using the ltebox simulated HSS')
			mySSH.command('if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/scripts ; fi', '\$', 5)
			mySSH.command('mkdir -p ' + self.SourceCodePath + '/scripts', '\$', 5)
			mySSH.command('cd /opt/hss_sim0609', '\$', 5)
			mySSH.command('echo ' + self.Password + ' | sudo -S rm -f hss.log', '\$', 5)
			mySSH.command('echo ' + self.Password + ' | sudo -S echo "Starting sudo session" && sudo su -c "screen -dm -S simulated_hss ./starthss"', '\$', 5)
		else:
			logging.error('This option should not occur!')
		mySSH.close()
		if self.htmlObj is not None:
			self.htmlObj.CreateHtmlTestRow(self.Type, 'OK', CONST.ALL_PROCESSES_OK)
Esempio n. 3
0
	def InitializeSPGW(self):
		if self.IPAddress == '' or self.UserName == '' or self.Password == '' or self.SourceCodePath == '' or self.Type == '':
			HELP.GenericHelp(CONST.Version)
			HELP.EPCSrvHelp(self.IPAddress, self.UserName, self.Password, self.SourceCodePath, self.Type)
			sys.exit('Insufficient EPC Parameters')
		mySSH = SSH.SSHConnection() 
		mySSH.open(self.IPAddress, self.UserName, self.Password)
		if re.match('OAI-Rel14-Docker', self.Type, re.IGNORECASE):
			logging.debug('Using the OAI EPC Release 14 SPGW-CUPS in Docker')
			mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-spgwc /bin/bash -c "nohup tshark -i eth0 -i lo:p5c -i lo:s5c -w /tmp/spgwc_check_run.pcap 2>&1 > /dev/null"', '\$', 5)
			mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-spgwu-tiny /bin/bash -c "nohup tshark -i eth0 -w /tmp/spgwu_check_run.pcap 2>&1 > /dev/null"', '\$', 5)
			time.sleep(5)
			mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-spgwc /bin/bash -c "nohup ./bin/oai_spgwc -o -c ./etc/spgw_c.conf > spgwc_check_run.log 2>&1"', '\$', 5)
			time.sleep(5)
			mySSH.command('docker exec -d ' + self.containerPrefix + '-oai-spgwu-tiny /bin/bash -c "nohup ./bin/oai_spgwu -o -c ./etc/spgw_u.conf > spgwu_check_run.log 2>&1"', '\$', 5)
		elif re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
			logging.debug('Using the OAI EPC Release 14 SPGW-CUPS')
			mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
			mySSH.command('echo ' + self.Password + ' | sudo -S rm -f spgwc_' + self.testCase_id + '.log spgwu_' + self.testCase_id + '.log', '\$', 5)
			mySSH.command('echo "spgwc -c /usr/local/etc/oai/spgw_c.conf" > ./my-spgwc.sh', '\$', 5)
			mySSH.command('chmod 755 ./my-spgwc.sh', '\$', 5)
			mySSH.command('sudo daemon --unsafe --name=spgwc_daemon --chdir=' + self.SourceCodePath + '/scripts -o ' + self.SourceCodePath + '/scripts/spgwc_' + self.testCase_id + '.log ./my-spgwc.sh', '\$', 5)
			time.sleep(5)
			mySSH.command('echo "spgwu -c /usr/local/etc/oai/spgw_u.conf" > ./my-spgwu.sh', '\$', 5)
			mySSH.command('chmod 755 ./my-spgwu.sh', '\$', 5)
			mySSH.command('sudo daemon --unsafe --name=spgwu_daemon --chdir=' + self.SourceCodePath + '/scripts -o ' + self.SourceCodePath + '/scripts/spgwu_' + self.testCase_id + '.log ./my-spgwu.sh', '\$', 5)
		elif re.match('OAI', self.Type, re.IGNORECASE):
			mySSH.command('cd ' + self.SourceCodePath, '\$', 5)
			mySSH.command('source oaienv', '\$', 5)
			mySSH.command('cd scripts', '\$', 5)
			mySSH.command('echo ' + self.Password + ' | sudo -S ./run_spgw 2>&1 | stdbuf -o0 tee -a spgw_' + self.testCase_id + '.log &', 'Initializing SPGW-APP task interface: DONE', 30)
		elif re.match('ltebox', self.Type, re.IGNORECASE):
			mySSH.command('cd /opt/ltebox/tools', '\$', 5)
			mySSH.command('echo ' + self.Password + ' | sudo -S ./start_xGw', '\$', 5)
		else:
			logging.error('This option should not occur!')
		mySSH.close()
		if self.htmlObj is not None:
			self.htmlObj.CreateHtmlTestRow(self.Type, 'OK', CONST.ALL_PROCESSES_OK)
Esempio n. 4
0
    logging.debug('\u001B[1m----------------------------------------\u001B[0m')

    CiTestObj.RetrieveSystemVersion('eNB', HTML, RAN)
    CiTestObj.RetrieveSystemVersion('UE', HTML, RAN)
    HTML.CreateHtmlFooter(CiTestObj.finalStatus)
elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match(
        '^TestUE$', mode, re.IGNORECASE):
    logging.debug('\u001B[1m----------------------------------------\u001B[0m')
    logging.debug('\u001B[1m  Starting Scenario: ' +
                  CiTestObj.testXMLfiles[0] + '\u001B[0m')
    logging.debug('\u001B[1m----------------------------------------\u001B[0m')
    if re.match('^TesteNB$', mode, re.IGNORECASE):
        if RAN.eNBIPAddress == '' or RAN.ranRepository == '' or RAN.ranBranch == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '' or EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '' or CiTestObj.ADBIPAddress == '' or CiTestObj.ADBUserName == '' or CiTestObj.ADBPassword == '':
            HELP.GenericHelp(CONST.Version)
            if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '' or EPC.Type == '':
                HELP.EPCSrvHelp(EPC.IPAddress, EPC.UserName, EPC.Password,
                                EPC.SourceCodePath, EPC.Type)
            if RAN.ranRepository == '':
                HELP.GitSrvHelp(RAN.ranRepository, RAN.ranBranch,
                                RAN.ranCommitID, RAN.ranAllowMerge,
                                RAN.ranTargetBranch)
            if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '':
                HELP.eNBSrvHelp(RAN.eNBIPAddress, RAN.eNBUserName,
                                RAN.eNBPassword, RAN.eNBSourceCodePath)
            sys.exit('Insufficient Parameter')

        if (EPC.IPAddress != '') and (EPC.IPAddress != 'none'):
            SSH.copyout(EPC.IPAddress, EPC.UserName, EPC.Password,
                        cwd + "/tcp_iperf_stats.awk", "/tmp")
            SSH.copyout(EPC.IPAddress, EPC.UserName, EPC.Password,
                        cwd + "/active_net_interfaces.awk", "/tmp")
    else:
Esempio n. 5
0
    def DeployEpc(self, HTML):
        logging.debug('Trying to deploy')
        if not re.match('OAI-Rel14-Docker', self.Type, re.IGNORECASE):
            HTML.CreateHtmlTestRow(self.Type, 'KO', CONST.INVALID_PARAMETER)
            HTML.CreateHtmlTabFooter(False)
            sys.exit('Deploy not possible with this EPC type: ' + self.Type)

        if self.IPAddress == '' or self.UserName == '' or self.Password == '' or self.SourceCodePath == '' or self.Type == '':
            HELP.GenericHelp(CONST.Version)
            HELP.EPCSrvHelp(self.IPAddress, self.UserName, self.Password,
                            self.SourceCodePath, self.Type)
            sys.exit('Insufficient EPC Parameters')
        mySSH = SSH.SSHConnection()
        mySSH.open(self.IPAddress, self.UserName, self.Password)
        mySSH.command('docker-compose --version', '\$', 5)
        result = re.search('docker-compose version 1', mySSH.getBefore())
        if result is None:
            mySSH.close()
            HTML.CreateHtmlTestRow(self.Type, 'KO', CONST.INVALID_PARAMETER)
            HTML.CreateHtmlTabFooter(False)
            sys.exit('docker-compose not installed on ' + self.IPAddress)

        mySSH.command(
            'if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' +
            self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath +
            '/scripts ; fi', '\$', 5)
        mySSH.command(
            'if [ -d ' + self.SourceCodePath + '/logs ]; then echo ' +
            self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath +
            '/logs ; fi', '\$', 5)
        mySSH.command(
            'mkdir -p ' + self.SourceCodePath + '/scripts ' +
            self.SourceCodePath + '/logs', '\$', 5)

        # deploying and configuring the cassandra database
        # container names and services are currently hard-coded.
        # they could be recovered by:
        # - docker-compose config --services
        # - docker-compose config | grep container_name
        mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
        mySSH.copyout(self.IPAddress, self.UserName, self.Password,
                      './' + self.yamlPath + '/docker-compose.yml',
                      self.SourceCodePath + '/scripts')
        mySSH.command(
            'wget --quiet --tries=3 --retry-connrefused https://raw.githubusercontent.com/OPENAIRINTERFACE/openair-hss/develop/src/hss_rel14/db/oai_db.cql',
            '\$', 30)
        mySSH.command('docker-compose down', '\$', 60)
        mySSH.command('docker-compose up -d db_init', '\$', 60)

        # databases take time...
        time.sleep(10)
        cnt = 0
        db_init_status = False
        while (cnt < 10):
            mySSH.command('docker logs prod-db-init', '\$', 5)
            result = re.search('OK', mySSH.getBefore())
            if result is not None:
                cnt = 10
                db_init_status = True
            else:
                time.sleep(5)
                cnt += 1
        mySSH.command('docker rm -f prod-db-init', '\$', 5)
        if not db_init_status:
            HTML.CreateHtmlTestRow(self.Type, 'KO', CONST.INVALID_PARAMETER)
            HTML.CreateHtmlTabFooter(False)
            sys.exit('Cassandra DB deployment/configuration went wrong!')

        # deploying EPC cNFs
        mySSH.command('docker-compose up -d oai_spgwu', '\$', 60)
        listOfContainers = 'prod-cassandra prod-oai-hss prod-oai-mme prod-oai-spgwc prod-oai-spgwu-tiny'
        expectedHealthyContainers = 5

        # Checking for additional services
        mySSH.command('docker-compose config', '\$', 5)
        configResponse = mySSH.getBefore()
        if configResponse.count('flexran_rtc') == 1:
            mySSH.command('docker-compose up -d flexran_rtc', '\$', 60)
            listOfContainers += ' prod-flexran-rtc'
            expectedHealthyContainers += 1
        if configResponse.count('trf_gen') == 1:
            mySSH.command('docker-compose up -d trf_gen', '\$', 60)
            listOfContainers += ' prod-trf-gen'
            expectedHealthyContainers += 1

        # Checking if all are healthy
        cnt = 0
        while (cnt < 3):
            mySSH.command(
                'docker inspect --format=\'{{.State.Health.Status}}\' ' +
                listOfContainers, '\$', 10)
            unhealthyNb = mySSH.getBefore().count('unhealthy')
            healthyNb = mySSH.getBefore().count('healthy') - unhealthyNb
            startingNb = mySSH.getBefore().count('starting')
            if healthyNb == expectedHealthyContainers:
                cnt = 10
            else:
                time.sleep(10)
                cnt += 1
        logging.debug(' -- ' + str(healthyNb) + ' healthy container(s)')
        logging.debug(' -- ' + str(unhealthyNb) + ' unhealthy container(s)')
        logging.debug(' -- ' + str(startingNb) +
                      ' still starting container(s)')
        if healthyNb == expectedHealthyContainers:
            mySSH.command(
                'docker exec -d prod-oai-hss /bin/bash -c "nohup tshark -i any -f \'port 9042 or port 3868\' -w /tmp/hss_check_run.pcap 2>&1 > /dev/null"',
                '\$', 5)
            mySSH.command(
                'docker exec -d prod-oai-mme /bin/bash -c "nohup tshark -i any -f \'port 3868 or port 2123 or port 36412\' -w /tmp/mme_check_run.pcap 2>&1 > /dev/null"',
                '\$', 10)
            mySSH.command(
                'docker exec -d prod-oai-spgwc /bin/bash -c "nohup tshark -i any -f \'port 2123 or port 8805\' -w /tmp/spgwc_check_run.pcap 2>&1 > /dev/null"',
                '\$', 10)
            # on SPGW-U, not capturing on SGI to avoid huge file
            mySSH.command(
                'docker exec -d prod-oai-spgwu-tiny /bin/bash -c "nohup tshark -i any -f \'port 8805\'  -w /tmp/spgwu_check_run.pcap 2>&1 > /dev/null"',
                '\$', 10)
            mySSH.close()
            logging.debug('Deployment OK')
            HTML.CreateHtmlTestRow(self.Type, 'OK', CONST.ALL_PROCESSES_OK)
        else:
            mySSH.close()
            logging.debug('Deployment went wrong')
            HTML.CreateHtmlTestRow(self.Type, 'KO', CONST.INVALID_PARAMETER)