'Reads the settings from the ec2.ini file'

def read_settings(self):

    config = ConfigParser.SafeConfigParser()
    ec2_default_ini_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ec2.ini')
    ec2_ini_path = os.environ.get('EC2_INI_PATH', ec2_default_ini_path)
    config.read(ec2_ini_path)
    self.eucalyptus_host = None
    self.eucalyptus = False
    if config.has_option('ec2', 'eucalyptus'):
        self.eucalyptus = config.getboolean('ec2', 'eucalyptus')
    if (self.eucalyptus and config.has_option('ec2', 'eucalyptus_host')):
        self.eucalyptus_host = config.get('ec2', 'eucalyptus_host')
    self.regions = []
    configRegions = config.get('ec2', 'regions')
    configRegions_exclude = config.get('ec2', 'regions_exclude')
    if (configRegions == 'all'):
        if self.eucalyptus_host:
            self.regions.append(boto.connect_euca(host=self.eucalyptus_host).region.name)
        else:
            for regionInfo in ec2.regions():
                if (regionInfo.name not in configRegions_exclude):
                    self.regions.append(regionInfo.name)
    else:
        self.regions = configRegions.split(',')
    self.destination_variable = config.get('ec2', 'destination_variable')
    self.vpc_destination_variable = config.get('ec2', 'vpc_destination_variable')
    self.route53_enabled = config.getboolean('ec2', 'route53')
    self.route53_excluded_zones = []
    if config.has_option('ec2', 'route53_excluded_zones'):
        self.route53_excluded_zones.extend(config.get('ec2', 'route53_excluded_zones', '').split(','))
    self.rds_enabled = True
    if config.has_option('ec2', 'rds'):
        self.rds_enabled = config.getboolean('ec2', 'rds')
    if config.has_option('ec2', 'all_instances'):
        self.all_instances = config.getboolean('ec2', 'all_instances')
    else:
        self.all_instances = False
    if (config.has_option('ec2', 'all_rds_instances') and self.rds_enabled):
        self.all_rds_instances = config.getboolean('ec2', 'all_rds_instances')
    else:
        self.all_rds_instances = False
    cache_dir = os.path.expanduser(config.get('ec2', 'cache_path'))
    if (not os.path.exists(cache_dir)):
        os.makedirs(cache_dir)
    self.cache_path_cache = (cache_dir + '/ansible-ec2.cache')
    self.cache_path_index = (cache_dir + '/ansible-ec2.index')
    self.cache_max_age = config.getint('ec2', 'cache_max_age')
    if config.has_option('ec2', 'nested_groups'):
        self.nested_groups = config.getboolean('ec2', 'nested_groups')
    else:
        self.nested_groups = False
    try:
        pattern_include = config.get('ec2', 'pattern_include')
        if (pattern_include and (len(pattern_include) > 0)):
            self.pattern_include = re.compile(pattern_include)
        else:
            self.pattern_include = None
    except ConfigParser.NoOptionError as e:
        self.pattern_include = None
    try:
        pattern_exclude = config.get('ec2', 'pattern_exclude')
        if (pattern_exclude and (len(pattern_exclude) > 0)):
            self.pattern_exclude = re.compile(pattern_exclude)
        else:
            self.pattern_exclude = None
    except ConfigParser.NoOptionError as e:
        self.pattern_exclude = None
    self.ec2_instance_filters = defaultdict(list)
    if config.has_option('ec2', 'instance_filters'):
        for x in config.get('ec2', 'instance_filters', '').split(','):
            (filter_key, filter_value) = x.split('=')
            self.ec2_instance_filters[filter_key].append(filter_value)
