From: Martyn Taylor <martyn(a)martyn-work-laptop.(none)>
---
Rakefile | 4 +-
bin/aeolus-image | 20 ---
examples/custom_repo.tdl | 18 --
examples/image_description.xml | 3 -
examples/tdl.rng | 207 ------------------------
lib/aeolus_image/command/base_command.rb | 153 ------------------
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 ----------
man/aeolus-image-build.1 | 36 ----
man/aeolus-image-import.1 | 57 -------
man/aeolus-image-list.1 | 88 ----------
man/aeolus-image-push.1 | 40 -----
man/aeolus-image.1 | 16 --
rubygem-aeolus-image.spec | 21 +--
spec/base_command_spec.rb | 90 ----------
spec/build_command_spec.rb | 77 ---------
spec/config_parser_spec.rb | 96 -----------
spec/import_command_spec.rb | 57 -------
spec/list_command_spec.rb | 22 ---
spec/push_command_spec.rb | 70 --------
spec/spec_helper.rb | 43 +-----
25 files changed, 7 insertions(+), 1839 deletions(-)
delete mode 100755 bin/aeolus-image
delete mode 100644 examples/custom_repo.tdl
delete mode 100644 examples/image_description.xml
delete mode 100644 examples/tdl.rng
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 man/aeolus-image-build.1
delete mode 100644 man/aeolus-image-import.1
delete mode 100644 man/aeolus-image-list.1
delete mode 100644 man/aeolus-image-push.1
delete mode 100644 man/aeolus-image.1
delete mode 100644 spec/base_command_spec.rb
delete mode 100644 spec/build_command_spec.rb
delete mode 100644 spec/config_parser_spec.rb
delete mode 100644 spec/import_command_spec.rb
delete mode 100644 spec/list_command_spec.rb
delete mode 100644 spec/push_command_spec.rb
diff --git a/Rakefile b/Rakefile
index 0fa82fe..66500c3 100644
--- a/Rakefile
+++ b/Rakefile
@@ -33,10 +33,8 @@ spec = Gem::Specification.new do |s|
s.email = 'jguiditt(a)redhat.com, mtaylor(a)redhat.com'
s.license = 'ASL 2.0'
s.homepage = 'http://aeolusproject.org'
- s.executables << 'aeolus-image'
- s.files = %w(Rakefile) + Dir.glob("{bin,lib,spec,examples,man}/**/*") +
%w(COPYING)
+ s.files = %w(Rakefile) + Dir.glob("{lib,spec}/**/*") + %w(COPYING)
s.require_path = "lib"
- s.bindir = "bin"
s.add_dependency('nokogiri', '>=0.4.0')
s.add_dependency('rest-client')
s.add_dependency('imagefactory-console', '>=0.4.0')
diff --git a/bin/aeolus-image b/bin/aeolus-image
deleted file mode 100755
index 8a05848..0000000
--- a/bin/aeolus-image
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env ruby
-
-# 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.
-
-$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
-require 'aeolus_image.rb'
-parser = Aeolus::Image::ConfigParser.new(ARGV)
-puts parser.process
diff --git a/examples/custom_repo.tdl b/examples/custom_repo.tdl
deleted file mode 100644
index 2f96604..0000000
--- a/examples/custom_repo.tdl
+++ /dev/null
@@ -1,18 +0,0 @@
-<template>
- <name>tmpl1</name>
- <description>foo</description>
- <os>
- <name>Fedora</name>
- <arch>x86_64</arch>
- <version>14</version>
- <install type="url">
-
<
url>http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fed...
- </install>
- </os>
- <repositories>
- <repository name="custom">
- <
url>http://repos.fedorapeople.org/repos/aeolus/demo/webapp/</url>
- <signed>false</signed>
- </repository>
- </repositories>
-</template>
\ No newline at end of file
diff --git a/examples/image_description.xml b/examples/image_description.xml
deleted file mode 100644
index ecfd9ce..0000000
--- a/examples/image_description.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<image>
- <name>Test Image</name>
-</image>
\ No newline at end of file
diff --git a/examples/tdl.rng b/examples/tdl.rng
deleted file mode 100644
index ac2faf9..0000000
--- a/examples/tdl.rng
+++ /dev/null
@@ -1,207 +0,0 @@
-<?xml version="1.0"?>
-<!-- This Schema is lifted from the OZ project:
http://www.aeolusproject.org/oz.html
any changes to this schema should be done in the upstream project, then added here-->
-<!-- A Relax NG schema for the TDL (template description language) format -->
-<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <start>
- <ref name='template'/>
- </start>
-
- <define name='template'>
- <element name='template'>
- <interleave>
- <element name='name'>
- <text/>
- </element>
- <element name='os'>
- <interleave>
- <element name='name'>
- <text/>
- </element>
- <element name='version'>
- <text/>
- </element>
- <element name='arch'>
- <choice>
- <value>i386</value>
- <value>x86_64</value>
- </choice>
- </element>
- <element name='install'>
- <choice>
- <ref name='url'/>
- <ref name='iso'/>
- </choice>
- </element>
- <optional>
- <element name='rootpw'>
- <text/>
- </element>
- </optional>
- <optional>
- <element name='key'>
- <text/>
- </element>
- </optional>
- </interleave>
- </element>
- <optional>
- <element name='description'>
- <text/>
- </element>
- </optional>
- <optional>
- <element name='packages'>
- <zeroOrMore>
- <element name='package'>
- <attribute name='name'>
- <text/>
- </attribute>
- <interleave>
- <optional>
- <element name='repository'>
- <text/>
- </element>
- </optional>
- <optional>
- <element name='file'>
- <text/>
- </element>
- </optional>
- <optional>
- <element name='arguments'>
- <text/>
- </element>
- </optional>
- </interleave>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- <optional>
- <element name='files'>
- <zeroOrMore>
- <element name='file'>
- <attribute name='name'>
- <text/>
- </attribute>
- <choice>
- <ref name='rawtype'/>
- <ref name='base64type'/>
- </choice>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- <optional>
- <element name='commands'>
- <zeroOrMore>
- <element name='command'>
- <attribute name='name'>
- <text/>
- </attribute>
- <choice>
- <ref name='rawtype'/>
- <ref name='base64type'/>
- </choice>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- <optional>
- <element name='repositories'>
- <zeroOrMore>
- <element name='repository'>
- <attribute name='name'>
- <text/>
- </attribute>
- <interleave>
- <element name='url'>
- <text/>
- </element>
- <optional>
- <element name='signed'>
- <ref name='bool'/>
- </element>
- </optional>
- </interleave>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- </interleave>
- </element>
- </define>
-
- <define name='url'>
- <attribute name='type'>
- <value>url</value>
- </attribute>
- <element name='url'>
- <text/>
- </element>
- </define>
-
- <define name='iso'>
- <attribute name='type'>
- <value>iso</value>
- </attribute>
- <interleave>
- <element name='iso'>
- <text/>
- </element>
- <optional>
- <choice>
- <element name='md5sum'>
- <text/>
- </element>
- <element name='sha1sum'>
- <text/>
- </element>
- <element name='sha256sum'>
- <text/>
- </element>
- </choice>
- </optional>
- </interleave>
- </define>
-
- <define name='bool'>
- <choice>
- <data type="string">
- <param name="pattern">[Tt][Rr][Uu][Ee]</param>
- </data>
- <data type="string">
- <param name="pattern">[Ff][Aa][Ll][Ss][Ee]</param>
- </data>
- <data type="string">
- <param name="pattern">[Yy][Ee][Ss]</param>
- </data>
- <data type="string">
- <param name="pattern">[Nn][Oo]</param>
- </data>
- </choice>
- </define>
-
- <define name='rawtype'>
- <optional>
- <attribute name='type'>
- <value>raw</value>
- </attribute>
- </optional>
- <text/>
- </define>
-
- <define name='base64'>
- <data type="string">
- <param name="pattern">[a-zA-Z0-9+/]+={0,2}</param>
- </data>
- </define>
-
- <define name='base64type'>
- <attribute name='type'>
- <value>base64</value>
- </attribute>
- <ref name='base64'/>
- </define>
-
-</grammar>
diff --git a/lib/aeolus_image/command/base_command.rb
b/lib/aeolus_image/command/base_command.rb
deleted file mode 100644
index c758145..0000000
--- a/lib/aeolus_image/command/base_command.rb
+++ /dev/null
@@ -1,153 +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
- 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 iwhd
- create_resource(:iwhd)
- end
-
- def conductor
- create_resource(:conductor)
- 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 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
-
- def create_resource(resource_name)
- # Check to see if config has a resource with this name
- if !(a)config.has_key?(resource_name)
- raise "Unable to determine resource: " + resource_name.to_s + "
from configuration file. Please check: " + @config_location
- return
- end
-
- #Use command line arguments for username/password
- if @options.has_key?(:username)
- if @options.has_key?(:password)
- RestClient::Resource.new(@config[resource_name][:url], :user =>
@options[:username], :password => @options[:password])
- else
- #TODO: Create a custom exception to wrap CLI Exceptions
- raise "Password not found for user: " + @options[:username]
- end
-
- #Use config for username/password
- elsif @config[resource_name].has_key?(:username)
- if @config[resource_name].has_key?(:password)
- RestClient::Resource.new(@config[resource_name][:url], :user =>
@config[resource_name][:username], :password => @config[resource_name][:password])
- else
- #TODO: Create a custom exception to wrap CLI Exceptions
- raise "Password not found for user: " +
@config[resource_name][:username]
- end
-
- # Do not use authentication
- else
- RestClient::Resource.new(@config[resource_name][:url])
- 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/man/aeolus-image-build.1 b/man/aeolus-image-build.1
deleted file mode 100644
index 9a381ee..0000000
--- a/man/aeolus-image-build.1
+++ /dev/null
@@ -1,36 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER
COMMANDS"
-.SH NAME
-aeolus-image build \- command for building aeolus images
-.SH SYNOPSIS
-.B aeolus-image build [\-h|--help] [\-u|--username] [\-w|--password] [\-I|--image
[image-id]] [\-e|--template [path-to-template]] [\-t|--targets [targets]] [\-d|--daemon]
-.SH DESCRIPTION
-aeolus-image build command allows users to build new images based on a given TDL template
file for a set of specified targets such e.g. EC2, RHEVM etc... See list man list
target-images for information on how to list the completed builds.
-.SH OPTIONS
-.TP
-\-u, --user <username>
-Conductor username
-.TP
-\-w, --password <password>
-Conductor password
-.TP
-\-T, --target
-Provide a list of targets for the build
-.TP
-\-e, --template
-Provide path to a TDL template file for building against
-.TP
-\-d, --daemon
-Run as a background process
-.TP
-Get usage information for this command and associated commmands
-\-h, --help
-.SH EXAMPLES
-.TP
-Build a new image for ec2 based on the specified template TDL file template.tdl
-.B aeolus-image build
-\--targets ec2
-\--template ./template.tdl
-.TP
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-list(1), aeolus-image-push(1), aeolus-image-import(1)
diff --git a/man/aeolus-image-import.1 b/man/aeolus-image-import.1
deleted file mode 100644
index 82ee0ce..0000000
--- a/man/aeolus-image-import.1
+++ /dev/null
@@ -1,57 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER
COMMANDS"
-.SH NAME
-aeolus-image import \- command for importing existing provider images into aeolus
-.SH SYNOPSIS
-.B aeolus-image import [\-h|--help] [\-u|--username] [\-w|--password] [\-r|--provider
[provider-name]] [\--id [provider-image-id]] [--description [path-to-file|xml string]]
[\T|--target [target]] [\-d|--daemon]
-.SH DESCRIPTION
-aeolus-image import allows users to import pre-existing images that exist in cloud
provders for example AMI from EC2, into aeolus.
-.SH OPTIONS
-.TP
-\-u, --user <username>
-Conductor username
-.TP
-\-w, --password <password>
-Conductor password
-.TP
-\-r, --provider <provider-name>
-The provider name as it exists in conductor from where the importing image resides
-.TP
-\--id <provider-image-id>
-The providers ID given to the importing image
-.TP
-\-T, --target
-The target type for the given provider
-.TP
-\--description <path-to-xml-description|xml string>
-A user defined description to associate with the importing image
-.TP
-\-d, --daemon
-Run as a background process
-.TP
-Get usage information for this command and associated commmands
-\-h, --help
-.SH EXAMPLES
-.TP
-Import the AMI ami-1234567 from the provider ec2-us-east-1 into aeolus
-.B aeolus-image import
-\--provider ec2-us-east-1
-\--target ec2
-\--id ami-1234567
-.TP
-Import the AMI ami-1234567 from the provider ec2-us-west-1 into aeolus with a given xml
description
-.B aeolus-image import
-\--provider ec2-us-west-1
-\--target ec2
-\--id ami-1234567
-\--description '<image><name>myAMI</name></image>'
-.TP
-Import the AMI ami-1234567 from the provider ec2-us-west-1 into aeolus providing a path
to the description XML file
-.B aeolus-image import
-\--provider ec2-us-west-1
-\--target ec23
-\--id ami-1234567
-\--description /foo/bar/description.xml
-.SH AUTHOR
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-list(1), aeolus-image-push(1), aeolus-image-build(1)
diff --git a/man/aeolus-image-list.1 b/man/aeolus-image-list.1
deleted file mode 100644
index b75206a..0000000
--- a/man/aeolus-image-list.1
+++ /dev/null
@@ -1,88 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER
COMMANDS"
-.SH NAME
-aeolus-image \- command for listing aeolus image associated objects.
-.SH SYNOPSIS
-.B aeolus-image list [\-h|--help] [\-u|--username] [\-w|--password] [\-i|--images]
[\-b|--builds [image id]] [\-t|--targetimages [build id]] [\-P|--providerimages [target
image id]] [\-g|--targets] [\-a|--accounts] [\-p|--providers]
-.SH DESCRIPTION
-aeolus-image list commands allows users to list information on the contents of particular
objects in image warehouse including:
-.P
-images: high level image representation associated with underlying provider and target
images
-.br
-builds: an object representation of a particular build that has taken place for a high
level image
-.br
-targets: particular targets available to build against, for example 'ec2'
-.br
-targetimages: represents builds of particular image against a target. For example
building against target 'ec2' would create an AMI specific image
-.br
-providerimages: represents the actual images that have been uploaded to a provider.
Similiar to a target image but specific to a particular provider
-.SH OPTIONS
-.TP
-\-u, --user <username>
-Conductor username
-.TP
-\-w, --password <password>
-Conductor password
-Get usage information for this command and associated commmands
-.TP
-\-i, --images
-Retrieve a list of images
-.TP
-\-b, --builds <image id>
-Retrieve a list of builds of for a particular image
-.TP
-\-t, --targetimages <build id>
-Retrieve a list of completed target-images builds for a particular build id
-.TP
-\-P, --providerimages <target image id>
-Retrieve a list of completed provider-images builds for a particular target image id. Use
"all" to list all provider images.
-.TP
-\-g, --targets
-Retrieve a list of available targets
-.TP
-\-p, --providers
-Retrieve a list of available providers
-.TP
-\-a, --accounts
-Retrieve a list of available accounts
-.TP
-\-d, --daemon
-Run as a background process
-.TP
-\-h, --help
-.SH EXAMPLES
-.TP
-List all images
-.B aeolus-image list
-\--images
-.TP
-List all builds for an image with id: 12345678-aaaa-1234--1234567890ab
-.B aeolus-image list
-\--builds 12345678-aaaa-1234--1234567890ab
-.TP
-List all target images for a given build with id: 12345678-bbbb-1234--1234567890ab
-.B aeolus-image list
-\--targetimages 12345678-bbbb-1234--1234567890ab
-.TP
-List all provider images for a given target image with id:
12345678-tttt-1234--1234567890ab
-.B aeolus-image list
-\--providerimages 12345678-tttt-1234--1234567890ab
-.TP
-List all provider images
-.B aeolus-image list
-\--providerimages all
-.TP
-List all available targets
-.B aeolus-image list
-\--targets
-.TP
-List all available providers
-.B aeolus-image list
-\--providers
-.TP
-List all available accounts
-.B aeolus-image list
-\--account
-.SH AUTHOR
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-build(1), aeolus-image-push(1), aeolus-image-import(1),
aeolus-image-delete(1)
diff --git a/man/aeolus-image-push.1 b/man/aeolus-image-push.1
deleted file mode 100644
index c2e0215..0000000
--- a/man/aeolus-image-push.1
+++ /dev/null
@@ -1,40 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER
COMMANDS"
-.SH NAME
-aeolus-image push \- command for pushing aeolus images to back end providers
-.SH SYNOPSIS
-.B aeolus-image push [\-h|--help] [\-u|--username] [\-w|--password] [\-id [image-id]]
[-r|--provider [provider-name]]
-.SH DESCRIPTION
-aeolus-image push allows users to push built images to a particular backend provider
-.SH OPTIONS
-.TP
-\-u, --user <username>
-Conductor username
-.TP
-\-w, --password <password>
-Conductor password
-.TP
-\-r|--provider
-The provider name this image should be pushed to
-.TP
-\--id <id>
-The id of the image for pushing
-.TP
-\-d, --daemon
-Run as a background process
-.TP
-Get usage information for this command and associated commmands
-\-h, --help
-.SH EXAMPLES
-.TP
-Initial push of an image with id 12345678-bbbb-1234--1234567890ab to provider
ec2-us-east-1
-.B aeolus-image push
-\--id 12345678-bbbb-1234--1234567890ab
-\--provider ec2-us-east-1
-Push a build with id 12345678-bbbb-1234--1234567890ab to provider ec2-us-east-1
-.B aeolus-image push
-\--build 12345678-bbbb-1234--1234567890ab
-\--provider ec2-us-east-1
-.SH AUTHOR
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-list(1), aeolus-image-build(1), aeolus-image-import(1)
diff --git a/man/aeolus-image.1 b/man/aeolus-image.1
deleted file mode 100644
index 7e7cc04..0000000
--- a/man/aeolus-image.1
+++ /dev/null
@@ -1,16 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER
COMMANDS"
-.SH NAME
-aeolus-image \- command line tool for managing aeolus images
-.SH SYNOPSIS
-.B aeolus-image
-[\-h]
-.SH DESCRIPTION
-aeolus-image is a tool that allows users to control their aeolus images through image
builder and aeolus conductor. aeolus-image offers four commands options; list, build,
push, import. For more information on each command please run man aeolus-image
<command> or aeolus-image --help
-.SH OPTIONS
-.TP
-\-h, --help
-Get usage information for this tool and subcommands
-.SH AUTHOR
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-build(1), aeolus-image-push(1), aeolus-image-list(1),
aeolus-image-import(1)
diff --git a/rubygem-aeolus-image.spec b/rubygem-aeolus-image.spec
index 64fe4b6..2014ff9 100644
--- a/rubygem-aeolus-image.spec
+++ b/rubygem-aeolus-image.spec
@@ -1,10 +1,9 @@
%global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
%global gemname aeolus-image
%global geminstdir %{gemdir}/gems/%{gemname}-%{version}
-%global mandir %{_mandir}/man1
%global rubyabi 1.8
-Summary: Command-line interface for working with the Aeolus cloud suite
+Summary: Ruby Client for interacting with Image Warehouse and Image Factory
Name: rubygem-aeolus-image
Version: 0.1.0
Release: 3%{?extra_release}%{?dist}
@@ -34,7 +33,7 @@ BuildArch: noarch
Provides: rubygem(%{gemname}) = %{version}
%description
-QMF Console for Aeolus Image Factory
+Ruby Client for Image Warehouse and Image Factory
%prep
%setup -q -c -T
@@ -48,31 +47,21 @@ rm -rf %{buildroot}
mkdir -p %{buildroot}%{gemdir}
cp -a .%{gemdir}/* %{buildroot}%{gemdir}/
-mkdir -p %{buildroot}/%{_bindir}
-mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
-find %{buildroot}%{geminstdir}/bin -type f | xargs chmod 755
-rmdir %{buildroot}%{gemdir}/bin
rm -rf %{buildroot}%{gemdir}/gems/%{gemname}-%{version}/.yardoc
-mkdir -p %{buildroot}%{mandir}
-mv %{buildroot}%{geminstdir}/man/* %{buildroot}%{mandir}
-
%files
%doc %{geminstdir}/COPYING
-%{_bindir}/aeolus-image
%dir %{geminstdir}
%{geminstdir}/Rakefile
-%{geminstdir}/bin
-%{geminstdir}/examples
%{geminstdir}/lib
-%{geminstdir}/man
%{geminstdir}/spec
-%doc %{gemdir}/doc/%{gemname}-%{version}
%{gemdir}/cache/%{gemname}-%{version}.gem
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
-%{mandir}/*
%changelog
+* Tue Sep 20 2011 Martyn Taylor <mtaylor(a)redhat.com> - 0.0.1-3
+- split out command line tools
+
* Wed Jul 20 2011 Mo Morsi <mmorsi(a)redhat.com> - 0.0.1-3
- more updates to conform to fedora guidelines
diff --git a/spec/base_command_spec.rb b/spec/base_command_spec.rb
deleted file mode 100644
index 3ed5373..0000000
--- a/spec/base_command_spec.rb
+++ /dev/null
@@ -1,90 +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 'spec_helper'
-
-module Aeolus
- module Image
- describe BaseCommand do
-
- it "should determine the correct credentials for HTTP Authentication" do
- basec = BaseCommand.new
- iwhd = basec.send :iwhd
- iwhd.user.should == nil
-
- conductor = basec.send :conductor
- conductor.user.should == "admin"
- conductor.password.should == "password"
-
- basec = BaseCommand.new({:username => "testusername", :password=>
"testpassword"})
- conductor = basec.send :conductor
- conductor.user.should == "testusername"
- conductor.password.should == "testpassword"
- end
-
- describe "#read_file" do
-
- it "should return nil when it cannot find file" do
- b = BaseCommand.new
- b.send(:read_file, "foo.fake").should be_nil
- end
-
- it "should read file content into string variable" do
- b = BaseCommand.new
- template_str = b.send(:read_file, "#{File.dirname(__FILE__)}" +
"/../examples/custom_repo.tdl")
- template_str.should include("<template>")
- end
- end
-
- describe "#is_file?" do
- it "should return false if no file found" do
- b = BaseCommand.new
- b.send(:is_file?, "foo.fake").should be_false
- end
- it "should return true if file found" do
- b = BaseCommand.new
- valid_file = "#{File.dirname(__FILE__)}" +
"/../examples/aeolus-cli"
- b.instance_eval {@config_location = valid_file}
- b.send(:is_file?, valid_file).should be_true
- end
- end
-
- describe "#write_file" do
- it "should write a new file" do
- b = BaseCommand.new
- new_file = "/tmp/foo.fake"
- b.instance_eval {@config_location = new_file}
- b.send(:write_file)
- conf = YAML::load(File.open(File.expand_path(new_file)))
- conf.has_key?(:iwhd).should be_true
- File.delete(new_file)
- end
- end
-
- describe "#validate_xml_document?" do
- it "should return errors given non compliant xml" do
- b = BaseCommand.new
- errors = b.send(:validate_xml_document, "examples/tdl.rng",
File.read("spec/fixtures/invalid_template.tdl"))
- errors.length.should > 0
- end
-
- it "should return no errors" do
- b = BaseCommand.new
- errors = b.send(:validate_xml_document, "examples/tdl.rng",
File.read("spec/fixtures/valid_template.tdl"))
- errors.length.should == 0
- end
- end
- end
- end
-end
diff --git a/spec/build_command_spec.rb b/spec/build_command_spec.rb
deleted file mode 100644
index be4b2b9..0000000
--- a/spec/build_command_spec.rb
+++ /dev/null
@@ -1,77 +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 'spec_helper'
-
-module Aeolus
- module Image
- describe BuildCommand do
- before(:each) do
- @options[:target] = ['mock','ec2']
- @options[:template] = "#{File.dirname(__FILE__)}" +
"/../examples/custom_repo.tdl"
- end
-
- describe "#run" do
- it "should kick off a build with valid options" do
- b = BuildCommand.new(@options, @output)
- begin
- b.run
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Target Image:")
- $stdout.string.should include("Build:")
- end
- it "should exit with a message if only image id is provided" do
- @options.delete(:template)
- @options.delete(:target)
- @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
- b = BuildCommand.new(@options, @output)
- begin
- b.run
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("This combination of parameters is not
currently supported")
- end
- it "should exit with appropriate message when a non compliant template is
given" do
- @options[:template] = "spec/fixtures/invalid_template.tdl"
- @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
- b = BuildCommand.new(@options, @output)
- begin
- b.run
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("ERROR: The given Template does not conform
to the TDL Schema")
- end
- end
-
- describe "#combo_implemented?" do
- it "should give useful feedback if no template or target is specified"
do
- @options[:template] = ''
- @options[:target] = []
- b = BuildCommand.new(@options, @output)
- begin
- b.combo_implemented?
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("This combination of parameters is not
currently supported")
- end
- end
- end
- end
-end
diff --git a/spec/config_parser_spec.rb b/spec/config_parser_spec.rb
deleted file mode 100644
index f920afb..0000000
--- a/spec/config_parser_spec.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.
-
-require 'spec_helper'
-
-module Aeolus
- module Image
- describe ConfigParser do
- it "should parse the specified command" do
- config_parser = ConfigParser.new(%w(list --images))
- config_parser.process
- config_parser.command.should == 'list'
- end
-
- it "should exit gracefully when a required subcommand is not provided"
do
- begin
- silence_stream(STDOUT) do
- config_parser = ConfigParser.new(%w(list))
- config_parser.process
- config_parser.should_receive(:exit).with(1)
- end
- rescue SystemExit => e
- e.status.should == 1
- end
- end
-
- it "should notify the user of an invalid command" do
- config_parser = ConfigParser.new(%w(sparkle))
- config_parser.should_receive(:exit).with(0)
- silence_stream(STDOUT) do
- config_parser.process
- end
- end
-
- it "should exit gracefully with bad params" do
- begin
- silence_stream(STDOUT) do
- ConfigParser.new(%w(delete --fred)).should_receive(:exit).with(1)
- end
- rescue SystemExit => e
- e.status.should == 1
- end
- end
-
- it "should set options hash for valid general options" do
- config_parser = ConfigParser.new(%w(list --user joe --password cloud --images))
- config_parser.options[:user].should == 'joe'
- config_parser.options[:password].should == 'cloud'
- config_parser.options[:subcommand].should == :images
- end
-
- it "should set options hash for valid list options" do
- config_parser = ConfigParser.new(%w(list --builds 12345))
- config_parser.options[:subcommand].should == :builds
- config_parser.options[:id].should == '12345'
- end
-
- it "should set options hash for valid build options" do
- config_parser = ConfigParser.new(%w(build --target ec2,rackspace --image 12345
--template my.tmpl))
- config_parser.options[:target].should == ['ec2','rackspace']
- config_parser.options[:image].should == '12345'
- config_parser.options[:template].should == 'my.tmpl'
- end
-
- it "should set options hash for valid push options" do
- config_parser = ConfigParser.new(%w(push --provider ec2-us-east1 --id 12345))
- config_parser.options[:provider].should == ['ec2-us-east1']
- config_parser.options[:id].should == '12345'
- end
-
- it "should set options hash for valid delete options" do
- config_parser = ConfigParser.new(%w(delete --build 12345))
- config_parser.options[:build].should == '12345'
- end
-
- it "should set options hash for valid import options" do
- config_parser = ConfigParser.new(%w(import --provider ec2-us-east-1a
--description /path/to/file --id ami-123456 --target ec2))
- config_parser.options[:provider].should == ['ec2-us-east-1a']
- config_parser.options[:target].should == ['ec2']
- config_parser.options[:description].should == '/path/to/file'
- config_parser.options[:id].should == 'ami-123456'
- end
- end
- end
-end
diff --git a/spec/import_command_spec.rb b/spec/import_command_spec.rb
deleted file mode 100644
index 6b9121a..0000000
--- a/spec/import_command_spec.rb
+++ /dev/null
@@ -1,57 +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 'spec_helper'
-
-module Aeolus
- module Image
- describe ImportCommand do
- before(:each) do
- @options[:id] = "ami-test"
- @options[:target] = "ec2"
- @options[:provider] = "ec2-us-east-1"
- end
-
- describe "#import_image" do
- it "should import an image with default description values" do
- importc = ImportCommand.new(@options)
- begin
- importc.import_image
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Target Image:")
- $stdout.string.should include("Build:")
- $stdout.string.should include("Provider Image:")
- end
-
- it "should import an image with file description" do
- @options[:description] = 'spec/sample_data/image_description.xml'
- importc = ImportCommand.new(@options)
- begin
- importc.import_image
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Target Image:")
- $stdout.string.should include("Build:")
- $stdout.string.should include("Provider Image:")
- #TODO: Add test to check that file was uploaded properly (when we have
implemented a show/view image command)
- end
- end
- end
- end
-end
diff --git a/spec/list_command_spec.rb b/spec/list_command_spec.rb
deleted file mode 100644
index bf7fc0d..0000000
--- a/spec/list_command_spec.rb
+++ /dev/null
@@ -1,22 +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 'spec_helper'
-
-module Aeolus
- module Image
- describe ListCommand do
- end
- end
-end
diff --git a/spec/push_command_spec.rb b/spec/push_command_spec.rb
deleted file mode 100644
index 4d60606..0000000
--- a/spec/push_command_spec.rb
+++ /dev/null
@@ -1,70 +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 'spec_helper'
-
-module Aeolus
- module Image
- describe PushCommand do
-
- before(:each) do
- @options[:provider] = ['mock']
- @options[:user] = 'admin'
- @options[:password] = 'password'
- end
-
- describe "#run" do
- before(:each) do
- options = {}
- options[:target] = ['mock','ec2']
- options[:template] = "#{File.dirname(__FILE__)}" +
"/../examples/custom_repo.tdl"
- b = BuildCommand.new(options)
- sleep(5)
- tmpl_str = b.send(:read_file, options[:template])
- b.console.build(tmpl_str, ['mock','ec2']).each do |adaptor|
- @build_id = adaptor.image
- end
- b.console.shutdown
- @options[:id] = @build_id
- end
-
- it "should push an image with valid options" do
- p = PushCommand.new(@options, @output)
- begin
- p.run
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Provider Image:")
- $stdout.string.should include("Build:")
- end
- end
-
- describe "#combo_implemented?" do
- it "should give useful feedback if no template or target is specified"
do
- @options.delete(:id)
- @options.delete(:provider)
- b = PushCommand.new(@options, @output)
- begin
- b.combo_implemented?
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("This combination of parameters is not
currently supported")
- end
- end
- end
- end
-end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 69b1139..6706fe2 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -12,7 +12,6 @@
# 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/"))
require 'rubygems'
@@ -22,39 +21,8 @@ require 'image'
require 'image_build'
require 'target_image'
require 'provider_image'
-require 'config_parser'
-require 'stringio'
-require 'base_command'
-require 'list_command'
-require 'build_command'
-require 'push_command'
-require 'import_command'
-require 'delete_command'
-
-
-
-module Helpers
- # Silences any stream for the duration of the block.
- #
- # silence_stream(STDOUT) do
- # puts 'This will never be seen'
- # end
- #
- # puts 'But this will'
- #
- # (Taken from ActiveSupport)
- def silence_stream(stream)
- old_stream = stream.dup
- stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
- stream.sync = true
- yield
- ensure
- stream.reopen(old_stream)
- end
-end
RSpec.configure do |config|
- config.include Helpers
config.before(:all) do
Aeolus::Image::BaseCommand.class_eval do
def load_config
@@ -62,13 +30,4 @@ RSpec.configure do |config|
end
end
end
- config.before(:each) do
- @output = double('output')
- @stdout_orig = $stdout
- $stdout = StringIO.new
- @options = {}
- end
- config.after(:each) do
- $stdout = @stdout_orig
- end
-end
+end
\ No newline at end of file
--
1.7.6.2