Script

Test to check advisor scripts

Configuration Script

Description

In this scenario, an advisor is triggered to activate the automatic script. When the advisor is changed to true, the automatic script associated with the advisor is executed, aplying the commands in the active configuration.

Scenario

Step 1: Set the following configuration in DUT0:

set system script SCRIPT_1 advisor ADVISOR1
set system advisor ADVISOR1 test false
set system cli configuration logging global info
set system script SCRIPT_1 configuration 'set system description \'advisor applied\''

Step 2: Set the following configuration in DUT0:

set system advisor ADVISOR1 test true

Step 3: Run command show running at DUT0 and check if output contains the following tokens:

set system description 'advisor applied'
Show output
# Teldat OSDx VM version v3.10.1.3
# Wed 22 May 2024 10:24:09 UTC +00:00
# Warning: Configuration has not been saved
set system advisor ADVISOR1 test true
set system cli configuration logging global info
set system description 'advisor applied'
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system script SCRIPT_1 advisor ADVISOR1
set system script SCRIPT_1 configuration 'set system description \'advisor applied\''

Operational Script

Description

In this scenario, an advisor is triggered to activate the automatic script. When the advisor is changed to true, the automatic script associated with the advisor is executed, proccessing the operational commands in the specified order.

Scenario

Step 1: Set the following configuration in DUT0:

set system script SCRIPT_1 advisor ADVISOR1
set system advisor ADVISOR1 test false
set system cli configuration logging global info
set system script SCRIPT_1 advisor ADVISOR1
set interfaces ethernet eth0 address 10.215.200.50/24
set system script SCRIPT_1 operational 1 command 'interfaces ethernet show'
set system script SCRIPT_1 operational 2 command 'license show'

Step 2: Set the following configuration in DUT0:

set system advisor ADVISOR1 test true

Step 3: Run command system journal show | cat at DUT0 and check if output contains the following tokens:

interfaces ethernet show
Show output
-- Logs begin at Wed 2024-05-22 10:24:15 UTC, end at Wed 2024-05-22 10:24:18 UTC. --
May 22 10:24:15.395855 osdx systemd-journald[11035]: Runtime journal (/run/log/journal/99893f06e2ec475e9e852fdd13370208) is 2.0M, max 16.0M, 14.0M free.
May 22 10:24:15.421293 osdx OSDxCLI[4891]: User 'admin' executed a new command: 'system journal clear'.
May 22 10:24:16.005249 osdx osdx-coredump[5388]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
May 22 10:24:16.013571 osdx OSDxCLI[4891]: User 'admin' executed a new command: 'system coredump delete all'.
May 22 10:24:16.958813 osdx OSDxCLI[4891]: User 'admin' entered the configuration menu.
May 22 10:24:17.090440 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
May 22 10:24:17.185483 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
May 22 10:24:17.284700 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
May 22 10:24:17.389248 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
May 22 10:24:17.502058 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
May 22 10:24:17.597372 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
May 22 10:24:17.720163 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
May 22 10:24:17.846282 osdx modulelauncher[978]: + Received data: ['4891', 'osdx.utils.xos', 'set_console_log_level', 'info']
May 22 10:24:17.859532 osdx OSDxCLI[4891]: Signal 10 received
May 22 10:24:17.869391 osdx ifmon[983]: Changed log-level to info
May 22 10:24:17.905027 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
May 22 10:24:17.935424 osdx cfgd[1125]: [4891]Completed change to active configuration
May 22 10:24:17.938326 osdx OSDxCLI[4891]: User 'admin' committed the configuration.
May 22 10:24:17.965514 osdx OSDxCLI[4891]: User 'admin' left the configuration menu.
May 22 10:24:18.178245 osdx OSDxCLI[4891]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
May 22 10:24:18.179137 osdx OSDxCLI[4891]: pam_unix(cli:session): session closed for user admin
May 22 10:24:18.179608 osdx OSDxCLI[4891]: User 'admin' entered the configuration menu.
May 22 10:24:18.284165 osdx OSDxCLI[4891]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
May 22 10:24:18.284682 osdx cfgd[1125]: Execute action [syntax] for node [(null)]
May 22 10:24:18.284778 osdx cfgd[1125]: Execute action [syntax] for node [(null)]
May 22 10:24:18.285144 osdx OSDxCLI[4891]: pam_unix(cli:session): session closed for user admin
May 22 10:24:18.285485 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
May 22 10:24:18.394914 osdx OSDxCLI[4891]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
May 22 10:24:18.411815 osdx cfgd[1125]: [4891]must validation for [system login user admin role] was skipped
May 22 10:24:18.411850 osdx cfgd[1125]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
May 22 10:24:18.423082 osdx cfgd[1125]: Execute action [end] for node [system advisor ADVISOR1]
May 22 10:24:18.429301 osdx cfgd[1125]: [4891]Completed change to active configuration
May 22 10:24:18.433676 osdx OSDxCLI[4891]: pam_unix(cli:session): session closed for user admin
May 22 10:24:18.434012 osdx OSDxCLI[4891]: User 'admin' committed the configuration.
May 22 10:24:18.437769 osdx INFO[5510]: SCRIPT SCRIPT_1 operations:
May 22 10:24:18.445735 osdx OSDxCLI[5518]: Tecla::GetLine tcgetattr error
May 22 10:24:18.446032 osdx OSDxCLI[5518]: User 'admin' has logged in.
May 22 10:24:18.456386 osdx OSDxCLI[5518]: User 'admin' executed a new command: 'interfaces ethernet show'.
May 22 10:24:18.458009 osdx OSDxCLI[5518]: User 'admin' has logged out.
May 22 10:24:18.458117 osdx OSDxCLI[5518]: Tecla::GetLine tcgetattr error
May 22 10:24:18.460154 osdx OSDxCLI[4891]: User 'admin' left the configuration menu.
May 22 10:24:18.460887 osdx INFO[5510]: Operation 1 'interfaces ethernet show
                                        ':

                                        -----------------------------------------------
                                        Name  IP Address  Admin  Oper  Vrf  Description
                                        -----------------------------------------------
                                        eth0              down   down
                                        eth1              down   down
May 22 10:24:18.462627 osdx modulelauncher[5510]: Traceback (most recent call last):
                                                    File "/osdx/sbin/modulelauncher.py", line 37, in run_file
                                                      result = getattr(module, args[0])(args, cfg_ses_id)
                                                    File "osdx/sbin/cfg/auto_scripts.py", line 62, in process
                                                    File "osdx/sbin/cfg/auto_scripts.py", line 107, in _execute_script
                                                    File "usr/lib/python2.7/subprocess.py", line 483, in communicate
                                                    File "usr/lib/python2.7/subprocess.py", line 1119, in _communicate
                                                  ValueError: I/O operation on closed file
May 22 10:24:18.463313 osdx cfgd[1125]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
May 22 10:24:18.463330 osdx cfgd[1125]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
May 22 10:24:18.607066 osdx OSDxCLI[4891]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)

Step 4: Run command system journal show | cat at DUT0 and check if output contains the following tokens:

license show
Show output
-- Logs begin at Wed 2024-05-22 10:24:15 UTC, end at Wed 2024-05-22 10:24:18 UTC. --
May 22 10:24:15.395855 osdx systemd-journald[11035]: Runtime journal (/run/log/journal/99893f06e2ec475e9e852fdd13370208) is 2.0M, max 16.0M, 14.0M free.
May 22 10:24:15.421293 osdx OSDxCLI[4891]: User 'admin' executed a new command: 'system journal clear'.
May 22 10:24:16.005249 osdx osdx-coredump[5388]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
May 22 10:24:16.013571 osdx OSDxCLI[4891]: User 'admin' executed a new command: 'system coredump delete all'.
May 22 10:24:16.958813 osdx OSDxCLI[4891]: User 'admin' entered the configuration menu.
May 22 10:24:17.090440 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
May 22 10:24:17.185483 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
May 22 10:24:17.284700 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
May 22 10:24:17.389248 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
May 22 10:24:17.502058 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
May 22 10:24:17.597372 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
May 22 10:24:17.720163 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
May 22 10:24:17.846282 osdx modulelauncher[978]: + Received data: ['4891', 'osdx.utils.xos', 'set_console_log_level', 'info']
May 22 10:24:17.859532 osdx OSDxCLI[4891]: Signal 10 received
May 22 10:24:17.869391 osdx ifmon[983]: Changed log-level to info
May 22 10:24:17.905027 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
May 22 10:24:17.935424 osdx cfgd[1125]: [4891]Completed change to active configuration
May 22 10:24:17.938326 osdx OSDxCLI[4891]: User 'admin' committed the configuration.
May 22 10:24:17.965514 osdx OSDxCLI[4891]: User 'admin' left the configuration menu.
May 22 10:24:18.178245 osdx OSDxCLI[4891]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
May 22 10:24:18.179137 osdx OSDxCLI[4891]: pam_unix(cli:session): session closed for user admin
May 22 10:24:18.179608 osdx OSDxCLI[4891]: User 'admin' entered the configuration menu.
May 22 10:24:18.284165 osdx OSDxCLI[4891]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
May 22 10:24:18.284682 osdx cfgd[1125]: Execute action [syntax] for node [(null)]
May 22 10:24:18.284778 osdx cfgd[1125]: Execute action [syntax] for node [(null)]
May 22 10:24:18.285144 osdx OSDxCLI[4891]: pam_unix(cli:session): session closed for user admin
May 22 10:24:18.285485 osdx OSDxCLI[4891]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
May 22 10:24:18.394914 osdx OSDxCLI[4891]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
May 22 10:24:18.411815 osdx cfgd[1125]: [4891]must validation for [system login user admin role] was skipped
May 22 10:24:18.411850 osdx cfgd[1125]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
May 22 10:24:18.423082 osdx cfgd[1125]: Execute action [end] for node [system advisor ADVISOR1]
May 22 10:24:18.429301 osdx cfgd[1125]: [4891]Completed change to active configuration
May 22 10:24:18.433676 osdx OSDxCLI[4891]: pam_unix(cli:session): session closed for user admin
May 22 10:24:18.434012 osdx OSDxCLI[4891]: User 'admin' committed the configuration.
May 22 10:24:18.437769 osdx INFO[5510]: SCRIPT SCRIPT_1 operations:
May 22 10:24:18.445735 osdx OSDxCLI[5518]: Tecla::GetLine tcgetattr error
May 22 10:24:18.446032 osdx OSDxCLI[5518]: User 'admin' has logged in.
May 22 10:24:18.456386 osdx OSDxCLI[5518]: User 'admin' executed a new command: 'interfaces ethernet show'.
May 22 10:24:18.458009 osdx OSDxCLI[5518]: User 'admin' has logged out.
May 22 10:24:18.458117 osdx OSDxCLI[5518]: Tecla::GetLine tcgetattr error
May 22 10:24:18.460154 osdx OSDxCLI[4891]: User 'admin' left the configuration menu.
May 22 10:24:18.460887 osdx INFO[5510]: Operation 1 'interfaces ethernet show
                                        ':

                                        -----------------------------------------------
                                        Name  IP Address  Admin  Oper  Vrf  Description
                                        -----------------------------------------------
                                        eth0              down   down
                                        eth1              down   down
May 22 10:24:18.462627 osdx modulelauncher[5510]: Traceback (most recent call last):
                                                    File "/osdx/sbin/modulelauncher.py", line 37, in run_file
                                                      result = getattr(module, args[0])(args, cfg_ses_id)
                                                    File "osdx/sbin/cfg/auto_scripts.py", line 62, in process
                                                    File "osdx/sbin/cfg/auto_scripts.py", line 107, in _execute_script
                                                    File "usr/lib/python2.7/subprocess.py", line 483, in communicate
                                                    File "usr/lib/python2.7/subprocess.py", line 1119, in _communicate
                                                  ValueError: I/O operation on closed file
May 22 10:24:18.463313 osdx cfgd[1125]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
May 22 10:24:18.463330 osdx cfgd[1125]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
May 22 10:24:18.607066 osdx OSDxCLI[4891]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)
May 22 10:24:18.655148 osdx OSDxCLI[4891]: pam_unix(cli:session): session closed for user admin
May 22 10:24:18.655407 osdx OSDxCLI[4891]: User 'admin' executed a new command: 'system journal show | cat'.
May 22 10:24:18.793492 osdx OSDxCLI[4891]: pam_unix(cli:session): session opened for user admin by admin(uid=1000)

Simple Script Execution

Description

In this scenario, an automatic script is activated directly without any advisor triggering. The script is activated using the system script <txt> activate command.

Scenario

Step 1: Set the following configuration in DUT0:

set system script SCRIPT_1 advisor ADVISOR1
set system advisor ADVISOR1 test false
set system cli configuration logging global info
set system script SCRIPT_1 advisor ADVISOR1
set system advisor ADVISOR1 test false
set system script SCRIPT_1 configuration 'set interfaces dummy dum0'
set system script SCRIPT_1 configuration 'set interfaces dummy dum1'

Step 2: Run command system script SCRIPT_1 activate at DUT0.

Step 3: Run command interfaces dummy show at DUT0 and check if output matches the following regular expressions:

dum0.*\ndum1
Show output
-----------------------------------------------------------------
Name           IP Address           Admin  Oper  Vrf  Description
-----------------------------------------------------------------
dum0  fe80::7036:48ff:fe70:c60d/64  up     up
dum1  fe80::5c86:34ff:fe4e:43dc/64  up     up

Multiple Triggers Script

Description

In this scenario, an advisor is triggered multiple times to activate the automatic script. When the advisor is changed to true, the automatic script associated with the advisor is executed, proccessing the operational commands in the specified order.

Scenario

Step 1: Set the following configuration in DUT0:

set system script SCRIPT_1 advisor ADVISOR1
set system advisor ADVISOR1 test false
set system cli configuration logging global info
set system script SCRIPT_1 configuration 'set system description \'advisor applied\''
set system script SCRIPT_1 number-of-triggers 3

Note

Wait for the advisor to turn on. After that, wait for the advisor to turn off. This produces only one trigger.

Step 2: Set the following configuration in DUT0:

set system advisor ADVISOR1 test true

Step 3: Set the following configuration in DUT0:

set system advisor ADVISOR1 test false

Step 4: Expect a failure in the following command: Run command show running at DUT0 and check if output contains the following tokens:

set system description 'advisor applied'
Show output
# Teldat OSDx VM version v3.10.1.3
# Wed 22 May 2024 10:24:35 UTC +00:00
# Warning: Configuration has not been saved
set system advisor ADVISOR1 test false
set system cli configuration logging global info
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system script SCRIPT_1 advisor ADVISOR1
set system script SCRIPT_1 configuration 'set system description \'advisor applied\''
set system script SCRIPT_1 number-of-triggers 3

Note

Wait for the advisor to turn on. After that, wait for the advisor to turn off. This produces only one trigger.

Step 5: Set the following configuration in DUT0:

set system advisor ADVISOR1 test true

Step 6: Set the following configuration in DUT0:

set system advisor ADVISOR1 test false

Step 7: Expect a failure in the following command: Run command show running at DUT0 and check if output contains the following tokens:

set system description 'advisor applied'
Show output
# Teldat OSDx VM version v3.10.1.3
# Wed 22 May 2024 10:24:36 UTC +00:00
# Warning: Configuration has not been saved
set system advisor ADVISOR1 test false
set system cli configuration logging global info
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system script SCRIPT_1 advisor ADVISOR1
set system script SCRIPT_1 configuration 'set system description \'advisor applied\''
set system script SCRIPT_1 number-of-triggers 3

Note

Wait for the advisor to turn on. After that, wait for the advisor to turn off. This produces only one trigger.

Step 8: Set the following configuration in DUT0:

set system advisor ADVISOR1 test true

Step 9: Set the following configuration in DUT0:

set system advisor ADVISOR1 test false

Step 10: Run command show running at DUT0 and check if output contains the following tokens:

set system description 'advisor applied'
Show output
# Teldat OSDx VM version v3.10.1.3
# Wed 22 May 2024 10:24:38 UTC +00:00
# Warning: Configuration has not been saved
set system advisor ADVISOR1 test false
set system cli configuration logging global info
set system description 'advisor applied'
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
set system script SCRIPT_1 advisor ADVISOR1
set system script SCRIPT_1 configuration 'set system description \'advisor applied\''
set system script SCRIPT_1 number-of-triggers 3