From 560d86464db88d49d59805b35bf1f07b9695b726 Mon Sep 17 00:00:00 2001 From: Dr Nic Williams Date: Tue, 24 May 2011 09:20:52 -0700 Subject: [PATCH] "ey-dns domains" lists the registered domains for each DNS provider (with a count of records for each) --- features/list_available_domains.feature | 17 +++++++++++++++++ lib/engineyard-dns/cli.rb | 19 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 features/list_available_domains.feature diff --git a/features/list_available_domains.feature b/features/list_available_domains.feature new file mode 100644 index 0000000..da45757 --- /dev/null +++ b/features/list_available_domains.feature @@ -0,0 +1,17 @@ +Feature: List available domains + I want to see the available domains I can associate with my AppCloud apps + + Scenario: Show domains without any records: + Given I have setup my fog credentials for "DNSimple" + And I have DNS domain "myapp.com" with provider "DNSimple" + And I have DNS domain "myotherapp.com" with provider "DNSimple" + When I run local executable "ey-dns" with arguments "domains" + Then I should see exactly + """ + DNSimple: + myapp.com - 0 records + myotherapp.com - 0 records + + """ + + diff --git a/lib/engineyard-dns/cli.rb b/lib/engineyard-dns/cli.rb index 1fb57b3..3cca411 100644 --- a/lib/engineyard-dns/cli.rb +++ b/lib/engineyard-dns/cli.rb @@ -18,7 +18,6 @@ def self.start(*) super end - desc "assign DOMAIN [NAME]", "Assign DNS domain/tld (or name.tld) to your AppCloud environment" method_option :verbose, :aliases => ["-V"], :desc => "Display more output" method_option :environment, :aliases => ["-e"], :desc => "Environment in which to deploy this application", :type => :string @@ -61,6 +60,24 @@ def assign(domain_name, name = "") # ::DNSimple::Commands::ListRecords.new.execute([domain]) end + desc "domains", "List available domains/zones from your DNS providers" + def domains + 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 + desc "version", "show version information" def version require 'engineyard-dns/version'