Skip to content

Commit

Permalink
Change the verification command to verify-next-image
Browse files Browse the repository at this point in the history
  • Loading branch information
xumia committed Jul 10, 2020
1 parent 73cfbaf commit b10af37
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ function reboot_pre_check()
exit ${EXIT_FILE_SYSTEM_FULL}
fi
# Verify reboot by sonic_installer
local message=$(sonic_installer verify-reboot)
# Verify the next image by sonic_installer
local message=$(sonic_installer verify-next-image 2>&1)
if [ $? -ne 0 ]; then
debug "Failed to verify next reboot by running command: sonic_installer verify-reboot, result message: ${message}"
debug "Failed to verify next image by running command: sonic_installer verify-next-image, result message: ${message}"
exit ${EXIT_SONIC_INSTALLER_VERIFY_REBOOT}
fi
Expand Down
6 changes: 3 additions & 3 deletions scripts/reboot
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ function reboot_pre_check()
fi
rm ${filename}

# Verify reboot by sonic_installer
local message=$(sonic_installer verify-reboot)
# Verify the next image by sonic_installer
local message=$(sonic_installer verify-next-image 2>&1)
if [ $? -ne 0 ]; then
VERBOSE=yes debug "Failed to verify next reboot by running command: sonic_installer verify-reboot, result message: ${message}"
VERBOSE=yes debug "Failed to verify the next image by running command: sonic_installer verify-next-image, result message: ${message}"
exit ${EXIT_SONIC_INSTALLER_VERIFY_REBOOT}
fi
}
Expand Down
11 changes: 6 additions & 5 deletions sonic_installer/bootloader/aboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .bootloader import Bootloader

_secureboot = None
DEFAULT_SWI_IMAGE = 'sonic.swi'

# For the signature format, see: https://github.com/aristanetworks/swi-tools/tree/master/switools
SWI_SIG_FILE_NAME = 'swi-signature'
Expand Down Expand Up @@ -110,9 +111,9 @@ def remove_image(self, image):
self._boot_config_set(SWI=image_path, SWI_DEFAULT=image_path)
click.echo("Set next and default boot to current image %s" % current)

image_dir = image.replace(IMAGE_PREFIX, IMAGE_DIR_PREFIX)
image_path = self.get_image_path(image)
click.echo('Removing image root filesystem...')
subprocess.call(['rm','-rf', os.path.join(HOST_PATH, image_dir)])
subprocess.call(['rm','-rf', image_path])
click.echo('Image removed')

def get_binary_image_version(self, image_path):
Expand All @@ -129,11 +130,11 @@ def verify_binary_image(self, image_path):
except subprocess.CalledProcessError:
return False

def verify_reboot(self):
if not super(AbootBootloader, self).verify_reboot():
def verify-next-image(self):
if not super(AbootBootloader, self).verify-next-image():
return False
image = self.get_next_image()
image_path = self.get_image_path(image) + '/sonic.swi'
image_path = os.path.join(self.get_image_path(image), DEFAULT_SWI_IMAGE)
return self._verify_secureboot_image(image_path)

def _verify_secureboot_image(self, image_path):
Expand Down
6 changes: 3 additions & 3 deletions sonic_installer/bootloader/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def verify_binary_image(self, image_path):
"""verify that the image is supported by the bootloader"""
raise NotImplementedError

def verify_reboot(self):
"""verify the image for reboot"""
def verify-next-image(self):
"""verify the next image for reboot"""
image = self.get_next_image()
image_path = self.get_image_path(image)
if not path.exists(image_path):
Expand All @@ -69,6 +69,6 @@ def detect(cls):
@classmethod
def get_image_path(cls, image):
"""returns the image path"""
prefix = HOST_PATH + '/' + IMAGE_DIR_PREFIX
prefix = path.join(Host_PATH, IMAGE_DIR_PREFIX)
return image.replace(IMAGE_PREFIX, prefix)

8 changes: 4 additions & 4 deletions sonic_installer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,12 @@ def rollback_docker(container_name):

click.echo('Done')

# verify reboot
@cli.command('verify_reboot')
# verify the next image
@cli.command('verify-next-image')
def verify_reboot():
""" Verify the image for reboot"""
""" Verify the next image for reboot"""
bootloader = get_bootloader()
if not bootloader.verify_reboot():
if not bootloader.verify-next-image():
click.echo('Failed')
sys.exit(1)
click.echo('Done')
Expand Down

0 comments on commit b10af37

Please sign in to comment.