Class: EngineYard::DNS::CLI

Inherits:
Thor
  • Object
show all
Includes:
EY::UtilityMethods
Defined in:
lib/engineyard-dns/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.startObject



17
18
19
20
21
# File 'lib/engineyard-dns/cli.rb', line 17

def self.start(*)
  Thor::Base.shell = EY::CLI::UI
  EY.ui = EY::CLI::UI.new
  super
end

Instance Method Details

#assign(full_domain, deprecated_sub_domain = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/engineyard-dns/cli.rb', line 27

def assign(full_domain, deprecated_sub_domain = nil)
  $stdout.sync
  validate_fog_credentials

  if deprecated_sub_domain
    full_domain = combine_domain_name(full_domain, deprecated_sub_domain)
    say "Subdomain as second argument is deprecated. Please use:"
    say "% ey assign #{full_domain}"
  end

  say "Fetching AppCloud environment information..."
  environment = fetch_environment(options[:environment], options[:account])

  public_ip = fetch_public_ip(environment)

  subdomain, domain_name = split_subdomain(full_domain)

  say ""
  say "Searching for #{domain_name} in your DNS providers..."

  domain, provider_name = find_domain(domain_name)
  unless domain
    error "Please register domain #{domain_name} with your DNS provider."
  end
  say "Found #{domain.domain} in #{provider_name} account."
  say ""

  assign_dns(domain, environment..name, environment.name, public_ip, subdomain, options[:force])
  assign_dns(domain, environment..name, environment.name, public_ip, "www", options[:force]) if subdomain == ""

  say "Complete!", :green
end

#domainsObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/engineyard-dns/cli.rb', line 61

def domains
  validate_fog_credentials
  dns_provider_names.each do |provider_name|
    dns_provider = ::Fog::DNS.new({:provider => provider_name})
    domains      = dns_provider.zones

    if domains.size == 0
      say "#{provider_name}: ", :yellow; say "none"
    else
      say "#{provider_name}:", :green
      domains.each do |domain|
        records = domain.records.all
        say "  #{domain.domain} - #{records.size} records"
      end
    end
  end
end

#versionObject



80
81
82
83
# File 'lib/engineyard-dns/cli.rb', line 80

def version
  require 'engineyard-dns/version'
  say EngineYard::DNS::VERSION
end