Sha256: 6e2e471ce7e9d78f0e3ab7db5241c1a17d6d6f16fc37519946b9febc49b70306
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
module Clouddns module Actions class Migrate < GenericAction def run require 'fog' @fog = Fog::DNS.new(@options[:fog]) @fog_zone = @fog.zones.find { |z| z.domain == @zone.name } puts puts "Migrating '#{@zone.name}'" create_zone! unless @fog_zone # required to pick up nameservers and records @fog_zone = @fog_zone.reload print_nameservers @migration = ZoneMigration.new(@zone, @fog_zone) print_changes # no changes required return if @migration.completed? require_confirmation! @migration.perform! puts "Done" end private def create_zone! puts puts "Zone '#{@zone.name}' does not exist. Creating..." require_confirmation! @fog_zone = @fog.zones.create(:domain => @zone.name) puts "Zone '#{@zone.name}' created." end def print_nameservers puts puts "Nameservers:" @fog_zone.nameservers.each do |nameserver| puts " #{nameserver}" end end def print_changes namelength = @migration.changes.map do |change| change.record.name.length end.max puts puts "Changes:" @migration.changes.each do |change| puts change.to_s(namelength) end end def require_confirmation! print "Type 'Yes' to continute: " STDOUT.flush unless STDIN.readline.strip == 'Yes' puts "aborting" exit 1 end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clouddns-0.0.3 | lib/clouddns/actions/migrate.rb |