ocp 0.0.11 → 0.0.12
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.
- checksums.yaml +4 -4
- data/lib/base/Base.rb +11 -12
- data/lib/client/OcpClient.rb +26 -15
- data/lib/commander/OcpCommander.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e086507bd429a4becbf113a55ef20f09c10dce9
|
4
|
+
data.tar.gz: f98fe258a1dc02d728e7f449668f98d59b6a7938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c668293f3506370a3570ace16d148d62b3ecbf9f470c767dacbaefc45db68ac1615cd6583688347d20ac6a50a6d85d6f6eee48b9201c77896f2c76c5d54384d
|
7
|
+
data.tar.gz: 41c608f06dd635c7a9aeedf2c02930ca1ecffc258c9a12a3e638d7b2061841759a9df88ce78e262b93a257ed39ca9ba4bb16b9737a9e0d76259f0542f063b1d5
|
data/lib/base/Base.rb
CHANGED
@@ -24,12 +24,15 @@ load 'client/OcpClient.rb'
|
|
24
24
|
|
25
25
|
class Base
|
26
26
|
|
27
|
+
attr_reader :response
|
28
|
+
|
27
29
|
def initialize(version, api, path, namespace)
|
28
30
|
@client = OcpClient.instance
|
29
31
|
@api = api
|
30
32
|
@version = version
|
31
33
|
@path = path
|
32
34
|
@namespace = namespace
|
35
|
+
@response = nil
|
33
36
|
|
34
37
|
@endpoint = "/"+@api+"/"+@version
|
35
38
|
|
@@ -46,27 +49,23 @@ class Base
|
|
46
49
|
end
|
47
50
|
|
48
51
|
def list
|
49
|
-
|
50
|
-
|
51
|
-
return data
|
52
|
+
@response = @client.get(@endpoint)
|
53
|
+
return @response
|
52
54
|
end
|
53
55
|
|
54
56
|
def create(body)
|
55
|
-
|
56
|
-
|
57
|
-
return data
|
57
|
+
@response = @client.post(@endpoint,body)
|
58
|
+
return @response
|
58
59
|
end
|
59
60
|
|
60
61
|
def update(body)
|
61
|
-
|
62
|
-
|
63
|
-
return data
|
62
|
+
@response = @client.put(@endpoint,body)
|
63
|
+
return @response
|
64
64
|
end
|
65
65
|
|
66
66
|
def delete(name)
|
67
|
-
|
68
|
-
|
69
|
-
return data
|
67
|
+
@response = @client.delete(@endpoint+"/"+name)
|
68
|
+
return @response
|
70
69
|
end
|
71
70
|
|
72
71
|
private
|
data/lib/client/OcpClient.rb
CHANGED
@@ -28,6 +28,7 @@ class OcpClient
|
|
28
28
|
include Singleton
|
29
29
|
|
30
30
|
attr_reader :url
|
31
|
+
attr_reader :response
|
31
32
|
|
32
33
|
def initialize
|
33
34
|
@method = nil
|
@@ -40,6 +41,7 @@ class OcpClient
|
|
40
41
|
@clientca = nil
|
41
42
|
@clientcafile = nil
|
42
43
|
@debug = nil
|
44
|
+
@response = nil
|
43
45
|
end
|
44
46
|
|
45
47
|
def setup(ocpconfig)
|
@@ -57,18 +59,22 @@ class OcpClient
|
|
57
59
|
|
58
60
|
|
59
61
|
def get(location)
|
62
|
+
@method = :get
|
60
63
|
return call(location,nil,:get)
|
61
64
|
end
|
62
65
|
|
63
66
|
def post(location, body)
|
67
|
+
@method = :post
|
64
68
|
return call(location,body,:post)
|
65
69
|
end
|
66
70
|
|
67
71
|
def put(location, body)
|
72
|
+
@method = :put
|
68
73
|
return call(location,body,:put)
|
69
74
|
end
|
70
75
|
|
71
76
|
def delete(location)
|
77
|
+
@method = :delete
|
72
78
|
return call(location,nil,:delete)
|
73
79
|
end
|
74
80
|
|
@@ -120,20 +126,21 @@ class OcpClient
|
|
120
126
|
).execute
|
121
127
|
end
|
122
128
|
rescue => exception
|
123
|
-
|
129
|
+
if @debug and !exception.nil?
|
130
|
+
puts "Exception: " << exception.response.to_s
|
131
|
+
end
|
132
|
+
@response = exception.response
|
124
133
|
end
|
125
134
|
|
126
|
-
|
127
|
-
puts "Response Code: #{exception.response.code}"
|
128
|
-
end
|
135
|
+
@response = response
|
129
136
|
|
130
137
|
if !response.nil? and @pretty
|
131
138
|
results = JSON.pretty_generate(JSON.parse(response.to_str))
|
132
|
-
|
133
|
-
elsif !response.nil?
|
134
|
-
return response
|
139
|
+
@response = results
|
135
140
|
end
|
136
141
|
|
142
|
+
return @response
|
143
|
+
|
137
144
|
end
|
138
145
|
|
139
146
|
def callbycert(location, body=nil, method)
|
@@ -173,22 +180,26 @@ class OcpClient
|
|
173
180
|
).execute
|
174
181
|
end
|
175
182
|
rescue => exception
|
183
|
+
puts "----- EXCEPTION ----"
|
176
184
|
if @debug and !exception.nil?
|
177
185
|
puts "Exception: " << exception.response.to_s
|
178
186
|
end
|
179
|
-
|
187
|
+
@response = exception.response
|
180
188
|
end
|
181
189
|
|
190
|
+
|
191
|
+
|
192
|
+
puts "----- GOT HERE ----"
|
193
|
+
|
194
|
+
@response = response
|
195
|
+
|
182
196
|
if !response.nil? and @pretty
|
183
197
|
results = JSON.pretty_generate(JSON.parse(response.to_str))
|
184
|
-
|
185
|
-
return results
|
186
|
-
elsif !response.nil?
|
187
|
-
puts "Response -- #{response}"
|
188
|
-
return response
|
189
|
-
else
|
190
|
-
return "nil response"
|
198
|
+
@response = results
|
191
199
|
end
|
200
|
+
|
201
|
+
return @response
|
202
|
+
|
192
203
|
end
|
193
204
|
|
194
205
|
def query_params
|