Pyats
Set up test environment
lcha_lib.lcha.poll_lc_warm scp build@cmts-build02:/home/build/pyats/team/sereno_rest_api_test.py 172.22.10.41:3 easypy rphy_basic_lcha_job.py -no_log_copy easypy /home/build/pyats/yuanliu2/monitor_test/sereno_syslog_job.py -no_archive -datafile 'template.yaml'
We use pyATS to do our automation. Here's the wiki link: http://wwwin-pyats.cisco.com. I have a sample script you can use to start your automation:
/ws/jcwu-sjc/pyats3/aramanan/demo/bringupTest.py, the testbed file is demo.yaml.
1. To bring up pyats environment, you can run "source /auto/sjc-ccebuild-ar5/pyats-gate/env.sh; source /auto/pysw/ats64/env.sh" if you use BASH shell. source /auto/sjc-ccebuild-ar5/pyats-gate/env.sh; source /auto/pysw/ats64/env.sh 2.export PYTHONPATH=/opt/pyats_docker:/auto/sjgate/okrun/pyats_project
3.export GATE_SCRIPT_AREA=/auto/pysw/ats64/regression/gate/scripts/ ------------tcl 2017-07-13T05:40:13: %AETEST-ERROR: File "/auto/shgate/shared/cvsworkarea/zhiyqiu/regression/tests/cable/battlestar/SDN/D31_SREG1/rphy_basic_lcha.py", line 34, in <module> 2017-07-13T05:40:13: %AETEST-ERROR: tcl.eval('source $env(GATE_SCRIPT_AREA)/libInit') 2017-07-13T05:40:13: %AETEST-ERROR: File "/auto/sjc-ccebuild-ar5/pyats-gate/lib/python3.4/site-packages/ats/tcl/interpreter.py", line 272, in eval 2017-07-13T05:40:13: %AETEST-ERROR: raise TclError(self.vars['::errorInfo']) from None 2017-07-13T05:40:13: %AETEST-ERROR: _tkinter.TclError: can't read "env(GATE_SCRIPT_AREA)": no such variable 2017-07-13T05:40:13: %AETEST-ERROR: while executing 2017-07-13T05:40:13: %AETEST-ERROR: "source $env(GATE_SCRIPT_AREA)/libInit" 2017-07-13T05:40:13: %AETEST-ERROR: 4.pip install parsergen 2017-07-13T21:59:50: %AETEST-ERROR: from cable.testbed.pyats_oop import * 2017-07-13T21:59:50: %AETEST-ERROR: File "/auto/sjgate/okrun/pyats_project/cable/testbed/pyats_oop.py", line 8, in <module> 2017-07-13T21:59:50: %AETEST-ERROR: from ..topology import * 2017-07-13T21:59:50: %AETEST-ERROR: File "/auto/sjgate/okrun/pyats_project/cable/topology/__init__.py", line 6, in <module> 2017-07-13T21:59:50: %AETEST-ERROR: from .binos import Binos, \ 2017-07-13T21:59:50: %AETEST-ERROR: File "/auto/sjgate/okrun/pyats_project/cable/topology/binos.py", line 4, in <module> 2017-07-13T21:59:50: %AETEST-ERROR: from .util import oper_fill_tabular_raw 2017-07-13T21:59:50: %AETEST-ERROR: ImportError: cannot import name 'oper_fill_tabular_raw' 2017-07-13T21:59:50: %AETEST-ERROR:
telemetry easypy ./sereno_ui_rpdAssignments_job.py -no_archive -testbed_file R7673-cbr8-e2e_vm_build.yaml -datafile R7673-CBR8-vm-data-ui.yaml --no_rtr_chk 1 --skip_rpd_vm_reboot 1 -uids "Or('common_setup', 'ui_rpd_assignment_test','common_cleanup')"
python decode gcp redirect packet
str(netaddr.IPAddress(int(data.encode('hex')[-32:], 16))) --------- get -32: ip address
pyats docker install package
Step1: pyats@sh-cable-vnc-8:~$ ./start_pyats_docker.sh What's your userid? stelo start web shell ... start ssh server ... start bash ...
You can use https:// web shell or ssh shell to access your docker container To use cablepi python lib, you should do 'export PYTHONPATH=/opt/pyats_docker:/auto/shgate/shared/cable_py/pyats_project' for CRDC 'export PYTHONPATH=/opt/pyats_docker:/auto/sjgate/okrun/pyats_project' for SJC
Activating the pyATS instance @ /opt/pyats_docker
PYTHONPATH=/opt/pyats_docker: LD_LIBRARY_PATH=/opt/ats6.0.0/lib
Make sure to setup the Tcl ATS env separately!
(pyats_docker) okrun@sh-cable-vnc-8:/$ * Starting OpenBSD Secure Shell server sshd [ OK ]
(pyats_docker) okrun@sh-cable-vnc-8:/$ (pyats_docker) okrun@sh-cable-vnc-8:/$
Step2:
(pyats_docker) okrun@sh-cable-vnc-8:/$ sudo su
root@sh-cable-vnc-8:/#
root@sh-cable-vnc-8:/#
export http_proxy="http://proxy.esl.cisco.com:80/"
export https_proxy="http://proxy.esl.cisco.com:80/"
export ftp_proxy="http://proxy.esl.cisco.com:80/"
export no_proxy=".cisco.com,localhost"
export HTTP_PROXY="http://proxy.esl.cisco.com:80/"
export HTTPS_PROXY="http://proxy.esl.cisco.com:80/"
export FTP_PROXY="http://proxy.esl.cisco.com:80/"
export PIP_TRUSTED_HOST="ats-pypi-server.cisco.com"
export PIP_INDEX_URL="http://ats-pypi-server.cisco.com/simple"
root@sh-cable-vnc-8:/#
root@sh-cable-vnc-8:/#
Step3: root@sh-cable-vnc-8:~# source /opt/pyats_docker/env.sh Activating the pyATS instance @ /opt/pyats_docker
PYTHONPATH=/opt/pyats_docker: LD_LIBRARY_PATH= Make sure to setup the Tcl ATS env separately!
(pyats_docker) root@sh-cable-vnc-8:~# env | grep proxy http_proxy=http://proxy.esl.cisco.com:80/ FTP_PROXY=http://proxy.esl.cisco.com:80/ ftp_proxy=http://proxy.esl.cisco.com:80/ HTTPS_PROXY=http://proxy.esl.cisco.com:80/ https_proxy=http://proxy.esl.cisco.com:80/ no_proxy=.cisco.com,localhost HTTP_PROXY=http://proxy.esl.cisco.com:80/ (pyats_docker) root@sh-cable-vnc-8:~# env | grep PIP PIP_TRUSTED_HOST=ats-pypi-server.cisco.com PIP_INDEX_URL=http://ats-pypi-server.cisco.com/simple
Step4: (pyats_docker) root@sh-cable-vnc-8:~# pip install requests Downloading/unpacking requests
http://ats-pypi-server.cisco.com/simple/requests/ uses an insecure transport scheme (http). Consider using https if ats-pypi-server.cisco.com has it available Downloading requests-2.18.3-py2.py3-none-any.whl (88kB): 88kB downloaded
Downloading/unpacking certifi>=2017.4.17 (from requests)
http://ats-pypi-server.cisco.com/simple/certifi/ uses an insecure transport scheme (http). Consider using https if ats-pypi-server.cisco.com has it available Downloading certifi-2017.7.27.1-py2.py3-none-any.whl (349kB): 349kB downloaded
Downloading/unpacking idna>=2.5,<2.6 (from requests)
http://ats-pypi-server.cisco.com/simple/idna/ uses an insecure transport scheme (http). Consider using https if ats-pypi-server.cisco.com has it available Downloading idna-2.5-py2.py3-none-any.whl (55kB): 55kB downloaded
Downloading/unpacking chardet>=3.0.2,<3.1.0 (from requests)
http://ats-pypi-server.cisco.com/simple/chardet/ uses an insecure transport scheme (http). Consider using https if ats-pypi-server.cisco.com has it available Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB): 133kB downloaded
Downloading/unpacking urllib3>=1.21.1,<1.23 (from requests)
http://ats-pypi-server.cisco.com/simple/urllib3/ uses an insecure transport scheme (http). Consider using https if ats-pypi-server.cisco.com has it available Downloading urllib3-1.22-py2.py3-none-any.whl (132kB): 132kB downloaded
Installing collected packages: requests, certifi, idna, chardet, urllib3 Successfully installed requests certifi idna chardet urllib3 Cleaning up... (pyats_docker) root@sh-cable-vnc-8:~# python Python 3.4.1 (default, Dec 15 2014, 01:54:12) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> exit() (pyats_docker) root@sh-cable-vnc-8:~#