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.1.1.0
# Wed 03 Jul 2024 14:33:32 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 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
Jul 03 14:33:36.299383 osdx systemd-journald[19587]: Runtime Journal (/run/log/journal/aa1bd7befff24a8b91d1e90ef92c032b) is 2.2M, max 15.3M, 13.1M free.
Jul 03 14:33:36.301237 osdx systemd-journald[19587]: Received client request to rotate journal, rotating.
Jul 03 14:33:36.301293 osdx systemd-journald[19587]: Vacuuming done, freed 0B of archived journals from /run/log/journal/aa1bd7befff24a8b91d1e90ef92c032b.
Jul 03 14:33:36.311430 osdx OSDxCLI[30252]: User 'admin' executed a new command: 'system journal clear'.
Jul 03 14:33:36.662147 osdx osdx-coredump[31661]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Jul 03 14:33:36.669922 osdx OSDxCLI[30252]: User 'admin' executed a new command: 'system coredump delete all'.
Jul 03 14:33:37.204796 osdx OSDxCLI[30252]: User 'admin' entered the configuration menu.
Jul 03 14:33:37.272437 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jul 03 14:33:37.364507 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Jul 03 14:33:37.419975 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Jul 03 14:33:37.512848 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jul 03 14:33:37.580592 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Jul 03 14:33:37.683502 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
Jul 03 14:33:37.743664 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
Jul 03 14:33:37.857940 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'show working'.
Jul 03 14:33:37.929096 osdx modulelauncher[1313]: + Received data: ['30252', 'osdx.utils.xos', 'set_console_log_level', 'info']
Jul 03 14:33:37.946238 osdx OSDxCLI[30252]: Signal 10 received
Jul 03 14:33:37.954741 osdx ifmon[1340]: Changed log-level to info
Jul 03 14:33:38.005546 osdx cfgd[1440]: [30252]Completed change to active configuration
Jul 03 14:33:38.007417 osdx OSDxCLI[30252]: User 'admin' committed the configuration.
Jul 03 14:33:38.033048 osdx OSDxCLI[30252]: User 'admin' left the configuration menu.
Jul 03 14:33:38.190341 osdx OSDxCLI[30252]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 03 14:33:38.190816 osdx OSDxCLI[30252]: pam_unix(cli:session): session closed for user admin
Jul 03 14:33:38.191024 osdx OSDxCLI[30252]: User 'admin' entered the configuration menu.
Jul 03 14:33:38.246052 osdx OSDxCLI[30252]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 03 14:33:38.246389 osdx cfgd[1440]: Execute action [syntax] for node [system advisor ADVISOR1]
Jul 03 14:33:38.246673 osdx OSDxCLI[30252]: pam_unix(cli:session): session closed for user admin
Jul 03 14:33:38.246864 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Jul 03 14:33:38.336216 osdx OSDxCLI[30252]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 03 14:33:38.346736 osdx OSDxCLI[30252]: pam_unix(cli:session): session closed for user admin
Jul 03 14:33:38.347051 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'show changes'.
Jul 03 14:33:38.394964 osdx OSDxCLI[30252]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 03 14:33:38.403002 osdx cfgd[1440]: [30252]must validation for [system login user admin role] was skipped
Jul 03 14:33:38.403015 osdx cfgd[1440]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Jul 03 14:33:38.410994 osdx cfgd[1440]: Execute action [end] for node [system advisor ADVISOR1]
Jul 03 14:33:38.417260 osdx cfgd[1440]: [30252]Completed change to active configuration
Jul 03 14:33:38.420100 osdx OSDxCLI[30252]: pam_unix(cli:session): session closed for user admin
Jul 03 14:33:38.420340 osdx OSDxCLI[30252]: User 'admin' committed the configuration.
Jul 03 14:33:38.422995 osdx INFO[31772]: SCRIPT SCRIPT_1 operations:
Jul 03 14:33:38.428656 osdx OSDxCLI[31781]: Tecla::GetLine tcgetattr error
Jul 03 14:33:38.428661 osdx OSDxCLI[31781]: User 'admin' has logged in.
Jul 03 14:33:38.436534 osdx OSDxCLI[31781]: User 'admin' executed a new command: 'interfaces ethernet show'.
Jul 03 14:33:38.437512 osdx OSDxCLI[31781]: User 'admin' has logged out.
Jul 03 14:33:38.437517 osdx OSDxCLI[31781]: Tecla::GetLine tcgetattr error
Jul 03 14:33:38.437979 osdx INFO[31772]: Operation 1 'interfaces ethernet show
                                         ':

                                         -----------------------------------------------
                                         Name  IP Address  Admin  Oper  Vrf  Description
                                         -----------------------------------------------
                                         eth0              down   down
                                         eth1              down   down
Jul 03 14:33:38.439462 osdx modulelauncher[31772]: 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
Jul 03 14:33:38.439873 osdx cfgd[1440]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
Jul 03 14:33:38.439885 osdx cfgd[1440]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
Jul 03 14:33:38.456951 osdx OSDxCLI[30252]: User 'admin' left the configuration menu.
Jul 03 14:33:38.579153 osdx OSDxCLI[30252]: 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
Jul 03 14:33:36.299383 osdx systemd-journald[19587]: Runtime Journal (/run/log/journal/aa1bd7befff24a8b91d1e90ef92c032b) is 2.2M, max 15.3M, 13.1M free.
Jul 03 14:33:36.301237 osdx systemd-journald[19587]: Received client request to rotate journal, rotating.
Jul 03 14:33:36.301293 osdx systemd-journald[19587]: Vacuuming done, freed 0B of archived journals from /run/log/journal/aa1bd7befff24a8b91d1e90ef92c032b.
Jul 03 14:33:36.311430 osdx OSDxCLI[30252]: User 'admin' executed a new command: 'system journal clear'.
Jul 03 14:33:36.662147 osdx osdx-coredump[31661]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Jul 03 14:33:36.669922 osdx OSDxCLI[30252]: User 'admin' executed a new command: 'system coredump delete all'.
Jul 03 14:33:37.204796 osdx OSDxCLI[30252]: User 'admin' entered the configuration menu.
Jul 03 14:33:37.272437 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jul 03 14:33:37.364507 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test false'.
Jul 03 14:33:37.419975 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system cli configuration logging global info'.
Jul 03 14:33:37.512848 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 advisor ADVISOR1'.
Jul 03 14:33:37.580592 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set interfaces ethernet eth0 address 10.215.200.50/24'.
Jul 03 14:33:37.683502 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 1 command 'interfaces ethernet show''.
Jul 03 14:33:37.743664 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system script SCRIPT_1 operational 2 command 'license show''.
Jul 03 14:33:37.857940 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'show working'.
Jul 03 14:33:37.929096 osdx modulelauncher[1313]: + Received data: ['30252', 'osdx.utils.xos', 'set_console_log_level', 'info']
Jul 03 14:33:37.946238 osdx OSDxCLI[30252]: Signal 10 received
Jul 03 14:33:37.954741 osdx ifmon[1340]: Changed log-level to info
Jul 03 14:33:38.005546 osdx cfgd[1440]: [30252]Completed change to active configuration
Jul 03 14:33:38.007417 osdx OSDxCLI[30252]: User 'admin' committed the configuration.
Jul 03 14:33:38.033048 osdx OSDxCLI[30252]: User 'admin' left the configuration menu.
Jul 03 14:33:38.190341 osdx OSDxCLI[30252]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 03 14:33:38.190816 osdx OSDxCLI[30252]: pam_unix(cli:session): session closed for user admin
Jul 03 14:33:38.191024 osdx OSDxCLI[30252]: User 'admin' entered the configuration menu.
Jul 03 14:33:38.246052 osdx OSDxCLI[30252]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 03 14:33:38.246389 osdx cfgd[1440]: Execute action [syntax] for node [system advisor ADVISOR1]
Jul 03 14:33:38.246673 osdx OSDxCLI[30252]: pam_unix(cli:session): session closed for user admin
Jul 03 14:33:38.246864 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'set system advisor ADVISOR1 test true'.
Jul 03 14:33:38.336216 osdx OSDxCLI[30252]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 03 14:33:38.346736 osdx OSDxCLI[30252]: pam_unix(cli:session): session closed for user admin
Jul 03 14:33:38.347051 osdx OSDxCLI[30252]: User 'admin' added a new cfg line: 'show changes'.
Jul 03 14:33:38.394964 osdx OSDxCLI[30252]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 03 14:33:38.403002 osdx cfgd[1440]: [30252]must validation for [system login user admin role] was skipped
Jul 03 14:33:38.403015 osdx cfgd[1440]: Execute action [commit-subtree] for node [system advisor ADVISOR1]
Jul 03 14:33:38.410994 osdx cfgd[1440]: Execute action [end] for node [system advisor ADVISOR1]
Jul 03 14:33:38.417260 osdx cfgd[1440]: [30252]Completed change to active configuration
Jul 03 14:33:38.420100 osdx OSDxCLI[30252]: pam_unix(cli:session): session closed for user admin
Jul 03 14:33:38.420340 osdx OSDxCLI[30252]: User 'admin' committed the configuration.
Jul 03 14:33:38.422995 osdx INFO[31772]: SCRIPT SCRIPT_1 operations:
Jul 03 14:33:38.428656 osdx OSDxCLI[31781]: Tecla::GetLine tcgetattr error
Jul 03 14:33:38.428661 osdx OSDxCLI[31781]: User 'admin' has logged in.
Jul 03 14:33:38.436534 osdx OSDxCLI[31781]: User 'admin' executed a new command: 'interfaces ethernet show'.
Jul 03 14:33:38.437512 osdx OSDxCLI[31781]: User 'admin' has logged out.
Jul 03 14:33:38.437517 osdx OSDxCLI[31781]: Tecla::GetLine tcgetattr error
Jul 03 14:33:38.437979 osdx INFO[31772]: Operation 1 'interfaces ethernet show
                                         ':

                                         -----------------------------------------------
                                         Name  IP Address  Admin  Oper  Vrf  Description
                                         -----------------------------------------------
                                         eth0              down   down
                                         eth1              down   down
Jul 03 14:33:38.439462 osdx modulelauncher[31772]: 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
Jul 03 14:33:38.439873 osdx cfgd[1440]: External python command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true] finished with status 1
Jul 03 14:33:38.439885 osdx cfgd[1440]: Run trap command [cfg.auto_scripts process ADVISOR1 SCRIPT_1 true]: 1
Jul 03 14:33:38.456951 osdx OSDxCLI[30252]: User 'admin' left the configuration menu.
Jul 03 14:33:38.579153 osdx OSDxCLI[30252]: pam_unix(cli:session): session opened for user admin(uid=1000) by admin(uid=1000)
Jul 03 14:33:38.623992 osdx OSDxCLI[30252]: pam_unix(cli:session): session closed for user admin
Jul 03 14:33:38.624260 osdx OSDxCLI[30252]: User 'admin' executed a new command: 'system journal show | cat'.
Jul 03 14:33:38.727256 osdx OSDxCLI[30252]: 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::c843:3bff:fe90:3a1/64   up     up
dum1  fe80::1c8a:d6ff:fe92:40c9/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.1.1.0
# Wed 03 Jul 2024 14:33:51 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: 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.1.1.0
# Wed 03 Jul 2024 14:33:52 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: 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.1.1.0
# Wed 03 Jul 2024 14:33:53 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