Skip to content

Commit

Permalink
Merge pull request #58 from arax/client-dev
Browse files Browse the repository at this point in the history
Fixes #52 by allowing relative resource paths
  • Loading branch information
ffeldhaus committed Feb 22, 2013
2 parents b21e760 + fa549ec commit 5066c48
Show file tree
Hide file tree
Showing 14 changed files with 514 additions and 302 deletions.
2 changes: 1 addition & 1 deletion Gemfile
@@ -1,4 +1,4 @@
source :rubygems source "https://rubygems.org/"


gemspec gemspec


Expand Down
60 changes: 31 additions & 29 deletions Gemfile.lock
Expand Up @@ -7,18 +7,18 @@ GIT


GIT GIT
remote: git://github.com/jruby/warbler.git remote: git://github.com/jruby/warbler.git
revision: 75da5228c39d0e1f93599fb61db2575f2369fee7 revision: ce3ce4df137504822e4cbb9399dee7e7dd767c44
specs: specs:
warbler (1.3.7.dev) warbler (1.3.7.dev)
jruby-jars (>= 1.4.0) jruby-jars (>= 1.5.6)
jruby-rack (>= 1.0.0) jruby-rack (>= 1.0.0)
rake (>= 0.8.7) rake (>= 0.9.6)
rubyzip (>= 0.9.4) rubyzip (>= 0.9.8)


PATH PATH
remote: . remote: .
specs: specs:
occi (3.0.0) occi (3.1.0.alpha.1)
activesupport activesupport
amqp amqp
antlr3 antlr3
Expand All @@ -31,19 +31,19 @@ PATH
uuidtools (>= 2.1.3) uuidtools (>= 2.1.3)


GEM GEM
remote: http://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activesupport (3.2.11) activesupport (3.2.12)
i18n (~> 0.6) i18n (~> 0.6)
multi_json (~> 1.0) multi_json (~> 1.0)
addressable (2.3.2) addressable (2.3.3)
amq-client (0.9.11) amq-client (0.9.12)
amq-protocol (>= 1.0.1) amq-protocol (>= 1.2.0)
eventmachine eventmachine
amq-protocol (1.1.0) amq-protocol (1.2.0)
amqp (0.9.8) amqp (0.9.9)
amq-client (~> 0.9.5) amq-client (~> 0.9.12)
amq-protocol (>= 0.9.4) amq-protocol (~> 1.2.0)
eventmachine eventmachine
antlr3 (1.8.12) antlr3 (1.8.12)
builder (3.1.4) builder (3.1.4)
Expand All @@ -56,22 +56,22 @@ GEM
diff-lcs (1.1.3) diff-lcs (1.1.3)
eventmachine (1.0.0) eventmachine (1.0.0)
eventmachine (1.0.0-java) eventmachine (1.0.0-java)
gherkin (2.11.5) gherkin (2.11.6)
json (>= 1.4.6) json (>= 1.7.6)
gherkin (2.11.5-java) gherkin (2.11.6-java)
json (>= 1.4.6) json (>= 1.7.6)
hashie (1.2.0) hashie (2.0.0)
highline (1.6.15) highline (1.6.15)
httparty (0.10.2) httparty (0.10.2)
multi_json (~> 1.0) multi_json (~> 1.0)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
i18n (0.6.1) i18n (0.6.1)
jruby-jars (1.7.2) jruby-jars (1.7.3)
jruby-rack (1.1.13.1) jruby-rack (1.1.13.1)
json (1.7.6) json (1.7.7)
json (1.7.6-java) json (1.7.7-java)
multi_json (1.5.0) multi_json (1.6.1)
multi_xml (0.5.2) multi_xml (0.5.3)
nokogiri (1.5.6) nokogiri (1.5.6)
nokogiri (1.5.6-java) nokogiri (1.5.6-java)
rake (10.0.3) rake (10.0.3)
Expand All @@ -84,18 +84,19 @@ GEM
diff-lcs (~> 1.1.3) diff-lcs (~> 1.1.3)
rspec-http (0.10.0) rspec-http (0.10.0)
rspec (~> 2.0) rspec (~> 2.0)
rspec-mocks (2.12.1) rspec-mocks (2.12.2)
rubygems-tasks (0.2.3)
rubyzip (0.9.9) rubyzip (0.9.9)
simplecov (0.7.1) simplecov (0.7.1)
multi_json (~> 1.0) multi_json (~> 1.0)
simplecov-html (~> 0.7.1) simplecov-html (~> 0.7.1)
simplecov-html (0.7.1) simplecov-html (0.7.1)
uuidtools (2.1.3) uuidtools (2.1.3)
webmock (1.9.0) webmock (1.9.3)
addressable (>= 2.2.7) addressable (>= 2.2.7)
crack (>= 0.1.7) crack (>= 0.3.2)
yard (0.8.3) yard (0.8.4.1)
yard-cucumber (2.2.2) yard-cucumber (2.2.3)
cucumber (>= 0.7.5) cucumber (>= 0.7.5)
gherkin (>= 2.2.9) gherkin (>= 2.2.9)
yard (>= 0.8.1) yard (>= 0.8.1)
Expand All @@ -114,6 +115,7 @@ DEPENDENCIES
rake rake
rspec rspec
rspec-http rspec-http
rubygems-tasks
simplecov simplecov
vcr! vcr!
warbler! warbler!
Expand Down
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -150,10 +150,14 @@ For keystone auth use
#### DSL #### DSL
In your scripts, you can use the OCCI client DSL. In your scripts, you can use the OCCI client DSL.


To include the DSL definitions in your script use To include the DSL definitions in a script use


extend Occi::Api::Dsl extend Occi::Api::Dsl


To include the DSL definitions in a class use

include Occi::Api:Dsl

To connect to an OCCI endpoint/server (e.g. running on http://localhost:3300/ ) To connect to an OCCI endpoint/server (e.g. running on http://localhost:3300/ )


connect(:http, 'http://localhost:3300',auth||=nil) connect(:http, 'http://localhost:3300',auth||=nil)
Expand Down
10 changes: 7 additions & 3 deletions Rakefile
@@ -1,7 +1,11 @@
require 'bundler' require 'rubygems/tasks'
Bundler::GemHelper.install_tasks


task :default => 'rcov:all' task :default => 'test'

desc "Run all tests; includes rspec, cucumber and coverage reports"
task :test => 'rcov:all'

Gem::Tasks.new(:build => {:tar => true, :zip => true}, :sign => {:checksum => true, :pgp => true})


namespace :rcov do namespace :rcov do


Expand Down
69 changes: 12 additions & 57 deletions bin/occi
Expand Up @@ -41,28 +41,6 @@ output = Occi::Bin::ResourceOutputFactory.new options.output_format
Occi::Log.info "Starting OCCI client ..." Occi::Log.info "Starting OCCI client ..."
Occi::Log.debug "Options: #{options}" Occi::Log.debug "Options: #{options}"


# TODO: this part isn't necessary, just annoying
# to make the interactive mode completely self-sufficient
# ask for endpoint and auth method (provide defaults)
#if options.interactive
# Occi::Log.debug "Checking for endpoint and auth changes ..."
#
# options.endpoint = ask("What endpoint should I use? ") {
# |q| q.default = options.endpoint
# }
#
# # separate menus
# say "\n"
#
# choose do |menu|
# menu.prompt = "Which auth method should I use? "
#
# Occi::Bin::OcciOpts::AUTH_METHODS.each do |auth_m|
# menu.choice(auth_m) { options.auth[:type] = auth_m.to_s }
# end
# end
#end

# running with an empty password, we should ask the user for one # running with an empty password, we should ask the user for one
# if auth method is not "none" # if auth method is not "none"
if options.auth[:password].nil? || options.auth[:user_cert_password].nil? || options.auth[:token].nil? if options.auth[:password].nil? || options.auth[:user_cert_password].nil? || options.auth[:token].nil?
Expand Down Expand Up @@ -118,7 +96,7 @@ end
if options.dump_model if options.dump_model


if !model.respond_to? :instance_variables if !model.respond_to? :instance_variables
puts "Your Ruby doesn't support 'instance_variables' calls!" Occi::Log.error "Your Ruby doesn't support 'instance_variables' calls!"
exit! exit!
end end


Expand Down Expand Up @@ -261,17 +239,19 @@ begin
# if the user didn't choose "Back", ask for details # if the user didn't choose "Back", ask for details
# TODO: currently only COMPUTE is supported # TODO: currently only COMPUTE is supported
if options.action == :create if options.action == :create
options.resource_title = ask("What name should I give to the new resource? ") options.attributes = {} if options.attributes.nil?

options.attributes[:title] = ask("What name should I give to the new resource? ")
number_of_mixins = ask("How many mixins do you wish me to mix into this resource? ", number_of_mixins = ask("How many mixins do you wish me to mix into this resource? ",
Integer) { |q| q.in = 0..2 } Integer) { |q| q.in = 0..2 }


options.mixin = {} options.mixins = {}
(1..number_of_mixins).each do |mixin_number| (1..number_of_mixins).each do |mixin_number|
mixin = ask("What mixin should I mix in? ") { |q| q.validate = /\A\w+#\w+\Z/ } mixin = ask("What mixin should I mix in? ") { |q| q.validate = /\A\w+#\w+\Z/ }
parts = mixin.split("#") parts = mixin.split("#")


options.mixin[parts[0]] = [] if options.mixin[parts[0]].nil? options.mixins[parts[0]] = [] if options.mixins[parts[0]].nil?
options.mixin[parts[0]] << parts[1] options.mixins[parts[0]] << parts[1]
end end
end end
} }
Expand Down Expand Up @@ -340,40 +320,15 @@ begin
# call the appropriate helper and then format its output # call the appropriate helper and then format its output
case options.action case options.action
when :list when :list
found = helper_list options helper_list options, output

valid = Occi::Bin::ResourceOutputFactory.allowed_resource_types.include? options.resource.to_sym
Occi::Log.error "Not printing, the resource type is not supported!" unless valid

puts output.format(found, :locations, options.resource.to_sym) if valid
when :describe when :describe
found = helper_describe options helper_describe options, output

if options.resource.start_with? options.endpoint
resource_type = options.resource.split("/")[3].to_sym
elsif mixin_types.include? options.resource.split('#').first
resource_type = options.resource.split('#').first.to_sym
else
resource_type = options.resource.to_sym
end

valid = Occi::Bin::ResourceOutputFactory.allowed_resource_types.include? resource_type
Occi::Log.error "Not printing, the resource type is not supported!" unless valid

puts output.format(found, :resources, resource_type) if valid
when :create when :create
location = helper_create options helper_create options, output
puts location
when :delete when :delete
result = helper_delete options helper_delete options, output

if result
puts "Resource #{options.resource} successfully removed!"
else
puts "Failed to remove resource #{options.resource}!"
end
when :trigger when :trigger
helper_trigger options helper_trigger options, output
when :refresh when :refresh
refresh refresh
when :skip when :skip
Expand Down
7 changes: 4 additions & 3 deletions ext/mkrf_conf.rb
Expand Up @@ -5,7 +5,8 @@
begin begin
Gem::Command.build_args = ARGV Gem::Command.build_args = ARGV
rescue NoMethodError rescue NoMethodError
# do nothing # do nothing but warn the user
warn "Gem::Command doesn't have a method named 'build_args'!"
end end


if defined? RUBY_PLATFORM && RUBY_PLATFORM == "java" if defined? RUBY_PLATFORM && RUBY_PLATFORM == "java"
Expand All @@ -14,8 +15,8 @@
begin begin
inst.install "jruby-openssl" if ((defined? JRUBY_VERSION) && (JRUBY_VERSION.split('.')[1].to_i < 7)) inst.install "jruby-openssl" if ((defined? JRUBY_VERSION) && (JRUBY_VERSION.split('.')[1].to_i < 7))
rescue rescue
# installation failed warn "Gem::DependencyInstaller failed to install 'jruby-openssl'!"
exit(1) exit
end end
end end


Expand Down

0 comments on commit 5066c48

Please sign in to comment.