Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Using python in telecommunications

An overview about python usage into telecommunications area. By an Ericsson employee.
by

Helio Loureiro

on 14 April 2016

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Using python in telecommunications

5.2.1
Python & gnuplot
parsing CSV/XML files from statistics
Python, perl and rrdtool
Not all nodes/machines have python available
Perl agents
Python at main server to grather data and generate graphs with rrdtool
TSP: Telecom Server Plataform
Linux based
No hard disk (in memory system)
Clustering (nowadays, you can say "cloud")
No python...
(python stylish Erlang)
http://elixir-lang.org/
As example...
#! /usr/bin/python -u

import pexpect
import time
import os
import sys

username = "username"
password = "password"
targethost = "ccn-io2"
targetdir = "statistics"
countersdir = "/opt/telorb/axe/tsp/NM/PMF/reporterLogs/CcnCounters/"
targetcmd = "./ccn5.4_stats.pl -t 20130711 " + countersdir

while True:
ssh = pexpect.spawn("ssh -C -l " + username + " " + targethost)
ssh.logfile = sys.stdout
ssh.expect("ssword:")
ssh.sendline(password)
ssh.expect(">")
ssh.sendline("cd " + targetdir)
ssh.expect(">")
ssh.sendline(targetcmd)
ssh.expect(">")
ssh.close()

scp = pexpect.spawn("scp " + username + "@" + targethost + ":" + \
targetdir + "/CCN-daily_statistics-2013-07-12.csv .")
scp.logfile = sys.stdout
scp.expect("ssword:")
scp.sendline(password)
scp.wait()
scp.close()

os.system("gnuplot < ccn-gnuplot.cmd")
time.sleep(15 * 60)
What kind of network?
Nodes?
Machines?
Systems?
#! /usr/local/bin/python

import telnetlib

host = "localhost"
route_port = 2601
bgp_port = 2605
passwd = "zebra"


bgp = telnetlib.Telnet(host, bgp_port)
bgp.read_until("Password:")
bgp.write(passwd + "\n")

bgp.write("show ip bgp summary\n")
bgp.write("exit\n")
print bgp.read_all()

route = telnetlib.Telnet(host, route_port)
route.read_until("Password:")
route.write(passwd + "\n")
route.write("show ip route static\n")
route.write("exit\n")
print route.read_all()

showbgp
keep_updated.py
NPC
== Number Portability Change
(9th digit)
551291234567 => 5512
9
91234567
#! /usr/bin/bash
#--------------------------------------
# MAIN SCRIPT
#--------------------------------------

checkIfRunning

createDirectories

checkPendingFiles

getFiles $baseDir/npc_input_files
checkFiles

getFiles $baseDirNPC/submit
checkSubscriberExist

getFiles $baseDirNPC/submit
checkCutover
#checkNPC
createDatabaseReference

getFiles $baseDirNPC/report
checkConsistency

getFiles $baseDirNPC/submit_sdp
upload

moveToArchive

rm /tmp/npc.pid
Shell script (bash)
Crontab
Sequencial
492 lines
400 subs/2 minutes
If no checks, 1600 subs
NPC_MGR_MINSAT.sh
Database lock
for content
protection
NPC_MGR_MINSAT_DAEMON
#### vodoo and black magic from here - don't touch ###
import time, os, sys, re
import posix, signal, random
from threading import Thread, Lock
import ftplib
from getopt import getopt, GetoptError

class NPCMinsat:
def __init__(self):
def Log(self, msg):
def GetOptions(self):
def CheckRun(self):
def CreateLock(self, pid):
def createDirectories(self):
def checkIfRunning(self):
def checkPendingFiles(self):
def checkFiles(self):
def checkSubscriberExist(self):
def run(self):
def Daemonize(self):


class ThreadedNPCMinsat(Thread):
def __init__(self, parent = None, function = None):
def AccountMSISDN(self, patt):
def DBthread(self):
def checkConsistency(self):
def Upload(self):
def checkCutover(self):
def GetPid(self, patt):
def createDatabaseReference(self):
def RejectAction(self):
def SafeMove(self, fileorig, filedest):
def moveToArchive(self):
def logging(self):
def NetMonitor(self):
def run(self):
def Usage():
Daemon mode
Options in place
Threaded
1580 lines (sorry)
Performance....
?
Any guess?
750 subscribers per minute
(total cycle ~80 seconds)
... and checking NPC before apply
Yes, we can!
What is the meaning of this?
sysadmin
Integration Engineer is
almost like a sysadmin job.
Installation, tunning and
scripts...

no product development
A real usage case
def conv989(msisdn):
"""
Converts 9 digits to 8, and 8 to 9.
"""
CC = msisdn[0:2] # Country Code (55)
AC = msisdn[2:4] # Area Code (1[2-9])
SUB = msisdn[4:]

m = ""
if (len(SUB) == 8):
m = "%s%s9%s" % (CC, AC, SUB)
elif (len(SUB) == 9):
m = "%s%s%s" % (CC, AC, SUB[1:])
#print "Converting %s => %s" % (msisdn, m)
return m
Converting 8 to 9 and 9 to 8 digits
#TEST 1
MSISDN 1 must be the same as MSISDN 2

#TEST 2
Number of digits must be old 12 digits ( 55 + AC + 8 digits ) and new 13 digits ( 55 + AC + 9 digits ) OR
Number of digits must be new 13 digits ( 55 + AC + 9 digits ) and old 12 digits ( 55 + AC + 8 digits )

#TEST 3
MSISDN must start with (55 + AC)

#TEST 4
Line length must be of 30

#TEST 5
Number of white spaces preceeding MSISDN must be 3 for 8 digits and 2 for 9 digits
NPC checks - integrity
,,,551222249101,,5512922249101
551222249102 5512922249102
551222249103 5512922249103
551222249104 5512922249104
551222249105 5512922249105
head -5 NPC/archive/submit/
NUMBER_CHANGE_20130806_00052.dat~

3 spaces
2 spaces
15 digits
15 digits
/usr/xpg4/bin/awk -F" " -v areaCode=$areaCode '{
if ((( substr($1,5,8) == substr($2,6,8) ) && (substr($2,5,1) == "9" ) && ( substr($1,0,4) == substr($2,0,4))) || \
(( substr($1,6,8) == substr($2,5,8) && (substr($1,5,1) == "9" ) && ( substr($1,0,4) == substr($2,0,4)) )))
if ( (length($1) == 12 && length($2) == 13) || (length($1) == 13 && length($2) == 12))
if (( substr($1,0,4) ~ 55areaCode ) && ( substr($2,0,4) ~ 55areaCode ))
if ( length($0) == 30 )
if ( (length($1) == 13) && (substr($0,0,2) == " ") && (substr($0,16,3) == " ") || \
(length($1) == 12) && (substr($0,0,3) == " ") && (substr($0,16,2) == " "))
#Verification OK
print $0 > "'"$baseDirNPC"'""/submit/""'"$filename"'";
else
#Verification ERROR: Number of white spaces preceeding MSISDNs not valid
print $0,",001" >> "'"$errorDir"'""/""'"$filename"'"".err"
else
#Verification ERROR: Lenght of line not equal to 30
print $0,",002" >> "'"$errorDir"'""/""'"$filename"'"".err"
else
#Verification ERROR: Country Code or Area Code not valid
print $0,",003" >> "'"$errorDir"'""/""'"$filename"'"".err"
else
#Verification ERROR: Lenght of MSISDNs not valid
print $0,",004" >> "'"$errorDir"'""/""'"$filename"'"".err"
else
#Verification ERROR: MSISDNs are not equal
print $0,",005" >> "'"$errorDir"'""/""'"$filename"'"".err"
}' $file
shell code (awk)
python code
for line in open(filename).readlines():
try:
msisdn1, msisdn2 = line.split()
except:
errorline += line
continue

prefix1 = line[:5]
prefix2 = line[:5]
m1_size = len(msisdn1)
m2_size = len(msisdn2)

# test 1
if not (msisdn1[-8:] == msisdn2[-8:]):
errorline += line
errorcount += 1
continue

# test 2
if not ( ( (m1_size == 12) and (m2_size == 13) ) or \
( (m1_size == 13) and (m2_size == 12) ) ):
errorline += line
errorcount += 1
continue


# test 3
if not (re.search("^55" + areaCode, msisdn1) and \
re.search("^55" + areaCode, msisdn2)):
errorline += line
errorcount += 1
continue

# test 4
if (len(line) != 31):
errorline += line
errorcount += 1
continue

# test 5
if (m1_size == 12):
# 8 digits
if not ( (line[:3] == 3 * space) or \
(line[15:17] == 2 * space) ):
errorline += line
errorcount += 1
continue

elif (m1_size == 13):
# 9 digits
if not ( (line[:2] == 2 * space) or \
(line[15:18] == 3 * space) ):
errorline += line
errorcount += 1
continue


else:
# Unknow size
errorline += line
errorcount += 1
continue
### approved ###
output += line

31
== line
(content + "\n")
@helioloureiro
http://helio.loureiro.eng.br
Electrical Engineering at UFSC
IT strategical management at FGV
Debian user since 1997
Python lover since 1.5 (1997)
what is this
presentation
about?
Ericsson
and
Open Source
Free Software?
ERLANG
created in Ericsson computer sciente laboratory
open source language
designed to work in clusters (robust fault-tolerant distributed systems)
Licensed as EPL (Ericsson Public LIcense) - Mozilla alike
http://www.erlang.org
2007
What I do...
about me...
http://eri.cx/5gV
Ericsson Open Source Projects
Feldspar - language for DSP programming
SIP container - Sailfin, SIP servlet
OpenSAF – Open Service Availability Framework
TIPC - Transparent Inter-Process Communication
Webkit - web browser engine
GDB - Gnu Debugger
LTTng - Linux Trace Toolkit Next Generation
Final results
Area 11 migration
Area 1[2-9] migration
Area 2* migration
7 weeks
4,5 weeks
2 weeks
Full transcript