Sha256: 87ffb9364811bd2edaa514795129766cb8c8165c28d3bc9091c34748290a146b

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 KB

Contents

class Slh::Cli::FetchMetadata < Slh::Cli::HostFilterableBase
  def perform_action
    Slh.strategies.each do |strategy|
      Slh::Cli.instance.output "Fetching metadata for all sites associated with strategy #{strategy.name}"
      strategy.hosts.each do |host|
        next if @options[:filter].kind_of?(String) && !host.name.match(@options[:filter])
        host.sites.each do |site|
          # Slh::Cli.instance.output "Writing fetched metadata for #{site.name} to \n  #{site.fetched_metadata_path}"
          FileUtils.mkdir_p(site.config_dir)
          File.open(site.fetched_metadata_path,'w') do |f| 
            begin
              f.write(site.metadata)
            rescue Slh::Models::Site::CouldNotGetMetadata => e
              Slh::Cli.instance.output "NOT FOUND metadata not found at #{site.metadata_url}", :highlight => :red
              Slh::Cli.instance.output "  Error message: #{e.message}"
              next # skip this site
            rescue Timeout::Error => e
              Slh::Cli.instance.output "  TIMEOUT at #{site.metadata_url}", :highlight => :red
              Slh::Cli.instance.output "    Remote metadata not available at #{site.metadata_url}, exception message: #{e.message}"
              next # skip this site
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shibboleths_lil_helper-1.0.9 lib/slh/cli/fetch_metadata.rb
shibboleths_lil_helper-1.0.8 lib/slh/cli/fetch_metadata.rb
shibboleths_lil_helper-1.0.7 lib/slh/cli/fetch_metadata.rb
shibboleths_lil_helper-1.0.6 lib/slh/cli/fetch_metadata.rb
shibboleths_lil_helper-1.0.5 lib/slh/cli/fetch_metadata.rb
shibboleths_lil_helper-1.0.4 lib/slh/cli/fetch_metadata.rb
shibboleths_lil_helper-1.0.3 lib/slh/cli/fetch_metadata.rb
shibboleths_lil_helper-1.0.2 lib/slh/cli/fetch_metadata.rb
shibboleths_lil_helper-1.0.1 lib/slh/cli/fetch_metadata.rb
shibboleths_lil_helper-1.0.0 lib/slh/cli/fetch_metadata.rb