TPROG is a Python scripting based solution for automation of telecommunications processes on heterogenous enviroments. It uses equipment´s interfaces to interact with them in order to acomplish configuration tasks, the currently version supports the follow integration technologies :
Python 3.6.8 or higher
bcrypt==3.1.7
bitarray==1.0.1
certifi==2019.9.11
cffi==1.13.2
chardet==3.0.4
cryptography==2.8
enum34==1.1.6
future==0.18.2
idna==2.8
lxml==4.4.1
netmiko==2.4.2
paramiko==2.6.0
pyang==2.1
pyangbind==0.8.1
pybind11==2.4.3
pycparser==2.19
PyNaCl==1.3.0
pyserial==3.4
PyYAML==5.1.2
regex==2019.8.19
requests==2.22.0
ruamel.yaml==0.16.5
ruamel.yaml.clib==0.2.0
scp==0.13.2
siesta==0.5.1
simplejson==3.16.0
six==1.12.0
textfsm==1.1.0
urllib3==1.25.6
xmltodict==0.12.0
git clone https://github.com/antoniogbn/tprog.git
pip install -r requirements.txt
The steps below will guide how to use the TPROG
The YANG model must be based on equipment API format honouring the data hiehierarchy, once that´s created the Pyang is used to convert the model into python objects that will be later used on TPROG workflow.
The data modeled on the YANG file will refer strictly to that data that will be applied on equipment using the follow YANG structure as reference :
module [modulename] {
yang-version "1";
namespace "https://[yournamespaceurl]/";
prefix "[]";
typedef data {
type string;
}
container [containername]___{
leaf [fieldname1]___ {
type data;
}
leaf [fieldname2]___ {
type data;
}
.
.
.
leaf [fieldname3]___ {
type data;
}
}
Notes : - The module information inside of YANG model must be the same as the YANG file name also
Once the YANG file is created, command line below should be used to generate the python object class that later will ve used on TPROG workflow :
python tprog.cyang.py [yangfilename]
The YAML file should have the tasks that will be performed when the TPROG is executed, it can contain one more multiple tasks entries that must follow the YAML format rules. The YAML file is read using library Ruamel
The service task file should have the below presented structure :
task1:
type :
action :
csv :
uri :
username :
password :
version :
data :
.
.
.
task2:
type :
action :
csv :
uri :
username :
password :
version :
data :
.
.
.
In the table below is listed the tags that are supported on YAML file also their description and mandatory rule accordinly with access technologies.
Tag | Description | REST | SOAP | SSH |
---|---|---|---|---|
task | Unique task idenfier | Y | Y | Y |
type | Equipment access method type. currently supported : restjson, soapaxl e ioscli | Y | Y | Y |
action | Action to be called during the process, must match with object class (YANG Model) | Y | Y | Y |
uri | Logical address for webservices protocols | Y | Y | N |
ip_address | Logical address for IP protocols | N | N | Y |
version | Equipment version | N | Y | N |
device_type | Equipment type | N | N | Y |
username | Username access | N | Y | Y |
password | Password access | N | Y | Y |
csv | CSV sub-file for batch execution | N | N | N |
data | Data that will submited in the equipment | Y | Y | Y |
return | Task return variable | N | N | N |
python tprog.py tasks.yaml
This example shows how to use TPROG to add customer and accounts information using REST API in a PortaOne Softswitch server.
The both YANG files were created to serve as model to both API methods that will be called based on service API sctructure :
Then the object classes were created from their respectively YANG models using the follow commands:
(tprog) user@localhost:/dev/tprog$ python tprog.cyang.py add_customer
pyang -f tree mdl/add_customer.yang
module: add_customer
+--rw auth_info___
| +--rw login___? data
| +--rw password___? data
+--rw params___
+--rw customer_info___
+--rw name___? data
+--rw iso_4217___? data
+--rw i_traffic_profile___? data
+--rw email___? data
pyang --plugindir $PYBINDPLUGIN -f pybind mdl/add_customer.yang > obj/add_customer.py
(tprog) user@localhost:/dev/tprog$ python tprog.cyang.py add_customer
pyang -f tree mdl/add_customer.yang
module: add_customer
+--rw auth_info___
| +--rw login___? data
| +--rw password___? data
+--rw params___
+--rw customer_info___
+--rw name___? data
+--rw iso_4217___? data
+--rw i_traffic_profile___? data
+--rw email___? data
pyang --plugindir $PYBINDPLUGIN -f pybind mdl/add_customer.yang > obj/add_customer.py
note : For the TPROG, the YANG files must use the presented format including "___" after the container and leaf names.
The object classes files were generated inside obj folder, then once that is completed, the next step will be to create the task YAML file, the example below shows the file with 2 tasks :
---
task1:
type : restjson
action : add_customer
uri : https://apiserver/rest/Customer/add_customer
data :
auth_info :
login : "UsernameDemo"
password : "PasswordDemo"
params :
customer_info:
name : "Telecom International"
iso_4217 : "USD"
return : i_customer
task2:
type : restjson
action : add_account
uri : https://apiserver/rest/Account/add_account
data :
auth_info :
login : "UsernameDemo"
password : "PasswordDemo"
params :
account_info:
id: 552137525665
billing_model: 1
i_product: 1676
i_customer: $i_customer
h323_password: 123456
batch_name: telecomint_accounts
The task1 will call the method add_customer to add customer information on the server and the task2 will call the method add_account to add the accounts posteriorly . The entry return present on the task1 refers to the variable returned from method called with customer key that was generated during the process and will avaiable on the task2 be used adding accounts for that recently added customer.
Once YAML is complete call tprog main script to execute the tasks file with below line :
python tprog.py demo1.yaml
The obteined output should be like presented below :
SENT >>>
{'auth_info': '{"login": "UsernameDemo", "password": "PasswordDemo"}', 'params': '{"customer_info": {"name": "Telecom International", "iso_4217": "USD", "i_traffic_profile": "", "email": ""}}'}
RECEIVED >>>
{'i_customer': 6736}
SENT >>>
{'auth_info': '{"login": "UsernameDemo", "password": "PasswordDemo"}', 'params': '{"account_info": {"id": "552137525665", "billing_model": "1", "i_product": "1676", "i_customer": "6736", "h323_password": "abc12356", "batch_name": "telecomint_accounts"}}'}
RECEIVED >>>
{'i_account': 570170}
--- 3.52347 seconds ---
This example shows how to use TPROG to add Phones and Numbers information using SOAP AXL API in a Cisco CUCM server.
Following the steps, on the first one the YANG file was created to serve as model to both API methods that will be called based on service API sctructure :
Then the object classes were created from their respectively YANG model using the follow commands:
(tprog) user@localhost:/dev/tprog$ python tprog.cyang.py addPhone
pyang -f tree mdl/addPhone.yang
module: addPhone
+--rw phone___
+--rw name___? data
+--rw description___? data
+--rw product___? data
+--rw class___? data
+--rw protocol___? data
+--rw devicePoolName___? data
+--rw lines___
+--rw line___
+--rw index___? data
+--rw dirn___
+--rw pattern___? data
+--rw routePartitionName___? data
note : For the TPROG, the YANG files must use the presented format including "___" after the container and leaf names.
The object classes files were generated inside obj folder, then once that is completed, the next step will be to create the task YAML file, the example below shows the file with 2 tasks :
---
task1:
type : soapaxl
action : addPhone
uri : 'https://apiserver:8443/axl/'
username : 'UsernameDemo'
password : 'PasswordDemo'
version : '8.5'
data :
phone :
name :
description : "Automation Demo Device"
product : "Cisco 7945"
class : "Phone"
protocol : "SCCP"
devicePoolName : "Default"
lines:
line:
index: '1'
dirn:
pattern: 552137525665
routePartitionName: "Default_Partition"
The task1 will call the server SOAP method addPhone to add the Phone device and it´s others parameters like description, phone model, line number, etc.
Once YAML is complete call tprog main script to execute the tasks file with below line :
This example shows how to use TPROG to add dial-peer configuration using SSH command line instructions to a Cisco Voice Gateway .
Following the steps, on the first one the YANG file was created to serve as model to both API methods that will be called based on service API sctructure :
In the next step the object classes were created from their respectively YANG models using the follow commands:
(tprog) user@localhost:/dev/tprog$ python tprog.cyang.py cisco_vg
pyang -f tree mdl/cisco_vg.yang
module: cisco_vg
+--rw cmd_list___? data
pyang --plugindir $PYBINDPLUGIN -f pybind mdl/cisco_vg.yang > obj/cisco_vg.py
note : For the TPROG, the YANG files must use the presented format including "___" after the container and leaf names.
The object classes files was generated inside obj folder, the next step will be to create the task YAML file, the example below shows the file with 2 tasks :
The TPROG tool is the result of a MSc. study currently in course with Universidade Federal Fluminense
Authors :
Antonio Garcia Brandão Neto - [email protected] (mastering)
Carlos Bazilio - [email protected] (advisor)