diff --git a/Gemfile b/Gemfile index 150f524..a37aef3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in aeolus_cli.gemspec +# Specify your gem's dependencies in aeolus-cli.gemspec gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 4076812..df9b7aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - aeolus_cli (0.0.2) + aeolus-cli (0.0.2) activeresource (~> 3.2.9) activesupport (~> 3.2.9) nokogiri (~> 1.5.5) @@ -54,7 +54,7 @@ PLATFORMS ruby DEPENDENCIES - aeolus_cli! + aeolus-cli! aruba cucumber rspec diff --git a/aeolus_cli.gemspec b/aeolus-cli.gemspec similarity index 89% rename from aeolus_cli.gemspec rename to aeolus-cli.gemspec index 9d61035..b79ee3a 100644 --- a/aeolus_cli.gemspec +++ b/aeolus-cli.gemspec @@ -1,11 +1,11 @@ # -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'aeolus_cli/version' +require 'aeolus/cli/version' Gem::Specification.new do |gem| - gem.name = "aeolus_cli" - gem.version = AeolusCli::VERSION + gem.name = "aeolus-cli" + gem.version = Aeolus::Cli::VERSION gem.authors = "Crag Wolfe" gem.email = "cwolfe@redhat.com" gem.description = %q{Command-line interface to aeolus} diff --git a/bin/aeolus b/bin/aeolus index 6cf9980..9596bcb 100755 --- a/bin/aeolus +++ b/bin/aeolus @@ -1,9 +1,9 @@ #!/usr/bin/env ruby -require 'aeolus_cli/main' +require 'aeolus/cli/main' begin - AeolusCli::Main.start + Aeolus::Cli::Main.start rescue Exception => ex if $aeolus_cli_supress_trace_message exit 1 diff --git a/lib/aeolus/cli.rb b/lib/aeolus/cli.rb new file mode 100644 index 0000000..c044baa --- /dev/null +++ b/lib/aeolus/cli.rb @@ -0,0 +1,15 @@ +module Aeolus +end + +module Aeolus::Cli +end + +class Aeolus::Cli::Error < StandardError + attr_reader :message + + def initialize(message) + @message = message + end +end + +class Aeolus::Cli::ConfigError < Aeolus::Cli::Error; end diff --git a/lib/aeolus_cli/common_cli.rb b/lib/aeolus/cli/common_cli.rb similarity index 86% rename from lib/aeolus_cli/common_cli.rb rename to lib/aeolus/cli/common_cli.rb index a1a7528..c492b05 100644 --- a/lib/aeolus_cli/common_cli.rb +++ b/lib/aeolus/cli/common_cli.rb @@ -1,10 +1,10 @@ require 'active_resource' require 'thor' -require 'aeolus_cli/formatting' -require 'aeolus_cli/model/base' -require 'aeolus_cli/model/provider_type' +require 'aeolus/cli/formatting' +require 'aeolus/client/base' +require 'aeolus/client/provider_type' -class AeolusCli::CommonCli < Thor +class Aeolus::Cli::CommonCli < Thor class_option :conductor_url, :type => :string class_option :username, :type => :string class_option :password, :type => :string @@ -74,7 +74,7 @@ def load_aeolus_config(options) if ENV.has_key?("AEOLUS_CLI_CONF") config_fname = ENV["AEOLUS_CLI_CONF"] if !is_file?(config_fname) - raise AeolusCli::ConfigError.new( + raise Aeolus::Cli::ConfigError.new( "environment variable AEOLUS_CLI_CONF with value "+ "'#{ ENV['AEOLUS_CLI_CONF']}' does not point to an existing file") end @@ -92,15 +92,15 @@ def load_aeolus_config(options) @config = YAML::load(File.open(File.expand_path(config_fname))) if @config.has_key?(:conductor) [:url, :password, :username].each do |key| - raise AeolusCli::ConfigError.new \ + raise Aeolus::Cli::ConfigError.new \ ("Error in configuration file: #{key} is missing" ) unless @config[:conductor].has_key?(key) end - AeolusCli::Model::Base.site = @config[:conductor][:url] - AeolusCli::Model::Base.user = @config[:conductor][:username] - AeolusCli::Model::Base.password = @config[:conductor][:password] + Aeolus::Client::Base.site = @config[:conductor][:url] + Aeolus::Client::Base.user = @config[:conductor][:username] + Aeolus::Client::Base.password = @config[:conductor][:password] else - raise AeolusCli::ConfigError.new("Error in configuration file") + raise Aeolus::Cli::ConfigError.new("Error in configuration file") end if @config.has_key?(:logging) if @config[:logging].has_key?(:logfile) @@ -116,7 +116,7 @@ def load_aeolus_config(options) if @config[:logging].has_key?(:level) log_level = @config[:logging][:level] if ! ['DEBUG','WARN','INFO','ERROR','FATAL'].include?(log_level) - raise AeolusCli::ConfigError.new \ + raise Aeolus::Cli::ConfigError.new \ ("log level specified in configuration #{log_level}, is not valid."+ ". shoud be one of DEBUG, WARN, INFO, ERROR or FATAL") else @@ -127,19 +127,19 @@ def load_aeolus_config(options) end # allow overrides from command line if options[:conductor_url] - AeolusCli::Model::Base.site = options[:conductor_url] + Aeolus::Client::Base.site = options[:conductor_url] end if options[:username] - AeolusCli::Model::Base.user = options[:username] + Aeolus::Client::Base.user = options[:username] end if options[:password] - AeolusCli::Model::Base.password = options[:password] + Aeolus::Client::Base.password = options[:password] end end # Set output format (human vs. machine) def set_output_format(options) - @output_format = AeolusCli::Formatting.create_format(shell, options) + @output_format = Aeolus::Cli::Formatting.create_format(shell, options) end # Transforms e.g. 'name,status' into [:name, :status] @@ -179,7 +179,7 @@ def provider_type(type_s) def provider_type_hash deltacloud_driver_to_provider_type = Hash.new - provider_types = AeolusCli::Model::ProviderType.all + provider_types = Aeolus::Client::ProviderType.all if provider_types.size == 0 raise "Retrieved zero provider types from Conductor" end diff --git a/lib/aeolus_cli/formatting.rb b/lib/aeolus/cli/formatting.rb similarity index 80% rename from lib/aeolus_cli/formatting.rb rename to lib/aeolus/cli/formatting.rb index f73710a..f03d788 100644 --- a/lib/aeolus_cli/formatting.rb +++ b/lib/aeolus/cli/formatting.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/errors' +require 'aeolus/cli/formatting/errors' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting class << self def create_format(shell, options) format_name = options[:format] || default_format @@ -17,7 +17,7 @@ def default_format def load_format_class(format_name) class_name = format_name.gsub(/^(.)/) { |first_letter| first_letter.upcase } + "Format" begin - require "aeolus_cli/formatting/#{format_name}_format" + require "aeolus/cli/formatting/#{format_name}_format" const_get(class_name) rescue LoadError, NameError raise UnknownFormatError.new(format_name) diff --git a/lib/aeolus_cli/formatting/errors.rb b/lib/aeolus/cli/formatting/errors.rb similarity index 94% rename from lib/aeolus_cli/formatting/errors.rb rename to lib/aeolus/cli/formatting/errors.rb index 51a7d7d..39ffb62 100644 --- a/lib/aeolus_cli/formatting/errors.rb +++ b/lib/aeolus/cli/formatting/errors.rb @@ -1,4 +1,4 @@ -module AeolusCli::Formatting +module Aeolus::Cli::Formatting class PresenterMissingError < StandardError def initialize(format, object) super("Presenter not defined for #{object.class.name} in #{format.to_s}") diff --git a/lib/aeolus_cli/formatting/format.rb b/lib/aeolus/cli/formatting/format.rb similarity index 94% rename from lib/aeolus_cli/formatting/format.rb rename to lib/aeolus/cli/formatting/format.rb index 1e587a5..607329c 100644 --- a/lib/aeolus_cli/formatting/format.rb +++ b/lib/aeolus/cli/formatting/format.rb @@ -1,7 +1,7 @@ -require 'aeolus_cli/formatting/errors' -require 'aeolus_cli/formatting/presenter_sorter' +require 'aeolus/cli/formatting/errors' +require 'aeolus/cli/formatting/presenter_sorter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # This class (or more precisely, classes that inherit from this one) can # format various objects for printing. Formatting is done via presenters. # Presenter classes can be registered with the Format to indicate which diff --git a/lib/aeolus_cli/formatting/human_format.rb b/lib/aeolus/cli/formatting/human_format.rb similarity index 74% rename from lib/aeolus_cli/formatting/human_format.rb rename to lib/aeolus/cli/formatting/human_format.rb index 00606f4..4ef2a2c 100644 --- a/lib/aeolus_cli/formatting/human_format.rb +++ b/lib/aeolus/cli/formatting/human_format.rb @@ -1,16 +1,16 @@ -require 'aeolus_cli/formatting/format' -require 'aeolus_cli/formatting/human_presenter_filter' -require 'aeolus_cli/formatting/provider_presenter' -require 'aeolus_cli/formatting/provider_account_presenter' +require 'aeolus/cli/formatting/format' +require 'aeolus/cli/formatting/human_presenter_filter' +require 'aeolus/cli/formatting/provider_presenter' +require 'aeolus/cli/formatting/provider_account_presenter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Format that prints objects in a human-friendly way. class HumanFormat < Format def initialize(shell) super(shell) - register("AeolusCli::Model::Provider", ProviderPresenter) - register("AeolusCli::Model::ProviderAccount", ProviderAccountPresenter) + register("Aeolus::Client::Provider", ProviderPresenter) + register("Aeolus::Client::ProviderAccount", ProviderAccountPresenter) end def detail(object, fields_override = nil) diff --git a/lib/aeolus_cli/formatting/human_presenter_filter.rb b/lib/aeolus/cli/formatting/human_presenter_filter.rb similarity index 95% rename from lib/aeolus_cli/formatting/human_presenter_filter.rb rename to lib/aeolus/cli/formatting/human_presenter_filter.rb index e1604ef..6cfd624 100644 --- a/lib/aeolus_cli/formatting/human_presenter_filter.rb +++ b/lib/aeolus/cli/formatting/human_presenter_filter.rb @@ -1,6 +1,6 @@ require 'delegate' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Wrapper for presenters that alters/adds behavior for # more human-friendly output. class HumanPresenterFilter < SimpleDelegator diff --git a/lib/aeolus_cli/formatting/machine_format.rb b/lib/aeolus/cli/formatting/machine_format.rb similarity index 67% rename from lib/aeolus_cli/formatting/machine_format.rb rename to lib/aeolus/cli/formatting/machine_format.rb index 41ba16f..1d6ace9 100644 --- a/lib/aeolus_cli/formatting/machine_format.rb +++ b/lib/aeolus/cli/formatting/machine_format.rb @@ -1,16 +1,16 @@ -require 'aeolus_cli/formatting/format' -require 'aeolus_cli/formatting/provider_presenter' -require 'aeolus_cli/formatting/provider_account_presenter' +require 'aeolus/cli/formatting/format' +require 'aeolus/cli/formatting/provider_presenter' +require 'aeolus/cli/formatting/provider_account_presenter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Format that prints objects in a machine-friendly way. class MachineFormat < Format def initialize(shell, separator = "\t") super(shell) @separator = separator - register("AeolusCli::Model::Provider", ProviderPresenter) - register("AeolusCli::Model::ProviderAccount", ProviderAccountPresenter) + register("Aeolus::Client::Provider", ProviderPresenter) + register("Aeolus::Client::ProviderAccount", ProviderAccountPresenter) end def detail(object, fields_override = nil) diff --git a/lib/aeolus_cli/formatting/presenter.rb b/lib/aeolus/cli/formatting/presenter.rb similarity index 97% rename from lib/aeolus_cli/formatting/presenter.rb rename to lib/aeolus/cli/formatting/presenter.rb index 8a32bdd..979c995 100644 --- a/lib/aeolus_cli/formatting/presenter.rb +++ b/lib/aeolus/cli/formatting/presenter.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/errors' +require 'aeolus/cli/formatting/errors' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Presenter class formats a single object for output. The generic Presenter # produces sort of machine-friendly output. class Presenter diff --git a/lib/aeolus_cli/formatting/presenter_sorter.rb b/lib/aeolus/cli/formatting/presenter_sorter.rb similarity index 97% rename from lib/aeolus_cli/formatting/presenter_sorter.rb rename to lib/aeolus/cli/formatting/presenter_sorter.rb index 1369371..0489151 100644 --- a/lib/aeolus_cli/formatting/presenter_sorter.rb +++ b/lib/aeolus/cli/formatting/presenter_sorter.rb @@ -1,4 +1,4 @@ -module AeolusCli::Formatting +module Aeolus::Cli::Formatting # Sorts array of Presenter objects by their field values. class PresenterSorter # Parameter sort_by is expected like e.g. [[:status, :desc], [:name, :asc]], diff --git a/lib/aeolus_cli/formatting/provider_account_presenter.rb b/lib/aeolus/cli/formatting/provider_account_presenter.rb similarity index 89% rename from lib/aeolus_cli/formatting/provider_account_presenter.rb rename to lib/aeolus/cli/formatting/provider_account_presenter.rb index 7dcdf1a..d28751d 100644 --- a/lib/aeolus_cli/formatting/provider_account_presenter.rb +++ b/lib/aeolus/cli/formatting/provider_account_presenter.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/presenter' +require 'aeolus/cli/formatting/presenter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting class ProviderAccountPresenter < Presenter default_list_item_fields(:name, :provider, :username, :quota) default_detail_fields(:name, :provider, :username, :quota) diff --git a/lib/aeolus_cli/formatting/provider_presenter.rb b/lib/aeolus/cli/formatting/provider_presenter.rb similarity index 78% rename from lib/aeolus_cli/formatting/provider_presenter.rb rename to lib/aeolus/cli/formatting/provider_presenter.rb index 89ab218..9798c4f 100644 --- a/lib/aeolus_cli/formatting/provider_presenter.rb +++ b/lib/aeolus/cli/formatting/provider_presenter.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/presenter' +require 'aeolus/cli/formatting/presenter' -module AeolusCli::Formatting +module Aeolus::Cli::Formatting class ProviderPresenter < Presenter default_list_item_fields(:name, :provider_type, :deltacloud_provider, :deltacloud_url) default_detail_fields(:id, :name, :provider_type, :deltacloud_provider, :deltacloud_url) diff --git a/lib/aeolus/cli/main.rb b/lib/aeolus/cli/main.rb new file mode 100644 index 0000000..02799c1 --- /dev/null +++ b/lib/aeolus/cli/main.rb @@ -0,0 +1,14 @@ +require 'aeolus/cli' +require 'thor' +require 'aeolus/cli/provider' +require 'aeolus/cli/provider_account' + +class Aeolus::Cli::Main < Thor + + desc 'provider', 'show provider subcommands' + subcommand 'provider', Aeolus::Cli::Provider + + desc 'provider_account', 'show provider account subcommands' + subcommand 'provider_account', Aeolus::Cli::ProviderAccount + +end diff --git a/lib/aeolus_cli/provider.rb b/lib/aeolus/cli/provider.rb similarity index 84% rename from lib/aeolus_cli/provider.rb rename to lib/aeolus/cli/provider.rb index 9b13ad5..82a2f9b 100644 --- a/lib/aeolus_cli/provider.rb +++ b/lib/aeolus/cli/provider.rb @@ -1,12 +1,12 @@ -require 'aeolus_cli/common_cli' -require 'aeolus_cli/model/provider' +require 'aeolus/cli/common_cli' +require 'aeolus/client/provider' -class AeolusCli::Provider < AeolusCli::CommonCli +class Aeolus::Cli::Provider < Aeolus::Cli::CommonCli desc "list", "List all providers" method_options_for_resource_list def list - providers = AeolusCli::Model::Provider.all + providers = Aeolus::Client::Provider.all output_format.list(providers, resource_fields(options[:fields]), resource_sort_by(options[:sort_by])) @@ -19,7 +19,7 @@ def list method_option :deltacloud_provider, :type => :string def add(provider_name) # TODO: validation on provider_type (make sure exists) - p = AeolusCli::Model::Provider.new(:name => provider_name, + p = Aeolus::Client::Provider.new(:name => provider_name, :url => options[:deltacloud_url], :provider_type => provider_type(options[:provider_type]), :deltacloud_provider => options[:deltacloud_provider]) diff --git a/lib/aeolus_cli/provider_account.rb b/lib/aeolus/cli/provider_account.rb similarity index 84% rename from lib/aeolus_cli/provider_account.rb rename to lib/aeolus/cli/provider_account.rb index ca040e3..af0737b 100644 --- a/lib/aeolus_cli/provider_account.rb +++ b/lib/aeolus/cli/provider_account.rb @@ -1,13 +1,13 @@ -require 'aeolus_cli/common_cli' -require 'aeolus_cli/model/provider_account' +require 'aeolus/cli/common_cli' +require 'aeolus/client/provider_account' -class AeolusCli::ProviderAccount < AeolusCli::CommonCli +class Aeolus::Cli::ProviderAccount < Aeolus::Cli::CommonCli desc "list", "list provider accounts" method_options_for_resource_list # TODO maybe an optional variable for provider_type def list - accounts = AeolusCli::Model::ProviderAccount.all_full_detail + accounts = Aeolus::Client::ProviderAccount.all_full_detail output_format.list(accounts, resource_fields(options[:fields]), resource_sort_by(options[:sort_by])) @@ -22,13 +22,13 @@ def list :default => "unlimited", :desc => "maximum running instances" def add(label) credentials = credentials_from_file(options[:credentials_file]) - provider = AeolusCli::Model::Provider.all.find {|p| p.name == options[:provider_name]} + provider = Aeolus::Client::Provider.all.find {|p| p.name == options[:provider_name]} unless provider self.shell.say "ERROR: The provider '#{options[:provider_name]}' does not exist" exit(1) end - pa = AeolusCli::Model::ProviderAccount.new( + pa = Aeolus::Client::ProviderAccount.new( :label => label, :provider => {:id => provider.id}, :credentials => credentials, diff --git a/lib/aeolus/cli/version.rb b/lib/aeolus/cli/version.rb new file mode 100644 index 0000000..b93a5a7 --- /dev/null +++ b/lib/aeolus/cli/version.rb @@ -0,0 +1,5 @@ +module Aeolus + module Cli + VERSION = "0.0.2" + end +end diff --git a/lib/aeolus_cli/model/base.rb b/lib/aeolus/client.rb similarity index 61% rename from lib/aeolus_cli/model/base.rb rename to lib/aeolus/client.rb index f063a40..f649d99 100644 --- a/lib/aeolus_cli/model/base.rb +++ b/lib/aeolus/client.rb @@ -1,12 +1,13 @@ require 'active_resource' -require 'aeolus_cli' -require 'logger' -ActiveResource::Base.logger = Logger.new(STDOUT) -ActiveResource::Base.logger.level = Logger::INFO +module Aeolus +end + +module Aeolus::Client +end module ActiveResource - class Errors + class Errors < ActiveModel::Errors # Grabs errors from an XML response. def from_xml(xml, save_cache = false) array = Array.wrap(Hash.from_xml(xml)['errors']['error']) @@ -24,14 +25,3 @@ def from_xml(xml, save_cache = false) end end end - -# declaring the namespace but for style reasons not including the Base -# class definition within the block (saving as much excessive -# indentation as possible) -module AeolusCli::Model -end - -class AeolusCli::Model::Base < ActiveResource::Base - self.timeout = 600 - self.format = :xml -end diff --git a/lib/aeolus/client/base.rb b/lib/aeolus/client/base.rb new file mode 100644 index 0000000..09c0c22 --- /dev/null +++ b/lib/aeolus/client/base.rb @@ -0,0 +1,11 @@ +require 'aeolus/client' +require 'logger' + +# FIXME: get rid of these when refactoring config loading: +ActiveResource::Base.logger = Logger.new(STDOUT) +ActiveResource::Base.logger.level = Logger::INFO + +class Aeolus::Client::Base < ActiveResource::Base + self.timeout = 600 + self.format = :xml +end diff --git a/lib/aeolus_cli/model/provider.rb b/lib/aeolus/client/provider.rb similarity index 84% rename from lib/aeolus_cli/model/provider.rb rename to lib/aeolus/client/provider.rb index 2e4f7a8..c70fbc3 100644 --- a/lib/aeolus_cli/model/provider.rb +++ b/lib/aeolus/client/provider.rb @@ -1,4 +1,6 @@ -class ProviderXMLFormat +require 'aeolus/client/base' + +class Aeolus::Client::ProviderXMLFormat include ActiveResource::Formats::XmlFormat def decode(xml) @@ -29,6 +31,6 @@ def decode(xml) end end -class AeolusCli::Model::Provider < AeolusCli::Model::Base - self.format = ProviderXMLFormat.new +class Aeolus::Client::Provider < Aeolus::Client::Base + self.format = Aeolus::Client::ProviderXMLFormat.new end diff --git a/lib/aeolus_cli/model/provider_account.rb b/lib/aeolus/client/provider_account.rb similarity index 84% rename from lib/aeolus_cli/model/provider_account.rb rename to lib/aeolus/client/provider_account.rb index 1c831db..5f545eb 100644 --- a/lib/aeolus_cli/model/provider_account.rb +++ b/lib/aeolus/client/provider_account.rb @@ -1,4 +1,6 @@ -class ProviderAccountXMLFormat +require 'aeolus/client/base' + +class Aeolus::Client::ProviderAccountXMLFormat include ActiveResource::Formats::XmlFormat def decode(xml) @@ -32,15 +34,15 @@ def decode(xml) end end -class AeolusCli::Model::ProviderAccount < AeolusCli::Model::Base - self.format = ProviderAccountXMLFormat.new +class Aeolus::Client::ProviderAccount < Aeolus::Client::Base + self.format = Aeolus::Client::ProviderAccountXMLFormat.new # FIXME: This should not be necessary when we update API to show full # representations in resource collections. def self.all_full_detail self.all.map! do |account| # getting a separate resource gives more details than collection - AeolusCli::Model::ProviderAccount.find(account.id) + Aeolus::Client::ProviderAccount.find(account.id) end end end diff --git a/lib/aeolus/client/provider_type.rb b/lib/aeolus/client/provider_type.rb new file mode 100644 index 0000000..4943384 --- /dev/null +++ b/lib/aeolus/client/provider_type.rb @@ -0,0 +1,13 @@ +require 'aeolus/client/base' + +class Aeolus::Client::ProviderTypeXMLFormat + include ActiveResource::Formats::XmlFormat + + def decode(xml) + ActiveResource::Formats::XmlFormat.decode(xml)['provider_type'] + end +end + +class Aeolus::Client::ProviderType < Aeolus::Client::Base + self.format = Aeolus::Client::ProviderTypeXMLFormat.new +end diff --git a/lib/aeolus_cli.rb b/lib/aeolus_cli.rb deleted file mode 100644 index f2c9c03..0000000 --- a/lib/aeolus_cli.rb +++ /dev/null @@ -1,12 +0,0 @@ -module AeolusCli -end - -class AeolusCli::Error < StandardError - attr_reader :message - - def initialize(message) - @message = message - end -end - -class AeolusCli::ConfigError < AeolusCli::Error; end diff --git a/lib/aeolus_cli/main.rb b/lib/aeolus_cli/main.rb deleted file mode 100644 index eb9221a..0000000 --- a/lib/aeolus_cli/main.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'aeolus_cli' -require 'thor' -require 'aeolus_cli/provider' -require 'aeolus_cli/provider_account' - -class AeolusCli::Main < Thor - - desc 'provider', 'show provider subcommands' - subcommand 'provider', AeolusCli::Provider - - desc 'provider_account', 'show provider account subcommands' - subcommand 'provider_account', AeolusCli::ProviderAccount - -end diff --git a/lib/aeolus_cli/model/provider_type.rb b/lib/aeolus_cli/model/provider_type.rb deleted file mode 100644 index ba5f3ef..0000000 --- a/lib/aeolus_cli/model/provider_type.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ProviderTypeXMLFormat - include ActiveResource::Formats::XmlFormat - - def decode(xml) - ActiveResource::Formats::XmlFormat.decode(xml)['provider_type'] - end -end - -class AeolusCli::Model::ProviderType < AeolusCli::Model::Base - self.format = ProviderTypeXMLFormat.new -end diff --git a/lib/aeolus_cli/version.rb b/lib/aeolus_cli/version.rb deleted file mode 100644 index 770ea7c..0000000 --- a/lib/aeolus_cli/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module AeolusCli - VERSION = "0.0.2" -end diff --git a/spec/aeolus_cli/common_cli_spec.rb b/spec/aeolus/cli/common_cli_spec.rb similarity index 90% rename from spec/aeolus_cli/common_cli_spec.rb rename to spec/aeolus/cli/common_cli_spec.rb index 091f9ed..c6e2bec 100644 --- a/spec/aeolus_cli/common_cli_spec.rb +++ b/spec/aeolus/cli/common_cli_spec.rb @@ -1,7 +1,7 @@ -require 'aeolus_cli/common_cli' +require 'aeolus/cli/common_cli' -describe AeolusCli::CommonCli do - let(:common_cli) { AeolusCli::CommonCli.new() } +describe Aeolus::Cli::CommonCli do + let(:common_cli) { Aeolus::Cli::CommonCli.new() } context "#resource_fields" do context "non-empty fields" do diff --git a/spec/aeolus_cli/formatting/format_spec.rb b/spec/aeolus/cli/formatting/format_spec.rb similarity index 88% rename from spec/aeolus_cli/formatting/format_spec.rb rename to spec/aeolus/cli/formatting/format_spec.rb index 2c4bf5a..126d85b 100644 --- a/spec/aeolus_cli/formatting/format_spec.rb +++ b/spec/aeolus/cli/formatting/format_spec.rb @@ -1,9 +1,9 @@ -require 'aeolus_cli/formatting/format' +require 'aeolus/cli/formatting/format' -describe AeolusCli::Formatting::Format do +describe Aeolus::Cli::Formatting::Format do let(:shell) { double('shell') } - let(:format) { AeolusCli::Formatting::Format.new(shell) } + let(:format) { Aeolus::Cli::Formatting::Format.new(shell) } context "with a presenter" do let(:presenter) { double('presenter') } @@ -18,7 +18,7 @@ it do expect { subject } - .to raise_error AeolusCli::Formatting::PresenterMissingError + .to raise_error Aeolus::Cli::Formatting::PresenterMissingError end end @@ -37,7 +37,7 @@ let(:sorted_presenters) { double('sorted_presenters') } let(:sorter) { double('sorter', :sorted_presenters => sorted_presenters) } before do - AeolusCli::Formatting::PresenterSorter + Aeolus::Cli::Formatting::PresenterSorter .should_receive(:new) .with([presenter, presenter], [:name, :asc]) .and_return(sorter) diff --git a/spec/aeolus_cli/formatting/human_format_spec.rb b/spec/aeolus/cli/formatting/human_format_spec.rb similarity index 89% rename from spec/aeolus_cli/formatting/human_format_spec.rb rename to spec/aeolus/cli/formatting/human_format_spec.rb index cb8ed9d..0657ce1 100644 --- a/spec/aeolus_cli/formatting/human_format_spec.rb +++ b/spec/aeolus/cli/formatting/human_format_spec.rb @@ -1,9 +1,9 @@ -require 'aeolus_cli/formatting/human_format' +require 'aeolus/cli/formatting/human_format' -describe AeolusCli::Formatting::HumanFormat do +describe Aeolus::Cli::Formatting::HumanFormat do let(:shell) { double('shell') } - let(:format) { AeolusCli::Formatting::HumanFormat.new(shell) } + let(:format) { Aeolus::Cli::Formatting::HumanFormat.new(shell) } context "printing a detail" do before do diff --git a/spec/aeolus_cli/formatting/human_presenter_filter_spec.rb b/spec/aeolus/cli/formatting/human_presenter_filter_spec.rb similarity index 84% rename from spec/aeolus_cli/formatting/human_presenter_filter_spec.rb rename to spec/aeolus/cli/formatting/human_presenter_filter_spec.rb index 123c603..bce8451 100644 --- a/spec/aeolus_cli/formatting/human_presenter_filter_spec.rb +++ b/spec/aeolus/cli/formatting/human_presenter_filter_spec.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/human_presenter_filter' +require 'aeolus/cli/formatting/human_presenter_filter' -describe AeolusCli::Formatting::HumanPresenterFilter do +describe Aeolus::Cli::Formatting::HumanPresenterFilter do let(:presenter) do bare_presenter = double('bare presenter') bare_presenter.stub('detail') @@ -13,7 +13,7 @@ .and_return(['Joe the Virtual Machine', 'true']) bare_presenter.stub('list_item_fields') .and_return(['name', 'is_cool']) - AeolusCli::Formatting::HumanPresenterFilter.new(bare_presenter) + Aeolus::Cli::Formatting::HumanPresenterFilter.new(bare_presenter) end context "detail" do diff --git a/spec/aeolus_cli/formatting/machine_format_spec.rb b/spec/aeolus/cli/formatting/machine_format_spec.rb similarity index 84% rename from spec/aeolus_cli/formatting/machine_format_spec.rb rename to spec/aeolus/cli/formatting/machine_format_spec.rb index f538d56..7c1d80a 100644 --- a/spec/aeolus_cli/formatting/machine_format_spec.rb +++ b/spec/aeolus/cli/formatting/machine_format_spec.rb @@ -1,9 +1,9 @@ -require 'aeolus_cli/formatting/machine_format' +require 'aeolus/cli/formatting/machine_format' -describe AeolusCli::Formatting::MachineFormat do +describe Aeolus::Cli::Formatting::MachineFormat do let(:shell) { double('shell') } - let(:format) { AeolusCli::Formatting::MachineFormat.new(shell, ';') } + let(:format) { Aeolus::Cli::Formatting::MachineFormat.new(shell, ';') } context "printing a detail" do before do diff --git a/spec/aeolus_cli/formatting/presenter_sorter_spec.rb b/spec/aeolus/cli/formatting/presenter_sorter_spec.rb similarity index 82% rename from spec/aeolus_cli/formatting/presenter_sorter_spec.rb rename to spec/aeolus/cli/formatting/presenter_sorter_spec.rb index 1924df2..b5c187c 100644 --- a/spec/aeolus_cli/formatting/presenter_sorter_spec.rb +++ b/spec/aeolus/cli/formatting/presenter_sorter_spec.rb @@ -1,6 +1,6 @@ -require 'aeolus_cli/formatting/presenter_sorter' +require 'aeolus/cli/formatting/presenter_sorter' -describe AeolusCli::Formatting::PresenterSorter do +describe Aeolus::Cli::Formatting::PresenterSorter do def stub_fields(presenter, status, owner) presenter.stub(:field) do |param| @@ -23,7 +23,7 @@ def stub_fields(presenter, status, owner) let(:presenters) { [p4, p1, p3, p2] } let(:sorted_presenters) { [p1, p2, p3, p4] } let(:sort_by) { [[:status, :desc], [:owner, :asc]] } - let(:sorter) { AeolusCli::Formatting::PresenterSorter.new(presenters, sort_by) } + let(:sorter) { Aeolus::Cli::Formatting::PresenterSorter.new(presenters, sort_by) } context "#sorted_data" do subject { sorter.sorted_presenters } diff --git a/spec/aeolus_cli/formatting/presenter_spec.rb b/spec/aeolus/cli/formatting/presenter_spec.rb similarity index 92% rename from spec/aeolus_cli/formatting/presenter_spec.rb rename to spec/aeolus/cli/formatting/presenter_spec.rb index bdc12ac..c4113e0 100644 --- a/spec/aeolus_cli/formatting/presenter_spec.rb +++ b/spec/aeolus/cli/formatting/presenter_spec.rb @@ -1,8 +1,8 @@ -require 'aeolus_cli/formatting/presenter' +require 'aeolus/cli/formatting/presenter' -describe AeolusCli::Formatting::Presenter do +describe Aeolus::Cli::Formatting::Presenter do let(:presenter_class) do - Class.new(AeolusCli::Formatting::Presenter) do + Class.new(Aeolus::Cli::Formatting::Presenter) do default_detail_fields(:name, :status, :is_cool) default_list_item_fields(:name, :is_cool) end @@ -49,7 +49,7 @@ subject { presenter.field(:old_field) } it do expect { subject } - .to raise_error AeolusCli::Formatting::UnknownFieldError + .to raise_error Aeolus::Cli::Formatting::UnknownFieldError end end end @@ -76,7 +76,7 @@ subject { presenter.field(:some_unknown_field) } it do expect { subject } - .to raise_error AeolusCli::Formatting::UnknownFieldError + .to raise_error Aeolus::Cli::Formatting::UnknownFieldError end end diff --git a/spec/aeolus_cli/formatting/provider_account_presenter_spec.rb b/spec/aeolus/cli/formatting/provider_account_presenter_spec.rb similarity index 81% rename from spec/aeolus_cli/formatting/provider_account_presenter_spec.rb rename to spec/aeolus/cli/formatting/provider_account_presenter_spec.rb index c69e5db..64650fd 100644 --- a/spec/aeolus_cli/formatting/provider_account_presenter_spec.rb +++ b/spec/aeolus/cli/formatting/provider_account_presenter_spec.rb @@ -1,7 +1,7 @@ -require 'aeolus_cli/formatting/presenter' +require 'aeolus/cli/formatting/presenter' -describe AeolusCli::Formatting::ProviderAccountPresenter do - let(:presenter) { AeolusCli::Formatting::ProviderAccountPresenter.new(presented_object) } +describe Aeolus::Cli::Formatting::ProviderAccountPresenter do + let(:presenter) { Aeolus::Cli::Formatting::ProviderAccountPresenter.new(presented_object) } context "with full resource details" do let(:presented_object) do diff --git a/spec/aeolus_cli/formatting_spec.rb b/spec/aeolus/cli/formatting_spec.rb similarity index 75% rename from spec/aeolus_cli/formatting_spec.rb rename to spec/aeolus/cli/formatting_spec.rb index 3ca97cc..305863f 100644 --- a/spec/aeolus_cli/formatting_spec.rb +++ b/spec/aeolus/cli/formatting_spec.rb @@ -1,7 +1,7 @@ -require 'aeolus_cli/formatting' +require 'aeolus/cli/formatting' -describe AeolusCli::Formatting do - let(:formatting) { AeolusCli::Formatting } +describe Aeolus::Cli::Formatting do + let(:formatting) { Aeolus::Cli::Formatting } let(:shell) { double('shell') } context ".create_format" do @@ -14,7 +14,7 @@ end before do - formatting.should_receive(:require).with("aeolus_cli/formatting/human_format").and_return(true) + formatting.should_receive(:require).with("aeolus/cli/formatting/human_format").and_return(true) formatting.should_receive(:const_get).with("HumanFormat").and_return(human_format_class) end diff --git a/spec/config_spec.rb b/spec/config_spec.rb index 9f93712..8ec9791 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -1,4 +1,4 @@ -require 'aeolus_cli/main' +require 'aeolus/cli/main' describe "loading configuration-file by environment variable" do @@ -9,41 +9,41 @@ describe 'with no command line overrides' do before do - AeolusCli::Provider.start + Aeolus::Cli::Provider.start end it 'the configuration file should be loaded' do - AeolusCli::Model::Base.site.to_s.should == 'http://example.com:3013/api' - AeolusCli::Model::Base.user.to_s.should == 'master' - AeolusCli::Model::Base.password.to_s.should == 'ofuniverse' + Aeolus::Client::Base.site.to_s.should == 'http://example.com:3013/api' + Aeolus::Client::Base.user.to_s.should == 'master' + Aeolus::Client::Base.password.to_s.should == 'ofuniverse' ActiveResource::Base.logger.level.should == Logger::DEBUG end end describe 'with --username override' do before do - AeolusCli::Provider.start(["--username", "override-user"]) + Aeolus::Cli::Provider.start(["--username", "override-user"]) end it 'the configuration file should be loaded' do - AeolusCli::Model::Base.user.to_s.should == 'override-user' + Aeolus::Client::Base.user.to_s.should == 'override-user' end end describe 'with --password override' do before do - AeolusCli::Provider.start(["--password", "override-password"]) + Aeolus::Cli::Provider.start(["--password", "override-password"]) end it 'the configuration file should be loaded' do - AeolusCli::Model::Base.password.to_s.should == 'override-password' + Aeolus::Client::Base.password.to_s.should == 'override-password' end end describe 'with --conductor-url override' do before do - AeolusCli::Provider.start(["--conductor-url", + Aeolus::Cli::Provider.start(["--conductor-url", "https://localhost/conductor/api"]) end it 'the configuration file should be loaded' do - AeolusCli::Model::Base.site.to_s.should == + Aeolus::Client::Base.site.to_s.should == 'https://localhost/conductor/api' end end