Skip to content

Commit

Permalink
Releasing 23.11
Browse files Browse the repository at this point in the history
  • Loading branch information
domachad committed Nov 27, 2023
1 parent c4c857e commit f5c89f5
Show file tree
Hide file tree
Showing 216 changed files with 7,879 additions and 1,097 deletions.
15 changes: 15 additions & 0 deletions pkgs/clean-pkg/changelog/2023/november.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--------------------------------------------------------------------------------
Fix
--------------------------------------------------------------------------------

* clean
* clean.py
* Updated import to get BaseCleaner from pyats.clean

* iosxe
* Implemented image_override setting for copy_to_linux and copy_to_device clean stages

* clean/stages/iosxe/stages.py
* Updated image mapping logic for Copytodevice stage


16 changes: 8 additions & 8 deletions pkgs/clean-pkg/sdk_generator/output/github_clean.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/sdwan/stages.py#L969"
},
"uid": "ChangeBootVariable",
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L41"
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L38"
},
"nxos": {
"doc": "This stage configures boot variables of the device using the following steps:\n\n - Delete existing boot variables.\n - Configure boot variables using the provided 'images'.\n - Write memory.\n - Verify the boot variables are as expected.\n\nStage Schema\n------------\nchange_boot_variable:\n\n images:\n\n kickstart (list, optional): The kickstart image file\n\n system (list): The system image file\n\n copy_vdc_all (bool, optional): If True copy onto all VDCs. Defaults to False.\n\n timeout (int, optional): Execute timeout in seconds. Defaults to 300.\n\n max_time (int, optional): Maximum time in seconds allowed for verifications.\n Defaults to 300.\n\n check_interval (int, optional): How often to check verifications in seconds.\n Defaults to 60.\n\n standby_copy_max_time (int, optional): Maximum time in seconds allowed for\n copying to standby RP. Defaults to 300.\n\n standby_copy_check_interval (int, optional): How often to check if the copy\n to the standby RP is complete. Defaults to 20.\n\n current_running_image (bool, optional): Set the boot variable to the currently\n running image from the show version command instead of the image provided.\n Defaults to False.\n\nExample\n-------\nchange_boot_variable:\n images:\n kickstart: bootflash:/kisckstart.gbin\n system: bootflash:/system.gbin\n copy_vdc_all: True\n timeout: 150\n max_time: 300\n check_interval: 20\n standby_copy_max_time: 100\n standby_copy_check_interval: 10\n",
Expand Down Expand Up @@ -213,7 +213,7 @@
"module_name": "stages.stages",
"package": "genie.libs.clean",
"uid": "CopyToDevice",
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1359"
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1356"
}
},
"CopyToLinux": {
Expand Down Expand Up @@ -323,7 +323,7 @@
"module_name": "stages.stages",
"package": "genie.libs.clean",
"uid": "InstallImage",
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L516"
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L513"
},
"iosxr": {
"ncs540": {
Expand Down Expand Up @@ -359,7 +359,7 @@
"module_name": "stages.stages",
"package": "genie.libs.clean",
"uid": "InstallPackages",
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L766"
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L763"
}
},
"InstallRemoveInactive": {
Expand All @@ -368,7 +368,7 @@
"module_name": "stages.stages",
"package": "genie.libs.clean",
"uid": "InstallRemoveInactive",
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L461"
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L458"
}
},
"LoadPies": {
Expand Down Expand Up @@ -431,7 +431,7 @@
"module_name": "stages.stages",
"package": "genie.libs.clean",
"uid": "Reload",
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L850"
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L847"
}
},
"RevertVmSnapshot": {
Expand All @@ -456,7 +456,7 @@
"module_name": "stages.stages",
"package": "genie.libs.clean",
"uid": "RommonBoot",
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1097"
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L1094"
}
},
"RunConfigure": {
Expand Down Expand Up @@ -521,7 +521,7 @@
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/sdwan/stages.py#L395"
},
"uid": "TftpBoot",
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L192"
"url": "https://github.com/CiscoTestAutomation/genielibs/tree/master/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py#L189"
},
"iosxr": {
"doc": "This stage boots a new image onto your device using the tftp booting\nmethod.\n\nStage Schema\n------------\ntftp_boot:\n\n image (list): Image to boot with\n\n ip_address (list): Management ip address to configure to reach to the\n tftp server\n\n subnet_mask (str): Management subnet mask\n\n gateway (str): Management gateway\n\n tftp_server (str): Tftp server that is reachable with management interface\n\n timeout (int, optional): Max time during which tftp boot must\n complete. Defaults to 600.\n\n config_reg_timeout (int, optional): Max time to set config-register.\n Defaults to 30.\n\n device_reload_sleep (int, optional): Time in seconds to wait after\n reloading the device. Defaults to 20.\n\n recovery_username (str, optional): Enable username for device\n required after bootup. Defaults to None.\n\n recovery_password (str, optional): Enable password for device\n required after bootup. Defaults to None.\n\nExample\n-------\ntftp_boot:\n image:\n - /auto/some-location/that-this/image/asr9k-mini-px.vm\n ip_address: [10.1.7.126, 10.1.7.127]\n gateway: 10.1.7.1\n subnet_mask: 255.255.255.0\n tftp_server: 11.1.7.251\n timeout: 1200\n config_reg_timeout: 60\n device_reload_sleep: 300\n recovery_username: admin\n recovery_password: nbv_12345\n\nNote: There is more than one ip address, one for each supervisor.\n",
Expand Down
2 changes: 1 addition & 1 deletion pkgs/clean-pkg/src/genie/libs/clean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'''

# metadata
__version__ = '23.10'
__version__ = '23.11'
__author__ = 'Cisco Systems Inc.'
__contact__ = ['asg-genie-support@cisco.com', 'pyats-support-ext@cisco.com']
__copyright__ = 'Copyright (c) 2019, Cisco Systems Inc.'
Expand Down
2 changes: 1 addition & 1 deletion pkgs/clean-pkg/src/genie/libs/clean/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pyats.aetest.container import TestContainer
from pyats.log.utils import banner
from pyats.aetest import processors
from pyats.kleenex.bases import BaseCleaner
from pyats.clean.bases import BaseCleaner
from pyats.aetest.parameters import ParameterDict
from pyats.aetest.sections import TestSection

Expand Down
20 changes: 12 additions & 8 deletions pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/image_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,24 @@ def update_tftp_boot(self, number=''):
def update_copy_to_linux(self, number=''):
'''Update clean section 'copy_to_linux' with image information'''

files = self.device.clean.setdefault('copy_to_linux' + number, {}). \
setdefault('origin', {}).setdefault('files', [])
origin = self.device.clean.setdefault('copy_to_linux' + number, {}). \
setdefault('origin', {})

files.clear()
files.extend(self.image + self.packages + self.other)
if self.override_stage_images:
origin.update({'files': self.image + self.packages + self.other})
else:
origin.setdefault('files', self.image + self.packages + self.other)

def update_copy_to_device(self, number=''):
'''Update clean stage 'copy_to_device' with image information'''

files = self.device.clean.setdefault('copy_to_device' + number, {}). \
setdefault('origin', {}).setdefault('files', [])
origin = self.device.clean.setdefault('copy_to_device' + number, {}). \
setdefault('origin', {})

files.clear()
files.extend(self.image + self.packages + self.other)
if self.override_stage_images:
origin.update({'files': self.image + self.packages + self.other})
else:
origin.setdefault('files', self.image + self.packages + self.other)

def update_change_boot_variable(self, number=''):
'''Update clean stage 'change_boot_variable' with image information'''
Expand Down
16 changes: 8 additions & 8 deletions pkgs/clean-pkg/src/genie/libs/clean/stages/iosxe/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@
# pyATS
from pyats.async_ import pcall
from pyats.utils.fileutils import FileUtils
from pyats.utils.fileutils import FileUtils

# Genie
from genie.abstract import Lookup
from genie.libs import clean
from genie.libs.clean.recovery.recovery import _disconnect_reconnect
from genie.metaparser.util.schemaengine import Optional, Required, Any
from genie.utils import Dq
from genie.metaparser.util.schemaengine import Optional, Required, Any, Or, ListOf
from genie.utils import Dq
from genie.utils.timeout import Timeout
from genie.libs.clean import BaseStage
from genie.libs.sdk.libs.abstracted_libs.iosxe.subsection import get_default_dir
Expand Down Expand Up @@ -1641,18 +1638,21 @@ def copy_to_device(self, steps, device, origin, destination,
except Exception as e:
step.failed("Failed to verify the running image")

# To get the system image
dest_file_path = out.get("version", {}).get('system_image', "")

# if the device is in bundle mode and user passed install_image stage this step will not be executed.
if "BUNDLE" in Dq(out).get_values("mode") and "install_image" in device.clean.order:
step.skipped(f"The device is in bundle mode and install_image stage is passed in clean file. Skipping the verify running image check.")
elif 'packages.conf' in dest_file_path and any('change_boot_variable' in order_name for order_name in device.clean.order):
step.passed(f"The device is in install mode and change_boot_variable stage is passed in clean file. Continuing with the copy process.")
else:
# To get the image version
# To handle the image mapping
image_version = out.get("version", {}).get("xe_version", "")
image_match = re.search(image_version, file)
if image_match:
dest_file_path = out.get("version", {}).get('system_image', "")
if 'packages.conf' not in dest_file_path:
image_mapping = self.history['CopyToDevice'].parameters.setdefault('image_mapping', {})
image_mapping.update({origin['files'][index]: dest_file_path})
image_mapping = self.history['CopyToDevice'].parameters.setdefault('image_mapping', {})
image_mapping.update({origin['files'][index]: dest_file_path})
self.skipped(f"The image file provided is same as the current running image {image_version} on the device.\n\
Setting the destination image to {dest_file_path}. Skipping the copy process.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ def setUp(self):
'install_packages': {
'packages': ['/path/to/my/package.bin']
},
'copy_to_linux': {
'origin': {'files': ['/path/to/my/package.bin']}
},
'copy_to_device': {
'origin': {'files': ['/path/to/my/image.bin']}
},
}

images = ['/path/to/image.bin', '/path/to/package.bin']
Expand Down Expand Up @@ -222,6 +228,17 @@ def test_image_override_install_packages(self):
self.image_handler.update_section('install_packages')
self.assertEqual(self.image_handler.device.clean['install_packages'], {'packages': ['/path/to/package.bin']})

def test_image_override_copy_to_linux(self):
self.image_handler.override_stage_images = True
self.image_handler.update_section('copy_to_linux')
self.assertEqual(self.image_handler.device.clean['copy_to_linux'], {'origin': {'files': ['/path/to/image.bin', '/path/to/package.bin']}})

def test_image_override_copy_to_device(self):
self.image_handler.override_stage_images = True
self.image_handler.update_section('copy_to_device')
self.assertEqual(self.image_handler.device.clean['copy_to_device'], {'origin': {'files': ['/path/to/image.bin', '/path/to/package.bin']}})



def test_image_no_override_tftp_boot(self):
self.image_handler.override_stage_images = False
Expand Down Expand Up @@ -259,5 +276,16 @@ def test_image_no_override_install_packages(self):
self.image_handler.update_section('install_packages')
self.assertEqual(self.image_handler.device.clean['install_packages'], {'packages': ['/path/to/my/package.bin']})

def test_image_no_override_copy_to_linux(self):
self.image_handler.override_stage_images = False
self.image_handler.update_section('copy_to_linux')
self.assertEqual(self.image_handler.device.clean['copy_to_linux'], {'origin': {'files': ['/path/to/my/package.bin']}})

def test_image_no_override_copy_to_device(self):
self.image_handler.override_stage_images = False
self.image_handler.update_section('copy_to_device')
self.assertEqual(self.image_handler.device.clean['copy_to_device'], {'origin': {'files': ['/path/to/my/image.bin']}})


if __name__ == '__main__':
unittest.main()
18 changes: 18 additions & 0 deletions pkgs/conf-pkg/changelog/2023/november.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--------------------------------------------------------------------------------
New
--------------------------------------------------------------------------------

* nxos
* Added macsec conf
* added macsec cli for conf model


--------------------------------------------------------------------------------
Fix
--------------------------------------------------------------------------------

* nxos
* keychain
* fixed typo for crypto algorithm AES_256_CMAC


2 changes: 1 addition & 1 deletion pkgs/conf-pkg/src/genie/libs/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'''

# metadata
__version__ = '23.10'
__version__ = '23.11'
__author__ = 'Cisco Systems Inc.'
__contact__ = ['pyats-support@cisco.com', 'pyats-support-ext@cisco.com']
__copyright__ = 'Copyright (c) 2018, Cisco Systems Inc.'
Expand Down
6 changes: 6 additions & 0 deletions pkgs/conf-pkg/src/genie/libs/conf/keychains/keychains.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ class CRYPTO_ALGO(Enum):
default=None,
type=(None, managedattribute.test_istype(int)),
doc='Set key lifetime duration')

local_timezone = managedattribute(
name='local_timezone',
default=None,
type=(None, managedattribute.test_istype(bool)),
doc='Specify time in local timezone or not')

# =========================================================
# build_config
Expand Down
38 changes: 34 additions & 4 deletions pkgs/conf-pkg/src/genie/libs/conf/keychains/nxos/keychains.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,37 @@ def build_config(self,
'crypto_algo').value == 'aes-128-cmac':
key_string_str += ' cryptographic-algorithm AES_128_CMAC'
elif attributes.value(
'crypto_algo').value == 'aes-128-cmac':
'crypto_algo').value == 'aes-256-cmac':
key_string_str += ' cryptographic-algorithm AES_256_CMAC'

configurations.append_line(
attributes.format(key_string_str))

# key chain <key_chain> macsec
# key <key_id>
# send-lifetime <lifetime_start> duration <lifetime_duration>
# or
# send-lifetime <lifetime_start> infinite
# or
# send-lifetime local <lifetime_start> infinite
# or
# send-lifetime local <lifetime_start> duration <lifetime_duration>
if attributes.value('lifetime_start'):

if attributes.value('local_timezone'):
#send-lifetime local <lifetime_start> duration <lifetime_duration>
lifetime_str = 'send-lifetime local {lifetime_start}'
else:
# send-lifetime <lifetime_start> duration <lifetime_duration>
lifetime_str = 'send-lifetime {lifetime_start}'

if attributes.value('lifetime_duration'):
lifetime_str += ' duration {lifetime_duration}'
else:
lifetime_str += ' infinite'

configurations.append_line(
attributes.format(lifetime_str))

return str(configurations)

Expand Down Expand Up @@ -344,7 +370,7 @@ def build_config(self,
'crypto_algo').value == 'aes-128-cmac':
key_string_str += ' cryptographic-algorithm AES_128_CMAC'
elif attributes.value(
'crypto_algo').value == 'aes-128-cmac':
'crypto_algo').value == 'aes-256-cmac':
key_string_str += ' cryptographic-algorithm AES_256_CMAC'

configurations.append_line(
Expand All @@ -357,8 +383,12 @@ def build_config(self,
'lifetime_start') and attributes.value(
'lifetime_duration'):

# send-lifetime <lifetime_start> duration <lifetime_duration>
lifetime_str = 'send-lifetime {lifetime_start} duration {lifetime_duration}'
if attributes.value('local_timezone'):
#send-lifetime local <lifetime_start> duration <lifetime_duration>
lifetime_str = 'send-lifetime local {lifetime_start} duration {lifetime_duration}'
else:
# send-lifetime <lifetime_start> duration <lifetime_duration>
lifetime_str = 'send-lifetime {lifetime_start} duration {lifetime_duration}'

configurations.append_line(
attributes.format(lifetime_str))
Expand Down
Loading

0 comments on commit f5c89f5

Please sign in to comment.