occi-cli 4.0.0.alpha.2 → 4.0.0.alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +12 -6
- data/bin/occi +1 -0
- data/lib/occi/cli/helpers.rb +159 -120
- data/lib/occi/cli/occi_opts.rb +18 -1
- data/lib/occi/cli/version.rb +1 -1
- data/occi-cli.gemspec +2 -2
- metadata +5 -5
data/README.md
CHANGED
@@ -14,8 +14,7 @@ Ruby
|
|
14
14
|
|
15
15
|
The following setup is recommended
|
16
16
|
|
17
|
-
*
|
18
|
-
* Ruby 1.9.3
|
17
|
+
* Ruby 1.9.3+
|
19
18
|
* RubyGems installed
|
20
19
|
|
21
20
|
The following libraries / packages may be required to use rOCCI-cli
|
@@ -42,6 +41,8 @@ To install the most recent beta version
|
|
42
41
|
|
43
42
|
### Installation from source
|
44
43
|
|
44
|
+
**Installation from source is intended for advanced users or developers only!**
|
45
|
+
|
45
46
|
To use rOCCI-cli from source it is very much recommended to use RVM. [Install RVM](https://rvm.io/rvm/install/) with
|
46
47
|
|
47
48
|
curl -L https://get.rvm.io | bash -s stable --ruby
|
@@ -53,8 +54,8 @@ To build and install the bleeding edge version from master
|
|
53
54
|
git clone git://github.com/gwdg/rOCCI-cli.git
|
54
55
|
cd rOCCI-cli
|
55
56
|
rvm install ruby-1.9.3
|
56
|
-
|
57
|
-
bundle install
|
57
|
+
gem install bundler
|
58
|
+
bundle install
|
58
59
|
rake install
|
59
60
|
|
60
61
|
#### Java
|
@@ -63,8 +64,7 @@ To build a Java jar file from master use
|
|
63
64
|
|
64
65
|
git clone git://github.com/gwdg/rOCCI-cli.git
|
65
66
|
cd rOCCI-cli
|
66
|
-
rvm install jruby-1.7.
|
67
|
-
rvm --create --ruby-version use jruby-1.7.1@rOCCI-cli
|
67
|
+
rvm install jruby-1.7.4
|
68
68
|
gem install bundler
|
69
69
|
bundle install
|
70
70
|
warble
|
@@ -127,6 +127,12 @@ To delete a compute resource use
|
|
127
127
|
Changelog
|
128
128
|
---------
|
129
129
|
|
130
|
+
### Version 4.0
|
131
|
+
* added extended support for OCCI-OS
|
132
|
+
* updated human-readable output rendering
|
133
|
+
* split the code into rOCCI-core, rOCCI-api and rOCCI-cli
|
134
|
+
* internal changes, refactoring and some bugfixes
|
135
|
+
|
130
136
|
### Version 3.1
|
131
137
|
* added basic OS Keystone support
|
132
138
|
* added support for PKCS12 credentials for X.509 authN
|
data/bin/occi
CHANGED
data/lib/occi/cli/helpers.rb
CHANGED
@@ -1,149 +1,188 @@
|
|
1
1
|
# a bunch of OCCI client helpers for bin/occi
|
2
|
+
module Occi::Cli
|
3
|
+
module Helpers
|
4
|
+
|
5
|
+
def helper_list(options, output = nil)
|
6
|
+
found = []
|
7
|
+
|
8
|
+
if resource_types.include? options.resource
|
9
|
+
Occi::Log.debug "#{options.resource} is a resource type."
|
10
|
+
found = list options.resource
|
11
|
+
elsif mixin_types.include? options.resource
|
12
|
+
Occi::Log.debug "#{options.resource} is a mixin type."
|
13
|
+
found = mixins options.resource
|
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
|
2
18
|
|
3
|
-
|
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?
|
19
|
+
return found if output.nil?
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
21
|
+
if Occi::Cli::ResourceOutputFactory.allowed_resource_types.include? options.resource.to_sym
|
22
|
+
puts output.format(found, :locations, options.resource.to_sym)
|
23
|
+
else
|
24
|
+
Occi::Log.warn "Not printing, the resource type is not supported!"
|
25
|
+
end
|
26
|
+
end
|
25
27
|
|
26
|
-
def helper_describe(options, output = nil)
|
27
|
-
|
28
|
+
def helper_describe(options, output = nil)
|
29
|
+
found = []
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
if resource_types.include?(options.resource) || options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
|
32
|
+
Occi::Log.debug "#{options.resource} is a resource type or an actual resource."
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
found = describe(options.resource)
|
35
|
+
elsif mixin_types.include? options.resource
|
36
|
+
Occi::Log.debug "#{options.resourcre} is a mixin type."
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
38
|
+
mixins(options.resource).each do |mxn|
|
39
|
+
mxn = mxn.split("#").last
|
40
|
+
found << mixin(mxn, options.resource, true)
|
41
|
+
end
|
42
|
+
elsif mixin_types.include? options.resource.split('#').first
|
43
|
+
Occi::Log.debug "#{options.resource} is a specific mixin type."
|
44
|
+
|
45
|
+
mxn_type,mxn = options.resource.split('#')
|
46
|
+
found << mixin(mxn, mxn_type, true)
|
47
|
+
else
|
48
|
+
Occi::Log.warn "I have no idea what #{options.resource} is ..."
|
49
|
+
raise "Unknown resource #{options.resource}, there is nothing to describe here!"
|
50
|
+
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
52
|
+
return found if output.nil?
|
53
|
+
|
54
|
+
if options.resource.start_with? options.endpoint
|
55
|
+
# resource contains full endpoint URI
|
56
|
+
# e.g., http://localhost:3300/network/adfgadf-daf5a6df4afadf-adfad65f4ad
|
57
|
+
resource_type = options.resource.split('/')[3].to_sym
|
58
|
+
elsif options.resource.start_with? '/'
|
59
|
+
# resource contains a path relative to endpoint URI
|
60
|
+
# e.g., /network/adfgadf-daf5a6df4afadf-adfad65f4ad
|
61
|
+
resource_type = options.resource.split('/')[1].to_sym
|
62
|
+
elsif mixin_types.include? options.resource.split('#').first
|
63
|
+
# resource contains a mixin with a type
|
64
|
+
# e.g., os_tpl#debian6
|
65
|
+
resource_type = options.resource.split('#').first.to_sym
|
66
|
+
else
|
67
|
+
# resource probably contains RAW resource_type
|
68
|
+
resource_type = options.resource.to_sym
|
69
|
+
end
|
68
70
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
71
|
+
if Occi::Cli::ResourceOutputFactory.allowed_resource_types.include? resource_type
|
72
|
+
puts output.format(found, :resources, resource_type)
|
73
|
+
else
|
74
|
+
Occi::Log.warn "Not printing, the resource type [#{resource_type.to_s}] is not supported!"
|
75
|
+
end
|
76
|
+
end
|
75
77
|
|
76
|
-
def helper_create(options, output = nil)
|
77
|
-
|
78
|
+
def helper_create(options, output = nil)
|
79
|
+
location = nil
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
81
|
+
if resource_types.include? options.resource
|
82
|
+
Occi::Log.debug "#{options.resource} is a resource type."
|
83
|
+
raise "Not yet implemented!" unless options.resource.include? "compute"
|
82
84
|
|
83
|
-
|
85
|
+
res = resource options.resource
|
84
86
|
|
85
|
-
|
87
|
+
Occi::Log.debug "Creating #{options.resource}:\n#{res.inspect}"
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
+
if options.links
|
90
|
+
Occi::Log.debug "with links: #{options.links}"
|
89
91
|
|
90
|
-
|
91
|
-
|
92
|
+
options.links.each do |link|
|
93
|
+
link = options.endpoint.chomp('/') + link unless link.start_with? options.endpoint
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
if link.include? "/storage/"
|
96
|
+
Occi::Log.debug "Adding storagelink to #{options.resource}"
|
97
|
+
res.storagelink link
|
98
|
+
elsif link.include? "/network/"
|
99
|
+
Occi::Log.debug "Adding networkinterface to #{options.resource}"
|
100
|
+
res.networkinterface link
|
101
|
+
else
|
102
|
+
raise "Unknown link type #{link}, stopping here!"
|
103
|
+
end
|
104
|
+
end
|
101
105
|
end
|
102
|
-
end
|
103
|
-
end
|
104
106
|
|
105
|
-
|
106
|
-
|
107
|
+
if options.mixins
|
108
|
+
Occi::Log.debug "with mixins: #{options.mixins}"
|
109
|
+
|
110
|
+
options.mixins.keys.each do |type|
|
111
|
+
Occi::Log.debug "Adding mixins of type #{type} to #{options.resource}"
|
112
|
+
|
113
|
+
options.mixins[type].each do |name|
|
114
|
+
mxn = mixin name, type
|
115
|
+
|
116
|
+
raise "Unknown mixin #{type}##{name}, stopping here!" if mxn.nil?
|
117
|
+
Occi::Log.debug "Adding mixin #{mxn} to #{options.resource}"
|
118
|
+
res.mixins << mxn
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# TODO: find a better/universal way to do contextualization
|
123
|
+
if options.context_vars
|
124
|
+
Occi::Log.debug "with context variables: #{options.context_vars}"
|
125
|
+
|
126
|
+
options.context_vars.each_pair do |var, val|
|
127
|
+
schema = nil
|
128
|
+
mxn_attrs = Occi::Core::Attributes.new
|
129
|
+
|
130
|
+
case var
|
131
|
+
when :public_key
|
132
|
+
schema = "http://schemas.openstack.org/instance/credentials#"
|
133
|
+
mxn_attrs['org.openstack.credentials.publickey.name'] = {}
|
134
|
+
mxn_attrs['org.openstack.credentials.publickey.data'] = {}
|
135
|
+
when :user_data
|
136
|
+
schema = "http://schemas.openstack.org/compute/instance#"
|
137
|
+
mxn_attrs['org.openstack.compute.user_data'] = {}
|
138
|
+
else
|
139
|
+
schema = "http://schemas.ogf.org/occi/core#"
|
140
|
+
end
|
141
|
+
|
142
|
+
mxn = Occi::Core::Mixin.new(schema, var.to_s, 'OS contextualization mixin', mxn_attrs)
|
143
|
+
res.mixins << mxn
|
144
|
+
|
145
|
+
case var
|
146
|
+
when :public_key
|
147
|
+
res.attributes['org.openstack.credentials.publickey.name'] = 'Public SSH key'
|
148
|
+
res.attributes['org.openstack.credentials.publickey.data'] = val
|
149
|
+
when :user_data
|
150
|
+
res.attributes['org.openstack.compute.user_data'] = val
|
151
|
+
else
|
152
|
+
# do nothing
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
107
157
|
|
108
|
-
|
109
|
-
|
158
|
+
#TODO: set other attributes
|
159
|
+
res.title = options.attributes[:title]
|
110
160
|
|
111
|
-
options.
|
112
|
-
mxn = mixin name, type
|
161
|
+
Occi::Log.debug "Creating #{options.resource}:\n#{res.inspect}"
|
113
162
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
163
|
+
location = create res
|
164
|
+
else
|
165
|
+
Occi::Log.warn "I have no idea what #{options.resource} is ..."
|
166
|
+
raise "Unknown resource #{options.resource}, there is nothing to create here!"
|
118
167
|
end
|
119
|
-
end
|
120
168
|
|
121
|
-
|
122
|
-
res.title = options.attributes[:title]
|
169
|
+
return location if output.nil?
|
123
170
|
|
124
|
-
|
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
|
171
|
+
puts location
|
172
|
+
end
|
131
173
|
|
132
|
-
|
174
|
+
def helper_delete(options, output = nil)
|
175
|
+
if delete(options.resource)
|
176
|
+
Occi::Log.info "Resource #{options.resource} successfully removed!"
|
177
|
+
else
|
178
|
+
raise "Failed to remove resource #{options.resource}!"
|
179
|
+
end
|
133
180
|
|
134
|
-
|
135
|
-
end
|
181
|
+
true
|
182
|
+
end
|
136
183
|
|
137
|
-
def
|
138
|
-
|
139
|
-
|
140
|
-
else
|
141
|
-
raise "Failed to remove resource #{options.resource}!"
|
184
|
+
def helper_trigger(options, output = nil)
|
185
|
+
raise "Not yet implemented!"
|
186
|
+
end
|
142
187
|
end
|
143
|
-
|
144
|
-
true
|
145
|
-
end
|
146
|
-
|
147
|
-
def helper_trigger(options, output = nil)
|
148
|
-
raise "Not yet implemented!"
|
149
188
|
end
|
data/lib/occi/cli/occi_opts.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'optparse'
|
3
3
|
require 'uri'
|
4
|
+
require 'base64'
|
4
5
|
|
5
6
|
require 'occi/cli/resource_output_factory'
|
6
7
|
|
@@ -12,6 +13,7 @@ module Occi::Cli
|
|
12
13
|
MEDIA_TYPES = ["application/occi+json", "application/occi+xml", "text/plain,text/occi", "text/plain"].freeze
|
13
14
|
ACTIONS = [:list, :describe, :create, :delete, :trigger].freeze
|
14
15
|
LOG_OUTPUTS = [:stdout, :stderr].freeze
|
16
|
+
ALLOWED_CONTEXT_VARS = [:public_key, :user_data].freeze
|
15
17
|
|
16
18
|
def self.parse(args, test_env = false)
|
17
19
|
|
@@ -188,7 +190,22 @@ occi --endpoint https://localhost:3300/ --action delete --resource /compute/65sd
|
|
188
190
|
ary = /^(.+?)=(.+)$/.match(ctx).to_a.drop 1
|
189
191
|
raise ArgumentError, "Context variables must always contain ATTR=VALUE pairs!" if ary.length != 2
|
190
192
|
|
191
|
-
|
193
|
+
symbol = ary[0].to_sym
|
194
|
+
if ALLOWED_CONTEXT_VARS.include?(symbol)
|
195
|
+
context_data = ary[1]
|
196
|
+
if context_data.gsub!(/^file:\/\//,'')
|
197
|
+
raise 'File does not exist! #{context_data}' unless File.exist? context_data
|
198
|
+
context_data = File.read(context_data)
|
199
|
+
end
|
200
|
+
|
201
|
+
if symbol == :user_data
|
202
|
+
context_data = Base64.encode64(context_data)
|
203
|
+
end
|
204
|
+
|
205
|
+
options.context_vars[symbol] = context_data.strip
|
206
|
+
else
|
207
|
+
Occi::Log.warn "Only #{ALLOWED_CONTEXT_VARS.join(', ')} context variables are supported! Skipping #{ary[0].to_s} ..."
|
208
|
+
end
|
192
209
|
end
|
193
210
|
end
|
194
211
|
|
data/lib/occi/cli/version.rb
CHANGED
data/occi-cli.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.version = Occi::Cli::VERSION
|
10
10
|
gem.authors = ["Florian Feldhaus","Piotr Kasprzak", "Boris Parak"]
|
11
11
|
gem.email = ["florian.feldhaus@gwdg.de", "piotr.kasprzak@gwdg.de", "xparak@mail.muni.cz"]
|
12
|
-
gem.description = %q{
|
13
|
-
gem.summary = %q{OCCI
|
12
|
+
gem.description = %q{This gem is a client implementation of the Open Cloud Computing Interface in Ruby}
|
13
|
+
gem.summary = %q{Executable OCCI client}
|
14
14
|
gem.homepage = 'https://github.com/gwdg/rOCCI-cli'
|
15
15
|
gem.license = 'Apache License, Version 2.0'
|
16
16
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occi-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.alpha.
|
4
|
+
version: 4.0.0.alpha.3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-07-
|
14
|
+
date: 2013-07-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: occi-api
|
@@ -189,8 +189,8 @@ dependencies:
|
|
189
189
|
- - ! '>='
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
|
-
description:
|
193
|
-
|
192
|
+
description: This gem is a client implementation of the Open Cloud Computing Interface
|
193
|
+
in Ruby
|
194
194
|
email:
|
195
195
|
- florian.feldhaus@gwdg.de
|
196
196
|
- piotr.kasprzak@gwdg.de
|
@@ -253,5 +253,5 @@ rubyforge_project:
|
|
253
253
|
rubygems_version: 1.8.25
|
254
254
|
signing_key:
|
255
255
|
specification_version: 3
|
256
|
-
summary: OCCI
|
256
|
+
summary: Executable OCCI client
|
257
257
|
test_files: []
|