@sonic_installer.command('cleanup')
@click.option('-y', '--yes', is_flag=True, callback=abort_if_false, expose_value=False, prompt='Remove images which are not current and next, continue?')
def cleanup():
    ' Remove installed images which are not current and next '
    bootloader = get_bootloader()
    images = bootloader.get_installed_images()
    curimage = bootloader.get_current_image()
    nextimage = bootloader.get_next_image()
    image_removed = 0
    for image in images:
        if ((image != curimage) and (image != nextimage)):
            echo_and_log(('Removing image %s' % image))
            bootloader.remove_image(image)
            image_removed += 1
    if (image_removed == 0):
        echo_and_log('No image(s) to remove')
Remove installed images which are not current and next
@sonic_installer.command('cleanup')
@click.option('-y', '--yes', is_flag=True, callback=abort_if_false, expose_value=False, prompt='Remove images which are not current and next, continue?')
def cleanup():
    '  '
    bootloader = get_bootloader()
    images = bootloader.get_installed_images()
    curimage = bootloader.get_current_image()
    nextimage = bootloader.get_next_image()
    image_removed = 0
    for image in images:
        if ((image != curimage) and (image != nextimage)):
            echo_and_log(('Removing image %s' % image))
            bootloader.remove_image(image)
            image_removed += 1
    if (image_removed == 0):
        echo_and_log('No image(s) to remove')