[PATCH aeolus-image-rubygem] Add provider_account-filtered 'provider images' method to build model
by Scott Seago
---
lib/aeolus_image/model/warehouse/image_build.rb | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/aeolus_image/model/warehouse/image_build.rb b/lib/aeolus_image/model/warehouse/image_build.rb
index 234a3aa..5b9f7d4 100644
--- a/lib/aeolus_image/model/warehouse/image_build.rb
+++ b/lib/aeolus_image/model/warehouse/image_build.rb
@@ -34,6 +34,15 @@ module Aeolus
end
provider_images
end
+ def provider_images_by_provider_and_account(provider, provider_account)
+ provider_images = []
+ target_images.each do |t|
+ provider_images = provider_images +
+ t.find_provider_image_by_provider_and_account(provider,
+ provider_account)
+ end
+ provider_images
+ end
# Deletes this image and all child objects
def delete!
--
1.7.6.4
12 years, 3 months
[PATCH conductor 0/1] 744081 - Preset filters are always used
by Matt Wagner
I was asked to look at 744081, in which Monitor > Instances would "blink" when an instance was stopped. This was rather baffling, and what I found out (from this very old, but still applicable bug) is that Backbone would automatically fetch _all_ images to update the instance list with, even when a filter was selected. (And a filter is selected by default -- "Non-stopped instances".) So the instance would correctly disappear from the list when stopped, but then incorrectly re-appear in the list on the next Backbone update.
As luck would have it, Imre made some unrelated changes to Backbone's treatment of filter lists that were committed this morning. This was incredibly fortunate because it just happened to be the perfect base for me to build on top of, so cheers for that!
Please note that I would rank my Backbone / jQuery / JavaScript skills as relatively marginal, so whoever reviews this patch may want to be a little more careful than usual in scrutinizing the changes I made.
-- Matt
12 years, 3 months
Push image to ESX host
by Baird Cowan
I am also having issues, pushing it to the ESX host. Could this center around my oauth issues, I have restarted imagefactory with --no_oauth that helped me build the image from the template, but when I push the image to the ESX host. I can see it try to go but if fails
aeolus-cli push --provider vsphere --account vsphere --image d60f6adf-1930-420e-9c78-8b8089e1b2bb
2012-01-05 14:47:47,933 DEBUG imgfac.builders.BaseBuilder.Fedora_vsphere_Builder pid(19144) Message: Exception caught in ImageFactory
2012-01-05 14:47:47,933 DEBUG imgfac.builders.BaseBuilder.Fedora_vsphere_Builder pid(19144) Message: Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/imgfac/builders/Fedora_vsphere_Builder.py", line 234, in push_image_upload
credentials)
File "/usr/lib/python2.7/site-packages/imgfac/builders/Fedora_vsphere_Builder.py", line 221, in vmware_push_image_upload
guest_id='otherLinux64Guest', imagefilename=input_image)
File "/usr/lib/python2.7/site-packages/imgfac/VMWare.py", line 183, in import_vm
curl.perform()
error: (6, 'Could not resolve host: (HttpNfcLeaseDeviceUrl){; Cannot allocate memory')
2012-01-05 14:47:47,933 DEBUG imgfac.BuildJob.BuildJob pid(19144) Message: Builder (a8dde64f-0f88-430d-a1bd-c14660e691f0) changed status from PUSHING to FAILED
2012-01-05 14:47:47,933 DEBUG imgfac.builders.BaseBuilder.Fedora_vsphere_Builder pid(19144) Message: Exception caught in ImageFactory
2012-01-05 14:47:47,933 DEBUG imgfac.builders.BaseBuilder.Fedora_vsphere_Builder pid(19144) Message: Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/imgfac/builders/Fedora_vsphere_Builder.py", line 192, in push_image
self.push_image_upload(target_image_id, provider, credentials)
File "/usr/lib/python2.7/site-packages/imgfac/builders/Fedora_vsphere_Builder.py", line 234, in push_image_upload
credentials)
File "/usr/lib/python2.7/site-packages/imgfac/builders/Fedora_vsphere_Builder.py", line 221, in vmware_push_image_upload
guest_id='otherLinux64Guest', imagefilename=input_image)
File "/usr/lib/python2.7/site-packages/imgfac/VMWare.py", line 183, in import_vm
curl.perform()
error: (6, 'Could not resolve host: (HttpNfcLeaseDeviceUrl){; Cannot allocate memory')
2012-01-05 14:47:47,933 DEBUG imgfac.BuildJob.BuildJob pid(19144) Message: Builder (a8dde64f-0f88-430d-a1bd-c14660e691f0) changed status from FAILED to FAILED
CONFIDENTIALITY NOTICE: This communication with its contents may contain confidential and/or legally privileged information. It is solely for the use of the intended recipient(s). Unauthorized interception, review, use or disclosure is prohibited and may violate applicable laws including the Electronic Communications Privacy Act. If you are not the intended recipient, please contact the sender and destroy all copies of the communication.
12 years, 3 months
build error
by Baird Cowan
What could be causing this when trying to build a template. I am following the configure it as detailed. It happens regardless of the template I use.
# aeolus-cli build --target vsphere --template ~/template2.tpl
cat ~/template2.xml
cat ~/template2.tpl
<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/Fedora/x86...</url>
</install>
</os>
<repositories>
<repository name="custom">
<url>http://repos.fedorapeople.org/repos/aeolus/demo/webapp/</url>
<signed>false</signed>
</repository>
</repositories>
</template>
2012-01-05 11:33:52,842 ERROR imgfac.rest.imagefactory pid(3189) Message: None object cannot be quoted
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/imgfac/rest/imagefactory.py", line 50, in validate_two_leg_oauth
oauth_server.verify_request(req, oauth_consumer, None)
File "/usr/lib/python2.7/site-packages/oauth2/__init__.py", line 602, in verify_request
self._check_signature(request, consumer, token)
File "/usr/lib/python2.7/site-packages/oauth2/__init__.py", line 652, in _check_signature
valid = signature_method.check(request, consumer, token, signature)
File "/usr/lib/python2.7/site-packages/oauth2/__init__.py", line 705, in check
built = self.sign(request, consumer, token)
File "/usr/lib/python2.7/site-packages/oauth2/__init__.py", line 730, in sign
key, raw = self.signing_base(request, consumer, token)
File "/usr/lib/python2.7/site-packages/oauth2/__init__.py", line 722, in signing_base
key = '%s&' % escape(consumer.secret)
File "/usr/lib/python2.7/site-packages/oauth2/__init__.py", line 86, in escape
return urllib.quote(s, safe='~')
File "/usr/lib64/python2.7/urllib.py", line 1225, in quote
raise TypeError('None object cannot be quoted')
TypeError: None object cannot be quoted
CONFIDENTIALITY NOTICE: This communication with its contents may contain confidential and/or legally privileged information. It is solely for the use of the intended recipient(s). Unauthorized interception, review, use or disclosure is prohibited and may violate applicable laws including the Electronic Communications Privacy Act. If you are not the intended recipient, please contact the sender and destroy all copies of the communication.
12 years, 3 months
[PATCH conductor] Fix autoupdate with table filters
by Imre Farkas
From: Imre Farkas <ifarkas(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=770625
---
src/public/javascripts/application.js | 13 ++++++++++++
src/public/javascripts/backbone/models.js | 19 ++++++++++++++---
src/public/javascripts/backbone/routers.js | 3 +-
src/public/javascripts/backbone/views.js | 30 ++++++++++++++++++++++++++++
4 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/src/public/javascripts/application.js b/src/public/javascripts/application.js
index 04fb4d3..621a175 100644
--- a/src/public/javascripts/application.js
+++ b/src/public/javascripts/application.js
@@ -169,6 +169,19 @@ $.extend(Conductor, {
return prefix + path;
},
+ parameterizedPath: function(url, queryParams) {
+ var result = url;
+
+ if (!$.isEmptyObject(queryParams)) {
+ var params = $.map(queryParams, function(value, key) {
+ return key + '=' + value;
+ });
+ result += '?' + params.join('&');
+ }
+
+ return result;
+ },
+
AJAX_REFRESH_INTERVAL: 30 * 1000,
initializeBackbone: function() {
diff --git a/src/public/javascripts/backbone/models.js b/src/public/javascripts/backbone/models.js
index 7c48778..d576feb 100644
--- a/src/public/javascripts/backbone/models.js
+++ b/src/public/javascripts/backbone/models.js
@@ -7,17 +7,24 @@ Conductor.Models.Pool = Backbone.Model.extend({
Conductor.Models.Pools = Backbone.Collection.extend({
model: Backbone.Model.Pool,
- url: Conductor.prefixedPath('/pools'),
+ queryParams: {},
+ url: function() {
+ var path = Conductor.prefixedPath('/pools');
+ return Conductor.parameterizedPath(path, this.queryParams);
+ }
});
-
Conductor.Models.Instance = Backbone.Model.extend({
urlRoot: Conductor.prefixedPath('/instances'),
});
Conductor.Models.Instances = Backbone.Collection.extend({
model: Backbone.Model.Instance,
- url: Conductor.prefixedPath('/instances'),
+ queryParams: {},
+ url: function() {
+ var path = Conductor.prefixedPath('/instances');
+ return Conductor.parameterizedPath(path, this.queryParams);
+ }
});
Conductor.Models.Deployment = Backbone.Model.extend({
@@ -32,5 +39,9 @@ Conductor.Models.Deployment = Backbone.Model.extend({
Conductor.Models.Deployments = Backbone.Collection.extend({
model: Backbone.Model.Deployment,
- url: Conductor.prefixedPath('/deployments'),
+ queryParams: {},
+ url: function() {
+ var path = Conductor.prefixedPath('/deployments');
+ return Conductor.parameterizedPath(path, this.queryParams);
+ }
});
diff --git a/src/public/javascripts/backbone/routers.js b/src/public/javascripts/backbone/routers.js
index cb55730..d7606b7 100644
--- a/src/public/javascripts/backbone/routers.js
+++ b/src/public/javascripts/backbone/routers.js
@@ -31,10 +31,11 @@ Conductor.Routers.Pools = Backbone.Router.extend({
view.collection = new Conductor.Models.Deployments();
}
+ view.collection.queryParams = view.queryParams();
view.collection.bind('change', function() { view.render() });
view.collection.fetch({ success: function() {
- view.collection.trigger('change')
+ view.collection.trigger('change');
}})
}, Conductor.AJAX_REFRESH_INTERVAL);
diff --git a/src/public/javascripts/backbone/views.js b/src/public/javascripts/backbone/views.js
index 680ca9d..0f38e18 100644
--- a/src/public/javascripts/backbone/views.js
+++ b/src/public/javascripts/backbone/views.js
@@ -38,6 +38,36 @@ Conductor.Views.PoolsIndex = Backbone.View.extend({
}
},
+ urlParams: function() {
+ var paramsData = window.location.search.slice(1).split('&');
+ var params = {};
+ $.each(paramsData, function(index, value){
+ var eqSign = value.search('=');
+ if(eqSign != -1) {
+ params[value.substring(0, eqSign)] = value.substring(eqSign+1);
+ }
+ });
+
+ return params;
+ },
+
+ queryParams: function() {
+ var result = {};
+ var paramsToInclude = [this.currentTab() + '_preset_filter', this.currentTab() + '_search'];
+ var urlParams = this.urlParams();
+
+ $.each(paramsToInclude, function(paramIndex, paramValue) {
+ for (var urlParamName in urlParams) {
+ if (urlParamName == paramValue) {
+ result[urlParamName] = urlParams[urlParamName];
+ break;
+ }
+ };
+ });
+
+ return result;
+ },
+
render: function() {
var $template = this.template();
--
1.7.6.4
12 years, 3 months
[PATCH conductor] Adding 'No catalog' label when no catalog available for the deployable when creating image
by Imre Farkas
From: Imre Farkas <ifarkas(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=770807
---
.../views/deployables/_new_from_image.html.haml | 16 ++++++++++------
src/config/locales/en.yml | 1 +
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/app/views/deployables/_new_from_image.html.haml b/src/app/views/deployables/_new_from_image.html.haml
index d11ff29..d57c5ed 100644
--- a/src/app/views/deployables/_new_from_image.html.haml
+++ b/src/app/views/deployables/_new_from_image.html.haml
@@ -26,12 +26,16 @@
 
%div.catalog_list
%ul.more
- - @catalogs.each do |catalog|
- %li.catalog
- .catalog_with_checkbox
- = check_box_tag 'catalog_id[]', catalog.id, @selected_catalogs.any?{|c| c.id == catalog.id}
- = catalog.name
- .clear
+ - if @catalogs.empty?
+ = t('deployables.new_from_image.no_available_catalog')
+ - else
+ - @catalogs.each do |catalog|
+ %li.catalog
+ .catalog_with_checkbox
+ = check_box_tag 'catalog_id[]', catalog.id, @selected_catalogs.any?{|c| c.id == catalog.id}
+ = catalog.name
+ .clear
+
.clear
.centered
%fieldset.align-center
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 4be4510..adbbf04 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -792,6 +792,7 @@ en:
catalog_entry_name: "%{name}"
title: Create Deployable
description: "Creating a deployable from the \"%{name}\" component outline will allow it to be built and launched. Simply choose a catalog in which to store the deployable, and define a default cloud resource profile."
+ no_available_catalog: 'No available catalog exists'
show:
images: "Images"
launch: "Launch"
--
1.7.6.4
12 years, 3 months
[PATCH aeolus-image-rubygem 0/1] RFC: Properly sign POSTs for iwhd
by Matt Wagner
Hi all,
This patch should fix https://bugzilla.redhat.com/show_bug.cgi?id=760592 (with a moderately-incorrect title), in which aeolus-image-rubygem generates invalid OAuth requests when speaking to iwhd. Specifically, the oauth_body_hash is incorrect.
Greg Blomquist fixed a related issue in Audrey, determining that RestClient is not including the entire body when signing requests and just using the OAuth gem directly to make requests. (See https://bugzilla.redhat.com/show_bug.cgi?id=760377 for that one.) This patch implements a similar approach for aeolus-image-rubygem.
Note that, today, iwhd is not verifying this value; https://www.aeolusproject.org/redmine/issues/2606 exists to implement that feature. The bad news is that this means this fix is mostly academic until that patch is implemented. The good news is that it means we can safely implement this patch now without breaking reverse compatibility.
I verified that the oauth_body_hash parameter was changed by using Wireshark with a "tcp.port == 9090" filter, for what it's worth. The POST generated by fetching an image has a body of "op=parts", which should generate the hashes seen in Redmine 2606, linked above.
-- Matt
12 years, 3 months
[PATCH aeolus-cli] BZ#767099 Restructured Config Parser
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
lib/aeolus_cli/command/config_parser.rb | 338 ++++++++++++++++--------------
spec/command/config_parser_spec.rb | 32 ++--
2 files changed, 193 insertions(+), 177 deletions(-)
diff --git a/lib/aeolus_cli/command/config_parser.rb b/lib/aeolus_cli/command/config_parser.rb
index 6f66fba..ff1172d 100644
--- a/lib/aeolus_cli/command/config_parser.rb
+++ b/lib/aeolus_cli/command/config_parser.rb
@@ -19,6 +19,7 @@ module Aeolus
module CLI
class ConfigParser
COMMANDS = %w(list build push import delete status)
+
attr_accessor :options, :command, :args
def initialize(argv)
@@ -34,124 +35,152 @@ module Aeolus
# Eventually get the config file from user dir if it exists.
# File.expand_path("~")
if COMMANDS.include?(@command)
- parse(@command)
- self.send((a)command.to_sym) unless @args.include?('-h')
+ opts = self.send((@command + "Options").to_sym)
+ if @args.include?('-h')
+ puts opts
+ else
+ parse(opts)
+ self.send((a)command.to_sym)
+ end
else
- @args << "-h"
- puts "Valid command required: \n\n"
- parse
+ puts generalOptions
+ exit(1)
end
end
- private
- def parse(subcommand = nil)
- subcommand = subcommand.to_sym if subcommand
+ def parse(opts)
+ begin
+ opts.parse(@args)
+ rescue OptionParser::InvalidOption => io
+ puts "Warning, " + io.message + "\n\tSee `aeolus-image " + @command + " -h` for usage information."
+ exit(1)
+ rescue OptionParser::MissingArgument => e
+ puts "Warning, #{e.message}" + "\n\tSee `aeolus-image " + @command + " -h` for usage information."
+ exit(1)
+ end
+ end
- @optparse ||= OptionParser.new do|opts|
- opts.banner = "Usage: aeolus-image [#{COMMANDS.join('|')}] [general options] [command options]"
+ def generalOptions
+ subtext = "Aeolus Image Commands:"
+ subtext += "\n list : Lists Aeolus Image Resources"
+ subtext += "\n build : Builds a new Image"
+ subtext += "\n push : Pushes an Image to a particular Provider Account"
+ subtext += "\n import : Imports an existing image"
+ subtext += "\n delete : Delete an Aeolus Image Resource"
+ subtext += "\n status : Check the status of a push or build"
+ subtext += "\nSee `aeolus-image <command> -h` for more information on each command"
- opts.separator ""
- opts.separator "General options:"
- opts.on('-d', '--id ID', 'id for a given object') do |id|
+ general = OptionParser.new do |opts|
+ opts.banner = "Usage: aeolus-image [#{COMMANDS.join('|')}] [command options]"
+ opts.on( '-h', '--help', 'Get usage information for this tool') do
+ puts opts
+ exit(0)
+ end
+ opts.separator(subtext)
+ end
+ general
+ end
+
+ def listOptions
+ OptionParser.new do |opts|
+ opts.banner = "Usage: aeolus-image list [command 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('-r', '--description NAME', 'description (e.g. "<image><name>MyImage</name></image>" or "/home/user/myImage.xml")') do |description|
- @options[:description] = description
+ opts.on('-t', '--targetimages ID', 'Retrieve the target images from a build') do |id|
+ @options[:subcommand] = :targetimages
+ @options[:id] = id
end
- opts.on('-r', '--provider NAME1,NAME2', Array,'name of specific provider (ie ec2-us-east1)') do |name|
- @options[:provider] = name
+ opts.on('-P', '--providerimages ID', 'Retrieve the provider images from a target image') do |id|
+ @options[:subcommand] = :providerimages
+ @options[:id] = id
end
- opts.on('-a', '--provider_account NAME1,NAME2', Array,'name of specific provider account (ie my-ec2') do |name|
- @options[:provider_account] = name
+ opts.on('-g', '--targets', 'Retrieve the values available for the --target parameter') do
+ @options[:subcommand] = :targets
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
+ 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.on( '-h', '--help', 'Get usage information for this command')
+
+ opts.separator ""
+ opts.separator "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 --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"
+ end
+ end
+
+ def buildOptions
+ OptionParser.new do |opts|
+ opts.banner = "Usage: aeolus-image build [command options]"
+ opts.separator ""
+ opts.separator "Options:"
+ opts.on('-e', '--template FILE', 'path to file that contains template xml') do |file|
+ @options[:template] = file
+ end
+ opts.on('-z', '--no-validation', 'Do not validation the template against the TDL XML Schema') do |description|
+ @options[:validation] = false
end
opts.on('-T', '--target TARGET1,TARGET2', Array, 'provider type (ec2, rackspace, rhevm, etc)') do |name|
@options[:target] = name
end
- opts.on( '-h', '--help', 'Get usage information for this tool') do
- puts opts
- exit(0)
- end
+ opts.on( '-h', '--help', 'Get usage information for this command')
- if !subcommand || subcommand == :list
- 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
- end
+ opts.separator ""
+ opts.separator "Examples:"
+ opts.separator "aeolus-image build --target ec2 --template my.tmpl # build a new image for ec2 from based on the given template"
+ opts.separator "aeolus-image build --target ec2,rhevm --template my.tmpl # build a new image for ec2 and for rhevm based on the given 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}
+ end
+ end
- if !subcommand || subcommand == :build
- 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.on('-z', '--no-validation', 'Do not validation the template against the TDL XML Schema') do |description|
- @options[:validation] = false
- end
+ def pushOptions
+ OptionParser.new do |opts|
+ opts.banner = "Usage: aeolus-image push [command options]"
+ opts.separator ""
+ opts.separator "Options:"
+ 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
-
- if !subcommand || subcommand == :push
- 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('-t', '--targetimages ID', 'Retrieve the target images from a build') do |id|
- @options[:targetimage] = id
- end
- opts.on('-A', '--account NAME', 'name of specific provider account to use for push') do |name|
- @options[:account] = name
- end
+ opts.on('-B', '--build ID', 'push all target images for a build, to same providers as previously') do |id|
+ @options[:build] = id
end
-
- if !subcommand || subcommand == :delete
- 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('-t', '--targetimages ID', 'Retrieve the target images from a build') do |id|
+ @options[:targetimage] = id
end
+ opts.on('-A', '--account NAME,NAME', Array, 'name of specific provider account to use for push') do |name|
+ @options[:account] = name
+ end
+ opts.on( '-h', '--help', 'Get usage information for this command')
+
+ opts.separator ""
+ opts.separator "Examples:"
+ opts.separator "aeolus-image push --account ec2-account,ec2-account2 --targetimage $target_image_id # Push target images to each of the specified account"
+ opts.separator "aeolus-image push --account ec2-account,rhevm-account --build $build_id # Push target images attached to a particular build to each of the specified accounts"
+ opts.separator "aeolus-image push --account ec2-account,rhevm-account --image $image_id # Push target images attached to a particular image to each of the specified accounts"
+ end
+ end
+ def statusOptions
+ OptionParser.new do |opts|
+ opts.banner = "Usage: aeolus-image status [command options]"
opts.separator ""
- opts.separator "Status options:"
+ opts.separator "Options:"
opts.on('-t', '--targetimage ID', 'target image status') do |id|
@options[:subcommand] = :target_image
@options[:targetimage] = id
@@ -160,79 +189,71 @@ module Aeolus
@options[:subcommand] = :provider_image
@options[:providerimage] = id
end
+ opts.on( '-h', '--help', 'Get usage information for this command')
- opts.separator ""
- opts.separator "URL with credentials to Conductor are set in ~/.aeolus-cli"
- opts.separator "Conductor URL should point to https://<host_where_conductor_runs>/conductor/api"
+ opts.separator "Examples:"
+ opts.separator "aeolus-image status --targetimage $target_image # status of target image build"
+ opts.separator "aeolus-image status --providerimage $provider_image # status of provider image push"
+ end
+ end
- if !subcommand || subcommand == :list
- 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 --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"
+ def importOptions
+ OptionParser.new do |opts|
+ opts.banner = "Usage: aeolus-image import [command options]"
+ opts.separator ""
+ opts.separator "Options:"
+ opts.on('-d', '--id ID', 'id for a given object') do |id|
+ @options[:id] = id
end
-
- if !subcommand || subcommand == :build
- opts.separator ""
- opts.separator "Build examples:"
- opts.separator "aeolus-image build --target ec2 --template my.tmpl # build a new image for ec2 from based on the given template"
- opts.separator "aeolus-image build --target ec2,rhevm --template my.tmpl # build a new image for ec2 and for rhevm based on the given 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.on('-r', '--description NAME', 'description (e.g. "<image><name>MyImage</name></image>" or "/home/user/myImage.xml")') do |description|
+ @options[:description] = description
end
-
- if !subcommand || subcommand == :push
- opts.separator ""
- opts.separator "Push examples:"
- opts.separator "aeolus-image push --account ec2-account,ec2-account2 --targetimage $target_image_id # Push target images to each of the specified account"
- opts.separator "aeolus-image push --account ec2-account,rhevm-account --build $build_id # Push target images attached to a particular build to each of the specified accounts"
- opts.separator "aeolus-image push --account ec2-account,rhevm-account --image $image_id # Push target images attached to a particular image to each of the specified accounts"
+ opts.on('-A', '--account NAME,NAME', Array, 'name of specific account to import to') do |name|
+ @options[:provider_account] = name
end
+ opts.on( '-h', '--help', 'Get usage information for this command')
- if !subcommand || subcommand == :import
- opts.separator ""
- opts.separator "Import examples:"
- opts.separator "aeolus-image import --provider_account my-ec2 --id $ami_id # import an AMI from the specified provider"
- opts.separator "aeolus-image import --provider_account my-ec2 --id $ami_id --description '<image><name>My Image</name></image>' # import an AMI from the specified provider"
- opts.separator "aeolus-image import --provider_account my-ec2 --id $ami_id --description <path_to_xml_file> # import an AMI from the specified provider"
- end
+ opts.separator ""
+ opts.separator "Examples:"
+ opts.separator "aeolus-image import --account my-ec2 --id $ami_id # import an AMI from the specified provider"
+ opts.separator "aeolus-image import --account my-ec2 --id $ami_id --description '<image><name>My Image</name></image>' # import an AMI from the specified provider"
+ opts.separator "aeolus-image import --account my-ec2 --id $ami_id --description <path_to_xml_file> # import an AMI from the specified provider"
+ end
+ end
- if !subcommand || subcommand == :status
- opts.separator "Status examples:"
- opts.separator "aeolus-image status --targetimage $target_image # status of target image build"
- opts.separator "aeolus-image status --providerimage $provider_image # status of provider image push"
- end
+ def deleteOptions
+ OptionParser.new do |opts|
+ opts.banner = "Usage: aeolus-image delete [command options]"
+ opts.separator ""
- if !subcommand || subcommand == :delete
- opts.separator ""
- opts.separator "Delete examples: (DELETE CURRENTLY NOT IMPLEMENTED) "
- opts.separator "aeolus-image delete --image $image_id # deletes a image and all associated builds"
- opts.separator "aeolus-image delete --build $build_id # deletes a build and all associated targetimages"
- opts.separator "aeolus-image delete --targetimage $target_image # deletes a target image and all associated provider images"
- opts.separator "aeolus-image delete --providerimage $provider_image # deletes a provider image"
+ opts.separator "Delete options:"
+ opts.on('-I', '--image ID', 'delete build image and associated objects') do |id|
+ @options[:subcommand] = :image
+ @options[:image] = id
end
- 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( '-h', '--help', 'Get usage information for this command')
- begin
- @optparse.parse(@args)
- rescue OptionParser::InvalidOption
- puts "Warning: Invalid option"
- exit(1)
- rescue OptionParser::MissingArgument => e
- puts "Warning, #{e.message}"
- exit(1)
+ opts.separator ""
+ opts.separator "Delete examples:"
+ opts.separator "aeolus-image delete --image $image_id # deletes a image and all associated builds"
+ opts.separator "aeolus-image delete --build $build_id # deletes a build and all associated targetimages"
+ opts.separator "aeolus-image delete --targetimage $target_image # deletes a target image and all associated provider images"
+ opts.separator "aeolus-image delete --providerimage $provider_image # deletes a provider image"
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)
@@ -242,7 +263,7 @@ module Aeolus
# 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"
+ puts "Could not find options for list, run `./aeolus-image list --help` for usage instructions"
exit(1)
else
list_command = ListCommand.new(@options)
@@ -280,6 +301,7 @@ module Aeolus
status_command = StatusCommand.new(@options)
status_command.run
end
+
end
end
-end
+end
\ No newline at end of file
diff --git a/spec/command/config_parser_spec.rb b/spec/command/config_parser_spec.rb
index f3ab88c..5c9c46a 100644
--- a/spec/command/config_parser_spec.rb
+++ b/spec/command/config_parser_spec.rb
@@ -43,7 +43,7 @@ module Aeolus
it "should notify the user of an invalid command" do
config_parser = ConfigParser.new(%w(sparkle))
- config_parser.should_receive(:exit).with(0)
+ config_parser.should_receive(:exit).with(1)
silence_stream(STDOUT) do
config_parser.process
end
@@ -146,8 +146,8 @@ module Aeolus
context "for import command" do
context "without other options" do
- let ( :parameters ) { %w(import --provider ec2-us-east-1a --description /path/to/file --id ami-123456 --target ec2) }
- let ( :options_hash ) { { :provider => ['ec2-us-east-1a'], :target => ['ec2'], :description => '/path/to/file', :id => 'ami-123456' } }
+ let ( :parameters ) { %w(import --account ec2-us-east-1a --description /path/to/file --id ami-123456) }
+ let ( :options_hash ) { { :provider_account => ['ec2-us-east-1a'], :description => '/path/to/file', :id => 'ami-123456' } }
its ( :options ) { should include( options_hash ) }
end
@@ -155,14 +155,14 @@ module Aeolus
context "for build command" do
context "with --template FILE" do
- let ( :parameters ) { %w(build --target ec2,rackspace --image 12345 --template my.tmpl) }
- let ( :options_hash ) { { :target => ['ec2','rackspace'], :image => '12345', :template => 'my.tmpl' } }
+ let ( :parameters ) { %w(build --target ec2,rackspace --template my.tmpl) }
+ let ( :options_hash ) { { :target => ['ec2','rackspace'], :template => 'my.tmpl' } }
its ( :options ) { should include( options_hash ) }
end
context "with --no-validation" do
- let ( :parameters ) { %w(build --target ec2,rackspace --image 12345 --no-validation) }
- let ( :options_hash ) { { :target => ['ec2','rackspace'], :image => '12345', :validation => false } }
+ let ( :parameters ) { %w(build --target ec2,rackspace --no-validation) }
+ let ( :options_hash ) { { :target => ['ec2','rackspace'], :validation => false } }
its ( :options ) { should include( options_hash ) }
end
@@ -170,26 +170,20 @@ module Aeolus
context "for push command" do
context "without other options" do
- let ( :parameters ) { %w(push --provider ec2-us-east1 --id 12345) }
- let ( :options_hash ) { { :provider => ['ec2-us-east1'], :id => '12345' } }
+ let ( :parameters ) { %w(push --account ec2-us-east1 --image 12345) }
+ let ( :options_hash ) { { :account => ['ec2-us-east1'], :image => '12345' } }
its ( :options ) { should include( options_hash ) }
end
context "with --build ID" do
- let ( :parameters ) { %w(push --provider ec2-us-east1 --build 12345) }
- let ( :options_hash ) { { :provider => ['ec2-us-east1'], :build => '12345' } }
+ let ( :parameters ) { %w(push --account ec2-us-east1 --build 12345) }
+ let ( :options_hash ) { { :account => ['ec2-us-east1'], :build => '12345' } }
its ( :options ) { should include( options_hash ) }
end
context "with --targetimage ID" do
- let ( :parameters ) { %w(push --provider ec2-us-east1 --targetimage 12345) }
- let ( :options_hash ) { { :provider => ['ec2-us-east1'], :targetimage => '12345' } }
-
- its ( :options ) { should include( options_hash ) }
- end
- context "with --account NAME" do
- let ( :parameters ) { %w(push --provider ec2-us-east1 --account 12345) }
- let ( :options_hash ) { { :provider => ['ec2-us-east1'], :account => '12345' } }
+ let ( :parameters ) { %w(push --account ec2-us-east1 --targetimage 12345) }
+ let ( :options_hash ) { { :account => ['ec2-us-east1'], :targetimage => '12345' } }
its ( :options ) { should include( options_hash ) }
end
--
1.7.6.4
12 years, 3 months