-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
212 changed files
with
6,733 additions
and
568 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-------------------------------------------------------------------------------- | ||
Fix | ||
-------------------------------------------------------------------------------- | ||
|
||
* iosxe | ||
* Modified InstallRemoveInactive | ||
* Modified logic to search image using regular expression in remove_inactive_pkgs | ||
* Added c9800_cl stages back | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
New | ||
-------------------------------------------------------------------------------- | ||
|
||
* clean | ||
* Added ConfigureInterfaces stage | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
''' | ||
|
||
# metadata | ||
__version__ = '24.5' | ||
__version__ = '24.6' | ||
__author__ = 'Cisco Systems Inc.' | ||
__contact__ = ['[email protected]', '[email protected]'] | ||
__copyright__ = 'Copyright (c) 2019, Cisco Systems Inc.' | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
...libs/clean/stages/iosxe/tests/test_install_remove_inactive/mock_data/iosxe/mock_data.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
connect: &connect | ||
preface: | | ||
Trying mock_device ... | ||
Connected to mock_device. | ||
Escape character is ''^]''. | ||
prompt: "%N#" | ||
|
||
execute: &execute | ||
show version | include operating mode: '' | ||
|
||
remove_inactive_no: | ||
<<: *connect | ||
commands: | ||
? '' | ||
: new_state: execute1 | ||
|
||
execute1: | ||
commands: | ||
<<: *execute | ||
install remove inactive: | ||
new_state: do_you_want_to_remove1 | ||
prompt: "%N#" | ||
|
||
do_you_want_to_remove1: | ||
preface: | ||
timing: | ||
- 0:,0,0.05 | ||
response: | | ||
install_remove: START Tue May 28 18:23:26 UTC 2024 | ||
install_remove: Removing IMG | ||
Cleaning up unnecessary package files | ||
No path specified, will use booted path /bootflash//packages.conf | ||
Cleaning /bootflash | ||
Scanning boot directory for packages ... done. | ||
Preparing packages list to delete ... | ||
[R0]: /bootflash/packages.conf File is in use, will not delete. | ||
The following files will be deleted: | ||
[R0]: /bootflash/image.bin | ||
[R0]: /bootflash/image.bin.conf | ||
prompt: Do you want to remove the above files? [y/n] | ||
commands: | ||
"n": | ||
timing: | ||
- 0:,0,0.05 | ||
response: | | ||
[1] R0 Add succeed with reason: User Rejected Deletion | ||
SUCCESS: install_remove Tue May 28 18:23:27 UTC 2024 | ||
new_state: execute1 | ||
|
||
remove_inactive_yes: | ||
<<: *connect | ||
commands: | ||
? '' | ||
: new_state: execute2 | ||
|
||
execute2: | ||
commands: | ||
<<: *execute | ||
install remove inactive: | ||
new_state: do_you_want_to_remove2 | ||
prompt: "%N#" | ||
|
||
do_you_want_to_remove2: | ||
preface: | ||
timing: | ||
- 0:,0,0.05 | ||
response: | | ||
install_remove: START Tue May 28 18:23:26 UTC 2024 | ||
install_remove: Removing IMG | ||
Cleaning up unnecessary package files | ||
No path specified, will use booted path /bootflash//packages.conf | ||
Cleaning /bootflash | ||
Scanning boot directory for packages ... done. | ||
Preparing packages list to delete ... | ||
[R0]: /bootflash/packages.conf File is in use, will not delete. | ||
The following files will be deleted: | ||
[R0]: /bootflash/image.bin.conf | ||
prompt: Do you want to remove the above files? [y/n] | ||
commands: | ||
"y": | ||
timing: | ||
- 0:,0,0.05 | ||
response: | | ||
Deleting file /bootflash/image.bin.conf ... done. | ||
SUCCESS: Files deleted. | ||
--- Starting Post_Remove_Cleanup --- | ||
Performing REMOVE_POSTCHECK on all members | ||
Finished Post_Remove_Cleanup | ||
SUCCESS: install_remove Sat Jun 01 19:50:22 UTC 2024 | ||
new_state: execute1 |
81 changes: 81 additions & 0 deletions
81
...ibs/clean/stages/iosxe/tests/test_install_remove_inactive/test_install_remove_inactive.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import unittest | ||
|
||
from pyats.results import Passed | ||
from pyats.topology import loader | ||
from pyats.aetest.steps import Steps | ||
from genie.libs.clean.stages.iosxe.stages import InstallRemoveInactive | ||
|
||
|
||
class TestIosXEConnect(unittest.TestCase): | ||
""" Run unit testing on a mocked IOSXE c8kv device """ | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
# Make sure we have a unique Steps() object for result verification | ||
cls.steps = Steps() | ||
|
||
cls.image = 'image.bin' | ||
|
||
# And we want the following methods to be mocked to simulate the stage. | ||
cls.install_remove_inactive = InstallRemoveInactive() | ||
|
||
def test_install_remove_inactive_pass_n(self): | ||
|
||
testbed = """ | ||
devices: | ||
router: | ||
connections: | ||
defaults: | ||
class: unicon.Unicon | ||
a: | ||
command: mock_device_cli --os iosxe --mock_data_dir mock_data --state remove_inactive_no | ||
protocol: unknown | ||
os: iosxe | ||
platform: c8kv | ||
type: router | ||
""" | ||
self.testbed = loader.load(testbed) | ||
self.device = self.testbed.devices['router'] | ||
self.device.connect( | ||
learn_hostname=True, | ||
init_config_commands=[], | ||
init_exec_commands=[] | ||
) | ||
|
||
with self.assertLogs(level='DEBUG') as log: | ||
self.install_remove_inactive(steps=self.steps, device=self.device, images=[self.image]) | ||
self.assertIn(f'{self.image} is among the files to be deleted. send no so the {self.image} is not deleted.', log.output[1]) | ||
|
||
# Check the results is as expected. | ||
self.assertEqual(Passed, self.steps.details[0].result) | ||
|
||
|
||
def test_install_remove_inactive_pass_y(self): | ||
|
||
testbed = """ | ||
devices: | ||
router: | ||
connections: | ||
defaults: | ||
class: unicon.Unicon | ||
a: | ||
command: mock_device_cli --os iosxe --mock_data_dir mock_data --state remove_inactive_yes | ||
protocol: unknown | ||
os: iosxe | ||
platform: c8kv | ||
type: router | ||
""" | ||
self.testbed = loader.load(testbed) | ||
self.device = self.testbed.devices['router'] | ||
self.device.connect( | ||
learn_hostname=True, | ||
init_config_commands=[], | ||
init_exec_commands=[] | ||
) | ||
|
||
with self.assertLogs(level='DEBUG') as log: | ||
self.install_remove_inactive(steps=self.steps, device=self.device, images=[self.image]) | ||
self.assertIn(f'{self.image} is not among the files to be deleted. Hence, send yes to delete files.', log.output[1]) | ||
|
||
# Check the results is as expected. | ||
self.assertEqual(Passed, self.steps.details[0].result) |
Oops, something went wrong.