Class: EngineYard::DNSimple::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.startObject

include Thor::Actions



15
16
17
18
19
# File 'lib/engineyard-dnsimple/cli.rb', line 15

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

Instance Method Details

#assign(domain, name = "") ⇒ 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
# File 'lib/engineyard-dnsimple/cli.rb', line 27

def assign(domain, name = "")
  say "Fetching AppCloud environment information..."; $stdout.flush
  
  environment = fetch_environment(options[:environment], options[:account])
  , env_name = environment..name, environment.name
  unless environment.instances.first
    error "Environment #{}/#{env_name} has no booted instances."
  end
  public_hostname = environment.instances.first.public_hostname
  status          = environment.instances.first.status
  unless public_hostname =~ /ec2-(\d+)-(\d+)-(\d+)-(\d+)/
    error "Cannot determine public IP from current hostname #{public_hostname}"
  end
  
  public_ip = "#{$1}.#{$2}.#{$3}.#{$4}"

  say "Found AppCloud environment #{env_name} on account #{} with IP #{public_ip}"        
  $stdout.flush

  ::DNSimple::Client.load_credentials_if_necessary
  assign_dns(, env_name, domain, public_ip, name, options[:override])
  assign_dns(, env_name, domain, public_ip, "www", options[:override]) if name == ""

  say "Complete!", :green
  
  ::DNSimple::Commands::ListRecords.new.execute([domain])
end

#versionObject



56
57
58
59
# File 'lib/engineyard-dnsimple/cli.rb', line 56

def version
  require 'engineyard-jenkins/version'
  shell.say Engineyard::Jenkins::VERSION
end