groups_sources is a hash from type => options for each group source
 host_sources is a hash from type => options for each host source
 destinations is a similar hash from type => options for each alerter
493277
def run
      start_time = Time.new.to_f
      Signal.trap('TERM') do
        log.info('SIGTERM received. shutting down gracefully...')
        @request_shutdown = true
      end
      run_desc = @dry_run ? 'dry run' : 'run'
      log.info("beginning alerts #{run_desc}")

      alerts = read_alerts(@alert_sources)
      groups = read_groups(@group_sources)
      hosts = read_hosts(@host_sources)

      @destinations.each do |dest|
        dest['options'] ||= {}
        dest['options']['dry_run'] = true if @dry_run
      end

      update_alerts(@destinations, hosts, alerts, groups)

      run_time = Time.new.to_f - start_time
      if @request_shutdown
        log.info("interferon #{run_desc} shut down by SIGTERM")
      else
        statsd.gauge('run_time', run_time)
        log.info("interferon #{run_desc} complete in %.2f seconds" % run_time)
      end
    end
364878
def get_ansible_groups(group_map):
    
    # Some of this logic is cribbed from
    # ansible.inventory.script.InventoryScript
    all_hosts = {}
    group_all = Group('all')
    groups = [group_all]
    for gname, hosts in group_map.iteritems():
        g = Group(gname)
        for host in hosts:
            h = all_hosts.get(host, Host(host))
            all_hosts[host] = h
            g.add_host(h)
            group_all.add_host(h)
        group_all.add_child_group(g)
        groups.append(g)
    return groups
1169903
def parse_api_groups(self, request_resources=False, update=False):
        
        if not self._cache.get('resources') or update:
            self._cache['resources'] = self._cache.get('resources', {})
            groups_response = load_json(self.client.request('GET', '/{}'.format(DISCOVERY_PREFIX)))['groups']

            groups = self.default_groups(request_resources=request_resources)

            for group in groups_response:
                new_group = {}
                for version_raw in group['versions']:
                    version = version_raw['version']
                    resource_group = self._cache.get('resources', {}).get(DISCOVERY_PREFIX, {}).get(group['name'], {}).get(version)
                    preferred = version_raw == group['preferredVersion']
                    resources = resource_group.resources if resource_group else {}
                    if request_resources:
                        resources = self.get_resources_for_api_version(DISCOVERY_PREFIX, group['name'], version, preferred)
                    new_group[version] = ResourceGroup(preferred, resources=resources)
                groups[DISCOVERY_PREFIX][group['name']] = new_group
            self._cache['resources'].update(groups)
            self._write_cache()

        return self._cache['resources']
1023553
function(paths, options) {

      options = options || { };
      this.paths = paths || [ ];

      for (var i = this.paths.length; i--; ) {
        this.paths[i].group = this;
      }

      this.setOptions(options);
      this.setCoords();

      if (options.sourcePath) {
        this.setSourcePath(options.sourcePath);
      }
    }
1134100
def query_available_rewriters
      Core::Rewriter.availables.each do |group, rewriters|
        if group.include? @options[:query]
          puts group
          rewriters.each do |name, rewriter|
            puts '    ' + name
          end
        elsif rewriters.keys.any? { |name| name.include? @options[:query] }
          puts group
          rewriters.each do |name, rewriter|
            puts '    ' + name if name.include?(@options[:query])
          end
        end
      end
      puts
    end
208881
def host_events(self, host):
        '''
        
        '''
        all_host_events = filter(lambda x: 'event_data' in x and 'host' in x['event_data'] and x['event_data']['host'] == host,
                                 self.events)
        return all_host_events
151764
def add_sources(urls)
      urls.each_with_object( {}.compare_by_identity ) do |link, pairs|
        pairs[root_url(link)] = link
      end
    end
1191758
def on_each_source(self):
        
        return (self.info.applytosources and
                self.info.applytosources == self.source_ids)
844902
def source
      @source ||= Dassets.config.sources.select do |source|
        @file_path =~ /^#{slash_path(source.path)}/
      end.last
    end
992896
private SortedSet<ServerGroup> deriveGroups(List<HostInfo> hosts) {
        serverGroups.clear();
        for (HostInfo host : hosts) {
            List<ServerInstance> serverInstances = host.getServerInstances();
            for (ServerInstance server : serverInstances) {
                String group = server.getGroup();
                String profile = server.getProfile();
                ServerGroup serverGroup = serverGroups.get(group);
                if (serverGroup == null) {
                    serverGroup = new ServerGroup(group, profile);
                    serverGroup.fill(hosts);
                    serverGroups.put(group, serverGroup);
                }
            }
        }
        return new TreeSet<ServerGroup>(serverGroups.values());
    }
1206837
def get_sources(zone, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --list-sources'.format(zone)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd).split()
63567
def sprockets(source_file, opts={})
      require 'sprockets'
      source_path = source_file || opt[:main] || opt[:from]
      env = ::Sprockets::Environment.new site.root
      env.append_path File.expand_path(File.join site.source_path, File.dirname(source_path))
      env.append_path site.source_path
      # env.append_path File.dirname(source_path)
      [opts[:paths]].flatten.each do |path|
        env.append_path(path) unless path.nil?
      end
      content= env[ source_path ].to_s
    rescue LoadError
      raise StandardError, "Sprockets can't be loaded. Please add it to your Gemfile."
    end
178542
def _hosts_in_unenumerated_pattern(self, pattern):
        

        hosts = {}
        # ignore any negative checks here, this is handled elsewhere
        pattern = pattern.replace("!","").replace("&", "")

        groups = self.get_groups()
        for group in groups:
            for host in group.get_hosts():
                if pattern == 'all' or self._match(group.name, pattern) or self._match(host.name, pattern):
                    hosts[host.name] = host
        return sorted(hosts.values(), key=lambda x: x.name)
386425
def lookup!(nameserver=nil)
      resolver = Resolv.resolver(nameserver)
      hosts = begin
                resolver.getnames(self.address.to_s)
              rescue
                []
              end

      hosts.map! do |name|
        HostName.first_or_create(
          :address => name,
          :ip_addresses => [self]
        )
      end

      return hosts
    end
1325244
def formatted_servers
      static_ips = connect.describe_addresses.addresses.map(&:public_ip)

      servers.select { |server| include_server? server }.map do |server|
        o = {
          date: server.launch_time.to_s,
          az: server.placement.availability_zone,
          id: server.instance_id,
          subnet: [server.subnet_id, "(#{subnet_name[server.subnet_id]})"].join(' '),
          priv_ip: server.private_ip_address,
          type: server.instance_type,
          vpc: server.vpc_id,
          state: opts[:csv] ? server.state.name : colorize_state(server.state.name).bold
        }

        if opts[:groups]
          groups_string =
            server.security_groupserver.map { |g| "#{g.group_id} (#{g.group_name})" }.join(', ')

          # Shorten the groups string to a manageable length
          unless (opts[:csv] || opts[:all_groups]) && groups_string.length > GROUPS_MAX_LENGTH
            groups_string = groups_string[0..GROUPS_MAX_LENGTH] + '...'
          end

          o[:groups] = groups_string
        end

        if server.vpc_id && opts[:vpc]
          o[:vpc] = [server.vpc_id, "(#{vpc_name[server.vpc_id]})"].join(' ')
        end

        if server.public_ip_address
          static_ip = static_ips.include?(server.public_ip_address) ? '(S)' : '(D)'
          o[:pub_ip] = [server.public_ip_address, static_ip].join(' ')
        end

        # Always include the name tag regardless of cli args (for searching)
        (opts[:tags] | %w[tag_Name]).each do |tag|
          next unless (k = server.tags.find { |t| t.key == tag })

          o["tag_#{tag}".to_sym] = k.value
        end

        o
      end
    end
1289032
def _get_host(self, hostname):
        
        if hostname not in self.hosts:
            self.hosts[hostname] = {
                'groups': set(),
                'hostvars': {}
            }
        return self.hosts[hostname]
843301
def priority_level_get
      hash = {}
      hash[:priority] = default_priority
      hash[:lower] = default_priority_forward_thresh_lower
      hash[:upper] = default_priority_forward_thresh_upper
      arr = config_get('interface_hsrp_group', 'priority_level', @get_args)
      if arr
        hash[:priority] = arr[0].to_i
        hash[:lower] = arr[1].to_i if arr[1]
        hash[:upper] = arr[2].to_i if arr[2]
      end
      hash
    end