On Fri, 2011-06-10 at 14:57 +0100, mtaylor(a)redhat.com wrote:
From: Martyn Taylor <mtaylor(a)redhat.com>
---
.../image_factory/aeolus-image/config/cli.yaml | 7 +++++++
.../image_factory/aeolus-image/lib/base_command.rb | 12 ++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
create mode 100644 services/image_factory/aeolus-image/config/cli.yaml
I haven't tested this, but looks mostly good, couple comments/thoughts
here and inline. I want to say 'needs tests', but since the whole point
here is to set up a connection to an external source, I am unsure, as
that means tests will only pass if you have the whole shebang up and
running. OTOH, I already assume this for console (build/push) tests, so
it would not be that inconsistent. On the fence, just thinking. At the
very least, we should probably test finding and parsing of the config
file.
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:
I think you mean iwhd ^, as factory uses qmf, not http
+ url:
http://localhost:9090
+
+conductor:
+ url:
http://localhost:3000/conductor
+ username: admin
+ password: password
Note that we are also accepting these from the cli as parameters, and I
was assuming that would be all for now. If we do have a config file
right away, mark had mentioned having it as a dotfile in the user's
homedir, so we would either have to add code to check there, take the
path as a param, etc..
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/lib/base_command.rb
b/services/image_factory/aeolus-image/lib/base_command.rb
index 4d4fa42..ae07644 100644
--- a/services/image_factory/aeolus-image/lib/base_command.rb
+++ b/services/image_factory/aeolus-image/lib/base_command.rb
@@ -1,11 +1,16 @@
+require 'yaml'
+require 'restclient'
+
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 = YAML::load( File.open( "config/cli.yaml" ) )
Covered
path above, but we would need to do some checking on this, as we
can't assume it is in the installed dir (other than for tests perhaps).
I think this check probably goes in the config parser, and then these
things can just be set in the options hash for all the command objects
to use as needed.
end
protected
@@ -19,6 +24,13 @@ module Aeolus
return @logger
end
+ def imagefactory
+ RestClient::Resource.new(@config['imagefactory']['url'])
+ end
+
+ def conductor
+ RestClient::Resource.new(@config['conductor']['url'], :user =>
@config['conductor']['username'], :password =>
@config['conductor']['password'])
Looks like 1 more space needed
here ^
+ end
end
end
end