From: Martyn Taylor <mtaylor(a)redhat.com>
---
lib/aeolus_cli.rb | 30 ++--
lib/aeolus_cli/command/base_command.rb | 121 ++++++++++++++
lib/aeolus_cli/command/build_command.rb | 82 ++++++++++
lib/aeolus_cli/command/config_parser.rb | 242 ++++++++++++++++++++++++++++
lib/aeolus_cli/command/delete_command.rb | 96 +++++++++++
lib/aeolus_cli/command/import_command.rb | 58 +++++++
lib/aeolus_cli/command/list_command.rb | 164 +++++++++++++++++++
lib/aeolus_cli/command/push_command.rb | 86 ++++++++++
lib/aeolus_cli/model/base.rb | 31 ++++
lib/aeolus_cli/model/build.rb | 20 +++
lib/aeolus_cli/model/image.rb | 20 +++
lib/aeolus_cli/model/provider.rb | 20 +++
lib/aeolus_cli/model/provider_account.rb | 20 +++
lib/aeolus_cli/model/provider_image.rb | 20 +++
lib/aeolus_cli/model/provider_type.rb | 20 +++
lib/aeolus_cli/model/target_image.rb | 20 +++
lib/aeolus_image/command/base_command.rb | 121 --------------
lib/aeolus_image/command/build_command.rb | 82 ----------
lib/aeolus_image/command/config_parser.rb | 242 ----------------------------
lib/aeolus_image/command/delete_command.rb | 96 -----------
lib/aeolus_image/command/import_command.rb | 58 -------
lib/aeolus_image/command/list_command.rb | 164 -------------------
lib/aeolus_image/command/push_command.rb | 86 ----------
lib/aeolus_image/model/base.rb | 31 ----
lib/aeolus_image/model/build.rb | 20 ---
lib/aeolus_image/model/image.rb | 20 ---
lib/aeolus_image/model/provider.rb | 20 ---
lib/aeolus_image/model/provider_account.rb | 20 ---
lib/aeolus_image/model/provider_image.rb | 20 ---
lib/aeolus_image/model/provider_type.rb | 20 ---
lib/aeolus_image/model/target_image.rb | 20 ---
spec/spec_helper.rb | 4 +-
32 files changed, 1037 insertions(+), 1037 deletions(-)
create mode 100644 lib/aeolus_cli/command/base_command.rb
create mode 100644 lib/aeolus_cli/command/build_command.rb
create mode 100644 lib/aeolus_cli/command/config_parser.rb
create mode 100644 lib/aeolus_cli/command/delete_command.rb
create mode 100644 lib/aeolus_cli/command/import_command.rb
create mode 100644 lib/aeolus_cli/command/list_command.rb
create mode 100644 lib/aeolus_cli/command/push_command.rb
create mode 100644 lib/aeolus_cli/model/base.rb
create mode 100644 lib/aeolus_cli/model/build.rb
create mode 100644 lib/aeolus_cli/model/image.rb
create mode 100644 lib/aeolus_cli/model/provider.rb
create mode 100644 lib/aeolus_cli/model/provider_account.rb
create mode 100644 lib/aeolus_cli/model/provider_image.rb
create mode 100644 lib/aeolus_cli/model/provider_type.rb
create mode 100644 lib/aeolus_cli/model/target_image.rb
delete mode 100644 lib/aeolus_image/command/base_command.rb
delete mode 100644 lib/aeolus_image/command/build_command.rb
delete mode 100644 lib/aeolus_image/command/config_parser.rb
delete mode 100644 lib/aeolus_image/command/delete_command.rb
delete mode 100644 lib/aeolus_image/command/import_command.rb
delete mode 100644 lib/aeolus_image/command/list_command.rb
delete mode 100644 lib/aeolus_image/command/push_command.rb
delete mode 100644 lib/aeolus_image/model/base.rb
delete mode 100644 lib/aeolus_image/model/build.rb
delete mode 100644 lib/aeolus_image/model/image.rb
delete mode 100644 lib/aeolus_image/model/provider.rb
delete mode 100644 lib/aeolus_image/model/provider_account.rb
delete mode 100644 lib/aeolus_image/model/provider_image.rb
delete mode 100644 lib/aeolus_image/model/provider_type.rb
delete mode 100644 lib/aeolus_image/model/target_image.rb
diff --git a/lib/aeolus_cli.rb b/lib/aeolus_cli.rb
index d55a15a..46dd8e5 100644
--- a/lib/aeolus_cli.rb
+++ b/lib/aeolus_cli.rb
@@ -14,19 +14,19 @@
require 'optparse'
require 'logger'
-require File.join(File.dirname(__FILE__), 'aeolus_image/command',
'base_command')
-require File.join(File.dirname(__FILE__), 'aeolus_image/command',
'list_command')
-require File.join(File.dirname(__FILE__), 'aeolus_image/command',
'build_command')
-require File.join(File.dirname(__FILE__), 'aeolus_image/command',
'push_command')
-require File.join(File.dirname(__FILE__), 'aeolus_image/command',
'import_command')
-require File.join(File.dirname(__FILE__), 'aeolus_image/command',
'delete_command')
-require File.join(File.dirname(__FILE__), 'aeolus_image/command',
'config_parser')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/command',
'base_command')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/command',
'list_command')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/command',
'build_command')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/command',
'push_command')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/command',
'import_command')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/command',
'delete_command')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/command',
'config_parser')
-require File.join(File.dirname(__FILE__), 'aeolus_image/model', 'base')
-require File.join(File.dirname(__FILE__), 'aeolus_image/model', 'image')
-require File.join(File.dirname(__FILE__), 'aeolus_image/model', 'build')
-require File.join(File.dirname(__FILE__), 'aeolus_image/model',
'provider_image')
-require File.join(File.dirname(__FILE__), 'aeolus_image/model',
'target_image')
-require File.join(File.dirname(__FILE__), 'aeolus_image/model',
'provider')
-require File.join(File.dirname(__FILE__), 'aeolus_image/model',
'provider_account')
-require File.join(File.dirname(__FILE__), 'aeolus_image/model',
'provider_type')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/model', 'base')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/model', 'image')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/model', 'build')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/model',
'provider_image')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/model',
'target_image')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/model',
'provider')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/model',
'provider_account')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/model',
'provider_type')
diff --git a/lib/aeolus_cli/command/base_command.rb
b/lib/aeolus_cli/command/base_command.rb
new file mode 100644
index 0000000..5d3f8ed
--- /dev/null
+++ b/lib/aeolus_cli/command/base_command.rb
@@ -0,0 +1,121 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'yaml'
+require 'rest_client'
+require 'nokogiri'
+
+module Aeolus
+ module Image
+ #This will house some methods that multiple Command classes need to use.
+ class BaseCommand
+ attr_accessor :options
+
+ def initialize(opts={}, logger=nil)
+ logger(logger)
+ @options = opts
+ @config_location = "~/.aeolus-cli"
+ @config = load_config
+ configure_active_resource
+ end
+
+ protected
+ def not_implemented
+ "This option or combination is not yet implemented"
+ end
+
+ def logger(logger=nil)
+ @logger ||= logger
+ unless @logger
+ @logger = Logger.new(STDOUT)
+ @logger.level = Logger::INFO
+ @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
+ end
+ return @logger
+ end
+
+ def read_file(path)
+ begin
+ full_path = File.expand_path(path)
+ if is_file?(path)
+ File.read(full_path)
+ else
+ return nil
+ end
+ rescue
+ nil
+ end
+ end
+
+ # TODO: Consider ripping all this file-related stuff into a module or
+ # class for better encapsulation and testability
+ def is_file?(path)
+ full_path = File.expand_path(path)
+ if File.exist?(full_path) && !File.directory?(full_path)
+ return true
+ end
+ false
+ end
+
+ def quit(code)
+ exit(code)
+ end
+
+ def validate_xml_document(schema_path, xml_string)
+ schema = Nokogiri::XML::RelaxNG(File.read(schema_path))
+ doc = Nokogiri::XML xml_string
+ schema.validate(doc)
+ end
+
+ def is_uuid?(id)
+ uuid = Regexp.new('[\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
+ uuid.match(id).nil? ? false : true
+ end
+
+ private
+ def configure_active_resource
+ Aeolus::CLI::Base.site = @config[:conductor][:url]
+ Aeolus::CLI::Base.user = @config[:conductor][:username]
+ Aeolus::CLI::Base.password = @config[:conductor][:password]
+ end
+
+ def load_config
+ begin
+ file_str = read_file(@config_location)
+ if is_file?(@config_location) && !file_str.include?(":url")
+ lines = File.readlines(File.expand_path((a)config_location)).map do |line|
+ "#" + line
+ end
+ File.open(File.expand_path(@config_location), 'w') do |file|
+ file.puts lines
+ end
+ write_file
+ end
+ write_file unless is_file?(@config_location)
+ YAML::load(File.open(File.expand_path(@config_location)))
+ rescue Errno::ENOENT
+ #TODO: Create a custom exception to wrap CLI Exceptions
+ raise "Unable to locate or write configuration file: \"" +
@config_location + "\""
+ end
+ end
+
+ def write_file
+ example = File.read(File.expand_path(File.dirname(__FILE__) +
"/../../../examples/aeolus-cli"))
+ File.open(File.expand_path(@config_location), 'a+') do |f|
+ f.write(example)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/aeolus_cli/command/build_command.rb
b/lib/aeolus_cli/command/build_command.rb
new file mode 100644
index 0000000..651b0e9
--- /dev/null
+++ b/lib/aeolus_cli/command/build_command.rb
@@ -0,0 +1,82 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'imagefactory'
+
+module Aeolus
+ module Image
+ class BuildCommand < BaseCommand
+ attr_accessor :console
+ def initialize(opts={}, logger=nil)
+ super(opts, logger)
+ default = {
+ :template_str => '',
+ :template => '',
+ :target => [],
+ :image => '',
+ :build => ''
+ }
+ @options = default.merge(@options)
+ @console = ImageFactoryConsole.new()
+ @console.start
+ end
+
+ def run
+ if combo_implemented?
+ @options[:template_str] = read_file(@options[:template])
+ if @options[:template_str].nil?
+ puts "Cannot find specified file"
+ quit(1)
+ end
+
+ # Validate XML against TDL Schema
+ errors = validate_xml_document(File.dirname(__FILE__) +
"/../../../examples/tdl.rng", @options[:template_str])
+ if errors.length > 0
+ puts "ERROR: The given Template does not conform to the TDL Schema, see
below for specific details:"
+ errors.each do |error|
+ puts "- " + error.message
+ end
+ quit(1)
+ end
+
+ #This is a temporary hack in case the agent doesn't show up on bus
immediately
+ sleep(5)
+ @console.build(@options[:template_str], @options[:target], @options[:image],
@options[:build]).each do |adaptor|
+ puts ""
+ puts "Target Image: #{adaptor.image_id}"
+ puts "Image: #{adaptor.image}"
+ puts "Build: #{adaptor.build}"
+ puts "Status: #{adaptor.status}"
+ puts "Percent Complete: #{adaptor.percent_complete}"
+ end
+ quit(0)
+ end
+ end
+
+ def combo_implemented?
+ if @options[:template].empty? || @options[:target].empty?
+ puts "This combination of parameters is not currently supported"
+ quit(1)
+ end
+ true
+ end
+
+ def quit(code)
+ @console.shutdown
+ super
+ end
+
+ end
+ end
+end
diff --git a/lib/aeolus_cli/command/config_parser.rb
b/lib/aeolus_cli/command/config_parser.rb
new file mode 100644
index 0000000..98e1c00
--- /dev/null
+++ b/lib/aeolus_cli/command/config_parser.rb
@@ -0,0 +1,242 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'optparse'
+require 'logger'
+
+module Aeolus
+ module Image
+ class ConfigParser
+ COMMANDS = %w(list build push import delete)
+ attr_accessor :options, :command, :args
+
+ def initialize(argv)
+ @args = argv
+ # Default options
+ @options = {}
+ parse
+ end
+
+ def process
+ # Check for command, then call appropriate Optionparser and initiate
+ # call to that class.
+ @command = @args.shift
+ # Eventually get the config file from user dir if it exists.
+ # File.expand_path("~")
+ if COMMANDS.include?(@command)
+ self.send((a)command.to_sym)
+ else
+ @args << "-h"
+ puts "Valid command required: \n\n"
+ parse
+ end
+ end
+
+ private
+ def parse
+ @optparse ||= OptionParser.new do|opts|
+ opts.banner = "Usage: aeolus-image [#{COMMANDS.join('|')}]
[general options] [command options]"
+
+ opts.separator ""
+ opts.separator "General options:"
+ opts.on('-u', '--user USERNAME', 'Conductor username')
do |user|
+ @options[:user] = user
+ end
+ opts.on('-w', '--password PASSWORD', 'Conductor
password') do |pw|
+ @options[:password] = pw
+ end
+ opts.on('-d', '--id ID', 'id for a given object') do
|id|
+ @options[:id] = id
+ end
+ opts.on('-r', '--description NAME', 'description (e.g.
"<image><name>MyImage</name></image>" or
"/home/user/myImage.xml")') do |description|
+ @options[:description] = description
+ end
+ opts.on('-r', '--provider NAME1,NAME2', Array,'name of
specific provider (ie ec2-us-east1)') do |name|
+ @options[:provider] = name
+ end
+ opts.on('-I', '--image ID', 'ID of the base image, can be
used in build and push commands, see examples') do |id|
+ @options[:image] = id
+ end
+ opts.on('-T', '--target TARGET1,TARGET2', Array, 'provider
type (ec2, rackspace, rhevm, etc)') do |name|
+ @options[:target] = name
+ end
+ opts.on('-d', '--daemon', 'run as a background
process') do
+ @options[:subcommand] = :images
+ end
+ opts.on( '-h', '--help', 'Get usage information for this
tool') do
+ puts opts
+ exit(0)
+ end
+
+ opts.separator ""
+ opts.separator "List options:"
+ opts.on('-i', '--images', 'Retrieve a list of images')
do
+ @options[:subcommand] = :images
+ end
+ opts.on('-b', '--builds ID', 'Retrieve the builds of an
image') do |id|
+ @options[:subcommand] = :builds
+ @options[:id] = id
+ end
+ opts.on('-t', '--targetimages ID', 'Retrieve the target
images from a build') do |id|
+ @options[:subcommand] = :targetimages
+ @options[:id] = id
+ end
+ opts.on('-P', '--providerimages ID', 'Retrieve the provider
images from a target image') do |id|
+ @options[:subcommand] = :providerimages
+ @options[:id] = id
+ end
+ opts.on('-g', '--targets', 'Retrieve the values available
for the --target parameter') do
+ @options[:subcommand] = :targets
+ end
+ opts.on('-p', '--providers', 'Retrieve the values available
for the --provider parameter') do
+ @options[:subcommand] = :providers
+ end
+ opts.on('-a', '--accounts', 'Retrieve the values available
for the --account parameter') do
+ @options[:subcommand] = :accounts
+ end
+
+ opts.separator ""
+ opts.separator "Build options:"
+ opts.on('-e', '--template FILE', 'path to file that
contains template xml') do |file|
+ @options[:template] = file
+ end
+
+ opts.separator ""
+ opts.separator "Push options:"
+ opts.on('-B', '--build ID', 'push all target images for a
build, to same providers as previously') do |id|
+ @options[:build] = id
+ end
+ opts.on('-A', '--account NAME', 'name of specific provider
account to use for push') do |name|
+ @options[:account] = name
+ end
+
+ opts.separator ""
+ opts.separator "Delete options:"
+ opts.on('-I', '--image ID', 'delete build image and
associated objects') do |id|
+ @options[:subcommand] = :image
+ @options[:image] = id
+ end
+ opts.on('-B', '--build ID', 'delete build and associated
objects') do |id|
+ @options[:subcommand] = :build
+ @options[:build] = id
+ end
+ opts.on('-m', '--targetimage ID', 'delete target image and
its provider images') do |id|
+ @options[:subcommand] = :target_image
+ @options[:targetimage] = id
+ end
+ opts.on('-D', '--providerimage ID', 'delete provider
image') do |id|
+ @options[:subcommand] = :provider_image
+ @options[:providerimage] = id
+ end
+ opts.on('-W', '--iwhd', 'Delete everything stored in
IWHD') do
+ @options[:subcommand] = :iwhd
+ end
+
+ opts.separator ""
+ opts.separator "List Examples:"
+ opts.separator "aeolus-image list --images # list
available images"
+ opts.separator "aeolus-image list --builds $image_id # list the
builds of an image"
+ opts.separator "aeolus-image list --targetimages $build_id # list the
target images from a build"
+ opts.separator "aeolus-image list --providerimages $target_id # list the
provider images from a target image"
+ opts.separator "aeolus-image list --providerimages all # list all
provider images"
+ opts.separator "aeolus-image list --targets # list the
values available for the --target parameter"
+ opts.separator "aeolus-image list --providers # list the
values available for the --provider parameter"
+ opts.separator "aeolus-image list --accounts # list the
values available for the --account parameter"
+
+ opts.separator ""
+ opts.separator "Build examples:"
+ opts.separator "aeolus-image build --target ec2 --template my.tmpl #
build a new image for ec2 from the template"
+ opts.separator "aeolus-image build --image $image_id # (NOT
IMPLEMENTED) rebuild the image template and targets from latest build"
+ opts.separator %q{aeolus-image build --target ec2,rackspace \ # rebuild
the image with a new template and set of targets
+ --image $image_i \
+ --template my.tmpl}
+
+ opts.separator ""
+ opts.separator "Push examples:"
+ opts.separator "aeolus-image push --provider ec2-us-east-1 --id $image_id
# initial push of an image build via image id to the specified provider"
+ opts.separator "aeolus-image push --build $build_id
# push an image build via build id to the specified provider"
+ opts.separator "aeolus-image push --account $provider_account --build
$build_id # (NOT IMPLEMENTED) ditto, using a specific provider account"
+ opts.separator "aeolus-image push --image $image_id
# (NOT IMPLEMENTED) push all the target images for the latest build"
+
+ opts.separator ""
+ opts.separator "Import examples:"
+ opts.separator "aeolus-image import --provider ec2-us-east-1 --target ec2
--id $ami_id # import an AMI from the specified provider"
+ opts.separator "aeolus-image import --provider ec2-us-east-1 --target ec2
--id $ami_id --description '<image><name>My
Image</name></image>' # import an AMI from the specified provider"
+ opts.separator "aeolus-image import --provider ec2-us-east-1 --target ec2
--id $ami_id --description <path_to_xml_file> # import an AMI from the specified
provider"
+
+ opts.separator ""
+ opts.separator "Delete examples: (DELETE CURRENTLY NOT IMPLEMENTED)
"
+ opts.separator "aeolus-image delete --build $build_id #
deletes a build, updating latest/parent references as appropriate"
+ opts.separator "aeolus-image delete --targetimage $target_image #
deletes a target image and its provider images"
+ opts.separator "aeolus-image delete --providerimage $provider_image #
deletes a provider image"
+ end
+
+ begin
+ @optparse.parse!(@args)
+ rescue OptionParser::InvalidOption
+ puts "Warning: Invalid option"
+ exit(1)
+ rescue OptionParser::MissingArgument => e
+ puts "Warning, #{e.message}"
+ exit(1)
+ end
+ end
+
+ # TODO: Remove all this boilerplate and replace with some metaprogramming,
+ # perhaps method_missing
+ def list
+ # TODO: Instantiate and call object matching command type, for example:
+ # l = ListCommand.new(@options)
+ # Each Command will call it's own internal method depending on the contents
of the hash.
+ # For the list example above, that object would call a method 'images'
based on the item
+ # @options[:subcommand] being :images, so internally that class may do something
like:
+ # self.send(@options[:subcommand])
+ if @options[:subcommand].nil?
+ # TODO: Pull out Print Usage into seporate method, and print
+ puts "Could not find subcommand for list, run `./aeolus-image --help` for
usage instructions"
+ exit(1)
+ else
+ list_command = ListCommand.new(@options)
+ list_command.send(@options[:subcommand])
+ end
+ end
+
+ def build
+ b = BuildCommand.new(@options)
+ b.run
+ end
+
+ def push
+ b = PushCommand.new(@options)
+ b.run
+ end
+
+ def import
+ import_command = ImportCommand.new(@options)
+ import_command.import_image
+ end
+
+ def delete
+ if @options[:subcommand].nil?
+ # TODO: Pull out Print Usage into seporate method, and print
+ puts "Could not find subcommand for delete, run `./aeolus-image --help`
for usage instructions"
+ exit(1)
+ else
+ delete_command = DeleteCommand.new(@options)
+ delete_command.send(@options[:subcommand])
+ end
+ end
+ end
+ end
+end
diff --git a/lib/aeolus_cli/command/delete_command.rb
b/lib/aeolus_cli/command/delete_command.rb
new file mode 100644
index 0000000..ba9078e
--- /dev/null
+++ b/lib/aeolus_cli/command/delete_command.rb
@@ -0,0 +1,96 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module Image
+ class DeleteCommand < BaseCommand
+ def initialize(opts={}, logger=nil)
+ super(opts, logger)
+ end
+
+ def provider_image
+ if pi = ProviderImage.find(@options[:providerimage])
+ if pi.delete!
+ puts "b: " + @options[:providerimage] + " Deleted
Successfully"
+ exit(0)
+ end
+ puts "ERROR: Unable to Delete Provider Image: " +
@options[:providerimage]
+ else
+ puts "Provider Image: " + @options[:providerimage] + " does not
exist"
+ end
+ exit(1)
+ end
+
+ def target_image
+ if ti = TargetImage.find(@options[:targetimage])
+ if ti.delete!
+ puts "Target Image: " + @options[:targetimage] + " Deleted
Successfully"
+ exit(0)
+ end
+ puts "ERROR: Unable to Delete Target Image: " +
@options[:targetimage]
+ else
+ puts "Target Image: " + @options[:targetimage] + " does not
exist"
+ end
+ exit(1)
+ end
+
+ def build
+ if b = ImageBuild.find(@options[:build])
+ if b.delete!
+ puts "Build: " + @options[:build] + " Deleted
Successfully"
+ exit(0)
+ end
+ puts "ERROR: Unable to Delete Build: " + @options[:build]
+ else
+ puts "Build: " + @options[:build] + " does not exist"
+ end
+ exit(1)
+ end
+
+ def image
+ if i = Image.find(@options[:image])
+ if i.delete!
+ puts "Image: " + @options[:image] + " Deleted
Successfully"
+ exit(0)
+ end
+ puts "ERROR: Unable to Delete Image: " + @options[:image]
+ else
+ puts "Image: " + @options[:image] + " does not exist"
+ end
+ exit(1)
+ end
+
+ # Deletes all Images,Builds,TargetImages,ProviderImages
+ def iwhd
+ Image.all.each do |image|
+ Image.delete(image.uuid)
+ end
+
+ ImageBuild.all.each do |build|
+ ImageBuild.delete(build.uuid)
+ end
+
+ TargetImage.all.each do |target_image|
+ TargetImage.delete(target_image.uuid)
+ end
+
+ ProviderImage.all.each do |provider_image|
+ ProviderImage.delete(provider_image.uuid)
+ end
+ puts "Deleted all objects in IWHD"
+ exit(0)
+ end
+ end
+ end
+end
diff --git a/lib/aeolus_cli/command/import_command.rb
b/lib/aeolus_cli/command/import_command.rb
new file mode 100644
index 0000000..8fa15cf
--- /dev/null
+++ b/lib/aeolus_cli/command/import_command.rb
@@ -0,0 +1,58 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module Image
+ class ImportCommand < BaseCommand
+ def initialize(opts={}, logger=nil)
+ super(opts, logger)
+ default = {
+ :image => '',
+ :build => '',
+ :id => '',
+ :description => '<image><name>' + @options[:id] +
'</name></image>',
+ :target => '',
+ :provider => ''
+ }
+ @options = default.merge(@options)
+ @console = ImageFactoryConsole.new()
+ @console.start
+ end
+
+ def import_image
+ description = read_file(@options[:description])
+ if !description.nil?
+ @options[:description] = description
+ end
+ # TODO: Validate Description XML
+
+ #This is a temporary hack in case the agent doesn't show up on bus
+ #immediately
+ sleep(5)
+ import_map = @console.import_image(@options[:image], @options[:build],
@options[:id], @options[:description], @options[:target].first,
@options[:provider].first)
+ puts ""
+ puts "Target Image: " + import_map['target_image']
+ puts "Image: " + import_map['image']
+ puts "Build: " + import_map['build']
+ puts "Provider Image: " + import_map['provider_image']
+ quit(0)
+ end
+
+ def quit(code)
+ @console.shutdown
+ super
+ end
+ end
+ end
+end
diff --git a/lib/aeolus_cli/command/list_command.rb
b/lib/aeolus_cli/command/list_command.rb
new file mode 100644
index 0000000..f350c9a
--- /dev/null
+++ b/lib/aeolus_cli/command/list_command.rb
@@ -0,0 +1,164 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module Image
+ class ListCommand < BaseCommand
+ def initialize(opts={}, logger=nil)
+ super(opts, logger)
+ end
+
+ def images
+ check_bucket_exists("images")
+ images = [["IMAGE ID", "LASTEST PUSHED BUILD",
"NAME", "OS", "OS VERSION", "ARCH",
"DESCRIPTION"]]
+ Image.all.each do |i|
+ images << [i.uuid, (i.latest_pushed_build.nil? ? "" :
i.latest_pushed_build.uuid), i.name, i.os.name, i.os.version, i.os.arch, i.description]
+ end
+ format_print(images)
+ quit(0)
+ end
+
+ def builds
+ builds = [["Build ID"]]
+ image = Image.find(@options[:id])
+ if image
+ image.image_builds.each do |b|
+ builds << [b.uuid]
+ end
+ format_print(builds)
+ else
+ puts "ERROR: could not find Image with ID: " + options[:id]
+ end
+ quit(0)
+ end
+
+ def targetimages
+ targetimages = [["Target Image Id"]]
+ build = ImageBuild.find(@options[:id])
+ if build
+ build.target_images.each do |ti|
+ targetimages << [ti.uuid]
+ end
+ format_print(targetimages)
+ else
+ puts "ERROR: could not find Build with ID: " + options[:id]
+ end
+ quit(0)
+ end
+
+ def providerimages
+ providerimages = [["PROVIDER IMAGE", "PROVIDER", "TARGET
IMAGE", "TARGET IDENTIFIER"]]
+ target_image = TargetImage.find(@options[:id])
+ if target_image
+ target_image.provider_images.each do |pi|
+ providerimages << [pi.uuid, pi.provider_name, target_image.uuid,
target_image.target]
+ end
+ format_print(providerimages)
+ else
+ puts "ERROR: could not find Target Image with ID: " + options[:id]
+ end
+ quit(0)
+ end
+
+ def targets
+ targets = [["NAME", "TARGET CODE"]]
+ targets << ["Mock", "mock"]
+ targets << ["Amazon EC2", "ec2"]
+ targets << ["RHEV-M", "rhevm"]
+ targets << ["VMware vSphere", "vsphere"]
+ targets << ["Condor Cloud", "condor_cloud"]
+ format_print(targets)
+ quit(0)
+ end
+
+ def providers
+ print_values = [["NAME", "TYPE", "URL"]]
+
+ doc = Nokogiri::XML conductor['/providers'].get
+ doc.xpath("/providers/provider").each do |provider|
+ print_values << [provider.xpath("name").text,
provider.xpath("provider_type").text, provider.xpath("url").text]
+ end
+
+ format_print(print_values)
+ quit(0)
+ end
+
+ def accounts
+ print_values = [["NAME", "PROVIDER", "PROVIDER
TYPE"]]
+ doc = Nokogiri::XML conductor['/provider_accounts/'].get
+ doc.xpath("/provider_accounts/provider_account").each do |account|
+ print_values << [account.xpath("name").text,
account.xpath("provider").text, account.xpath("provider_type").text]
+ end
+
+ format_print(print_values)
+ quit(0)
+ end
+
+ private
+ # Takes a 2D array of strings and neatly prints them to STDOUT
+ def format_print(print_values)
+ widths = Array.new(print_values[0].size, 0)
+ print_values.each do |print_value|
+ widths = widths.zip(print_value).map! {|width, value| value.length > width ?
value.length : width }
+ end
+
+ print_values.each do |print_value|
+ widths.zip(print_value) do |width, value|
+ printf("%-#{width + 5}s", value)
+ end
+ puts ""
+ end
+ end
+
+ def get_template_info(image, targetimage)
+ begin
+ template = Nokogiri::XML iwhd["/templates/" +
iwhd["/target_images/" + targetimage + "/template"].get].get
+ [template.xpath("/template/name").text,
+ iwhd["/target_images/" + targetimage + "/target"].get,
+ template.xpath("/template/os/name").text,
+ template.xpath("/template/os/version").text,
+ template.xpath("/template/os/arch").text,
+ template.xpath("/template/description").text]
+ rescue
+ end
+ end
+
+ def get_image_name(image)
+ begin
+ template_xml = Nokogiri::XML iwhd["images/" + image].get
+ template_xml.xpath("/image/name").text
+ rescue
+ ""
+ end
+ end
+
+ def lastest_pushed(image)
+ begin
+ build = iwhd["/images/" + image + "/latest_build"].get
+ build.nil? ? "" : build
+ rescue
+ ""
+ end
+ end
+
+ def check_bucket_exists(bucket)
+ begin
+ iwhd["/" + bucket].get
+ rescue
+ nil
+ end
+ end
+ end
+ end
+end
diff --git a/lib/aeolus_cli/command/push_command.rb
b/lib/aeolus_cli/command/push_command.rb
new file mode 100644
index 0000000..275ed37
--- /dev/null
+++ b/lib/aeolus_cli/command/push_command.rb
@@ -0,0 +1,86 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'rest_client'
+
+module Aeolus
+ module Image
+ class PushCommand < BaseCommand
+ attr_accessor :console
+ def initialize(opts={}, logger=nil)
+ super(opts, logger)
+ default = {
+ :provider => [],
+ :id => '',
+ :build => ''
+ }
+ @options = default.merge(@options)
+ @console = ImageFactoryConsole.new()
+ @console.start
+ end
+ def run
+ begin
+ if combo_implemented?
+ if !@options[:id].empty? && pushed?(@options[:id])
+ puts "ERROR: This image has already been pushed, to push to another
provider please push via build-id rather than image-id"
+ puts "e.g. aeolus-image push --provider <provider> --build
<build-id>"
+ quit(1)
+ end
+
+ sleep(5)
+ @console.push(@options[:provider], get_creds, @options[:id],
@options[:build]).each do |adaptor|
+ puts ""
+ puts "Provider Image: #{adaptor.image_id}"
+ puts "Image: #{adaptor.image}"
+ puts "Build: #{adaptor.build}"
+ puts "Status: #{adaptor.status}"
+ puts "Percent Complete: #{adaptor.percent_complete}"
+ end
+ quit(0)
+ end
+ rescue
+ puts "An Error occured whilst trying to push this build, please check
aeolus-image --help for details on how to use this command"
+ quit(1)
+ end
+ end
+
+ def get_creds
+ conductor['provider_accounts'].get
+ end
+
+ def combo_implemented?
+ if @options[:provider].empty? || (@options[:build].empty? &&
@options[:id].empty?)
+ puts "This combination of parameters is not currently supported"
+ quit(1)
+ end
+ true
+ end
+
+ private
+ def quit(code)
+ @console.shutdown
+ exit(code)
+ end
+
+ def pushed?(image)
+ begin
+ uuid = Regexp.new('[\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
+ uuid.match(iwhd["/images/" + image +
"/latest_unpushed"].get).nil? ? true : false
+ rescue
+ true
+ end
+ end
+ end
+ end
+end
diff --git a/lib/aeolus_cli/model/base.rb b/lib/aeolus_cli/model/base.rb
new file mode 100644
index 0000000..692a87a
--- /dev/null
+++ b/lib/aeolus_cli/model/base.rb
@@ -0,0 +1,31 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'active_resource'
+module Aeolus
+ module CLI
+ class Base < ActiveResource::Base
+ self.timeout = 600
+ class << self
+ def instantiate_collection(collection, prefix_options = {})
+ unless collection.kind_of? Array
+ [instantiate_record(collection, prefix_options)]
+ else
+ collection.collect! { |record| instantiate_record(record, prefix_options) }
+ end
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/aeolus_cli/model/build.rb b/lib/aeolus_cli/model/build.rb
new file mode 100644
index 0000000..624f18d
--- /dev/null
+++ b/lib/aeolus_cli/model/build.rb
@@ -0,0 +1,20 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module CLI
+ class Build < Base
+ end
+ end
+end
diff --git a/lib/aeolus_cli/model/image.rb b/lib/aeolus_cli/model/image.rb
new file mode 100644
index 0000000..249009f
--- /dev/null
+++ b/lib/aeolus_cli/model/image.rb
@@ -0,0 +1,20 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module CLI
+ class Image < Base
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/aeolus_cli/model/provider.rb b/lib/aeolus_cli/model/provider.rb
new file mode 100644
index 0000000..2508833
--- /dev/null
+++ b/lib/aeolus_cli/model/provider.rb
@@ -0,0 +1,20 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module CLI
+ class Provider < Base
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/aeolus_cli/model/provider_account.rb
b/lib/aeolus_cli/model/provider_account.rb
new file mode 100644
index 0000000..e10c856
--- /dev/null
+++ b/lib/aeolus_cli/model/provider_account.rb
@@ -0,0 +1,20 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module CLI
+ class ProviderAccount < Base
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/aeolus_cli/model/provider_image.rb
b/lib/aeolus_cli/model/provider_image.rb
new file mode 100644
index 0000000..c3d3a52
--- /dev/null
+++ b/lib/aeolus_cli/model/provider_image.rb
@@ -0,0 +1,20 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module CLI
+ class ProviderImage < Base
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/aeolus_cli/model/provider_type.rb
b/lib/aeolus_cli/model/provider_type.rb
new file mode 100644
index 0000000..4bfbf88
--- /dev/null
+++ b/lib/aeolus_cli/model/provider_type.rb
@@ -0,0 +1,20 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module CLI
+ class ProviderType < Base
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/aeolus_cli/model/target_image.rb b/lib/aeolus_cli/model/target_image.rb
new file mode 100644
index 0000000..9972372
--- /dev/null
+++ b/lib/aeolus_cli/model/target_image.rb
@@ -0,0 +1,20 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module Aeolus
+ module CLI
+ class TargetImage < Base
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/aeolus_image/command/base_command.rb
b/lib/aeolus_image/command/base_command.rb
deleted file mode 100644
index 5d3f8ed..0000000
--- a/lib/aeolus_image/command/base_command.rb
+++ /dev/null
@@ -1,121 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'yaml'
-require 'rest_client'
-require 'nokogiri'
-
-module Aeolus
- module Image
- #This will house some methods that multiple Command classes need to use.
- class BaseCommand
- attr_accessor :options
-
- def initialize(opts={}, logger=nil)
- logger(logger)
- @options = opts
- @config_location = "~/.aeolus-cli"
- @config = load_config
- configure_active_resource
- end
-
- protected
- def not_implemented
- "This option or combination is not yet implemented"
- end
-
- def logger(logger=nil)
- @logger ||= logger
- unless @logger
- @logger = Logger.new(STDOUT)
- @logger.level = Logger::INFO
- @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
- end
- return @logger
- end
-
- def read_file(path)
- begin
- full_path = File.expand_path(path)
- if is_file?(path)
- File.read(full_path)
- else
- return nil
- end
- rescue
- nil
- end
- end
-
- # TODO: Consider ripping all this file-related stuff into a module or
- # class for better encapsulation and testability
- def is_file?(path)
- full_path = File.expand_path(path)
- if File.exist?(full_path) && !File.directory?(full_path)
- return true
- end
- false
- end
-
- def quit(code)
- exit(code)
- end
-
- def validate_xml_document(schema_path, xml_string)
- schema = Nokogiri::XML::RelaxNG(File.read(schema_path))
- doc = Nokogiri::XML xml_string
- schema.validate(doc)
- end
-
- def is_uuid?(id)
- uuid = Regexp.new('[\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
- uuid.match(id).nil? ? false : true
- end
-
- private
- def configure_active_resource
- Aeolus::CLI::Base.site = @config[:conductor][:url]
- Aeolus::CLI::Base.user = @config[:conductor][:username]
- Aeolus::CLI::Base.password = @config[:conductor][:password]
- end
-
- def load_config
- begin
- file_str = read_file(@config_location)
- if is_file?(@config_location) && !file_str.include?(":url")
- lines = File.readlines(File.expand_path((a)config_location)).map do |line|
- "#" + line
- end
- File.open(File.expand_path(@config_location), 'w') do |file|
- file.puts lines
- end
- write_file
- end
- write_file unless is_file?(@config_location)
- YAML::load(File.open(File.expand_path(@config_location)))
- rescue Errno::ENOENT
- #TODO: Create a custom exception to wrap CLI Exceptions
- raise "Unable to locate or write configuration file: \"" +
@config_location + "\""
- end
- end
-
- def write_file
- example = File.read(File.expand_path(File.dirname(__FILE__) +
"/../../../examples/aeolus-cli"))
- File.open(File.expand_path(@config_location), 'a+') do |f|
- f.write(example)
- end
- end
- end
- end
-end
diff --git a/lib/aeolus_image/command/build_command.rb
b/lib/aeolus_image/command/build_command.rb
deleted file mode 100644
index 651b0e9..0000000
--- a/lib/aeolus_image/command/build_command.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'imagefactory'
-
-module Aeolus
- module Image
- class BuildCommand < BaseCommand
- attr_accessor :console
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- default = {
- :template_str => '',
- :template => '',
- :target => [],
- :image => '',
- :build => ''
- }
- @options = default.merge(@options)
- @console = ImageFactoryConsole.new()
- @console.start
- end
-
- def run
- if combo_implemented?
- @options[:template_str] = read_file(@options[:template])
- if @options[:template_str].nil?
- puts "Cannot find specified file"
- quit(1)
- end
-
- # Validate XML against TDL Schema
- errors = validate_xml_document(File.dirname(__FILE__) +
"/../../../examples/tdl.rng", @options[:template_str])
- if errors.length > 0
- puts "ERROR: The given Template does not conform to the TDL Schema, see
below for specific details:"
- errors.each do |error|
- puts "- " + error.message
- end
- quit(1)
- end
-
- #This is a temporary hack in case the agent doesn't show up on bus
immediately
- sleep(5)
- @console.build(@options[:template_str], @options[:target], @options[:image],
@options[:build]).each do |adaptor|
- puts ""
- puts "Target Image: #{adaptor.image_id}"
- puts "Image: #{adaptor.image}"
- puts "Build: #{adaptor.build}"
- puts "Status: #{adaptor.status}"
- puts "Percent Complete: #{adaptor.percent_complete}"
- end
- quit(0)
- end
- end
-
- def combo_implemented?
- if @options[:template].empty? || @options[:target].empty?
- puts "This combination of parameters is not currently supported"
- quit(1)
- end
- true
- end
-
- def quit(code)
- @console.shutdown
- super
- end
-
- end
- end
-end
diff --git a/lib/aeolus_image/command/config_parser.rb
b/lib/aeolus_image/command/config_parser.rb
deleted file mode 100644
index 98e1c00..0000000
--- a/lib/aeolus_image/command/config_parser.rb
+++ /dev/null
@@ -1,242 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'optparse'
-require 'logger'
-
-module Aeolus
- module Image
- class ConfigParser
- COMMANDS = %w(list build push import delete)
- attr_accessor :options, :command, :args
-
- def initialize(argv)
- @args = argv
- # Default options
- @options = {}
- parse
- end
-
- def process
- # Check for command, then call appropriate Optionparser and initiate
- # call to that class.
- @command = @args.shift
- # Eventually get the config file from user dir if it exists.
- # File.expand_path("~")
- if COMMANDS.include?(@command)
- self.send((a)command.to_sym)
- else
- @args << "-h"
- puts "Valid command required: \n\n"
- parse
- end
- end
-
- private
- def parse
- @optparse ||= OptionParser.new do|opts|
- opts.banner = "Usage: aeolus-image [#{COMMANDS.join('|')}]
[general options] [command options]"
-
- opts.separator ""
- opts.separator "General options:"
- opts.on('-u', '--user USERNAME', 'Conductor username')
do |user|
- @options[:user] = user
- end
- opts.on('-w', '--password PASSWORD', 'Conductor
password') do |pw|
- @options[:password] = pw
- end
- opts.on('-d', '--id ID', 'id for a given object') do
|id|
- @options[:id] = id
- end
- opts.on('-r', '--description NAME', 'description (e.g.
"<image><name>MyImage</name></image>" or
"/home/user/myImage.xml")') do |description|
- @options[:description] = description
- end
- opts.on('-r', '--provider NAME1,NAME2', Array,'name of
specific provider (ie ec2-us-east1)') do |name|
- @options[:provider] = name
- end
- opts.on('-I', '--image ID', 'ID of the base image, can be
used in build and push commands, see examples') do |id|
- @options[:image] = id
- end
- opts.on('-T', '--target TARGET1,TARGET2', Array, 'provider
type (ec2, rackspace, rhevm, etc)') do |name|
- @options[:target] = name
- end
- opts.on('-d', '--daemon', 'run as a background
process') do
- @options[:subcommand] = :images
- end
- opts.on( '-h', '--help', 'Get usage information for this
tool') do
- puts opts
- exit(0)
- end
-
- opts.separator ""
- opts.separator "List options:"
- opts.on('-i', '--images', 'Retrieve a list of images')
do
- @options[:subcommand] = :images
- end
- opts.on('-b', '--builds ID', 'Retrieve the builds of an
image') do |id|
- @options[:subcommand] = :builds
- @options[:id] = id
- end
- opts.on('-t', '--targetimages ID', 'Retrieve the target
images from a build') do |id|
- @options[:subcommand] = :targetimages
- @options[:id] = id
- end
- opts.on('-P', '--providerimages ID', 'Retrieve the provider
images from a target image') do |id|
- @options[:subcommand] = :providerimages
- @options[:id] = id
- end
- opts.on('-g', '--targets', 'Retrieve the values available
for the --target parameter') do
- @options[:subcommand] = :targets
- end
- opts.on('-p', '--providers', 'Retrieve the values available
for the --provider parameter') do
- @options[:subcommand] = :providers
- end
- opts.on('-a', '--accounts', 'Retrieve the values available
for the --account parameter') do
- @options[:subcommand] = :accounts
- end
-
- opts.separator ""
- opts.separator "Build options:"
- opts.on('-e', '--template FILE', 'path to file that
contains template xml') do |file|
- @options[:template] = file
- end
-
- opts.separator ""
- opts.separator "Push options:"
- opts.on('-B', '--build ID', 'push all target images for a
build, to same providers as previously') do |id|
- @options[:build] = id
- end
- opts.on('-A', '--account NAME', 'name of specific provider
account to use for push') do |name|
- @options[:account] = name
- end
-
- opts.separator ""
- opts.separator "Delete options:"
- opts.on('-I', '--image ID', 'delete build image and
associated objects') do |id|
- @options[:subcommand] = :image
- @options[:image] = id
- end
- opts.on('-B', '--build ID', 'delete build and associated
objects') do |id|
- @options[:subcommand] = :build
- @options[:build] = id
- end
- opts.on('-m', '--targetimage ID', 'delete target image and
its provider images') do |id|
- @options[:subcommand] = :target_image
- @options[:targetimage] = id
- end
- opts.on('-D', '--providerimage ID', 'delete provider
image') do |id|
- @options[:subcommand] = :provider_image
- @options[:providerimage] = id
- end
- opts.on('-W', '--iwhd', 'Delete everything stored in
IWHD') do
- @options[:subcommand] = :iwhd
- end
-
- opts.separator ""
- opts.separator "List Examples:"
- opts.separator "aeolus-image list --images # list
available images"
- opts.separator "aeolus-image list --builds $image_id # list the
builds of an image"
- opts.separator "aeolus-image list --targetimages $build_id # list the
target images from a build"
- opts.separator "aeolus-image list --providerimages $target_id # list the
provider images from a target image"
- opts.separator "aeolus-image list --providerimages all # list all
provider images"
- opts.separator "aeolus-image list --targets # list the
values available for the --target parameter"
- opts.separator "aeolus-image list --providers # list the
values available for the --provider parameter"
- opts.separator "aeolus-image list --accounts # list the
values available for the --account parameter"
-
- opts.separator ""
- opts.separator "Build examples:"
- opts.separator "aeolus-image build --target ec2 --template my.tmpl #
build a new image for ec2 from the template"
- opts.separator "aeolus-image build --image $image_id # (NOT
IMPLEMENTED) rebuild the image template and targets from latest build"
- opts.separator %q{aeolus-image build --target ec2,rackspace \ # rebuild
the image with a new template and set of targets
- --image $image_i \
- --template my.tmpl}
-
- opts.separator ""
- opts.separator "Push examples:"
- opts.separator "aeolus-image push --provider ec2-us-east-1 --id $image_id
# initial push of an image build via image id to the specified provider"
- opts.separator "aeolus-image push --build $build_id
# push an image build via build id to the specified provider"
- opts.separator "aeolus-image push --account $provider_account --build
$build_id # (NOT IMPLEMENTED) ditto, using a specific provider account"
- opts.separator "aeolus-image push --image $image_id
# (NOT IMPLEMENTED) push all the target images for the latest build"
-
- opts.separator ""
- opts.separator "Import examples:"
- opts.separator "aeolus-image import --provider ec2-us-east-1 --target ec2
--id $ami_id # import an AMI from the specified provider"
- opts.separator "aeolus-image import --provider ec2-us-east-1 --target ec2
--id $ami_id --description '<image><name>My
Image</name></image>' # import an AMI from the specified provider"
- opts.separator "aeolus-image import --provider ec2-us-east-1 --target ec2
--id $ami_id --description <path_to_xml_file> # import an AMI from the specified
provider"
-
- opts.separator ""
- opts.separator "Delete examples: (DELETE CURRENTLY NOT IMPLEMENTED)
"
- opts.separator "aeolus-image delete --build $build_id #
deletes a build, updating latest/parent references as appropriate"
- opts.separator "aeolus-image delete --targetimage $target_image #
deletes a target image and its provider images"
- opts.separator "aeolus-image delete --providerimage $provider_image #
deletes a provider image"
- end
-
- begin
- @optparse.parse!(@args)
- rescue OptionParser::InvalidOption
- puts "Warning: Invalid option"
- exit(1)
- rescue OptionParser::MissingArgument => e
- puts "Warning, #{e.message}"
- exit(1)
- end
- end
-
- # TODO: Remove all this boilerplate and replace with some metaprogramming,
- # perhaps method_missing
- def list
- # TODO: Instantiate and call object matching command type, for example:
- # l = ListCommand.new(@options)
- # Each Command will call it's own internal method depending on the contents
of the hash.
- # For the list example above, that object would call a method 'images'
based on the item
- # @options[:subcommand] being :images, so internally that class may do something
like:
- # self.send(@options[:subcommand])
- if @options[:subcommand].nil?
- # TODO: Pull out Print Usage into seporate method, and print
- puts "Could not find subcommand for list, run `./aeolus-image --help` for
usage instructions"
- exit(1)
- else
- list_command = ListCommand.new(@options)
- list_command.send(@options[:subcommand])
- end
- end
-
- def build
- b = BuildCommand.new(@options)
- b.run
- end
-
- def push
- b = PushCommand.new(@options)
- b.run
- end
-
- def import
- import_command = ImportCommand.new(@options)
- import_command.import_image
- end
-
- def delete
- if @options[:subcommand].nil?
- # TODO: Pull out Print Usage into seporate method, and print
- puts "Could not find subcommand for delete, run `./aeolus-image --help`
for usage instructions"
- exit(1)
- else
- delete_command = DeleteCommand.new(@options)
- delete_command.send(@options[:subcommand])
- end
- end
- end
- end
-end
diff --git a/lib/aeolus_image/command/delete_command.rb
b/lib/aeolus_image/command/delete_command.rb
deleted file mode 100644
index ba9078e..0000000
--- a/lib/aeolus_image/command/delete_command.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module Image
- class DeleteCommand < BaseCommand
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- end
-
- def provider_image
- if pi = ProviderImage.find(@options[:providerimage])
- if pi.delete!
- puts "b: " + @options[:providerimage] + " Deleted
Successfully"
- exit(0)
- end
- puts "ERROR: Unable to Delete Provider Image: " +
@options[:providerimage]
- else
- puts "Provider Image: " + @options[:providerimage] + " does not
exist"
- end
- exit(1)
- end
-
- def target_image
- if ti = TargetImage.find(@options[:targetimage])
- if ti.delete!
- puts "Target Image: " + @options[:targetimage] + " Deleted
Successfully"
- exit(0)
- end
- puts "ERROR: Unable to Delete Target Image: " +
@options[:targetimage]
- else
- puts "Target Image: " + @options[:targetimage] + " does not
exist"
- end
- exit(1)
- end
-
- def build
- if b = ImageBuild.find(@options[:build])
- if b.delete!
- puts "Build: " + @options[:build] + " Deleted
Successfully"
- exit(0)
- end
- puts "ERROR: Unable to Delete Build: " + @options[:build]
- else
- puts "Build: " + @options[:build] + " does not exist"
- end
- exit(1)
- end
-
- def image
- if i = Image.find(@options[:image])
- if i.delete!
- puts "Image: " + @options[:image] + " Deleted
Successfully"
- exit(0)
- end
- puts "ERROR: Unable to Delete Image: " + @options[:image]
- else
- puts "Image: " + @options[:image] + " does not exist"
- end
- exit(1)
- end
-
- # Deletes all Images,Builds,TargetImages,ProviderImages
- def iwhd
- Image.all.each do |image|
- Image.delete(image.uuid)
- end
-
- ImageBuild.all.each do |build|
- ImageBuild.delete(build.uuid)
- end
-
- TargetImage.all.each do |target_image|
- TargetImage.delete(target_image.uuid)
- end
-
- ProviderImage.all.each do |provider_image|
- ProviderImage.delete(provider_image.uuid)
- end
- puts "Deleted all objects in IWHD"
- exit(0)
- end
- end
- end
-end
diff --git a/lib/aeolus_image/command/import_command.rb
b/lib/aeolus_image/command/import_command.rb
deleted file mode 100644
index 8fa15cf..0000000
--- a/lib/aeolus_image/command/import_command.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module Image
- class ImportCommand < BaseCommand
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- default = {
- :image => '',
- :build => '',
- :id => '',
- :description => '<image><name>' + @options[:id] +
'</name></image>',
- :target => '',
- :provider => ''
- }
- @options = default.merge(@options)
- @console = ImageFactoryConsole.new()
- @console.start
- end
-
- def import_image
- description = read_file(@options[:description])
- if !description.nil?
- @options[:description] = description
- end
- # TODO: Validate Description XML
-
- #This is a temporary hack in case the agent doesn't show up on bus
- #immediately
- sleep(5)
- import_map = @console.import_image(@options[:image], @options[:build],
@options[:id], @options[:description], @options[:target].first,
@options[:provider].first)
- puts ""
- puts "Target Image: " + import_map['target_image']
- puts "Image: " + import_map['image']
- puts "Build: " + import_map['build']
- puts "Provider Image: " + import_map['provider_image']
- quit(0)
- end
-
- def quit(code)
- @console.shutdown
- super
- end
- end
- end
-end
diff --git a/lib/aeolus_image/command/list_command.rb
b/lib/aeolus_image/command/list_command.rb
deleted file mode 100644
index f350c9a..0000000
--- a/lib/aeolus_image/command/list_command.rb
+++ /dev/null
@@ -1,164 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module Image
- class ListCommand < BaseCommand
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- end
-
- def images
- check_bucket_exists("images")
- images = [["IMAGE ID", "LASTEST PUSHED BUILD",
"NAME", "OS", "OS VERSION", "ARCH",
"DESCRIPTION"]]
- Image.all.each do |i|
- images << [i.uuid, (i.latest_pushed_build.nil? ? "" :
i.latest_pushed_build.uuid), i.name, i.os.name, i.os.version, i.os.arch, i.description]
- end
- format_print(images)
- quit(0)
- end
-
- def builds
- builds = [["Build ID"]]
- image = Image.find(@options[:id])
- if image
- image.image_builds.each do |b|
- builds << [b.uuid]
- end
- format_print(builds)
- else
- puts "ERROR: could not find Image with ID: " + options[:id]
- end
- quit(0)
- end
-
- def targetimages
- targetimages = [["Target Image Id"]]
- build = ImageBuild.find(@options[:id])
- if build
- build.target_images.each do |ti|
- targetimages << [ti.uuid]
- end
- format_print(targetimages)
- else
- puts "ERROR: could not find Build with ID: " + options[:id]
- end
- quit(0)
- end
-
- def providerimages
- providerimages = [["PROVIDER IMAGE", "PROVIDER", "TARGET
IMAGE", "TARGET IDENTIFIER"]]
- target_image = TargetImage.find(@options[:id])
- if target_image
- target_image.provider_images.each do |pi|
- providerimages << [pi.uuid, pi.provider_name, target_image.uuid,
target_image.target]
- end
- format_print(providerimages)
- else
- puts "ERROR: could not find Target Image with ID: " + options[:id]
- end
- quit(0)
- end
-
- def targets
- targets = [["NAME", "TARGET CODE"]]
- targets << ["Mock", "mock"]
- targets << ["Amazon EC2", "ec2"]
- targets << ["RHEV-M", "rhevm"]
- targets << ["VMware vSphere", "vsphere"]
- targets << ["Condor Cloud", "condor_cloud"]
- format_print(targets)
- quit(0)
- end
-
- def providers
- print_values = [["NAME", "TYPE", "URL"]]
-
- doc = Nokogiri::XML conductor['/providers'].get
- doc.xpath("/providers/provider").each do |provider|
- print_values << [provider.xpath("name").text,
provider.xpath("provider_type").text, provider.xpath("url").text]
- end
-
- format_print(print_values)
- quit(0)
- end
-
- def accounts
- print_values = [["NAME", "PROVIDER", "PROVIDER
TYPE"]]
- doc = Nokogiri::XML conductor['/provider_accounts/'].get
- doc.xpath("/provider_accounts/provider_account").each do |account|
- print_values << [account.xpath("name").text,
account.xpath("provider").text, account.xpath("provider_type").text]
- end
-
- format_print(print_values)
- quit(0)
- end
-
- private
- # Takes a 2D array of strings and neatly prints them to STDOUT
- def format_print(print_values)
- widths = Array.new(print_values[0].size, 0)
- print_values.each do |print_value|
- widths = widths.zip(print_value).map! {|width, value| value.length > width ?
value.length : width }
- end
-
- print_values.each do |print_value|
- widths.zip(print_value) do |width, value|
- printf("%-#{width + 5}s", value)
- end
- puts ""
- end
- end
-
- def get_template_info(image, targetimage)
- begin
- template = Nokogiri::XML iwhd["/templates/" +
iwhd["/target_images/" + targetimage + "/template"].get].get
- [template.xpath("/template/name").text,
- iwhd["/target_images/" + targetimage + "/target"].get,
- template.xpath("/template/os/name").text,
- template.xpath("/template/os/version").text,
- template.xpath("/template/os/arch").text,
- template.xpath("/template/description").text]
- rescue
- end
- end
-
- def get_image_name(image)
- begin
- template_xml = Nokogiri::XML iwhd["images/" + image].get
- template_xml.xpath("/image/name").text
- rescue
- ""
- end
- end
-
- def lastest_pushed(image)
- begin
- build = iwhd["/images/" + image + "/latest_build"].get
- build.nil? ? "" : build
- rescue
- ""
- end
- end
-
- def check_bucket_exists(bucket)
- begin
- iwhd["/" + bucket].get
- rescue
- nil
- end
- end
- end
- end
-end
diff --git a/lib/aeolus_image/command/push_command.rb
b/lib/aeolus_image/command/push_command.rb
deleted file mode 100644
index 275ed37..0000000
--- a/lib/aeolus_image/command/push_command.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'rest_client'
-
-module Aeolus
- module Image
- class PushCommand < BaseCommand
- attr_accessor :console
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- default = {
- :provider => [],
- :id => '',
- :build => ''
- }
- @options = default.merge(@options)
- @console = ImageFactoryConsole.new()
- @console.start
- end
- def run
- begin
- if combo_implemented?
- if !@options[:id].empty? && pushed?(@options[:id])
- puts "ERROR: This image has already been pushed, to push to another
provider please push via build-id rather than image-id"
- puts "e.g. aeolus-image push --provider <provider> --build
<build-id>"
- quit(1)
- end
-
- sleep(5)
- @console.push(@options[:provider], get_creds, @options[:id],
@options[:build]).each do |adaptor|
- puts ""
- puts "Provider Image: #{adaptor.image_id}"
- puts "Image: #{adaptor.image}"
- puts "Build: #{adaptor.build}"
- puts "Status: #{adaptor.status}"
- puts "Percent Complete: #{adaptor.percent_complete}"
- end
- quit(0)
- end
- rescue
- puts "An Error occured whilst trying to push this build, please check
aeolus-image --help for details on how to use this command"
- quit(1)
- end
- end
-
- def get_creds
- conductor['provider_accounts'].get
- end
-
- def combo_implemented?
- if @options[:provider].empty? || (@options[:build].empty? &&
@options[:id].empty?)
- puts "This combination of parameters is not currently supported"
- quit(1)
- end
- true
- end
-
- private
- def quit(code)
- @console.shutdown
- exit(code)
- end
-
- def pushed?(image)
- begin
- uuid = Regexp.new('[\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
- uuid.match(iwhd["/images/" + image +
"/latest_unpushed"].get).nil? ? true : false
- rescue
- true
- end
- end
- end
- end
-end
diff --git a/lib/aeolus_image/model/base.rb b/lib/aeolus_image/model/base.rb
deleted file mode 100644
index 692a87a..0000000
--- a/lib/aeolus_image/model/base.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'active_resource'
-module Aeolus
- module CLI
- class Base < ActiveResource::Base
- self.timeout = 600
- class << self
- def instantiate_collection(collection, prefix_options = {})
- unless collection.kind_of? Array
- [instantiate_record(collection, prefix_options)]
- else
- collection.collect! { |record| instantiate_record(record, prefix_options) }
- end
- end
- end
- end
- end
-end
\ No newline at end of file
diff --git a/lib/aeolus_image/model/build.rb b/lib/aeolus_image/model/build.rb
deleted file mode 100644
index 624f18d..0000000
--- a/lib/aeolus_image/model/build.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module CLI
- class Build < Base
- end
- end
-end
diff --git a/lib/aeolus_image/model/image.rb b/lib/aeolus_image/model/image.rb
deleted file mode 100644
index 249009f..0000000
--- a/lib/aeolus_image/model/image.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module CLI
- class Image < Base
- end
- end
-end
\ No newline at end of file
diff --git a/lib/aeolus_image/model/provider.rb b/lib/aeolus_image/model/provider.rb
deleted file mode 100644
index 2508833..0000000
--- a/lib/aeolus_image/model/provider.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module CLI
- class Provider < Base
- end
- end
-end
\ No newline at end of file
diff --git a/lib/aeolus_image/model/provider_account.rb
b/lib/aeolus_image/model/provider_account.rb
deleted file mode 100644
index e10c856..0000000
--- a/lib/aeolus_image/model/provider_account.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module CLI
- class ProviderAccount < Base
- end
- end
-end
\ No newline at end of file
diff --git a/lib/aeolus_image/model/provider_image.rb
b/lib/aeolus_image/model/provider_image.rb
deleted file mode 100644
index c3d3a52..0000000
--- a/lib/aeolus_image/model/provider_image.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module CLI
- class ProviderImage < Base
- end
- end
-end
\ No newline at end of file
diff --git a/lib/aeolus_image/model/provider_type.rb
b/lib/aeolus_image/model/provider_type.rb
deleted file mode 100644
index 4bfbf88..0000000
--- a/lib/aeolus_image/model/provider_type.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module CLI
- class ProviderType < Base
- end
- end
-end
\ No newline at end of file
diff --git a/lib/aeolus_image/model/target_image.rb
b/lib/aeolus_image/model/target_image.rb
deleted file mode 100644
index 9972372..0000000
--- a/lib/aeolus_image/model/target_image.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-module Aeolus
- module CLI
- class TargetImage < Base
- end
- end
-end
\ No newline at end of file
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 53f43b4..435ff5c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-$: << File.expand_path(File.join(File.dirname(__FILE__),
"../lib/aeolus_image/command/"))
-$: << File.expand_path(File.join(File.dirname(__FILE__),
"../lib/aeolus_image/model/"))
+$: << File.expand_path(File.join(File.dirname(__FILE__),
"../lib/aeolus_cli/command/"))
+$: << File.expand_path(File.join(File.dirname(__FILE__),
"../lib/aeolus_cli/model/"))
require 'rubygems'
require 'base'
--
1.7.6.2