import json


def load_configuration_params(parser, section_name):
    """ Return a dict of EBS parameters for this section.

        :param  parser  safeconfigparser object of the config file.
        :param  section_name  string  The name of the section to parse.
        :return  dict  The EBS parameters for this section.
    """
    filters = {'Name': "tag:{0}" .format(parser.get(section_name, 'tag_name')),
               "Values": [parser.get(section_name, 'tag_value')]}
    tags = [{'Key': parser.get(section_name, 'tag_name'),
             'Value': parser.get(section_name, 'tag_value')}]

    extra_tags_string = parser.get(section_name, 'extra_tags')
    extra_tags = json.loads(extra_tags_string)
    for tag_name, tag_value in extra_tags.items():
        tags.append({
            'Key': tag_name,
            'Value': tag_value
        })

    encrypted = parser.get(section_name, 'encrypted').lower() in ['true', '1']
    params = {'volume_size': int(parser.get(section_name, 'volume_size')),
              'volume_type': parser.get(section_name, 'volume_type'),
              'mount_point': parser.get(section_name, 'mount_point'),
              'volume_iops': int(parser.get(section_name, 'volume_iops')),
              'time_limit': parser.get(section_name, 'time_limit'),
              'tags': tags,
              'filters': filters,
              'encrypted': encrypted}
    return params