Method: CloudFlock::App::Common#configure_ips

Defined in:
lib/cloudflock/app/common/servers.rb

#configure_ips(shell, profile) ⇒ Object

Public: For each IP detected on the source host, perform IP remediation on the destination host post-migration. Allow the list of IPs and the list of directories to target to be overridden by the user.

shell - SSH object logged in to the target host. profile - Profile containing IPs gathered from the source host.

Returns nothing.



612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/cloudflock/app/common/servers.rb', line 612

def configure_ips(shell, profile)
  destination_profile = CloudFlock::Task::ServerProfile.new(shell)
  source_ips          = profile.select_entries(/IP Usage/, /./)
  destination_ips     = destination_profile.select_entries(/IP Usage/, /./)
  target_directories  = ['/etc']

  puts "Detected IPs on the source: #{source_ips.join(', ')} "
  if UI.prompt_yn('Edit IP list? (Y/N)', default_answer: 'N')
    source_ips = edit_ip_list(source_ips)
  end

  puts 'By default only config files under /etc will be remediated.  '
  if UI.prompt_yn('Edit remediation targets? (Y/N)', default_answer: 'N')
    target_directories = edit_directory_list(target_directories)
  end

  puts "Detected IPs on the destination: #{destination_ips.join(', ')}"
  source_ips.each do |ip|
    appropriate = destination_ips.select do |dest_ip|
      Addrinfo.ip(ip).ipv4_private? == Addrinfo.ip(dest_ip).ipv4_private?
    end
    suggested = appropriate.first || destination_ips.first
    remediate_ip(shell, ip, suggested, target_directories)
  end
end