[PATCH aeolus 2/2] Added List Images Functionaliy
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
.../aeolus-image/lib/config_parser.rb | 9 ++++++++-
.../image_factory/aeolus-image/lib/list_command.rb | 5 +++++
.../aeolus-image/spec/config_parser_spec.rb | 14 +++++++++++++-
.../aeolus-image/spec/list_command_spec.rb | 17 +++++++++++++++++
4 files changed, 43 insertions(+), 2 deletions(-)
create mode 100644 services/image_factory/aeolus-image/spec/list_command_spec.rb
diff --git a/services/image_factory/aeolus-image/lib/config_parser.rb b/services/image_factory/aeolus-image/lib/config_parser.rb
index 3ee8b1e..b59a723 100644
--- a/services/image_factory/aeolus-image/lib/config_parser.rb
+++ b/services/image_factory/aeolus-image/lib/config_parser.rb
@@ -171,7 +171,14 @@ module Aeolus
# 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])
- "Not implemented"
+ 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(0)
+ else
+ list_command = ListCommand.new(@options)
+ list_command.send(@options[:subcommand])
+ end
end
def build
diff --git a/services/image_factory/aeolus-image/lib/list_command.rb b/services/image_factory/aeolus-image/lib/list_command.rb
index 35f6927..9939f74 100644
--- a/services/image_factory/aeolus-image/lib/list_command.rb
+++ b/services/image_factory/aeolus-image/lib/list_command.rb
@@ -4,6 +4,11 @@ module Aeolus
def initialize(opts={}, logger=nil)
super(opts, logger)
end
+
+ def images
+ doc = Nokogiri::XML iwhd['/images'].get
+ doc.xpath("/objects/object/key").collect { |node| "uuid: " + node.text }
+ end
end
end
end
diff --git a/services/image_factory/aeolus-image/spec/config_parser_spec.rb b/services/image_factory/aeolus-image/spec/config_parser_spec.rb
index e923345..7473add 100644
--- a/services/image_factory/aeolus-image/spec/config_parser_spec.rb
+++ b/services/image_factory/aeolus-image/spec/config_parser_spec.rb
@@ -4,11 +4,23 @@ module Aeolus
module Image
describe ConfigParser do
it "should parse the specified command" do
- config_parser = ConfigParser.new(%w(list))
+ 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(0)
+ end
+ rescue SystemExit => e
+ e.status.should == 0
+ 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)
diff --git a/services/image_factory/aeolus-image/spec/list_command_spec.rb b/services/image_factory/aeolus-image/spec/list_command_spec.rb
new file mode 100644
index 0000000..1f47b47
--- /dev/null
+++ b/services/image_factory/aeolus-image/spec/list_command_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+module Aeolus
+ module Image
+ describe ListCommand do
+ it "should return a list of images" do
+ regexp = Regexp.new('[uuid:\s][\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
+ listc = ListCommand.new(:subcommand => 'images')
+ images = listc.images
+ images.each do |image|
+ regexp.match(image.to_s).should_not == nil
+ end
+ end
+
+ end
+ end
+end
\ No newline at end of file
--
1.7.4
12 years, 11 months
[PATCH] Make the oz package architecture independent
by Pádraig Brady
I noticed that the oz package wasn't "noarch".
I changed that and considered excluding icicle-nc from
the "binary in noarch rpm" check, but then thought it
better to replace the static binary with the following script.
Hopefully it's generic enough.
The patch can be applied with `git am`
and is available here (due to mailing list size limits (200K)):
http://www.pixelbeat.org/patches/oz-noarch.diff
cheers,
Pádraig.
#!/bin/bash
# A script that tries various methods to connect to...
host=$1
port=$2
exec 3<>/dev/tcp/$host/$port ||
nc $host $port </dev/null ||
echo "\
use strict;
use IO::Socket;
my \$sock = new IO::Socket::INET (PeerAddr => '$host',
PeerPort => '$port',
Proto => 'tcp',
);
die \"Could not create socket: \$!\n\" unless \$sock;
close (\$sock);
" | perl
12 years, 11 months
Weird Aeolus repo problem - .index.html.swp
by Justin Clift
Hi all,
Does anyone know what's re-creating the .index.html.swp file
below in our Aeolus repos:
$ ls -la /srv/repos/aeolus/conductor/
total 20
drwxrwsr-x. 4 morazi gitaeolus 4096 Jun 13 19:36 .
drwxrwxr-x. 9 mmorsi gitaeolus 4096 Jun 10 17:30 ..
drwxrwsr-x. 4 morazi gitaeolus 4096 May 12 22:18 0.2.0
-rw-------. 1 slinabery gitaeolus 4096 May 18 03:23 .index.html.swp
drwxrwxr-x. 4 rwsu gitaeolus 4096 May 17 19:53 testing
$
Looks like a vi temp file that's left over, which normally
wouldn't be a stress.
The no-group-read access permissions on it break my nightly rsync
backup of our repo though. :(
And every time I nuke the file, it comes back within a day or
two. (always with May 18th timestamp)
Is someone accidentally recreating it from their own local
repo or something when they update our repo site?
Regards and best wishes,
Justin Clift
--
Aeolus Community Manager
http://www.aeolusproject.org
12 years, 11 months
Breadcrumbs in Administer section
by Jirka Tomasek
Revorked breadcrumbs, now work in administer section, remember history
when going back, clearing breadcrumbs in selected actions. Doesnt
support hierarchy yet.
12 years, 11 months
[PATCH conductor] Fixed "New Deployment" link
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
Added missing pool_id param
---
src/app/views/pools/_pretty_list.haml | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/app/views/pools/_pretty_list.haml b/src/app/views/pools/_pretty_list.haml
index 3a0c2ca..b9683f0 100644
--- a/src/app/views/pools/_pretty_list.haml
+++ b/src/app/views/pools/_pretty_list.haml
@@ -30,7 +30,7 @@
%li
%a{:href => pool_path(pool)}= "#{pool.name} Pool details »"
%li
- = link_to 'New Deployment', launch_new_deployments_path, :class => 'button primary', :id => 'new_deployment_button'
+ = link_to 'New Deployment', launch_new_deployments_path(:pool_id => pool.id), :class => 'button primary', :id => 'new_deployment_button'
:javascript
$(document).ready(function() {
--
1.7.4
12 years, 11 months
Fixing patch related w/ #1755
by jzigmund@redhat.com
During testing #1755 I found that some flash messages weren't implemented on multi_destroy actions so this patch adds those messages.
12 years, 11 months
[PATCH aeolus 1/2] Added RestClient Resources for imagefactory/conductor
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
.../image_factory/aeolus-image/config/cli.yaml | 7 +++
.../aeolus-image/config/imagefactory_cli | 8 +++
.../image_factory/aeolus-image/lib/base_command.rb | 56 ++++++++++++++++++++
.../aeolus-image/spec/base_command_spec.rb | 26 +++++++++
.../aeolus-image/spec/fixtures/imagefactory-cli | 7 +++
5 files changed, 104 insertions(+), 0 deletions(-)
create mode 100644 services/image_factory/aeolus-image/config/cli.yaml
create mode 100644 services/image_factory/aeolus-image/config/imagefactory_cli
create mode 100644 services/image_factory/aeolus-image/spec/base_command_spec.rb
create mode 100644 services/image_factory/aeolus-image/spec/fixtures/imagefactory-cli
diff --git a/services/image_factory/aeolus-image/config/cli.yaml b/services/image_factory/aeolus-image/config/cli.yaml
new file mode 100644
index 0000000..b83862e
--- /dev/null
+++ b/services/image_factory/aeolus-image/config/cli.yaml
@@ -0,0 +1,7 @@
+imagefactory:
+ url: http://localhost:9090
+
+conductor:
+ url: http://localhost:3000/conductor
+ username: admin
+ password: password
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/config/imagefactory_cli b/services/image_factory/aeolus-image/config/imagefactory_cli
new file mode 100644
index 0000000..9ab77bb
--- /dev/null
+++ b/services/image_factory/aeolus-image/config/imagefactory_cli
@@ -0,0 +1,8 @@
+# Place this file in: ~/.imagefactory-cli
+imagefactory:
+ url: http://localhost:9090
+
+conductor:
+ url: http://localhost:3000/conductor
+ username: admin
+ password: password
diff --git a/services/image_factory/aeolus-image/lib/base_command.rb b/services/image_factory/aeolus-image/lib/base_command.rb
index 4d4fa42..3bf1d4d 100644
--- a/services/image_factory/aeolus-image/lib/base_command.rb
+++ b/services/image_factory/aeolus-image/lib/base_command.rb
@@ -1,11 +1,19 @@
+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
+ @@config_location = ENV['HOME'] + "/.imagefactory-cli"
+
attr_accessor :options
+
def initialize(opts={}, logger=nil)
logger(logger)
@options = opts
+ @config = load_config
end
protected
@@ -19,6 +27,54 @@ module Aeolus
return @logger
end
+ def imagefactory
+ createResource('imagefactory')
+ end
+
+ def conductor
+ createResource('conductor')
+ end
+
+ private
+ def load_config
+ begin
+ YAML::load( File.open(@@config_location))
+ rescue Errno::ENOENT
+ #TODO: Create a custom exception to wrap CLI Exceptions
+ raise "Unable to locate configuration file: \"" + @@config_url + "\""
+ end
+ end
+
+ def createResource(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 + " from configuraion 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/services/image_factory/aeolus-image/spec/base_command_spec.rb b/services/image_factory/aeolus-image/spec/base_command_spec.rb
new file mode 100644
index 0000000..3c9cada
--- /dev/null
+++ b/services/image_factory/aeolus-image/spec/base_command_spec.rb
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+module Aeolus
+ module Image
+ describe ConfigParser do
+ before(:each) do
+ BaseCommand.stub!(:load_config).and_return(YAML::load( File.open(File.join(File.dirname(__FILE__), "fixtures/imagefactory-cli"))))
+ end
+
+ it "should determine the correct credentials for HTTP Authentication" do
+ basec = BaseCommand.new
+ imagefactory = basec.send :imagefactory
+ imagefactory.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
+ end
+ end
+end
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/fixtures/imagefactory-cli b/services/image_factory/aeolus-image/spec/fixtures/imagefactory-cli
new file mode 100644
index 0000000..b83862e
--- /dev/null
+++ b/services/image_factory/aeolus-image/spec/fixtures/imagefactory-cli
@@ -0,0 +1,7 @@
+imagefactory:
+ url: http://localhost:9090
+
+conductor:
+ url: http://localhost:3000/conductor
+ username: admin
+ password: password
\ No newline at end of file
--
1.7.4
12 years, 11 months