From b0ae8c85687fd6cc29113b83519e44b8e1370b56 Mon Sep 17 00:00:00 2001 From: Cian McGrath Date: Fri, 6 Oct 2023 11:27:11 +0100 Subject: [PATCH] delete-swis: Account for Bug836028 in deletion of swis 'flash:/EOS.swi' or 'flash:EOS.swi' are possible boot image values. Account for this in the script to avoid deletion of boot image accidentally Change-Id: Ie97c3500b22cbb57bb8931d8beae88efb1bbe834 --- delete-swis-action-pack/config.yaml | 2 +- delete-swis-action-pack/delete-swis/script.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/delete-swis-action-pack/config.yaml b/delete-swis-action-pack/config.yaml index 6b6ab54..4e32545 100644 --- a/delete-swis-action-pack/config.yaml +++ b/delete-swis-action-pack/config.yaml @@ -1,4 +1,4 @@ type: PACKAGE -version: 1.1.0 +version: 1.1.1 name: delete-swis Action package description: Action package containing a script that deletes all unused EOS images on /mnt/flash diff --git a/delete-swis-action-pack/delete-swis/script.py b/delete-swis-action-pack/delete-swis/script.py index d33a4bc..9d7da84 100644 --- a/delete-swis-action-pack/delete-swis/script.py +++ b/delete-swis-action-pack/delete-swis/script.py @@ -17,9 +17,12 @@ showbootResp = cmdOut[1]["response"] # Show boot response is a dict. The eos boot image is under 'softwareImage' eosBootImageFull = showbootResp["softwareImage"] -# The eos boot image is in the form of 'flash:/EOS.swi'. Only the image name is of interest, -# so split on the / to get 'EOS.swi' -eosBootImage = eosBootImageFull.split("/")[1] +# The eos boot image is in the form of either 'flash:/EOS.swi' or 'flash:EOS.swi'. +# Only the image name is of interest, so split on the common ':' to get 'EOS.swi' part +# and parse further if needed +eosBootImage: str = eosBootImageFull.split(':')[1] +if eosBootImage.startswith('/'): + eosBootImage = eosBootImage[1:] # This command returns a large response message cmdOut = ctx.runDeviceCmds(["enable", "dir flash:EOS*"])