occi-cli 4.1.0 → 4.2.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -0
- data/README.md +36 -17
- data/bin/occi +9 -12
- data/lib/occi/cli/errors/formatter_input_type_error.rb +5 -0
- data/lib/occi/cli/errors/formatter_output_type_error.rb +5 -0
- data/lib/occi/cli/errors.rb +4 -0
- data/lib/occi/cli/helpers/common_helper.rb +5 -0
- data/lib/occi/cli/helpers/create_helper.rb +103 -0
- data/lib/occi/cli/helpers/delete_helper.rb +23 -0
- data/lib/occi/cli/helpers/describe_helper.rb +28 -0
- data/lib/occi/cli/helpers/list_helper.rb +26 -0
- data/lib/occi/cli/helpers/trigger_helper.rb +7 -0
- data/lib/occi/cli/helpers.rb +9 -209
- data/lib/occi/cli/occi_opts.rb +29 -33
- data/lib/occi/cli/resource_output_factory.rb +44 -69
- data/lib/occi/cli/templates/mixins.erb +9 -0
- data/lib/occi/cli/templates/resources.erb +25 -0
- data/lib/occi/cli/version.rb +1 -1
- data/lib/occi-cli.rb +6 -0
- data/occi-cli.gemspec +1 -10
- data/spec/spec_helper.rb +4 -1
- metadata +20 -142
- data/lib/occi/cli/templates/compute.erb +0 -22
- data/lib/occi/cli/templates/network.erb +0 -8
- data/lib/occi/cli/templates/os_tpl.erb +0 -6
- data/lib/occi/cli/templates/resource_tpl.erb +0 -6
- data/lib/occi/cli/templates/storage.erb +0 -7
data/Gemfile
CHANGED
@@ -5,4 +5,10 @@ gemspec
|
|
5
5
|
group :development do
|
6
6
|
gem 'warbler', :git => 'git://github.com/jruby/warbler.git', :ref => 'ce3ce4df137504822e4cbb9399dee7e7dd767c44'
|
7
7
|
gem 'rubygems-tasks', :git => 'git://github.com/postmodern/rubygems-tasks.git'
|
8
|
+
gem "rspec"
|
9
|
+
gem "rake"
|
10
|
+
gem "builder"
|
11
|
+
gem "simplecov"
|
12
|
+
gem "yard"
|
13
|
+
gem "yard-rspec"
|
8
14
|
end
|
data/README.md
CHANGED
@@ -14,20 +14,30 @@ Requirements
|
|
14
14
|
* RubyGems have to be installed
|
15
15
|
* Rake has to be installed (e.g., `gem install rake`)
|
16
16
|
|
17
|
-
###
|
18
|
-
* libxslt1-dev
|
19
|
-
* libxml2-dev
|
17
|
+
### Dependencies
|
18
|
+
* `libxslt1-dev` or `libxslt-devel`
|
19
|
+
* `libxml2-dev`or `libxml2-devel`
|
20
20
|
|
21
21
|
### Examples
|
22
|
-
For distros based on Debian:
|
22
|
+
#### For distros based on Debian:
|
23
23
|
~~~
|
24
24
|
apt-get install ruby rubygems ruby-dev libxslt1-dev libxml2-dev
|
25
25
|
~~~
|
26
|
+
~~~
|
27
|
+
ruby -v
|
28
|
+
~~~
|
29
|
+
|
30
|
+
**Unless you have Ruby >= 1.9.3, please, go to [rOCCI-cli#RVM](#rvm) and install RVM with a newer Ruby version.**
|
26
31
|
|
27
|
-
For distros based on RHEL:
|
32
|
+
#### For distros based on RHEL:
|
28
33
|
~~~
|
29
34
|
yum install libxml2-devel libxslt-devel ruby-devel openssl-devel gcc gcc-c++ ruby rubygems
|
30
35
|
~~~
|
36
|
+
~~~
|
37
|
+
ruby -v
|
38
|
+
~~~
|
39
|
+
|
40
|
+
**Unless you have Ruby >= 1.9.3, please, go to [rOCCI-cli#RVM](#rvm) and install RVM with a newer Ruby version.**
|
31
41
|
|
32
42
|
To use rOCCI-cli with Java, you need JRE 6 or 7. To build rOCCI-cli for Java, you need JDK 6 or 7.
|
33
43
|
|
@@ -51,13 +61,8 @@ To install the most recent beta version
|
|
51
61
|
### From source (dev)
|
52
62
|
|
53
63
|
**Installation from source should never be your first choice! Especially, if you are not familiar with RVM, Bundler, Rake and other dev tools for Ruby!**
|
54
|
-
**However, if you wish to contribute to our project, this is the right way to start.**
|
55
|
-
|
56
|
-
To use rOCCI-cli from source it is very much recommended to use RVM. [Install RVM](https://rvm.io/rvm/install/) with
|
57
64
|
|
58
|
-
|
59
|
-
rvm install 1.9.3
|
60
|
-
rvm use 1.9.3 --default
|
65
|
+
**However, if you wish to contribute to our project, this is the right way to start.**
|
61
66
|
|
62
67
|
To build and install the bleeding edge version from master
|
63
68
|
|
@@ -70,11 +75,7 @@ To build and install the bleeding edge version from master
|
|
70
75
|
|
71
76
|
### From source, for Java
|
72
77
|
|
73
|
-
|
74
|
-
|
75
|
-
curl -L https://get.rvm.io | bash -s stable --ruby
|
76
|
-
rvm install jruby
|
77
|
-
rvm use jruby --default
|
78
|
+
**Notice:** In order to build rOCCI-cli for Java, you need working jRuby installation. We recommend using [rOCCI-cli#RVM](#rvm).
|
78
79
|
|
79
80
|
To build a Java jar file from master use
|
80
81
|
|
@@ -86,7 +87,25 @@ To build a Java jar file from master use
|
|
86
87
|
|
87
88
|
For Linux / Mac OS X you can create a OCCI Java executable from the jar file using
|
88
89
|
|
89
|
-
sudo echo '#!/usr/bin/java -jar' | cat - occi.jar > occi ; sudo chmod +x occi
|
90
|
+
sudo echo '#!/usr/bin/java -jar' | cat - occi-cli.jar > occi ; sudo chmod +x occi
|
91
|
+
|
92
|
+
### RVM
|
93
|
+
|
94
|
+
**Notice:** Follow the RVM installation guide linked below, we recommend using the default 'Single-User installation'.
|
95
|
+
|
96
|
+
**Warning:** NEVER install RVM as root! If you choose the 'Multi-User installation', use a different user account with sudo access instead!
|
97
|
+
|
98
|
+
* [Installing RVM](https://rvm.io/rvm/install#explained)
|
99
|
+
* Install Ruby
|
100
|
+
|
101
|
+
~~~
|
102
|
+
rvm requirements
|
103
|
+
rvm install 1.9.3
|
104
|
+
rvm use 1.9.3 --default
|
105
|
+
~~~
|
106
|
+
~~~
|
107
|
+
ruby -v
|
108
|
+
~~~
|
90
109
|
|
91
110
|
Usage
|
92
111
|
-----
|
data/bin/occi
CHANGED
@@ -15,13 +15,11 @@
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
17
|
require 'rubygems'
|
18
|
-
require 'occi-cli'
|
19
18
|
require 'pp'
|
20
19
|
require 'highline/import'
|
21
20
|
require 'openssl'
|
22
21
|
|
23
|
-
|
24
|
-
extend Occi::Cli::Helpers
|
22
|
+
require 'occi-cli'
|
25
23
|
|
26
24
|
# get arguments and validate/parse them to an ostruct
|
27
25
|
options = Occi::Cli::OcciOpts.parse ARGV
|
@@ -144,7 +142,11 @@ begin
|
|
144
142
|
options.resource = nil
|
145
143
|
|
146
144
|
# offer just the resource types we will be able to process
|
147
|
-
menu_resources =
|
145
|
+
menu_resources = []
|
146
|
+
menu_resources << resource_type_identifiers.select { |i| i.include?("infrastructure#") }
|
147
|
+
menu_resources << ["http://schemas.ogf.org/occi/infrastructure#os_tpl", "http://schemas.ogf.org/occi/infrastructure#resource_tpl"]
|
148
|
+
menu_resources.flatten!
|
149
|
+
menu_resources.uniq!
|
148
150
|
|
149
151
|
# separate menus from each other
|
150
152
|
say("\n")
|
@@ -241,17 +243,12 @@ begin
|
|
241
243
|
number_of_mixins = ask("How many mixins do you wish me to mix into this resource? ",
|
242
244
|
Integer) { |q| q.in = 0..2 }
|
243
245
|
|
244
|
-
options.mixins =
|
246
|
+
options.mixins = Occi::Core::Mixins.new
|
245
247
|
(1..number_of_mixins).each do |mixin_number|
|
246
|
-
mixin = ask("What mixin should I mix in? ") { |q| q.validate =
|
248
|
+
mixin = ask("What mixin should I mix in? ") { |q| q.validate = Occi::Cli::OcciOpts::MIXIN_REGEXP }
|
247
249
|
parts = mixin.split("#")
|
248
250
|
|
249
|
-
|
250
|
-
parts[0] = 'os_tpl' if parts[0] == 'os'
|
251
|
-
parts[0] = 'resource_tpl' if parts[0] == 'resource'
|
252
|
-
|
253
|
-
options.mixins[parts[0]] = [] unless options.mixins[parts[0]]
|
254
|
-
options.mixins[parts[0]] << parts[1]
|
251
|
+
options.mixins << Occi::Core::Mixin.new("#{parts[0]}#", parts[1])
|
255
252
|
end
|
256
253
|
end
|
257
254
|
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Occi::Cli::Helpers::CreateHelper
|
2
|
+
|
3
|
+
def helper_create(options, output = nil)
|
4
|
+
location = nil
|
5
|
+
|
6
|
+
if resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource)
|
7
|
+
Occi::Log.debug "#{options.resource.inspect} is a resource type."
|
8
|
+
raise "Not yet implemented!" unless options.resource.include? "compute"
|
9
|
+
|
10
|
+
res = resource options.resource
|
11
|
+
|
12
|
+
Occi::Log.debug "Creating #{options.resource.inspect}:\n#{res.inspect}"
|
13
|
+
|
14
|
+
helper_attach_links(options, res)
|
15
|
+
helper_attach_mixins(options, res)
|
16
|
+
helper_attach_context_vars(options, res)
|
17
|
+
|
18
|
+
# TODO: set other attributes
|
19
|
+
# TODO: OCCI-OS uses occi.compute.hostname instead of title
|
20
|
+
res.title = options.attributes[:title]
|
21
|
+
res.hostname = options.attributes[:title]
|
22
|
+
|
23
|
+
Occi::Log.debug "Creating #{options.resource.inspect}:\n#{res.inspect}"
|
24
|
+
|
25
|
+
location = create res
|
26
|
+
else
|
27
|
+
Occi::Log.warn "I have no idea what #{options.resource.inspect} is ..."
|
28
|
+
raise "Unknown resource #{options.resource.inspect}, there is nothing to create here!"
|
29
|
+
end
|
30
|
+
|
31
|
+
return location if output.nil?
|
32
|
+
|
33
|
+
puts location
|
34
|
+
end
|
35
|
+
|
36
|
+
def helper_attach_links(options, res)
|
37
|
+
return unless options.links
|
38
|
+
Occi::Log.debug "with links: #{options.links.inspect}"
|
39
|
+
|
40
|
+
options.links.each do |link|
|
41
|
+
if link.start_with? options.endpoint
|
42
|
+
link.gsub!(options.endpoint.chomp('/'), '')
|
43
|
+
end
|
44
|
+
|
45
|
+
if link.include? "/storage/"
|
46
|
+
Occi::Log.debug "Adding storagelink to #{options.resource.inspect}"
|
47
|
+
res.storagelink link
|
48
|
+
elsif link.include? "/network/"
|
49
|
+
Occi::Log.debug "Adding networkinterface to #{options.resource.inspect}"
|
50
|
+
res.networkinterface link
|
51
|
+
else
|
52
|
+
raise "Unknown link type #{link.inspect}, stopping here!"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def helper_attach_mixins(options, res)
|
58
|
+
return unless options.mixins
|
59
|
+
Occi::Log.debug "with mixins: #{options.mixins}"
|
60
|
+
|
61
|
+
options.mixins.to_a.each do |mxn|
|
62
|
+
Occi::Log.debug "Adding mixin #{mxn.inspect} to #{options.resource.inspect}"
|
63
|
+
res.mixins << mxn
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def helper_attach_context_vars(options, res)
|
68
|
+
# TODO: find a better/universal way to do contextualization
|
69
|
+
return unless options.context_vars
|
70
|
+
Occi::Log.debug "with context variables: #{options.context_vars}"
|
71
|
+
|
72
|
+
options.context_vars.each_pair do |var, val|
|
73
|
+
schema = nil
|
74
|
+
mxn_attrs = Occi::Core::Attributes.new
|
75
|
+
|
76
|
+
case var
|
77
|
+
when :public_key
|
78
|
+
schema = "http://schemas.openstack.org/instance/credentials#"
|
79
|
+
mxn_attrs['org.openstack.credentials.publickey.name'] = {}
|
80
|
+
mxn_attrs['org.openstack.credentials.publickey.data'] = {}
|
81
|
+
when :user_data
|
82
|
+
schema = "http://schemas.openstack.org/compute/instance#"
|
83
|
+
mxn_attrs['org.openstack.compute.user_data'] = {}
|
84
|
+
else
|
85
|
+
schema = "http://schemas.ogf.org/occi/core#"
|
86
|
+
end
|
87
|
+
|
88
|
+
mxn = Occi::Core::Mixin.new(schema, var.to_s, 'OS contextualization mixin', mxn_attrs)
|
89
|
+
res.mixins << mxn
|
90
|
+
|
91
|
+
case var
|
92
|
+
when :public_key
|
93
|
+
res.attributes['org.openstack.credentials.publickey.name'] = 'Public SSH key'
|
94
|
+
res.attributes['org.openstack.credentials.publickey.data'] = val
|
95
|
+
when :user_data
|
96
|
+
res.attributes['org.openstack.compute.user_data'] = val
|
97
|
+
else
|
98
|
+
# do nothing
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Occi::Cli::Helpers::DeleteHelper
|
2
|
+
|
3
|
+
def helper_delete(options, output = nil)
|
4
|
+
unless resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) || options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
|
5
|
+
message = "Resource #{options.resource.inspect} cannot be deleted!"
|
6
|
+
|
7
|
+
Occi::Log.error message
|
8
|
+
raise ArgumentError, message
|
9
|
+
end
|
10
|
+
|
11
|
+
if delete(options.resource)
|
12
|
+
Occi::Log.info "Resource #{options.resource.inspect} successfully removed!"
|
13
|
+
else
|
14
|
+
message = "Failed to remove resource #{options.resource.inspect}!"
|
15
|
+
|
16
|
+
Occi::Log.error message
|
17
|
+
raise message
|
18
|
+
end
|
19
|
+
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Occi::Cli::Helpers::DescribeHelper
|
2
|
+
|
3
|
+
def helper_describe(options, output = nil)
|
4
|
+
if resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) || options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
|
5
|
+
Occi::Log.debug "#{options.resource.inspect} is a resource type, type identifier or an actual resource."
|
6
|
+
|
7
|
+
found = Occi::Core::Resources.new
|
8
|
+
found.merge describe(options.resource)
|
9
|
+
elsif mixin_types.include?(options.resource) || mixin_type_identifiers.include?(options.resource)
|
10
|
+
Occi::Log.debug "#{options.resourcre.inspect} is a mixin type or type identifier."
|
11
|
+
|
12
|
+
found = Occi::Core::Mixins.new
|
13
|
+
found.merge mixins(options.resource)
|
14
|
+
else
|
15
|
+
Occi::Log.error "I have no idea what #{options.resource.inspect} is ..."
|
16
|
+
raise "Unknown resource #{options.resource.inspect}, there is nothing to describe here!"
|
17
|
+
end
|
18
|
+
|
19
|
+
helper_describe_output(found, options, output)
|
20
|
+
end
|
21
|
+
|
22
|
+
def helper_describe_output(found, options, output)
|
23
|
+
return found unless output
|
24
|
+
|
25
|
+
puts output.format(found)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Occi::Cli::Helpers::ListHelper
|
2
|
+
|
3
|
+
def helper_list(options, output = nil)
|
4
|
+
found = []
|
5
|
+
|
6
|
+
if resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource)
|
7
|
+
Occi::Log.debug "#{options.resource.inspect} is a resource type."
|
8
|
+
found = list options.resource
|
9
|
+
elsif mixin_types.include?(options.resource) || mixin_type_identifiers.include?(options.resource)
|
10
|
+
Occi::Log.debug "#{options.resource.inspect} is a mixin type."
|
11
|
+
found = mixin_list options.resource
|
12
|
+
else
|
13
|
+
Occi::Log.error "I have no idea what #{options.resource.inspect} is ..."
|
14
|
+
raise "Unknown resource #{options.resource.inspect}, there is nothing to list here!"
|
15
|
+
end
|
16
|
+
|
17
|
+
helper_list_output(found, options, output)
|
18
|
+
end
|
19
|
+
|
20
|
+
def helper_list_output(found, options, output)
|
21
|
+
return found unless output
|
22
|
+
|
23
|
+
puts output.format(found)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/occi/cli/helpers.rb
CHANGED
@@ -1,212 +1,12 @@
|
|
1
1
|
# a bunch of OCCI client helpers for bin/occi
|
2
|
-
module Occi::Cli
|
3
|
-
module Helpers
|
2
|
+
module Occi::Cli::Helpers; end
|
4
3
|
|
5
|
-
|
6
|
-
|
4
|
+
# load all
|
5
|
+
Dir[File.join(File.dirname(__FILE__), 'helpers', '*.rb')].each { |file| require file.gsub('.rb', '') }
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
else
|
15
|
-
Occi::Log.warn "I have no idea what #{options.resource} is ..."
|
16
|
-
raise "Unknown resource #{options.resource}, there is nothing to list here!"
|
17
|
-
end
|
18
|
-
|
19
|
-
helper_list_output(found, options, output)
|
20
|
-
end
|
21
|
-
|
22
|
-
def helper_list_output(found, options, output)
|
23
|
-
return found unless output
|
24
|
-
|
25
|
-
helper_formatter_output(found, output, :locations, options.resource.to_sym)
|
26
|
-
|
27
|
-
nil
|
28
|
-
end
|
29
|
-
|
30
|
-
def helper_describe(options, output = nil)
|
31
|
-
found = []
|
32
|
-
|
33
|
-
if resource_types.include?(options.resource) || options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
|
34
|
-
Occi::Log.debug "#{options.resource} is a resource type or an actual resource."
|
35
|
-
|
36
|
-
found = describe(options.resource)
|
37
|
-
elsif mixin_types.include? options.resource
|
38
|
-
Occi::Log.debug "#{options.resourcre} is a mixin type."
|
39
|
-
|
40
|
-
mixins(options.resource).each do |mxn|
|
41
|
-
mxn = mxn.split("#").last
|
42
|
-
found << mixin(mxn, options.resource, true)
|
43
|
-
end
|
44
|
-
elsif mixin_types.include? options.resource.split('#').first
|
45
|
-
Occi::Log.debug "#{options.resource} is a specific mixin type."
|
46
|
-
|
47
|
-
mxn_type,mxn = options.resource.split('#')
|
48
|
-
found << mixin(mxn, mxn_type, true)
|
49
|
-
else
|
50
|
-
Occi::Log.warn "I have no idea what #{options.resource} is ..."
|
51
|
-
raise "Unknown resource #{options.resource}, there is nothing to describe here!"
|
52
|
-
end
|
53
|
-
|
54
|
-
helper_describe_output(found, options, output)
|
55
|
-
end
|
56
|
-
|
57
|
-
def helper_describe_output(found, options, output)
|
58
|
-
return found unless output
|
59
|
-
|
60
|
-
if options.resource.start_with? options.endpoint
|
61
|
-
# resource contains full endpoint URI
|
62
|
-
# e.g., http://localhost:3300/network/adfgadf-daf5a6df4afadf-adfad65f4ad
|
63
|
-
resource_type = options.resource.split('/')[3].to_sym
|
64
|
-
elsif options.resource.start_with? '/'
|
65
|
-
# resource contains a path relative to endpoint URI
|
66
|
-
# e.g., /network/adfgadf-daf5a6df4afadf-adfad65f4ad
|
67
|
-
resource_type = options.resource.split('/')[1].to_sym
|
68
|
-
elsif mixin_types.include? options.resource.split('#').first
|
69
|
-
# resource contains a mixin with a type
|
70
|
-
# e.g., os_tpl#debian6
|
71
|
-
resource_type = options.resource.split('#').first.to_sym
|
72
|
-
else
|
73
|
-
# resource probably contains RAW resource_type
|
74
|
-
resource_type = options.resource.to_sym
|
75
|
-
end
|
76
|
-
|
77
|
-
helper_formatter_output(found, output, :resources, resource_type)
|
78
|
-
|
79
|
-
nil
|
80
|
-
end
|
81
|
-
|
82
|
-
def helper_create(options, output = nil)
|
83
|
-
location = nil
|
84
|
-
|
85
|
-
if resource_types.include? options.resource
|
86
|
-
Occi::Log.debug "#{options.resource} is a resource type."
|
87
|
-
raise "Not yet implemented!" unless options.resource.include? "compute"
|
88
|
-
|
89
|
-
res = resource options.resource
|
90
|
-
|
91
|
-
Occi::Log.debug "Creating #{options.resource}:\n#{res.inspect}"
|
92
|
-
|
93
|
-
helper_attach_links(options, res)
|
94
|
-
helper_attach_mixins(options, res)
|
95
|
-
helper_attach_context_vars(options, res)
|
96
|
-
|
97
|
-
# TODO: set other attributes
|
98
|
-
# TODO: OCCI-OS uses occi.compute.hostname instead of title
|
99
|
-
res.title = options.attributes[:title]
|
100
|
-
res.hostname = options.attributes[:title]
|
101
|
-
|
102
|
-
Occi::Log.debug "Creating #{options.resource}:\n#{res.inspect}"
|
103
|
-
|
104
|
-
location = create res
|
105
|
-
else
|
106
|
-
Occi::Log.warn "I have no idea what #{options.resource} is ..."
|
107
|
-
raise "Unknown resource #{options.resource}, there is nothing to create here!"
|
108
|
-
end
|
109
|
-
|
110
|
-
return location if output.nil?
|
111
|
-
|
112
|
-
puts location
|
113
|
-
end
|
114
|
-
|
115
|
-
def helper_attach_links(options, res)
|
116
|
-
return unless options.links
|
117
|
-
Occi::Log.debug "with links: #{options.links}"
|
118
|
-
|
119
|
-
options.links.each do |link|
|
120
|
-
if link.start_with? options.endpoint
|
121
|
-
link.gsub!(options.endpoint.chomp('/'), '')
|
122
|
-
end
|
123
|
-
|
124
|
-
if link.include? "/storage/"
|
125
|
-
Occi::Log.debug "Adding storagelink to #{options.resource}"
|
126
|
-
res.storagelink link
|
127
|
-
elsif link.include? "/network/"
|
128
|
-
Occi::Log.debug "Adding networkinterface to #{options.resource}"
|
129
|
-
res.networkinterface link
|
130
|
-
else
|
131
|
-
raise "Unknown link type #{link}, stopping here!"
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def helper_attach_mixins(options, res)
|
137
|
-
return unless options.mixins
|
138
|
-
Occi::Log.debug "with mixins: #{options.mixins}"
|
139
|
-
|
140
|
-
options.mixins.keys.each do |type|
|
141
|
-
Occi::Log.debug "Adding mixins of type #{type} to #{options.resource}"
|
142
|
-
|
143
|
-
options.mixins[type].each do |name|
|
144
|
-
mxn = mixin name, type
|
145
|
-
|
146
|
-
raise "Unknown mixin #{type}##{name}, stopping here!" unless mxn
|
147
|
-
Occi::Log.debug "Adding mixin #{mxn} to #{options.resource}"
|
148
|
-
res.mixins << mxn
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def helper_attach_context_vars(options, res)
|
154
|
-
# TODO: find a better/universal way to do contextualization
|
155
|
-
return unless options.context_vars
|
156
|
-
Occi::Log.debug "with context variables: #{options.context_vars}"
|
157
|
-
|
158
|
-
options.context_vars.each_pair do |var, val|
|
159
|
-
schema = nil
|
160
|
-
mxn_attrs = Occi::Core::Attributes.new
|
161
|
-
|
162
|
-
case var
|
163
|
-
when :public_key
|
164
|
-
schema = "http://schemas.openstack.org/instance/credentials#"
|
165
|
-
mxn_attrs['org.openstack.credentials.publickey.name'] = {}
|
166
|
-
mxn_attrs['org.openstack.credentials.publickey.data'] = {}
|
167
|
-
when :user_data
|
168
|
-
schema = "http://schemas.openstack.org/compute/instance#"
|
169
|
-
mxn_attrs['org.openstack.compute.user_data'] = {}
|
170
|
-
else
|
171
|
-
schema = "http://schemas.ogf.org/occi/core#"
|
172
|
-
end
|
173
|
-
|
174
|
-
mxn = Occi::Core::Mixin.new(schema, var.to_s, 'OS contextualization mixin', mxn_attrs)
|
175
|
-
res.mixins << mxn
|
176
|
-
|
177
|
-
case var
|
178
|
-
when :public_key
|
179
|
-
res.attributes['org.openstack.credentials.publickey.name'] = 'Public SSH key'
|
180
|
-
res.attributes['org.openstack.credentials.publickey.data'] = val
|
181
|
-
when :user_data
|
182
|
-
res.attributes['org.openstack.compute.user_data'] = val
|
183
|
-
else
|
184
|
-
# do nothing
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def helper_delete(options, output = nil)
|
190
|
-
if delete(options.resource)
|
191
|
-
Occi::Log.info "Resource #{options.resource} successfully removed!"
|
192
|
-
else
|
193
|
-
raise "Failed to remove resource #{options.resource}!"
|
194
|
-
end
|
195
|
-
|
196
|
-
true
|
197
|
-
end
|
198
|
-
|
199
|
-
def helper_trigger(options, output = nil)
|
200
|
-
raise "Not yet implemented!"
|
201
|
-
end
|
202
|
-
|
203
|
-
def helper_formatter_output(found, output, format_symbol, resource_type)
|
204
|
-
if Occi::Cli::ResourceOutputFactory.allowed_resource_types.include? resource_type
|
205
|
-
puts output.format(found, format_symbol, resource_type)
|
206
|
-
else
|
207
|
-
Occi::Log.warn "Not printing, resource type [#{resource_type.to_s}] is not supported!"
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
end
|
212
|
-
end
|
7
|
+
extend Occi::Cli::Helpers::CommonHelper
|
8
|
+
extend Occi::Cli::Helpers::ListHelper
|
9
|
+
extend Occi::Cli::Helpers::DescribeHelper
|
10
|
+
extend Occi::Cli::Helpers::CreateHelper
|
11
|
+
extend Occi::Cli::Helpers::DeleteHelper
|
12
|
+
extend Occi::Cli::Helpers::TriggerHelper
|
data/lib/occi/cli/occi_opts.rb
CHANGED
@@ -15,6 +15,9 @@ module Occi::Cli
|
|
15
15
|
LOG_OUTPUTS = [:stdout, :stderr].freeze
|
16
16
|
ALLOWED_CONTEXT_VARS = [:public_key, :user_data].freeze
|
17
17
|
|
18
|
+
MIXIN_REGEXP = /^(https?:\/\/\S+?)#(\S+)$/
|
19
|
+
CONTEXT_REGEXP = ATTR_REGEXP = /^(.+?)=(.+)$/
|
20
|
+
|
18
21
|
def self.parse(args, test_env = false)
|
19
22
|
|
20
23
|
@@quiet = test_env
|
@@ -45,7 +48,7 @@ module Occi::Cli
|
|
45
48
|
|
46
49
|
options.output_format = :plain
|
47
50
|
|
48
|
-
options.mixins =
|
51
|
+
options.mixins = Occi::Core::Mixins.new
|
49
52
|
options.links = nil
|
50
53
|
options.attributes = nil
|
51
54
|
options.context_vars = nil
|
@@ -66,7 +69,7 @@ occi --endpoint https://localhost:3300/ --action list --resource resource_tpl --
|
|
66
69
|
|
67
70
|
occi --endpoint https://localhost:3300/ --action describe --resource os_tpl#debian6 --auth x509
|
68
71
|
|
69
|
-
occi --endpoint https://localhost:3300/ --action create --resource compute --mixin os_tpl#debian6 --mixin resource_tpl#small --
|
72
|
+
occi --endpoint https://localhost:3300/ --action create --resource compute --mixin os_tpl#debian6 --mixin resource_tpl#small --attribute title="My rOCCI VM" --auth x509
|
70
73
|
|
71
74
|
occi --endpoint https://localhost:3300/ --action delete --resource /compute/65sd4f654sf65g4-s5fg65sfg465sfg-sf65g46sf5g4sdfg --auth x509}
|
72
75
|
|
@@ -163,22 +166,18 @@ occi --endpoint https://localhost:3300/ --action delete --resource /compute/65sd
|
|
163
166
|
"--resource RESOURCE",
|
164
167
|
String,
|
165
168
|
"Resource to be queried (e.g. network, compute, storage etc.), required") do |resource|
|
166
|
-
# TODO: find a way to remove this OCCI-OS compatibility hack
|
167
|
-
resource = 'os_tpl' if resource == 'os'
|
168
|
-
resource = 'resource_tpl' if resource == 'resource'
|
169
|
-
|
170
169
|
options.resource = resource
|
171
170
|
end
|
172
171
|
|
173
172
|
opts.on("-t",
|
174
|
-
"--
|
173
|
+
"--attribute ATTRS",
|
175
174
|
Array,
|
176
175
|
"Comma separated attributes for new resources such as title=\"Name\", required") do |attributes|
|
177
|
-
options.attributes
|
176
|
+
options.attributes ||= {}
|
178
177
|
|
179
178
|
attributes.each do |attribute|
|
180
|
-
ary =
|
181
|
-
raise ArgumentError, "
|
179
|
+
ary = ATTR_REGEXP.match(attribute).to_a.drop 1
|
180
|
+
raise ArgumentError, "Attribute must always contain ATTR=VALUE pairs!" unless ary.length == 2
|
182
181
|
|
183
182
|
options.attributes[ary[0].to_sym] = ary[1]
|
184
183
|
end
|
@@ -187,12 +186,12 @@ occi --endpoint https://localhost:3300/ --action delete --resource /compute/65sd
|
|
187
186
|
opts.on("-T",
|
188
187
|
"--context CTX_VARS",
|
189
188
|
Array,
|
190
|
-
"Comma separated context variables for new compute resources such as
|
191
|
-
options.context_vars
|
189
|
+
"Comma separated context variables for new compute resources such as public_key=\"ssh-rsa dfsdf...adfdf== user@localhost\"") do |context|
|
190
|
+
options.context_vars ||= {}
|
192
191
|
|
193
192
|
context.each do |ctx|
|
194
|
-
ary =
|
195
|
-
raise ArgumentError, "Context variables must always contain ATTR=VALUE pairs!"
|
193
|
+
ary = CONTEXT_REGEXP.match(ctx).to_a.drop 1
|
194
|
+
raise ArgumentError, "Context variables must always contain ATTR=VALUE pairs!" unless ary.length == 2
|
196
195
|
|
197
196
|
symbol = ary[0].to_sym
|
198
197
|
if ALLOWED_CONTEXT_VARS.include?(symbol)
|
@@ -222,32 +221,29 @@ occi --endpoint https://localhost:3300/ --action delete --resource /compute/65sd
|
|
222
221
|
|
223
222
|
opts.on("-M",
|
224
223
|
"--mixin NAME",
|
225
|
-
|
226
|
-
"Type and name of the mixin as
|
227
|
-
|
228
|
-
raise "Unknown mixin format! Use TYPE#NAME!" unless parts
|
229
|
-
|
230
|
-
parts = parts.to_a.drop(1)
|
224
|
+
Array,
|
225
|
+
"Type and name of the mixin as SCHEME#NAME (e.g. http://localhost/os_tpl#monitoring, http://localhost/resource_tpl#medium)") do |mixins|
|
226
|
+
options.mixins ||= Occi::Core::Mixins.new
|
231
227
|
|
232
|
-
|
233
|
-
|
234
|
-
|
228
|
+
mixins.each do |mixin|
|
229
|
+
parts = MIXIN_REGEXP.match(mixin).to_a.drop(1)
|
230
|
+
raise "Unknown mixin format #{mixin.inspect}! Use SCHEME#NAME!" unless parts.length == 2
|
235
231
|
|
236
|
-
|
237
|
-
|
238
|
-
options.mixins[parts[0]] << parts[1]
|
232
|
+
options.mixins << Occi::Core::Mixin.new("#{parts[0]}#", parts[1])
|
233
|
+
end
|
239
234
|
end
|
240
235
|
|
241
236
|
opts.on("-j",
|
242
237
|
"--link URI",
|
243
|
-
|
244
|
-
"Link specified resource to the resource being created, only for action CREATE and resource COMPUTE") do |
|
245
|
-
|
246
|
-
|
247
|
-
raise ArgumentError, "Specified link URI is not valid!" unless link_relative_path.start_with? '/'
|
238
|
+
Array,
|
239
|
+
"Link specified resource to the resource being created, only for action CREATE and resource COMPUTE") do |links|
|
240
|
+
options.links ||= []
|
248
241
|
|
249
|
-
|
250
|
-
|
242
|
+
links.each do |link|
|
243
|
+
link_relative_path = URI(link).path
|
244
|
+
raise ArgumentError, "Specified link URI is not valid!" unless link_relative_path.start_with? '/'
|
245
|
+
options.links << link_relative_path
|
246
|
+
end
|
251
247
|
end
|
252
248
|
|
253
249
|
opts.on("-g",
|
@@ -6,108 +6,83 @@ module Occi::Cli
|
|
6
6
|
class ResourceOutputFactory
|
7
7
|
|
8
8
|
@@allowed_formats = [:json, :plain, :json_pretty].freeze
|
9
|
-
@@allowed_resource_types = [:compute, :storage, :network, :os_tpl, :resource_tpl].freeze
|
10
|
-
@@allowed_data_types = [:locations, :resources].freeze
|
11
9
|
|
12
10
|
attr_reader :output_format
|
13
11
|
|
14
12
|
def initialize(output_format = :plain)
|
15
|
-
raise
|
13
|
+
raise Occi::Cli::Errors::FormatterOutputTypeError,
|
14
|
+
"Format #{output_format.inspect} is not supported!" unless @@allowed_formats.include? output_format
|
16
15
|
@output_format = output_format
|
17
16
|
end
|
18
17
|
|
19
|
-
def format(data
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
def format(data)
|
19
|
+
# construct a method name from data type and output format
|
20
|
+
if data.kind_of? Occi::Core::Resources
|
21
|
+
method = "resources_to_#{@output_format}".to_sym
|
22
|
+
elsif data.kind_of? Occi::Core::Mixins
|
23
|
+
method = "mixins_to_#{@output_format}".to_sym
|
24
|
+
elsif data.kind_of? Array
|
25
|
+
raise Occi::Cli::Errors::FormatterInputTypeError,
|
26
|
+
"Arrays with #{data.first.class.name.inspect} are not supported!" unless data.first.nil? || data.first.kind_of?(String)
|
27
|
+
method = "locations_to_#{@output_format}".to_sym
|
28
|
+
else
|
29
|
+
raise Occi::Cli::Errors::FormatterInputTypeError,
|
30
|
+
"Data format #{data.class.name.inspect} is not supported!"
|
29
31
|
end
|
30
32
|
|
31
|
-
|
32
|
-
method = (data_type.to_s + "_to_" + output_format.to_s).to_sym
|
33
|
-
|
34
|
-
send method, data, resource_type
|
33
|
+
send method, data
|
35
34
|
end
|
36
35
|
|
37
36
|
def self.allowed_formats
|
38
37
|
@@allowed_formats
|
39
38
|
end
|
40
39
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
def resources_to_json(occi_resources)
|
41
|
+
# generate JSON document from Occi::Core::Resources
|
42
|
+
if @output_format == :json_pretty
|
43
|
+
JSON.pretty_generate occi_resources.as_json
|
44
|
+
else
|
45
|
+
JSON.generate occi_resources.as_json
|
46
|
+
end
|
47
47
|
end
|
48
|
+
alias_method :resources_to_json_pretty, :resources_to_json
|
49
|
+
alias_method :mixins_to_json, :resources_to_json
|
50
|
+
alias_method :mixins_to_json_pretty, :resources_to_json
|
48
51
|
|
49
|
-
def
|
50
|
-
# generate JSON document from an array of
|
52
|
+
def locations_to_json(url_locations)
|
53
|
+
# generate JSON document from an array of strings
|
51
54
|
if @output_format == :json_pretty
|
52
|
-
JSON.pretty_generate
|
55
|
+
JSON.pretty_generate locations
|
53
56
|
else
|
54
|
-
JSON.generate
|
57
|
+
JSON.generate locations
|
55
58
|
end
|
56
59
|
end
|
57
|
-
alias_method :
|
60
|
+
alias_method :locations_to_json_pretty, :locations_to_json
|
58
61
|
|
59
|
-
def resources_to_plain(occi_resources
|
62
|
+
def resources_to_plain(occi_resources)
|
60
63
|
# using ERB templates for known resource and mixin types
|
61
|
-
file = "#{File.expand_path('..', __FILE__)}/templates
|
64
|
+
file = "#{File.expand_path('..', __FILE__)}/templates/resources.erb"
|
62
65
|
template = ERB.new(File.new(file).read, nil, '-')
|
63
66
|
|
64
|
-
formatted_output = "
|
65
|
-
|
66
|
-
occi_resources.each do |occi_resource|
|
67
|
-
json_resource = occi_resource.as_json
|
68
|
-
next unless json_resource
|
69
|
-
|
70
|
-
if json_resource.resources && json_resource.resources.first
|
71
|
-
attributes = json_resource.resources.first.attributes
|
72
|
-
next unless attributes && attributes.occi
|
73
|
-
|
74
|
-
links = json_resource.links || []
|
75
|
-
end
|
76
|
-
|
77
|
-
formatted_output << template.result(binding)
|
78
|
-
end
|
67
|
+
formatted_output = ""
|
68
|
+
formatted_output << template.result(binding) unless occi_resources.blank?
|
79
69
|
|
80
70
|
formatted_output
|
81
71
|
end
|
82
72
|
|
83
|
-
def
|
84
|
-
#
|
85
|
-
|
73
|
+
def mixins_to_plain(occi_resources)
|
74
|
+
# using ERB templates for known resource and mixin types
|
75
|
+
file = "#{File.expand_path('..', __FILE__)}/templates/mixins.erb"
|
76
|
+
template = ERB.new(File.new(file).read, nil, '-')
|
86
77
|
|
87
|
-
|
88
|
-
|
89
|
-
locations[resource_type] << location
|
90
|
-
end
|
78
|
+
formatted_output = ""
|
79
|
+
formatted_output << template.result(binding) unless occi_resources.blank?
|
91
80
|
|
92
|
-
|
93
|
-
if @output_format == :json_pretty
|
94
|
-
JSON.pretty_generate locations
|
95
|
-
else
|
96
|
-
JSON.generate locations
|
97
|
-
end
|
81
|
+
formatted_output
|
98
82
|
end
|
99
|
-
alias_method :locations_to_json_pretty, :locations_to_json
|
100
|
-
|
101
|
-
def locations_to_plain(url_locations, resource_type)
|
102
|
-
# just an attempt to make the array more readable
|
103
|
-
output = "\n#{resource_type.to_s.capitalize} locations:\n"
|
104
|
-
|
105
|
-
url_locations.each do |location|
|
106
|
-
location = location.split("/").last if [:os_tpl, :resource_tpl].include? resource_type
|
107
|
-
output << "\t" << location << "\n"
|
108
|
-
end
|
109
83
|
|
110
|
-
|
84
|
+
def locations_to_plain(url_locations)
|
85
|
+
url_locations.join("\n")
|
111
86
|
end
|
112
87
|
|
113
88
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%- # We always get Occi::Core::Resources -%>
|
2
|
+
<%- occi_resources.each do |resource| -%>
|
3
|
+
[<%= resource.kind.type_identifier %>]
|
4
|
+
<%- resource.attributes.names.each_pair do |attribute, value| -%>
|
5
|
+
<%= attribute %> = <%= value %>
|
6
|
+
<%- end -%>
|
7
|
+
|
8
|
+
<%- resource.links.each do |link| -%>
|
9
|
+
[<%= link.kind.type_identifier %>]
|
10
|
+
<%- link.attributes.names.each_pair do |attribute, value| -%>
|
11
|
+
<%= attribute %> = <%= value %>
|
12
|
+
<%- end -%>
|
13
|
+
|
14
|
+
<%- end -%>
|
15
|
+
|
16
|
+
<%- resource.mixins.each do |mixin| -%>
|
17
|
+
[<%= mixin.type_identifier %>]
|
18
|
+
Title: <%= mixin.title %>
|
19
|
+
Term: <%= mixin.term %>
|
20
|
+
Location: <%= mixin.location %>
|
21
|
+
|
22
|
+
<%- end -%>
|
23
|
+
|
24
|
+
|
25
|
+
<%- end -%>
|
data/lib/occi/cli/version.rb
CHANGED
data/lib/occi-cli.rb
CHANGED
@@ -4,6 +4,12 @@ require 'occi-api'
|
|
4
4
|
module Occi::Cli; end
|
5
5
|
|
6
6
|
require 'occi/cli/version'
|
7
|
+
require 'occi/cli/errors'
|
7
8
|
require 'occi/cli/occi_opts'
|
8
9
|
require 'occi/cli/resource_output_factory'
|
10
|
+
|
11
|
+
# get DSL definitions
|
12
|
+
extend Occi::Api::Dsl
|
13
|
+
|
14
|
+
# include helpers
|
9
15
|
require 'occi/cli/helpers'
|
data/occi-cli.gemspec
CHANGED
@@ -19,18 +19,9 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.test_files = `git ls-files -- {test,spec}/*`.split("\n")
|
20
20
|
gem.require_paths = ["lib"]
|
21
21
|
|
22
|
-
gem.add_dependency 'occi-api', '
|
22
|
+
gem.add_dependency 'occi-api', '= 4.2.0.beta.2'
|
23
23
|
gem.add_dependency 'highline'
|
24
24
|
gem.add_dependency 'json'
|
25
25
|
|
26
|
-
gem.add_development_dependency "rspec"
|
27
|
-
gem.add_development_dependency "rake"
|
28
|
-
gem.add_development_dependency "builder"
|
29
|
-
gem.add_development_dependency "simplecov"
|
30
|
-
gem.add_development_dependency "yard"
|
31
|
-
gem.add_development_dependency "yard-sinatra"
|
32
|
-
gem.add_development_dependency "yard-rspec"
|
33
|
-
gem.add_development_dependency "yard-cucumber"
|
34
|
-
|
35
26
|
gem.required_ruby_version = ">= 1.9.3"
|
36
27
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'occi-cli'
|
3
2
|
|
4
3
|
# enable coverage reports
|
5
4
|
if ENV['COVERAGE']
|
6
5
|
require 'simplecov'
|
6
|
+
|
7
|
+
SimpleCov.add_filter "/spec/"
|
7
8
|
SimpleCov.start
|
8
9
|
end
|
9
10
|
|
11
|
+
require 'occi-cli'
|
12
|
+
|
10
13
|
RSpec.configure do |c|
|
11
14
|
# in RSpec 3 this will no longer be necessary.
|
12
15
|
c.treat_symbols_as_metadata_keys_with_true_values = true
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occi-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
5
|
-
prerelease:
|
4
|
+
version: 4.2.0.beta.2
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Florian Feldhaus
|
@@ -11,24 +11,24 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: occi-api
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - '='
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 4.
|
23
|
+
version: 4.2.0.beta.2
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
none: false
|
28
28
|
requirements:
|
29
|
-
- -
|
29
|
+
- - '='
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: 4.
|
31
|
+
version: 4.2.0.beta.2
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: highline
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,134 +61,6 @@ dependencies:
|
|
61
61
|
- - ! '>='
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: rspec
|
66
|
-
requirement: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
|
-
requirements:
|
69
|
-
- - ! '>='
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '0'
|
72
|
-
type: :development
|
73
|
-
prerelease: false
|
74
|
-
version_requirements: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
|
-
requirements:
|
77
|
-
- - ! '>='
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: '0'
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: rake
|
82
|
-
requirement: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
|
-
requirements:
|
85
|
-
- - ! '>='
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0'
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
|
-
requirements:
|
93
|
-
- - ! '>='
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
96
|
-
- !ruby/object:Gem::Dependency
|
97
|
-
name: builder
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
|
-
requirements:
|
101
|
-
- - ! '>='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
|
-
requirements:
|
109
|
-
- - ! '>='
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '0'
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: simplecov
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
|
-
requirements:
|
117
|
-
- - ! '>='
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: '0'
|
120
|
-
type: :development
|
121
|
-
prerelease: false
|
122
|
-
version_requirements: !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
|
-
requirements:
|
125
|
-
- - ! '>='
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '0'
|
128
|
-
- !ruby/object:Gem::Dependency
|
129
|
-
name: yard
|
130
|
-
requirement: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
|
-
requirements:
|
133
|
-
- - ! '>='
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
version: '0'
|
136
|
-
type: :development
|
137
|
-
prerelease: false
|
138
|
-
version_requirements: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
|
-
requirements:
|
141
|
-
- - ! '>='
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '0'
|
144
|
-
- !ruby/object:Gem::Dependency
|
145
|
-
name: yard-sinatra
|
146
|
-
requirement: !ruby/object:Gem::Requirement
|
147
|
-
none: false
|
148
|
-
requirements:
|
149
|
-
- - ! '>='
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '0'
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
none: false
|
156
|
-
requirements:
|
157
|
-
- - ! '>='
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
- !ruby/object:Gem::Dependency
|
161
|
-
name: yard-rspec
|
162
|
-
requirement: !ruby/object:Gem::Requirement
|
163
|
-
none: false
|
164
|
-
requirements:
|
165
|
-
- - ! '>='
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
version: '0'
|
168
|
-
type: :development
|
169
|
-
prerelease: false
|
170
|
-
version_requirements: !ruby/object:Gem::Requirement
|
171
|
-
none: false
|
172
|
-
requirements:
|
173
|
-
- - ! '>='
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
version: '0'
|
176
|
-
- !ruby/object:Gem::Dependency
|
177
|
-
name: yard-cucumber
|
178
|
-
requirement: !ruby/object:Gem::Requirement
|
179
|
-
none: false
|
180
|
-
requirements:
|
181
|
-
- - ! '>='
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
version: '0'
|
184
|
-
type: :development
|
185
|
-
prerelease: false
|
186
|
-
version_requirements: !ruby/object:Gem::Requirement
|
187
|
-
none: false
|
188
|
-
requirements:
|
189
|
-
- - ! '>='
|
190
|
-
- !ruby/object:Gem::Version
|
191
|
-
version: '0'
|
192
64
|
description: This gem is a client implementation of the Open Cloud Computing Interface
|
193
65
|
in Ruby
|
194
66
|
email:
|
@@ -213,14 +85,20 @@ files:
|
|
213
85
|
- config/warble.rb
|
214
86
|
- doc/macosx.md
|
215
87
|
- lib/occi-cli.rb
|
88
|
+
- lib/occi/cli/errors.rb
|
89
|
+
- lib/occi/cli/errors/formatter_input_type_error.rb
|
90
|
+
- lib/occi/cli/errors/formatter_output_type_error.rb
|
216
91
|
- lib/occi/cli/helpers.rb
|
92
|
+
- lib/occi/cli/helpers/common_helper.rb
|
93
|
+
- lib/occi/cli/helpers/create_helper.rb
|
94
|
+
- lib/occi/cli/helpers/delete_helper.rb
|
95
|
+
- lib/occi/cli/helpers/describe_helper.rb
|
96
|
+
- lib/occi/cli/helpers/list_helper.rb
|
97
|
+
- lib/occi/cli/helpers/trigger_helper.rb
|
217
98
|
- lib/occi/cli/occi_opts.rb
|
218
99
|
- lib/occi/cli/resource_output_factory.rb
|
219
|
-
- lib/occi/cli/templates/
|
220
|
-
- lib/occi/cli/templates/
|
221
|
-
- lib/occi/cli/templates/os_tpl.erb
|
222
|
-
- lib/occi/cli/templates/resource_tpl.erb
|
223
|
-
- lib/occi/cli/templates/storage.erb
|
100
|
+
- lib/occi/cli/templates/mixins.erb
|
101
|
+
- lib/occi/cli/templates/resources.erb
|
224
102
|
- lib/occi/cli/version.rb
|
225
103
|
- occi-cli.gemspec
|
226
104
|
- spec/occi/cli/helpers_spec.rb
|
@@ -243,9 +121,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
243
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
122
|
none: false
|
245
123
|
requirements:
|
246
|
-
- - ! '
|
124
|
+
- - ! '>'
|
247
125
|
- !ruby/object:Gem::Version
|
248
|
-
version:
|
126
|
+
version: 1.3.1
|
249
127
|
requirements: []
|
250
128
|
rubyforge_project:
|
251
129
|
rubygems_version: 1.8.25
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<%- # We always get a JSON -%>
|
2
|
-
COMPUTE:
|
3
|
-
ID: <%= attributes.occi.core.id %>
|
4
|
-
TITLE: <%= attributes.occi.core.title || attributes.occi.compute.hostname %>
|
5
|
-
STATE: <%= attributes.occi.compute.state %>
|
6
|
-
MEMORY: <%= attributes.occi.compute.memory %> GB
|
7
|
-
CORES: <%= attributes.occi.compute.cores %>
|
8
|
-
LINKS:
|
9
|
-
<%- links.each do |link| -%>
|
10
|
-
<%- next unless link && link.attributes -%>
|
11
|
-
|
12
|
-
LINK "<%= link.kind %>":
|
13
|
-
ID: <%= link.attributes.occi.core.id %>
|
14
|
-
TITLE: <%= link.attributes.occi.core.title || link.target.split('/').last %>
|
15
|
-
TARGET: <%= link.target %>
|
16
|
-
<% if link.attributes.occi.networkinterface %>
|
17
|
-
IP ADDRESS: <%= link.attributes.occi.networkinterface.address %>
|
18
|
-
MAC ADDRESS: <%= link.attributes.occi.networkinterface.mac %>
|
19
|
-
<% elsif link.attributes.occi.storagelink %>
|
20
|
-
MOUNT POINT: <%= link.attributes.occi.storagelink.deviceid %>
|
21
|
-
<%- end -%>
|
22
|
-
<% end if links %>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<%- # We always get a JSON -%>
|
2
|
-
NETWORK:
|
3
|
-
ID: <%= attributes.occi.core.id %>
|
4
|
-
TITLE: <%= attributes.occi.core.title || attributes.occi.network.label %>
|
5
|
-
STATE: <%= attributes.occi.network.state %>
|
6
|
-
ALLOCATION: <%= attributes.occi.network.allocation || (attributes.occi.networkinterface && attributes.occi.networkinterface.allocation) %>
|
7
|
-
ADDRESS: <%= attributes.occi.network.address || (attributes.occi.networkinterface && attributes.occi.networkinterface.address) %>
|
8
|
-
|