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 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\''

Step 2: Modify the following configuration lines 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 v4.2.1.1
# Wed 30 Oct 2024 13:08:29 +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 interfaces ethernet eth0 address 10.215.200.50/24
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 operational 1 command 'interfaces ethernet show'
set system script SCRIPT_1 operational 2 command 'license show'

Step 2: Modify the following configuration lines 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
Oct 30 13:08:33.353556 osdx systemd-journald[1923]: Runtime Journal (/run/log/journal/877522c656344df9b9ad28416f5f036f) is 2.0M, max 15.3M, 13.2M free.
Oct 30 13:08:33.354510 osdx systemd-journald[1923]: Received client request to rotate journal, rotating.
Oct 30 13:08:33.354562 osdx systemd-journald[1923]: Vacuuming done, freed 0B of archived journals from /run/log/journal/877522c656344df9b9ad28416f5f036f.
Oct 30 13:08:33.364243 osdx OSDxCLI[314505]: User 'admin' executed a new command: 'system journal clear'.
Oct 30 13:08:33.590686 osdx zebra[1601]: [RZ3YY-GPH41][EC 100663310] snmp[warning]: Warning: Failed to connect to the agentx master agent ([NIL]):
Oct 30 13:08:33.719304 osdx osdx-coredump[328890]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Oct 30 13:08:33.729010 osdx OSDxCLI[314505]: User 'admin' executed a new command: 'system coredump delete all'.
Oct 30 13:08:34.185106 osdx OSDxCLI[314505]: User 'admin' entered the configuration menu.
Oct 30 13:08:34.245967 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Oct 30 13:08:34.361602 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Oct 30 13:08:34.418768 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Oct 30 13:08:34.515660 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Oct 30 13:08:34.585775 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Oct 30 13:08:34.682532 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
Oct 30 13:08:34.738506 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
Oct 30 13:08:34.859402 osdx ERROR[328907]: unexpected
                                           Traceback (most recent call last):
                                             File "osdx/bin/op/fan_control.py", line 23, in _send_fan_control_cmd
                                           FileNotFoundError: [Errno 2] No such file or directory
Oct 30 13:08:34.860263 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'show working'.
Oct 30 13:08:34.932887 osdx modulelauncher[1476]: + Received data: ['314505', 'osdx.utils.xos', 'set_console_log_level', 'info']
Oct 30 13:08:34.945573 osdx OSDxCLI[314505]: Signal 10 received
Oct 30 13:08:34.953451 osdx ifmon[1478]: Changed log-level to info
Oct 30 13:08:34.982500 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Oct 30 13:08:35.054909 osdx cfgd[1636]: [314505]Completed change to active configuration
Oct 30 13:08:35.082529 osdx OSDxCLI[314505]: User 'admin' committed the configuration.
Oct 30 13:08:35.132853 osdx OSDxCLI[314505]: User 'admin' left the configuration menu.
Oct 30 13:08:35.298443 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Oct 30 13:08:35.299008 osdx OSDxCLI[314505]: pam_unix(cli:session): session closed for user admin
Oct 30 13:08:35.299417 osdx OSDxCLI[314505]: User 'admin' entered the configuration menu.
Oct 30 13:08:35.359133 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Oct 30 13:08:35.359416 osdx cfgd[1636]: Execute action [syntax] for node [system advisor ADVISOR1]
Oct 30 13:08:35.359863 osdx OSDxCLI[314505]: pam_unix(cli:session): session closed for user admin
Oct 30 13:08:35.360124 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Oct 30 13:08:35.460492 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Oct 30 13:08:35.468430 osdx OSDxCLI[314505]: pam_unix(cli:session): session closed for user admin
Oct 30 13:08:35.468724 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'show changes'.
Oct 30 13:08:35.532794 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Oct 30 13:08:35.544825 osdx cfgd[1636]: [314505]must validation for [system login user admin role] was skipped
Oct 30 13:08:35.544841 osdx cfgd[1636]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Oct 30 13:08:35.555575 osdx cfgd[1636]: Execute action [end] for node [system advisor ADVISOR1]
Oct 30 13:08:35.562332 osdx cfgd[1636]: [314505]Completed change to active configuration
Oct 30 13:08:35.564146 osdx OSDxCLI[314505]: pam_unix(cli:session): session closed for user admin
Oct 30 13:08:35.564443 osdx OSDxCLI[314505]: User 'admin' committed the configuration.
Oct 30 13:08:35.567341 osdx INFO[329037]: SCRIPT SCRIPT_1 operations:
Oct 30 13:08:35.573234 osdx OSDxCLI[329045]: Tecla::GetLine tcgetattr error
Oct 30 13:08:35.573239 osdx OSDxCLI[329045]: User 'admin' has logged in.
Oct 30 13:08:35.580200 osdx OSDxCLI[329045]: User 'admin' executed a new command: 'interfaces ethernet show'.
Oct 30 13:08:35.581093 osdx OSDxCLI[329045]: User 'admin' has logged out.
Oct 30 13:08:35.581098 osdx OSDxCLI[329045]: Tecla::GetLine tcgetattr error
Oct 30 13:08:35.581614 osdx INFO[329037]: Operation 1 'interfaces ethernet show
                                          ':

                                          -----------------------------------------------
                                          Name  IP Address  Admin  Oper  Vrf  Description
                                          -----------------------------------------------
                                          eth0              down   down
                                          eth1              down   down
Oct 30 13:08:35.582966 osdx modulelauncher[329037]: Traceback (most recent call last):
                                                      File "/osdx/sbin/modulelauncher.py", line 36, in run_file
                                                        result = getattr(module, args[0])(args, cfg_ses_id)
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                      File "osdx/sbin/cfg/auto_scripts.py", line 61, in process
                                                      File "osdx/sbin/cfg/auto_scripts.py", line 108, in _execute_script
                                                      File "usr/lib/python3.11/subprocess.py", line 1182, in communicate
                                                    ValueError: Cannot send input after starting communication
Oct 30 13:08:35.583347 osdx cfgd[1636]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
Oct 30 13:08:35.583357 osdx cfgd[1636]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
Oct 30 13:08:35.603467 osdx OSDxCLI[314505]: User 'admin' left the configuration menu.
Oct 30 13:08:35.686549 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) 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
Oct 30 13:08:33.353556 osdx systemd-journald[1923]: Runtime Journal (/run/log/journal/877522c656344df9b9ad28416f5f036f) is 2.0M, max 15.3M, 13.2M free.
Oct 30 13:08:33.354510 osdx systemd-journald[1923]: Received client request to rotate journal, rotating.
Oct 30 13:08:33.354562 osdx systemd-journald[1923]: Vacuuming done, freed 0B of archived journals from /run/log/journal/877522c656344df9b9ad28416f5f036f.
Oct 30 13:08:33.364243 osdx OSDxCLI[314505]: User 'admin' executed a new command: 'system journal clear'.
Oct 30 13:08:33.590686 osdx zebra[1601]: [RZ3YY-GPH41][EC 100663310] snmp[warning]: Warning: Failed to connect to the agentx master agent ([NIL]):
Oct 30 13:08:33.719304 osdx osdx-coredump[328890]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Oct 30 13:08:33.729010 osdx OSDxCLI[314505]: User 'admin' executed a new command: 'system coredump delete all'.
Oct 30 13:08:34.185106 osdx OSDxCLI[314505]: User 'admin' entered the configuration menu.
Oct 30 13:08:34.245967 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Oct 30 13:08:34.361602 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Oct 30 13:08:34.418768 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Oct 30 13:08:34.515660 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Oct 30 13:08:34.585775 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Oct 30 13:08:34.682532 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
Oct 30 13:08:34.738506 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
Oct 30 13:08:34.859402 osdx ERROR[328907]: unexpected
                                           Traceback (most recent call last):
                                             File "osdx/bin/op/fan_control.py", line 23, in _send_fan_control_cmd
                                           FileNotFoundError: [Errno 2] No such file or directory
Oct 30 13:08:34.860263 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'show working'.
Oct 30 13:08:34.932887 osdx modulelauncher[1476]: + Received data: ['314505', 'osdx.utils.xos', 'set_console_log_level', 'info']
Oct 30 13:08:34.945573 osdx OSDxCLI[314505]: Signal 10 received
Oct 30 13:08:34.953451 osdx ifmon[1478]: Changed log-level to info
Oct 30 13:08:34.982500 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Oct 30 13:08:35.054909 osdx cfgd[1636]: [314505]Completed change to active configuration
Oct 30 13:08:35.082529 osdx OSDxCLI[314505]: User 'admin' committed the configuration.
Oct 30 13:08:35.132853 osdx OSDxCLI[314505]: User 'admin' left the configuration menu.
Oct 30 13:08:35.298443 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Oct 30 13:08:35.299008 osdx OSDxCLI[314505]: pam_unix(cli:session): session closed for user admin
Oct 30 13:08:35.299417 osdx OSDxCLI[314505]: User 'admin' entered the configuration menu.
Oct 30 13:08:35.359133 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Oct 30 13:08:35.359416 osdx cfgd[1636]: Execute action [syntax] for node [system advisor ADVISOR1]
Oct 30 13:08:35.359863 osdx OSDxCLI[314505]: pam_unix(cli:session): session closed for user admin
Oct 30 13:08:35.360124 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Oct 30 13:08:35.460492 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Oct 30 13:08:35.468430 osdx OSDxCLI[314505]: pam_unix(cli:session): session closed for user admin
Oct 30 13:08:35.468724 osdx OSDxCLI[314505]: User 'admin' added a new cfg line: 'show changes'.
Oct 30 13:08:35.532794 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Oct 30 13:08:35.544825 osdx cfgd[1636]: [314505]must validation for [system login user admin role] was skipped
Oct 30 13:08:35.544841 osdx cfgd[1636]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Oct 30 13:08:35.555575 osdx cfgd[1636]: Execute action [end] for node [system advisor ADVISOR1]
Oct 30 13:08:35.562332 osdx cfgd[1636]: [314505]Completed change to active configuration
Oct 30 13:08:35.564146 osdx OSDxCLI[314505]: pam_unix(cli:session): session closed for user admin
Oct 30 13:08:35.564443 osdx OSDxCLI[314505]: User 'admin' committed the configuration.
Oct 30 13:08:35.567341 osdx INFO[329037]: SCRIPT SCRIPT_1 operations:
Oct 30 13:08:35.573234 osdx OSDxCLI[329045]: Tecla::GetLine tcgetattr error
Oct 30 13:08:35.573239 osdx OSDxCLI[329045]: User 'admin' has logged in.
Oct 30 13:08:35.580200 osdx OSDxCLI[329045]: User 'admin' executed a new command: 'interfaces ethernet show'.
Oct 30 13:08:35.581093 osdx OSDxCLI[329045]: User 'admin' has logged out.
Oct 30 13:08:35.581098 osdx OSDxCLI[329045]: Tecla::GetLine tcgetattr error
Oct 30 13:08:35.581614 osdx INFO[329037]: Operation 1 'interfaces ethernet show
                                          ':

                                          -----------------------------------------------
                                          Name  IP Address  Admin  Oper  Vrf  Description
                                          -----------------------------------------------
                                          eth0              down   down
                                          eth1              down   down
Oct 30 13:08:35.582966 osdx modulelauncher[329037]: Traceback (most recent call last):
                                                      File "/osdx/sbin/modulelauncher.py", line 36, in run_file
                                                        result = getattr(module, args[0])(args, cfg_ses_id)
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                      File "osdx/sbin/cfg/auto_scripts.py", line 61, in process
                                                      File "osdx/sbin/cfg/auto_scripts.py", line 108, in _execute_script
                                                      File "usr/lib/python3.11/subprocess.py", line 1182, in communicate
                                                    ValueError: Cannot send input after starting communication
Oct 30 13:08:35.583347 osdx cfgd[1636]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
Oct 30 13:08:35.583357 osdx cfgd[1636]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
Oct 30 13:08:35.603467 osdx OSDxCLI[314505]: User 'admin' left the configuration menu.
Oct 30 13:08:35.686549 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Oct 30 13:08:35.725619 osdx OSDxCLI[314505]: pam_unix(cli:session): session closed for user admin
Oct 30 13:08:35.725884 osdx OSDxCLI[314505]: User 'admin' executed a new command: 'system journal show | cat'.
Oct 30 13:08:35.824090 osdx OSDxCLI[314505]: pam_unix(cli:session): session opened for user admin(uid=1000) 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 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 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::54f5:b0ff:fea6:3c7/64   up     up
dum1  fe80::28de:a8ff:fe88:f570/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 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 2: Modify the following configuration lines in DUT0:

set system advisor ADVISOR1 test true

Step 3: Modify the following configuration lines 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 v4.2.1.1
# Wed 30 Oct 2024 13:08:58 +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: Modify the following configuration lines in DUT0:

set system advisor ADVISOR1 test true

Step 6: Modify the following configuration lines 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 v4.2.1.1
# Wed 30 Oct 2024 13:08:59 +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: Modify the following configuration lines in DUT0:

set system advisor ADVISOR1 test true

Step 9: Modify the following configuration lines 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 v4.2.1.1
# Wed 30 Oct 2024 13:09:01 +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