occi 2.5.19 → 3.0.0.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.travis.yml +3 -1
- data/AUTHORS +4 -3
- data/Gemfile +9 -0
- data/Gemfile.lock +64 -21
- data/README.md +19 -14
- data/Rakefile +12 -8
- data/Test Results - discovery_interface.html +862 -0
- data/bin/occi +333 -83
- data/examples/dsl_example.rb +6 -6
- data/examples/x509auth_example.rb +6 -6
- data/features/common/step_definitions/common_steps.rb +32 -0
- data/features/occi/core/create/create.feature +17 -0
- data/features/occi/core/create/step_definitions/create_steps.rb +0 -0
- data/features/occi/core/delete/delete.feature +14 -0
- data/features/occi/core/delete/step_definitions/delete_steps.rb +0 -0
- data/features/occi/core/discovery_interface/discovery_interface.feature +35 -0
- data/features/occi/core/discovery_interface/step_definitions/discovery_interface_steps.rb +19 -0
- data/features/occi/core/miscellaneous/miscellaneous.feature +14 -0
- data/features/occi/core/miscellaneous/step_definitions/miscellaneous_steps.rb +0 -0
- data/features/occi/core/read/read.feature +14 -0
- data/features/occi/core/read/step_definitions/read_steps.rb +0 -0
- data/features/occi/core/update/step_definitions/update_steps.rb +0 -0
- data/features/occi/core/update/update.feature +14 -0
- data/features/occi/infrastructure/create/create.feature +14 -0
- data/features/occi/infrastructure/create/step_definitions/create_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/lib/occi.rb +29 -3
- data/lib/occi/api/client/client_amqp.rb +756 -0
- data/lib/occi/api/client/client_http.rb +922 -0
- data/lib/occi/api/client/http/httparty_fix.rb +53 -0
- data/lib/occi/api/client/http/net_http_fix.rb +46 -0
- data/lib/occi/api/dsl.rb +77 -73
- data/lib/occi/bin/helpers.rb +91 -0
- data/lib/occi/bin/occi_opts.rb +251 -0
- data/lib/occi/bin/resource_output_factory.rb +90 -0
- data/lib/occi/bin/templates/compute.erb +15 -0
- data/lib/occi/bin/templates/network.erb +11 -0
- data/lib/occi/bin/templates/os_tpl.erb +9 -0
- data/lib/occi/bin/templates/resource_tpl.erb +9 -0
- data/lib/occi/bin/templates/storage.erb +10 -0
- data/lib/occi/collection.rb +122 -25
- data/lib/occi/core.rb +18 -9
- data/lib/occi/core/action.rb +20 -4
- data/lib/occi/core/action_instance.rb +24 -0
- data/lib/occi/core/actions.rb +22 -0
- data/lib/occi/core/attribute_properties.rb +33 -84
- data/lib/occi/core/attributes.rb +32 -14
- data/lib/occi/core/categories.rb +46 -0
- data/lib/occi/core/category.rb +94 -20
- data/lib/occi/core/entities.rb +50 -0
- data/lib/occi/core/entity.rb +130 -89
- data/lib/occi/core/kind.rb +28 -35
- data/lib/occi/core/kinds.rb +22 -0
- data/lib/occi/core/link.rb +43 -40
- data/lib/occi/core/links.rb +34 -0
- data/lib/occi/core/mixin.rb +28 -23
- data/lib/occi/core/mixins.rb +22 -0
- data/lib/occi/core/related.rb +20 -0
- data/lib/occi/core/resource.rb +40 -40
- data/lib/occi/core/resources.rb +14 -0
- data/lib/occi/infrastructure.rb +27 -0
- data/lib/occi/infrastructure/compute.rb +159 -0
- data/lib/occi/infrastructure/network.rb +131 -0
- data/lib/occi/infrastructure/network/ipnetwork.rb +34 -0
- data/lib/occi/infrastructure/networkinterface.rb +124 -0
- data/lib/occi/infrastructure/networkinterface/ipnetworkinterface.rb +34 -0
- data/lib/occi/infrastructure/os_tpl.rb +19 -0
- data/lib/occi/infrastructure/resource_tpl.rb +19 -0
- data/lib/occi/infrastructure/storage.rb +96 -0
- data/lib/occi/infrastructure/storagelink.rb +73 -0
- data/lib/occi/log.rb +6 -2
- data/lib/occi/model.rb +38 -70
- data/lib/occi/parser.rb +108 -88
- data/lib/occi/version.rb +2 -2
- data/lib/occiantlr/OCCIANTLR.g +6 -5
- data/lib/occiantlr/OCCIANTLRLexer.rb +52 -52
- data/lib/occiantlr/OCCIANTLRParser.rb +678 -569
- data/lib/occiantlr/README.md +1 -1
- data/occi.gemspec +2 -1
- data/spec/cassettes/client_http_text_plain.yml +1066 -0
- data/spec/occi/api/client/client_amqp_spec.rb +148 -0
- data/spec/occi/api/client/client_http_0.5_spec.rb +292 -0
- data/spec/occi/api/client/client_http_spec.rb +259 -0
- data/spec/occi/api/dsl_spec.rb +0 -0
- data/spec/occi/collection_spec.rb +23 -10
- data/spec/occi/core/categories_spec.rb +30 -0
- data/spec/occi/core/category_spec.rb +41 -0
- data/spec/occi/core/entity_spec.rb +52 -0
- data/spec/occi/core/resource_spec.rb +21 -0
- data/spec/occi/infrastructure/compute_spec.rb +32 -0
- data/spec/occi/log_spec.rb +10 -10
- data/spec/occi/model_spec.rb +24 -24
- data/spec/occi/parser_spec.rb +89 -39
- data/spec/occi/test.json +22 -58
- data/spec/occiantlr/parser_spec.rb +5 -7
- data/spec/spec_helper.rb +13 -3
- metadata +116 -19
- data/etc/model/infrastructure/compute.json +0 -108
- data/etc/model/infrastructure/ipnetwork.json +0 -40
- data/etc/model/infrastructure/ipnetworkinterface.json +0 -40
- data/etc/model/infrastructure/network.json +0 -55
- data/etc/model/infrastructure/networkinterface.json +0 -38
- data/etc/model/infrastructure/os_template.json +0 -9
- data/etc/model/infrastructure/resource_template.json +0 -9
- data/etc/model/infrastructure/storage.json +0 -72
- data/etc/model/infrastructure/storagelink.json +0 -38
- data/lib/occi/api/client.rb +0 -596
- data/lib/occi/client/occiopts.rb +0 -146
- data/spec/occi/client_spec.rb +0 -12
data/lib/occi/client/occiopts.rb
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
require 'optparse'
|
3
|
-
|
4
|
-
class OcciOpts
|
5
|
-
|
6
|
-
def self.parse(args)
|
7
|
-
|
8
|
-
options = OpenStruct.new
|
9
|
-
|
10
|
-
options.debug = false
|
11
|
-
options.verbose = false
|
12
|
-
|
13
|
-
options.log = {}
|
14
|
-
options.log[:out] = STDERR
|
15
|
-
options.log[:level] = OCCI::Log::WARN
|
16
|
-
|
17
|
-
options.endpoint = "https://localhost:3300/"
|
18
|
-
|
19
|
-
options.auth = {}
|
20
|
-
options.auth[:type] = "none"
|
21
|
-
options.auth[:user_cert] = ENV['HOME'] + "/.globus/usercred.pem"
|
22
|
-
options.auth[:ca_path] = "/etc/grid-security/certificates"
|
23
|
-
options.auth[:username] = "anonymous"
|
24
|
-
|
25
|
-
options.media_type = "application/occi+json"
|
26
|
-
|
27
|
-
opts = OptionParser.new do |opts|
|
28
|
-
opts.banner = "Usage: occi [OPTIONS]"
|
29
|
-
|
30
|
-
opts.separator ""
|
31
|
-
opts.separator "Options:"
|
32
|
-
|
33
|
-
opts.on("--endpoint URI", String, "OCCI server URI, defaults to '#{options.endpoint}'") do |endpoint|
|
34
|
-
options.endpoint = endpoint
|
35
|
-
end
|
36
|
-
|
37
|
-
opts.on("--auth METHOD", [:x509, :basic, :digest, :none], "Authentication method, defaults to '#{options.auth[:type]}'") do |auth|
|
38
|
-
options.auth[:type] = auth.to_s
|
39
|
-
end
|
40
|
-
|
41
|
-
opts.on("--username USER", String, "Username for basic or digest authentication, defaults to '#{options.auth[:username]}'") do |username|
|
42
|
-
options.auth[:username] = username
|
43
|
-
end
|
44
|
-
|
45
|
-
opts.on("--password PASSWORD", String, "Password for basic, digest or x509 authentication") do |password|
|
46
|
-
options.auth[:password] = password
|
47
|
-
options.auth[:user_cert_password] = password
|
48
|
-
end
|
49
|
-
|
50
|
-
opts.on("--ca-path PATH", String, "Path to CA certificates, defaults to '#{options.auth[:ca_path]}'") do |ca_path|
|
51
|
-
options.auth[:ca_path] = ca_path
|
52
|
-
end
|
53
|
-
|
54
|
-
opts.on("--user-cred X509_CREDENTIALS", String, "Path to user's x509 credentials, defaults to '#{options.auth[:user_cert]}'") do |user_cred|
|
55
|
-
options.auth[:user_cert] = user_cred
|
56
|
-
end
|
57
|
-
|
58
|
-
opts.on("--media-type MEDIA_TYPE", ["application/occi+json", "application/occi+xml", "text/plain"], "Media type for client <-> server communication, defaults to '#{options.media_type}'") do |media_type|
|
59
|
-
options.media_type = media_type
|
60
|
-
end
|
61
|
-
|
62
|
-
opts.on("--resource RESOURCE", String, "Resource to be queried (e.g. network, compute, storage etc.), required") do |resource|
|
63
|
-
options.resource = resource
|
64
|
-
end
|
65
|
-
|
66
|
-
opts.on("--resource-title TITLE", String, "Resource title for new resources") do |resource_title|
|
67
|
-
options.resource_title = resource_title
|
68
|
-
end
|
69
|
-
|
70
|
-
opts.on("--action ACTION", [:list, :describe, :create, :delete, :trigger], "Action to be performed on the resource, required") do |action|
|
71
|
-
options.action = action
|
72
|
-
end
|
73
|
-
|
74
|
-
opts.on("--mixin NAME", String, "Type and name of the mixin as TYPE#NAME (e.g. os_tpl#monitoring, resource_tpl#medium)") do |mixin|
|
75
|
-
parts = mixin.split("#")
|
76
|
-
|
77
|
-
raise "Unknown mixin format! Use TYPE#NAME!" unless parts.length == 2
|
78
|
-
|
79
|
-
options.mixin = {} if options.mixin.nil?
|
80
|
-
options.mixin[parts[0]] = [] if options.mixin[parts[0]].nil?
|
81
|
-
options.mixin[parts[0]] << parts[1]
|
82
|
-
end
|
83
|
-
|
84
|
-
opts.on("--trigger-action TRIGGER_ACTION", String, "Action to be triggered on the resource") do |trigger_action|
|
85
|
-
options.trigger_action = trigger_action
|
86
|
-
end
|
87
|
-
|
88
|
-
opts.on("--log-to OUTPUT", [:STDOUT, :stdout, :STDERR, :stderr], "Log to the specified device, defaults to 'STDERR'") do |log_to|
|
89
|
-
options.log[:out] = STDOUT if log_to == :stdout or log_to == :STDOUT
|
90
|
-
end
|
91
|
-
|
92
|
-
opts.on_tail("--debug", "Enable debugging messages") do |debug|
|
93
|
-
options.debug = debug
|
94
|
-
options.log[:level] = OCCI::Log::DEBUG
|
95
|
-
end
|
96
|
-
|
97
|
-
opts.on_tail("--verbose", "Be more verbose, less intrusive than debug mode") do |verbose|
|
98
|
-
options.verbose = verbose
|
99
|
-
options.log[:level] = OCCI::Log::INFO unless options.log[:level] == OCCI::Log::DEBUG
|
100
|
-
end
|
101
|
-
|
102
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
103
|
-
puts opts
|
104
|
-
exit!
|
105
|
-
end
|
106
|
-
|
107
|
-
opts.on_tail("--version", "Show version") do
|
108
|
-
puts OCCI::VERSION
|
109
|
-
exit!(true)
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
begin
|
115
|
-
opts.parse!(args)
|
116
|
-
rescue Exception => ex
|
117
|
-
puts ex.message.capitalize
|
118
|
-
puts opts
|
119
|
-
exit!
|
120
|
-
end
|
121
|
-
|
122
|
-
mandatory = []
|
123
|
-
|
124
|
-
if options.action == :trigger
|
125
|
-
mandatory << :trigger_action
|
126
|
-
end
|
127
|
-
|
128
|
-
if options.action == :create
|
129
|
-
mandatory << :mixin << :resource_title
|
130
|
-
end
|
131
|
-
|
132
|
-
mandatory.concat [:resource, :action]
|
133
|
-
|
134
|
-
options_hash = options.marshal_dump
|
135
|
-
|
136
|
-
missing = mandatory.select{ |param| options_hash[param].nil? }
|
137
|
-
if not missing.empty?
|
138
|
-
puts "Missing required arguments: #{missing.join(', ')}"
|
139
|
-
puts opts
|
140
|
-
exit!
|
141
|
-
end
|
142
|
-
|
143
|
-
options
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|