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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a352576f4ca8c0a33d39d52c2f2af18a3ab22753
4
- data.tar.gz: 2aaa783a048058dddbe7a95e80548652e95b4032
3
+ metadata.gz: 4e086507bd429a4becbf113a55ef20f09c10dce9
4
+ data.tar.gz: f98fe258a1dc02d728e7f449668f98d59b6a7938
5
5
  SHA512:
6
- metadata.gz: 8b8eb5cdbd734b43d5d266adfaf703ade6be48111605bd1213642d3b800b589addc59371ba90380434dd6c805a843f1e5ebc6444b4be4eb25b16ba1c99063ea5
7
- data.tar.gz: 2554b6533e8ce076ce666bcf348b48d419dbd210601feb79f1e90429da11cd786e4c3e15fbcc82911512422c9915cfd76c41ed89889d1f6ad548167d293787ba
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
- data = nil
50
- data = @client.get(@endpoint)
51
- return data
52
+ @response = @client.get(@endpoint)
53
+ return @response
52
54
  end
53
55
 
54
56
  def create(body)
55
- data = nil
56
- data = @client.post(@endpoint,body)
57
- return data
57
+ @response = @client.post(@endpoint,body)
58
+ return @response
58
59
  end
59
60
 
60
61
  def update(body)
61
- data = nil
62
- data = @client.put(@endpoint,body)
63
- return data
62
+ @response = @client.put(@endpoint,body)
63
+ return @response
64
64
  end
65
65
 
66
66
  def delete(name)
67
- data = nil
68
- data = @client.delete(@endpoint+"/"+name)
69
- return data
67
+ @response = @client.delete(@endpoint+"/"+name)
68
+ return @response
70
69
  end
71
70
 
72
71
  private
@@ -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
- puts "Exception: " << exception.response
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
- if @debug and !exception.nil?
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
- return results
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
- return exception.response
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
- puts "Results -- #{results}"
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
@@ -49,7 +49,9 @@ class OcpCommander
49
49
  end
50
50
  ocpapi = OcpApi.new
51
51
  ocpapi.setup(ocpconfig)
52
- puts "#{ocpapi}"
52
+ puts "---- GOT HERE COMMANDER ----"
53
+ ocpapi.list
54
+ puts "#{ocpapi.response}"
53
55
  end
54
56
  end
55
57
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Evensen