def _ensure_snapshot(connection, volume):
if '<STR_LIT>' not in volume.tags:<EOL><INDENT>logger.warning(<EOL>'<STR_LIT>'.format(<EOL>volume.id))<EOL>return<EOL><DEDENT>interval = volume.tags['<STR_LIT>']<EOL>if volume.tags['<STR_LIT>'] not in VALID_INTERVALS:<EOL><INDENT>logger.warning(<EOL>'<STR_LIT>'.format(<EOL>interval, volume.id))<EOL>return<EOL><DEDENT>snapshots = connection.get_all_snapshots(filters={'<STR_LIT>': volume.id})<EOL>if not snapshots:<EOL><INDENT>_create_snapshot(volume)<EOL>return<EOL><DEDENT>min_delta = <NUM_LIT>*<NUM_LIT>*<NUM_LIT>*<NUM_LIT:10>  <EOL>for snapshot in snapshots:<EOL><INDENT>timestamp = datetime.datetime.strptime(<EOL>snapshot.start_time,<EOL>'<STR_LIT>')<EOL>delta_seconds = int(<EOL>(datetime.datetime.utcnow() - timestamp).total_seconds())<EOL>if delta_seconds < min_delta:<EOL><INDENT>min_delta = delta_seconds<EOL><DEDENT><DEDENT>logger.info('<STR_LIT>'.format(<EOL>volume.id, min_delta))<EOL>if interval == '<STR_LIT>' and min_delta > <NUM_LIT>:<EOL><INDENT>_create_snapshot(volume)<EOL><DEDENT>elif interval == '<STR_LIT>' and min_delta > <NUM_LIT>*<NUM_LIT>:<EOL><INDENT>_create_snapshot(volume)<EOL><DEDENT>elif interval == '<STR_LIT>' and min_delta > <NUM_LIT>*<NUM_LIT>*<NUM_LIT:7>:<EOL><INDENT>_create_snapshot(volume)<EOL><DEDENT>elif interval == '<STR_LIT>' and min_delta > <NUM_LIT>*<NUM_LIT>*<NUM_LIT:30>:<EOL><INDENT>_create_snapshot(volume)<EOL><DEDENT>elif interval == '<STR_LIT>' and min_delta > <NUM_LIT>*<NUM_LIT>*<NUM_LIT>:<EOL><INDENT>_create_snapshot(volume)<EOL><DEDENT>else:<EOL><INDENT>logger.info('<STR_LIT>'.format(volume.id))<EOL><DEDENT>
Ensure that a given volume has an appropriate snapshot

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