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])
account_name, env_name = environment.account.name, environment.name
unless environment.instances.first
error "Environment #{account_name}/#{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 #{account_name} with IP #{public_ip}"
$stdout.flush
::DNSimple::Client.load_credentials_if_necessary
assign_dns(account_name, env_name, domain, public_ip, name, options[:override])
assign_dns(account_name, env_name, domain, public_ip, "www", options[:override]) if name == ""
say "Complete!", :green
::DNSimple::Commands::ListRecords.new.execute([domain])
end
|