Spirent Testcenter Automation Validating the Environment and Configuring the System Variables – an Overview
Total Page:16
File Type:pdf, Size:1020Kb
Spirent TestCenter Automation Validating the environment and configuring the system variables – an overview August 10 2016 SRE Chicago Vijay Muthucumarasamy Principle Field Service Engineer Spirent Communications PROPRIETARY AND CONFIDENTIAL 1 Agenda Spirent Automation and Supported Platforms Operating System and Validation Environment Set up and Verification • TCL • Python • Perl Lab Server HLTAPI Command Sequencer Q & A Spirent Communications PROPRIETARY AND CONFIDENTIAL 2 Supported OS and API 1. Multi-threaded 2. If you are using Avalanche on Spirent TestCenter, Windows 2008 server is not officially supported at this time. 3. Running as a 32-bit application 4. Requires LabServer 5. Requires openssh-client package **** PLEASE Check the release notes for updated information Spirent Communications PROPRIETARY AND CONFIDENTIAL 3 Spirent API Packages for Linux Environment Spirent Communications PROPRIETARY AND CONFIDENTIAL 4 Verify and Validate the OS & API Before install the STC installation packages • Verify the Operating System - Kernel - CPU - Memory - Validate the requirement : Check the Spirent TestCenter releases and verify Spirent requirements • Verify the API (TCL/Python/Perl) - Release version - Whether 32/64 bit platform - Whether need a Spirent Lab Server - Validate the requirement : Check the Spirent TestCenter releases and verify Spirent requirements Spirent Communications PROPRIETARY AND CONFIDENTIAL 5 Operating System and Validation Verify Kernel version • CentOS/RedHat/Ubuntu - cat /etc/issue - cat /etc/redhat-release (CentOs/RedHat) - uname –r -> Kernel Release - uname –i / uname –m / uname –p -> OS platform whether 32bit or 64bit - uname –a (display all the information) Memory and CPU - free -h -> Provides memory information - cat /proc/cpuinfo - cat /proc/meminfo Find File/Dir - Find / -name “filename” - Find /dir/path/look/up -name "pattern" Spirent Communications PROPRIETARY AND CONFIDENTIAL 6 TCL (Tool Command Language) Supported Versions • 8.4.13 • 8.5.9 • 8.5.14 • Both 32 bit and 64 bit (Lab Server is not mandatory from STC release v4.64) Verify TCL version • Info patchlevel - % info patchlevel 8.4.19 Verify whether the TCL platform (32 bit or 64 bit) • parray tcl_platform - % parray tcl_platform tcl_platform(byteOrder) = littleEndian tcl_platform(machine) = x86_64 tcl_platform(os) = Linux tcl_platform(osVersion) = 2.6.32-642.3.1.el6.x86_64 tcl_platform(platform) = unix tcl_platform(tip,268) = 1 tcl_platform(tip,280) = 1 tcl_platform(user) = spirent tcl_platform(wordSize) = 8 Spirent Communications PROPRIETARY AND CONFIDENTIAL 7 TCL and Environment Variables Windows • Spirent TCL installation - Make sure environment “path” variable has the TCL installation path as shown below « C:\Program Files (x86)\Spirent Communications\Spirent TestCenter 4.xx\TCL\bin; » Spirent Communications PROPRIETARY AND CONFIDENTIAL 8 TCL and Environment Variables cont.… Windows • Active State TCL /Other - Make sure environment “path” variable has the TCL installation path « C:\Tcl\bin; » - Set up environment and pkgIndex.tcl * Create a System Variable STC_INSTALL_DIR and assign STC dir * Under C:\Tcl\lib create a new folder named "stc" * Under the stc folder, create a new file named "pkgIndex.tcl" and edit/add the file as shown below: package ifneeded SpirentTestCenter 2.0 [list source [file join $env(STC_INSTALL_DIR) SpirentTestCenter.tcl]] package ifneeded stc 2.0 [list source [file join $env(STC_INSTALL_DIR) SpirentTestCenter.tcl]] package ifneeded stclib 4.xx [list source [file join $env(STC_INSTALL_DIR) stclib.tcl]] Spirent Communications PROPRIETARY AND CONFIDENTIAL 9 TCL and Environment Variable Linux • Active State TCL /Other - Set up .bash_profile (works for RedHat,CentOs and Ubuntu) for STC env. Variable # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs # TCL installtion for STC export PATH=/opt/ActiveTcl-8.4.19-32/bin:$PATH #Set up LD_LIBRARY_PATH with Spirent Installation dir export LD_LIBRARY_PATH=/opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux export STC_INSTALL_DIR=/opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux - Set up environment with pkgIndex.tcl * Under /opt/ActiveTcl-8.4.19-32/lib, create a new folder named "stc" * Under the stc folder, create a new file named "pkgIndex.tcl" and edit it as shown: package ifneeded SpirentTestCenter 2.0 [list source [file join $env(STC_INSTALL_DIR) SpirentTestCenter.tcl]] package ifneeded stc 2.0 [list source [file join $env(STC_INSTALL_DIR) SpirentTestCenter.tcl]] package ifneeded stclib 4.xx [list source [file join $env(STC_INSTALL_DIR) stclib.tcl]] Spirent Communications PROPRIETARY AND CONFIDENTIAL 10 TCL : Load STC package and verify Load the Spirent TestCenter Package C:\Users\vmuthucuma>tclsh % package require SpirentTestCenter 4.64 % Spirent Communications PROPRIETARY AND CONFIDENTIAL 11 TCL : Change Spirent Environment Variable in Runtime How to run multiple STC versions at the same time? • The environment variable can be changed in the script this allows to change the environment variable for that specific run. • This is also applicable to any API including Python, Perl and also HLTAPI as well • Windows - set auto_path [linsert $auto_path 0 "C:/Program Files (x86)/Spirent Communications/Spirent TestCenter x.xx/Spirent TestCenter Application"] • Linux - set auto_path [linsert $auto_path 0 "/opt/Spirent_TestCenter_4.64/Spirent_TestCenter_Application_Linux/"] Spirent Communications PROPRIETARY AND CONFIDENTIAL 12 Python Supported Versions • 2.6.6 • 2.7.5 • Both 32 bit and 64 bit (Lab Server is not mandatory from STC release v4.64) • 64 bit Only supported in Linux environment and not in Windows Verify Python version • python –V - C:\Users\vmuthucuma>python -V > Python 2.7.6 Verify Python version whether 32bit or 64bit • import struct;print struct.calcsize("P") * 8 >>> import struct;print struct.calcsize("P") * 8 32 >>> Spirent Communications PROPRIETARY AND CONFIDENTIAL 13 Python and Environment Variables Windows • Create a system environment variable “STC_PRIVATE_INSTALL_DIR” and set with Spirent Installation directory • Copy “StcPython.py” from C:\Program Files (x86)\Spirent Communications\Spirent TestCenter 4.xx\Spirent TestCenter Application\API\Python to Python installation directory - C:\Python27 Spirent Communications PROPRIETARY AND CONFIDENTIAL 14 Python and Environment Variables Linux • Create a system environment variable “STC_PRIVATE_INSTALL_DIR” in .bash_profile and set with Spirent Installation directory export STC_PRIVATE_INSTALL_DIR=/opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux • Copy “StcPython.py” From /InstallationDir/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux/API/Pyt hon To Python script directory example: /home/spirent/SpirentAPI Spirent Communications PROPRIETARY AND CONFIDENTIAL 15 Python : Load STC package and verify Load the Spirent TestCenter Package [spirent@localhost Python]$ python Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from StcPython import StcPython >>> stc = StcPython() >>> print "SpirentTestCenter system version:\t", stc.get("system1", "version") SpirentTestCenter system version: 4.64.8676.0000 >>> Spirent Communications PROPRIETARY AND CONFIDENTIAL 16 Perl Supported Versions • 5.8.8 • 5.8.9 • 5.14.x • Supported : Only running as 32-bit application Verify Perl version • perl –v - This provides version, subversion and architecture Verify Perl version whether 32bit or 64bit • perl -V:ivsize - If the returned value is 4, your Perl uses 32-bit integers - If the returned value is 8, your Perl uses 64-bit integers • perl -V:archname - If the returned value includes x86_64, it's a 64-bit process - If the returned value includes x86 (but not x86_64), it's a 32-bit process. Spirent Communications PROPRIETARY AND CONFIDENTIAL 17 Perl and Environment Variables Windows • Create a system environment variable “STC_PRIVATE_INSTALL_DIR” and set with Spirent Installation directory • Copy “SpirentTestCenter.pm” from C:\Program Files (x86)\Spirent Communications\Spirent TestCenter 4.xx\Spirent TestCenter Application\API\Perl to C:\Perl\site\lib • Edit “SpirentTestCenter.pm” and CHANGE use lib "/home/user/Spirent_TestCenter_2.3x/"; To use lib $ENV{'STC_PRIVATE_INSTALL_DIR'}; Spirent Communications PROPRIETARY AND CONFIDENTIAL 18 Perl and Environment Variables Linux • Create a system environment variable “STC_PRIVATE_INSTALL_DIR” in .bash_profile and set with Spirent Installation directory export STC_PRIVATE_INSTALL_DIR=/opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux • Set the path variable for perl execution file in .bash_profile export PATH=/opt/ActivePerl-5.14/bin:$PATH • Copy “SpirentTestCenter.pm” From opt/Spirent_TestCenter_4.xx/Spirent_TestCenter_Application_Linux\API\Perl To /opt/ActivePerl-5.14/site/lib or /perl_Installation/site/lib • Edit “SpirentTestCenter.pm” and Change use lib "/home/user/Spirent_TestCenter_2.3x/"; To use lib $ENV{'STC_PRIVATE_INSTALL_DIR'}; Spirent Communications PROPRIETARY AND CONFIDENTIAL 19 Perl : Load STC package and verify Load the Spirent TestCenter Package • Create a Load_show_version.pl • Add the following #!/usr/bin/perl -w # load the STC package print "Loading the STC package...\n"; use strict; use SpirentTestCenter; my($stc); $stc = new StcPerl; # Retrieve and display