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.
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 |
# File 'lib/cloudflock/app/common/servers.rb', line 936 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 |