occi-cli 4.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/.rspec +1 -0
- data/.travis.yml +43 -0
- data/.yardopts +1 -0
- data/AUTHORS +9 -0
- data/Gemfile +12 -0
- data/LICENSE +13 -0
- data/README.md +211 -0
- data/Rakefile +29 -0
- data/bin/occi +351 -0
- data/config/warble.rb +151 -0
- data/doc/macosx.md +27 -0
- data/ext/mkrf_conf.rb +34 -0
- data/lib/occi/cli/helpers.rb +149 -0
- data/lib/occi/cli/occi_opts.rb +388 -0
- data/lib/occi/cli/resource_output_factory.rb +95 -0
- data/lib/occi/cli/templates/compute.erb +18 -0
- data/lib/occi/cli/templates/network.erb +9 -0
- data/lib/occi/cli/templates/os_tpl.erb +7 -0
- data/lib/occi/cli/templates/resource_tpl.erb +7 -0
- data/lib/occi/cli/templates/storage.erb +8 -0
- data/lib/occi/cli/version.rb +5 -0
- data/lib/occi-cli.rb +9 -0
- data/occi-cli.gemspec +35 -0
- data/spec/occi/cli/helpers_spec.rb +9 -0
- data/spec/occi/cli/occi_opts_spec.rb +57 -0
- data/spec/occi/cli/resource_output_factory_spec.rb +9 -0
- data/spec/spec_helper.rb +13 -0
- metadata +240 -0
data/config/warble.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
# Disable Rake-environment-task framework detection by uncommenting/setting to false
|
2
|
+
# Warbler.framework_detection = false
|
3
|
+
|
4
|
+
# Warbler web application assembly configuration file
|
5
|
+
Warbler::Config.new do |config|
|
6
|
+
# Features: additional options controlling how the jar is built.
|
7
|
+
# Currently the following features are supported:
|
8
|
+
# - gemjar: package the gem repository in a jar file in WEB-INF/lib
|
9
|
+
# - executable: embed a web server and make the war executable
|
10
|
+
# - compiled: compile .rb files to .class files
|
11
|
+
config.features = %w(compiled)
|
12
|
+
|
13
|
+
# Application directories to be included in the webapp.
|
14
|
+
config.dirs = %w(config lib)
|
15
|
+
|
16
|
+
# Additional files/directories to include, above those in config.dirs
|
17
|
+
# config.includes = FileList["db"]
|
18
|
+
|
19
|
+
# Additional files/directories to exclude
|
20
|
+
# config.excludes = FileList["lib/tasks/*"]
|
21
|
+
|
22
|
+
# Additional Java .jar files to include. Note that if .jar files are placed
|
23
|
+
# in lib (and not otherwise excluded) then they need not be mentioned here.
|
24
|
+
# JRuby and JRuby-Rack are pre-loaded in this list. Be sure to include your
|
25
|
+
# own versions if you directly set the value
|
26
|
+
# config.java_libs += FileList["lib/java/*.jar"]
|
27
|
+
|
28
|
+
# Loose Java classes and miscellaneous files to be included.
|
29
|
+
# config.java_classes = FileList["target/classes/**.*"]
|
30
|
+
|
31
|
+
# One or more pathmaps defining how the java classes should be copied into
|
32
|
+
# the archive. The example pathmap below accompanies the java_classes
|
33
|
+
# configuration above. See http://rake.rubyforge.org/classes/String.html#M000017
|
34
|
+
# for details of how to specify a pathmap.
|
35
|
+
# config.pathmaps.java_classes << "%{target/classes/,}p"
|
36
|
+
|
37
|
+
# Bundler support is built-in. If Warbler finds a Gemfile in the
|
38
|
+
# project directory, it will be used to collect the gems to bundle
|
39
|
+
# in your application. If you wish to explicitly disable this
|
40
|
+
# functionality, uncomment here.
|
41
|
+
# config.bundler = false
|
42
|
+
|
43
|
+
# An array of Bundler groups to avoid including in the war file.
|
44
|
+
# Defaults to ["development", "test", "assets"].
|
45
|
+
# config.bundle_without = []
|
46
|
+
|
47
|
+
# Other gems to be included. If you don't use Bundler or a gemspec
|
48
|
+
# file, you need to tell Warbler which gems your application needs
|
49
|
+
# so that they can be packaged in the archive.
|
50
|
+
# For Rails applications, the Rails gems are included by default
|
51
|
+
# unless the vendor/rails directory is present.
|
52
|
+
# config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"]
|
53
|
+
# config.gems << "tzinfo"
|
54
|
+
|
55
|
+
# Uncomment this if you don't want to package rails gem.
|
56
|
+
# config.gems -= ["rails"]
|
57
|
+
|
58
|
+
# The most recent versions of gems are used.
|
59
|
+
# You can specify versions of gems by using a hash assignment:
|
60
|
+
# config.gems["rails"] = "2.3.10"
|
61
|
+
|
62
|
+
# You can also use regexps or Gem::Dependency objects for flexibility or
|
63
|
+
# finer-grained control.
|
64
|
+
# config.gems << /^merb-/
|
65
|
+
# config.gems << Gem::Dependency.new("merb-core", "= 0.9.3")
|
66
|
+
|
67
|
+
# Include gem dependencies not mentioned specifically. Default is
|
68
|
+
# true, uncomment to turn off.
|
69
|
+
# config.gem_dependencies = false
|
70
|
+
|
71
|
+
# Array of regular expressions matching relative paths in gems to be
|
72
|
+
# excluded from the war. Defaults to empty, but you can set it like
|
73
|
+
# below, which excludes test files.
|
74
|
+
# config.gem_excludes = [/^(test|spec)\//]
|
75
|
+
|
76
|
+
# Pathmaps for controlling how application files are copied into the archive
|
77
|
+
# config.pathmaps.application = ["WEB-INF/%p"]
|
78
|
+
|
79
|
+
# Name of the archive (without the extension). Defaults to the basename
|
80
|
+
# of the project directory.
|
81
|
+
config.jar_name = "occi"
|
82
|
+
|
83
|
+
# Name of the MANIFEST.MF template for the war file. Defaults to a simple
|
84
|
+
# MANIFEST.MF that contains the version of Warbler used to create the war file.
|
85
|
+
# config.manifest_file = "config/MANIFEST.MF"
|
86
|
+
|
87
|
+
# When using the 'compiled' feature and specified, only these Ruby
|
88
|
+
# files will be compiled. Default is to compile all \.rb files in
|
89
|
+
# the application.
|
90
|
+
# config.compiled_ruby_files = FileList['app/**/*.rb']
|
91
|
+
|
92
|
+
# === War files only below here ===
|
93
|
+
|
94
|
+
# Path to the pre-bundled gem directory inside the war file. Default
|
95
|
+
# is 'WEB-INF/gems'. Specify path if gems are already bundled
|
96
|
+
# before running Warbler. This also sets 'gem.path' inside web.xml.
|
97
|
+
# config.gem_path = "WEB-INF/vendor/bundler_gems"
|
98
|
+
|
99
|
+
# Files for WEB-INF directory (next to web.xml). This contains
|
100
|
+
# web.xml by default. If there is an .erb-File it will be processed
|
101
|
+
# with webxml-config. You may want to exclude this file via
|
102
|
+
# config.excludes.
|
103
|
+
# config.webinf_files += FileList["jboss-web.xml"]
|
104
|
+
|
105
|
+
# Files to be included in the root of the webapp. Note that files in public
|
106
|
+
# will have the leading 'public/' part of the path stripped during staging.
|
107
|
+
# config.public_html = FileList["public/**/*", "doc/**/*"]
|
108
|
+
|
109
|
+
# Pathmaps for controlling how public HTML files are copied into the .war
|
110
|
+
# config.pathmaps.public_html = ["%{public/,}p"]
|
111
|
+
|
112
|
+
# Embedded webserver to use with the 'executable' feature. Currently supported
|
113
|
+
# webservers are:
|
114
|
+
# * <tt>winstone</tt> (default) - Winstone 0.9.10 from sourceforge
|
115
|
+
# * <tt>jenkins-ci.winstone</tt> - Improved Winstone from Jenkins CI
|
116
|
+
# * <tt>jetty</tt> - Embedded Jetty from Eclipse
|
117
|
+
# config.webserver = 'jetty'
|
118
|
+
|
119
|
+
# Value of RAILS_ENV for the webapp -- default as shown below
|
120
|
+
# config.webxml.rails.env = ENV['RAILS_ENV'] || 'production'
|
121
|
+
|
122
|
+
# Application booter to use, one of :rack, :rails, or :merb (autodetected by default)
|
123
|
+
# config.webxml.booter = :rails
|
124
|
+
|
125
|
+
# Set JRuby to run in 1.9 mode.
|
126
|
+
# config.webxml.jruby.compat.version = "1.9"
|
127
|
+
|
128
|
+
# When using the :rack booter, "Rackup" script to use.
|
129
|
+
# - For 'rackup.path', the value points to the location of the rackup
|
130
|
+
# script in the web archive file. You need to make sure this file
|
131
|
+
# gets included in the war, possibly by adding it to config.includes
|
132
|
+
# or config.webinf_files above.
|
133
|
+
# - For 'rackup', the rackup script you provide as an inline string
|
134
|
+
# is simply embedded in web.xml.
|
135
|
+
# The script is evaluated in a Rack::Builder to load the application.
|
136
|
+
# Examples:
|
137
|
+
# config.webxml.rackup.path = 'WEB-INF/hello.ru'
|
138
|
+
# config.webxml.rackup = %{require './lib/demo'; run Rack::Adapter::Camping.new(Demo)}
|
139
|
+
# config.webxml.rackup = require 'cgi' && CGI::escapeHTML(File.read("config.ru"))
|
140
|
+
|
141
|
+
# Control the pool of Rails runtimes. Leaving unspecified means
|
142
|
+
# the pool will grow as needed to service requests. It is recommended
|
143
|
+
# that you fix these values when running a production server!
|
144
|
+
# If you're using threadsafe! mode, you probably don't want to set these values,
|
145
|
+
# since 1 runtime(default for threadsafe mode) will be enough.
|
146
|
+
# config.webxml.jruby.min.runtimes = 2
|
147
|
+
# config.webxml.jruby.max.runtimes = 4
|
148
|
+
|
149
|
+
# JNDI data source name
|
150
|
+
# config.webxml.jndi = 'jdbc/rails'
|
151
|
+
end
|
data/doc/macosx.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# rOCCI on Mac OS X
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
To use a recent version of Ruby on Mac OS X, a few preparations are needed. Installing Ruby on Apple Mac OS X is not as
|
6
|
+
straightforward as it is on other platforms, hence following detailed instructions.
|
7
|
+
|
8
|
+
1. Install the latest version of Xcode either
|
9
|
+
[from the Mac OS X App Store](itms://itunes.apple.com/de/app/xcode/id497799835?mt=12#) or by downloading it from
|
10
|
+
[[http://developer.apple.com]] and then installing the package.
|
11
|
+
2. Open Xcode, then download and install the Xcode command line tools (Menu->Xcode->Preferences->Downloads)
|
12
|
+
3. In the Terminal, install RVM with `curl -L https://get.rvm.io | bash -s stable`
|
13
|
+
4. Read the plattform requirements for your specific setup by running `rvm requirements` in the Terminal. Execute any
|
14
|
+
tasks mentioned there for installing Ruby 1.9.3 (you can ignore hints for Ruby 1.8.7). If you need to install additional
|
15
|
+
packages it is recommended to use Homebew for it (unless you already use MacPorts). To install Homebrew paste the
|
16
|
+
following in your Terminal `ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"`
|
17
|
+
5. Install Ruby 1.9.3 with `rvm install ruby-1.9.3`
|
18
|
+
|
19
|
+
Now that you have Ruby 1.9.3 installed, you can intall rOCCI.
|
20
|
+
|
21
|
+
To install the most recent stable version
|
22
|
+
|
23
|
+
gem install occi
|
24
|
+
|
25
|
+
To install the most recent beta version
|
26
|
+
|
27
|
+
gem install occi --pre
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/command.rb'
|
3
|
+
require 'rubygems/dependency_installer.rb'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Gem::Command.build_args = ARGV
|
7
|
+
rescue NoMethodError
|
8
|
+
# do nothing but warn the user
|
9
|
+
warn "Gem::Command doesn't have a method named 'build_args'!"
|
10
|
+
end
|
11
|
+
|
12
|
+
warn 'Installing platform-specific dependencies.'
|
13
|
+
|
14
|
+
warn 'Installing the most recent version of \'rake\''
|
15
|
+
inst = Gem::DependencyInstaller.new
|
16
|
+
inst.install "rake"
|
17
|
+
|
18
|
+
if RUBY_PLATFORM == "java"
|
19
|
+
warn 'Installing dependencies specific for jRuby'
|
20
|
+
|
21
|
+
jrver = (JRUBY_VERSION || "").split('.').map{ |elm| elm.to_i }
|
22
|
+
if jrver[0] == 1 && jrver[1] < 7
|
23
|
+
warn 'Installing \'jruby-openssl\' for jRuby 1.6.x'
|
24
|
+
inst.install "jruby-openssl"
|
25
|
+
end
|
26
|
+
else
|
27
|
+
# Nothing to install for rOCCI-api here
|
28
|
+
#warn 'Installing dependencies specific for Ruby'
|
29
|
+
end
|
30
|
+
|
31
|
+
# create dummy rakefile to indicate success
|
32
|
+
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
|
33
|
+
f.write "task :default\n"
|
34
|
+
f.close
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# a bunch of OCCI client helpers for bin/occi
|
2
|
+
|
3
|
+
def helper_list(options, output = nil)
|
4
|
+
found = []
|
5
|
+
|
6
|
+
if resource_types.include? options.resource
|
7
|
+
Occi::Log.debug "#{options.resource} is a resource type."
|
8
|
+
found = list options.resource
|
9
|
+
elsif mixin_types.include? options.resource
|
10
|
+
Occi::Log.debug "#{options.resource} is a mixin type."
|
11
|
+
found = mixins options.resource
|
12
|
+
else
|
13
|
+
Occi::Log.warn "I have no idea what #{options.resource} is ..."
|
14
|
+
raise "Unknown resource #{options.resource}, there is nothing to list here!"
|
15
|
+
end
|
16
|
+
|
17
|
+
return found if output.nil?
|
18
|
+
|
19
|
+
if Occi::Cli::ResourceOutputFactory.allowed_resource_types.include? options.resource.to_sym
|
20
|
+
puts output.format(found, :locations, options.resource.to_sym)
|
21
|
+
else
|
22
|
+
Occi::Log.warn "Not printing, the resource type is not supported!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def helper_describe(options, output = nil)
|
27
|
+
found = []
|
28
|
+
|
29
|
+
if resource_types.include?(options.resource) || options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
|
30
|
+
Occi::Log.debug "#{options.resource} is a resource type or an actual resource."
|
31
|
+
|
32
|
+
found = describe(options.resource)
|
33
|
+
elsif mixin_types.include? options.resource
|
34
|
+
Occi::Log.debug "#{options.resourcre} is a mixin type."
|
35
|
+
|
36
|
+
mixins(options.resource).each do |mxn|
|
37
|
+
mxn = mxn.split("#").last
|
38
|
+
found << mixin(mxn, options.resource, true)
|
39
|
+
end
|
40
|
+
elsif mixin_types.include? options.resource.split('#').first
|
41
|
+
Occi::Log.debug "#{options.resource} is a specific mixin type."
|
42
|
+
|
43
|
+
mxn_type,mxn = options.resource.split('#')
|
44
|
+
found << mixin(mxn, mxn_type, true)
|
45
|
+
else
|
46
|
+
Occi::Log.warn "I have no idea what #{options.resource} is ..."
|
47
|
+
raise "Unknown resource #{options.resource}, there is nothing to describe here!"
|
48
|
+
end
|
49
|
+
|
50
|
+
return found if output.nil?
|
51
|
+
|
52
|
+
if options.resource.start_with? options.endpoint
|
53
|
+
# resource contains full endpoint URI
|
54
|
+
# e.g., http://localhost:3300/network/adfgadf-daf5a6df4afadf-adfad65f4ad
|
55
|
+
resource_type = options.resource.split('/')[3].to_sym
|
56
|
+
elsif options.resource.start_with? '/'
|
57
|
+
# resource contains a path relative to endpoint URI
|
58
|
+
# e.g., /network/adfgadf-daf5a6df4afadf-adfad65f4ad
|
59
|
+
resource_type = options.resource.split('/')[1].to_sym
|
60
|
+
elsif mixin_types.include? options.resource.split('#').first
|
61
|
+
# resource contains a mixin with a type
|
62
|
+
# e.g., os_tpl#debian6
|
63
|
+
resource_type = options.resource.split('#').first.to_sym
|
64
|
+
else
|
65
|
+
# resource probably contains RAW resource_type
|
66
|
+
resource_type = options.resource.to_sym
|
67
|
+
end
|
68
|
+
|
69
|
+
if Occi::Cli::ResourceOutputFactory.allowed_resource_types.include? resource_type
|
70
|
+
puts output.format(found, :resources, resource_type)
|
71
|
+
else
|
72
|
+
Occi::Log.warn "Not printing, the resource type [#{resource_type.to_s}] is not supported!"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def helper_create(options, output = nil)
|
77
|
+
location = nil
|
78
|
+
|
79
|
+
if resource_types.include? options.resource
|
80
|
+
Occi::Log.debug "#{options.resource} is a resource type."
|
81
|
+
raise "Not yet implemented!" unless options.resource.include? "compute"
|
82
|
+
|
83
|
+
res = resource options.resource
|
84
|
+
|
85
|
+
Occi::Log.debug "Creating #{options.resource}:\n#{res.inspect}"
|
86
|
+
|
87
|
+
if options.links
|
88
|
+
Occi::Log.debug "with links: #{options.links}"
|
89
|
+
|
90
|
+
options.links.each do |link|
|
91
|
+
link = options.endpoint.chomp('/') + link unless link.start_with? options.endpoint
|
92
|
+
|
93
|
+
if link.include? "/storage/"
|
94
|
+
Occi::Log.debug "Adding storagelink to #{options.resource}"
|
95
|
+
res.storagelink link
|
96
|
+
elsif link.include? "/network/"
|
97
|
+
Occi::Log.debug "Adding networkinterface to #{options.resource}"
|
98
|
+
res.networkinterface link
|
99
|
+
else
|
100
|
+
raise "Unknown link type #{link}, stopping here!"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
if options.mixins
|
106
|
+
Occi::Log.debug "with mixins: #{options.mixins}"
|
107
|
+
|
108
|
+
options.mixins.keys.each do |type|
|
109
|
+
Occi::Log.debug "Adding mixins of type #{type} to #{options.resource}"
|
110
|
+
|
111
|
+
options.mixins[type].each do |name|
|
112
|
+
mxn = mixin name, type
|
113
|
+
|
114
|
+
raise "Unknown mixin #{type}##{name}, stopping here!" if mxn.nil?
|
115
|
+
Occi::Log.debug "Adding mixin #{mxn} to #{options.resource}"
|
116
|
+
res.mixins << mxn
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
#TODO: set other attributes
|
122
|
+
res.title = options.attributes[:title]
|
123
|
+
|
124
|
+
Occi::Log.debug "Creating #{options.resource}:\n#{res.inspect}"
|
125
|
+
|
126
|
+
location = create res
|
127
|
+
else
|
128
|
+
Occi::Log.warn "I have no idea what #{options.resource} is ..."
|
129
|
+
raise "Unknown resource #{options.resource}, there is nothing to create here!"
|
130
|
+
end
|
131
|
+
|
132
|
+
return location if output.nil?
|
133
|
+
|
134
|
+
puts location
|
135
|
+
end
|
136
|
+
|
137
|
+
def helper_delete(options, output = nil)
|
138
|
+
if delete(options.resource)
|
139
|
+
Occi::Log.info "Resource #{options.resource} successfully removed!"
|
140
|
+
else
|
141
|
+
raise "Failed to remove resource #{options.resource}!"
|
142
|
+
end
|
143
|
+
|
144
|
+
true
|
145
|
+
end
|
146
|
+
|
147
|
+
def helper_trigger(options, output = nil)
|
148
|
+
raise "Not yet implemented!"
|
149
|
+
end
|