def _remove_old_snapshots(connection, volume):
if '<STR_LIT>' not in volume.tags:<EOL><INDENT>logger.warning(<EOL>'<STR_LIT>'.format(<EOL>volume.id))<EOL>return<EOL><DEDENT>retention = int(volume.tags['<STR_LIT>'])<EOL>snapshots = connection.get_all_snapshots(filters={'<STR_LIT>': volume.id})<EOL>snapshots.sort(key=lambda x: x.start_time)<EOL>snapshots = snapshots[:-int(retention)]<EOL>if not snapshots:<EOL><INDENT>logger.info('<STR_LIT>')<EOL>return<EOL><DEDENT>for snapshot in snapshots:<EOL><INDENT>logger.info('<STR_LIT>'.format(snapshot.id))<EOL>try:<EOL><INDENT>snapshot.delete()<EOL><DEDENT>except EC2ResponseError as error:<EOL><INDENT>logger.warning('<STR_LIT>'.format(<EOL>error.message))<EOL><DEDENT><DEDENT>logger.info('<STR_LIT>')<EOL>
Remove old snapshots

    :type connection: boto.ec2.connection.EC2Connection
    :param connection: EC2 connection object
    :type volume: boto.ec2.volume.Volume
    :param volume: Volume to check
    :returns: None