hawkular-client 2.3.0 → 2.4.0
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/CHANGES.rdoc +7 -0
- data/hawkularclient.gemspec +1 -1
- data/lib/hawkular/inventory/entities.rb +52 -23
- data/lib/hawkular/operations/operations_api.rb +24 -0
- data/lib/hawkular/version.rb +1 -1
- data/spec/integration/inventory_spec.rb +9 -0
- data/spec/integration/operations_spec.rb +3 -3
- data/spec/unit/canonical_path_spec.rb +9 -0
- data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_have_the_same_requested_metric_type_id.yml +73 -0
- data/spec/vcr_cassettes/Operation/Operation/Undeploy_should_be_performed_and_eventually_respond_with_success.json +2 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e11ac018e665d5df965d8636e2854a668fccf67a
|
4
|
+
data.tar.gz: d832ab5278b0b256885b21a87825beb4fa39191a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f24ceb12b54bb212b93a3ed512b2c27656a1aa4b21fd7d55d638ae15542e8d174ff2dcb00d2eccccc9f9a83915fec36c5f53bc712b0cf6485dd7e00e3e049377
|
7
|
+
data.tar.gz: bb8479e029d5abdc8b530f4e8f1276d978c87ebb3bec858d24f98e006ba0578021605eb035a92054818216a85a20ed89b3a3b9014e749b87e2af1b27209cbe83
|
data/CHANGES.rdoc
CHANGED
@@ -3,6 +3,13 @@
|
|
3
3
|
This document describes the relevant changes between releases of the
|
4
4
|
_hawkular-client_ project.
|
5
5
|
|
6
|
+
=== V 2.4.0
|
7
|
+
|
8
|
+
* Expose `metric.type.id` in metric definitions from Inventory, as the agent changed what it sends
|
9
|
+
* Fix the 'Undeploy' operation
|
10
|
+
|
11
|
+
Full list of items can be found at https://github.com/hawkular/hawkular-client-ruby/milestone/9?closed=1
|
12
|
+
|
6
13
|
=== V 2.3.0
|
7
14
|
|
8
15
|
* Wrap connection errors in `HawkularConnectionException` (a subclass of `HawkularException`)
|
data/hawkularclient.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.add_runtime_dependency('websocket-client-simple', '~> 0.3.0')
|
26
26
|
gem.add_runtime_dependency('addressable')
|
27
27
|
gem.add_development_dependency('shoulda')
|
28
|
-
gem.add_development_dependency('rspec-rails', '~> 3.
|
28
|
+
gem.add_development_dependency('rspec-rails', '~> 3.1')
|
29
29
|
gem.add_development_dependency('rake', '< 11')
|
30
30
|
gem.add_development_dependency('simple-websocket-vcr', '= 0.0.7')
|
31
31
|
gem.add_development_dependency('yard')
|
@@ -101,10 +101,13 @@ module Hawkular::Inventory
|
|
101
101
|
class Metric < BaseEntity
|
102
102
|
include MetricFields
|
103
103
|
|
104
|
+
attr_reader :type_id
|
105
|
+
|
104
106
|
def initialize(metric_hash)
|
105
107
|
super(metric_hash)
|
106
108
|
@type = metric_hash['type']['type']
|
107
109
|
@type_path = metric_hash['type']['path']
|
110
|
+
@type_id = metric_hash['type']['id']
|
108
111
|
@unit = metric_hash['type']['unit']
|
109
112
|
@collection_interval = metric_hash['type']['collectionInterval']
|
110
113
|
end
|
@@ -175,39 +178,39 @@ module Hawkular::Inventory
|
|
175
178
|
@metric_id = hash[:metric_id]
|
176
179
|
end
|
177
180
|
|
178
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
179
181
|
def self.parse(path)
|
180
182
|
fail 'CanonicalPath must not be nil or empty' if path.to_s.strip.length == 0
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
when 'm'
|
193
|
-
hash[:metric_id] = val
|
194
|
-
when 'r'
|
195
|
-
hash[:resource_ids] = [] if hash[:resource_ids].nil?
|
196
|
-
hash[:resource_ids].push(val)
|
197
|
-
when 'mt'
|
198
|
-
hash[:metric_type_id] = val
|
199
|
-
when 'rt'
|
200
|
-
hash[:resource_type_id] = val
|
201
|
-
end
|
183
|
+
CanonicalPath.new(path_to_h path)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Move up to the parent path of the resource. resource_ids set to empty array when there is no parent.
|
187
|
+
# @return CanonicalPath corresponding to the direct ancestor of the resource represented by this path object.
|
188
|
+
def up
|
189
|
+
hash = to_h
|
190
|
+
if hash[:resource_ids].nil?
|
191
|
+
hash[:resource_ids] = []
|
192
|
+
else
|
193
|
+
hash[:resource_ids].pop
|
202
194
|
end
|
203
195
|
CanonicalPath.new(hash)
|
204
196
|
end
|
205
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
206
197
|
|
207
198
|
def ==(other)
|
208
199
|
self.equal?(other) || other.class == self.class && other.state == state
|
209
200
|
end
|
210
201
|
|
202
|
+
def to_h
|
203
|
+
{
|
204
|
+
tenant_id: @tenant_id,
|
205
|
+
feed_id: @feed_id,
|
206
|
+
environment_id: environment_id,
|
207
|
+
resource_type_id: resource_type_id,
|
208
|
+
metric_type_id: metric_type_id,
|
209
|
+
resource_ids: resource_ids,
|
210
|
+
metric_id: @metric_id
|
211
|
+
}
|
212
|
+
end
|
213
|
+
|
211
214
|
def to_s
|
212
215
|
ret = "/t;#{@tenant_id}"
|
213
216
|
ret += "/f;#{@feed_id}" unless @feed_id.nil?
|
@@ -230,5 +233,31 @@ module Hawkular::Inventory
|
|
230
233
|
def resources_chunk
|
231
234
|
@resource_ids.map { |r| "/r;#{r}" }.join unless @resource_ids.nil?
|
232
235
|
end
|
236
|
+
|
237
|
+
def self.path_to_h(path)
|
238
|
+
tmp = path.split('/')
|
239
|
+
hash = {}
|
240
|
+
tmp.each do |pair|
|
241
|
+
(key, val) = pair.split(';')
|
242
|
+
case key
|
243
|
+
when 't'
|
244
|
+
hash[:tenant_id] = val
|
245
|
+
when 'f'
|
246
|
+
hash[:feed_id] = val
|
247
|
+
when 'e'
|
248
|
+
hash[:environment_id] = val
|
249
|
+
when 'm'
|
250
|
+
hash[:metric_id] = val
|
251
|
+
when 'r'
|
252
|
+
hash[:resource_ids] = [] if hash[:resource_ids].nil?
|
253
|
+
hash[:resource_ids].push(val)
|
254
|
+
when 'mt'
|
255
|
+
hash[:metric_type_id] = val
|
256
|
+
when 'rt'
|
257
|
+
hash[:resource_type_id] = val
|
258
|
+
end
|
259
|
+
end
|
260
|
+
hash
|
261
|
+
end
|
233
262
|
end
|
234
263
|
end
|
@@ -2,6 +2,8 @@ require 'hawkular/base_client'
|
|
2
2
|
require 'websocket-client-simple'
|
3
3
|
require 'json'
|
4
4
|
|
5
|
+
require 'hawkular/inventory/entities'
|
6
|
+
|
5
7
|
# Adding a method `perform` for each block so that we can write nice callbacks for this client
|
6
8
|
class Proc
|
7
9
|
class PerformMethodMissing
|
@@ -144,6 +146,28 @@ module Hawkular::Operations
|
|
144
146
|
invoke_operation_helper(operation_payload, 'DeployApplication', hash[:binary_content], &callback)
|
145
147
|
end
|
146
148
|
|
149
|
+
# Removes an existing deployment from WildFly
|
150
|
+
#
|
151
|
+
# @param [Hash] hash Arguments for deployment removal
|
152
|
+
# @option hash [String] :resource_path canonical path of the WildFly server from which to remove the deployment
|
153
|
+
# @option hash [String] :deployment_name name of deployment to remove
|
154
|
+
#
|
155
|
+
# @param callback [Block] callback that is run after the operation is done
|
156
|
+
def remove_deployment(hash, &callback)
|
157
|
+
required = [:resource_path, :deployment_name]
|
158
|
+
check_pre_conditions hash, required, &callback
|
159
|
+
|
160
|
+
cp = ::Hawkular::Inventory::CanonicalPath.parse hash[:resource_path]
|
161
|
+
server_path = cp.up.to_s
|
162
|
+
|
163
|
+
payload_hash = {
|
164
|
+
resource_path: server_path,
|
165
|
+
destination_file_name: hash[:deployment_name]
|
166
|
+
}
|
167
|
+
operation_payload = prepare_payload_hash([], payload_hash)
|
168
|
+
invoke_operation_helper(operation_payload, 'UndeployApplication', &callback)
|
169
|
+
end
|
170
|
+
|
147
171
|
# Adds a new datasource
|
148
172
|
#
|
149
173
|
# @param [Hash] hash Arguments for the datasource
|
data/lib/hawkular/version.rb
CHANGED
@@ -292,6 +292,15 @@ module Hawkular::Inventory::RSpec
|
|
292
292
|
expect(metrics.size).to be(14)
|
293
293
|
end
|
294
294
|
|
295
|
+
it 'Should have the same requested metric type id' do
|
296
|
+
metric_type_id = 'Server Availability~Server Availability'
|
297
|
+
type_path = CanonicalPath.new(feed_id: feed_id, metric_type_id: hawk_escape_id(metric_type_id))
|
298
|
+
metrics = @client.list_metrics_for_metric_type(type_path)
|
299
|
+
|
300
|
+
expect(metrics.size).to be > 0
|
301
|
+
expect(metrics).to all(have_attributes(type_id: metric_type_id))
|
302
|
+
end
|
303
|
+
|
295
304
|
it 'Should return config data of given resource' do
|
296
305
|
resource_path = CanonicalPath.new(feed_id: feed_id, resource_ids: [hawk_escape_id('Local~~')])
|
297
306
|
config = @client.get_config_data_for_resource(resource_path)
|
@@ -327,11 +327,11 @@ module Hawkular::Operations::RSpec
|
|
327
327
|
resource_ids: [wf_server_resource_id, alerts_war_resource_id])
|
328
328
|
|
329
329
|
undeploy = {
|
330
|
-
|
331
|
-
|
330
|
+
resource_path: path.to_s,
|
331
|
+
deployment_name: 'hawkular-alerts-actions-email.war'
|
332
332
|
}
|
333
333
|
actual_data = {}
|
334
|
-
@client.
|
334
|
+
@client.remove_deployment(undeploy) do |on|
|
335
335
|
on.success do |data|
|
336
336
|
actual_data[:data] = data
|
337
337
|
end
|
@@ -37,6 +37,15 @@ describe 'CanonicalPath' do
|
|
37
37
|
.to be == CanonicalPath.new(tenant_id: 't1', environment_id: 'e1', resource_ids: %w(r1 r2 r3))
|
38
38
|
end
|
39
39
|
|
40
|
+
it 'with resource hierarchy should be upable' do
|
41
|
+
expect(CanonicalPath.parse('/t;t1/f;f1/r;r1/r;r2/r;r3/r;r4/r;r5').up)
|
42
|
+
.to be == CanonicalPath.new(tenant_id: 't1', feed_id: 'f1', resource_ids: %w(r1 r2 r3 r4))
|
43
|
+
expect(CanonicalPath.parse('/t;t1/e;e1/r;r1').up)
|
44
|
+
.to be == CanonicalPath.new(tenant_id: 't1', environment_id: 'e1', resource_ids: [])
|
45
|
+
expect(CanonicalPath.parse('/t;t1/e;e1').up)
|
46
|
+
.to be == CanonicalPath.new(tenant_id: 't1', environment_id: 'e1', resource_ids: [])
|
47
|
+
end
|
48
|
+
|
40
49
|
it 'should be identity when calling parse and then to_s' do
|
41
50
|
path_str = '/t;t1/e;e1/r;r1/r;r2'
|
42
51
|
path1 = CanonicalPath.parse(path_str)
|
@@ -0,0 +1,73 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://jdoe:password@localhost:8080/hawkular/inventory/traversal/f;<%= feed_uuid %>/mt;Server%20Availability~Server%20Availability/rl;defines/type=m
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- identity
|
14
|
+
User-Agent:
|
15
|
+
- hawkular-client-ruby
|
16
|
+
Hawkular-Tenant:
|
17
|
+
- hawkular
|
18
|
+
Content-Type:
|
19
|
+
- application/json
|
20
|
+
Host:
|
21
|
+
- localhost:8080
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 200
|
25
|
+
message: OK
|
26
|
+
headers:
|
27
|
+
Expires:
|
28
|
+
- '0'
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache, no-store, must-revalidate
|
31
|
+
X-Powered-By:
|
32
|
+
- Undertow/1
|
33
|
+
Server:
|
34
|
+
- WildFly/10
|
35
|
+
Pragma:
|
36
|
+
- no-cache
|
37
|
+
Date:
|
38
|
+
- Thu, 28 Jul 2016 00:09:29 GMT
|
39
|
+
X-Total-Count:
|
40
|
+
- '1'
|
41
|
+
Connection:
|
42
|
+
- keep-alive
|
43
|
+
Content-Type:
|
44
|
+
- application/json
|
45
|
+
Content-Length:
|
46
|
+
- '876'
|
47
|
+
Link:
|
48
|
+
- <http://localhost:8080/hawkular/inventory/traversal/f;<%= feed_uuid %>/mt;Server%20Availability~Server%20Availability/rl;defines/type=m>;
|
49
|
+
rel="current"
|
50
|
+
body:
|
51
|
+
encoding: UTF-8
|
52
|
+
string: |-
|
53
|
+
[ {
|
54
|
+
"path" : "/t;hawkular/f;<%= feed_uuid %>/m;AI~R~%5B<%= feed_uuid %>%2FLocal~~%5D~AT~Server%20Availability~Server%20Availability",
|
55
|
+
"properties" : {
|
56
|
+
"__identityHash" : "fa194dbc2719bcccbda7a8546db986adeff870df"
|
57
|
+
},
|
58
|
+
"name" : "Server Availability~Server Availability",
|
59
|
+
"identityHash" : "fa194dbc2719bcccbda7a8546db986adeff870df",
|
60
|
+
"type" : {
|
61
|
+
"path" : "/t;hawkular/f;<%= feed_uuid %>/mt;Server%20Availability~Server%20Availability",
|
62
|
+
"name" : "Server Availability~Server Availability",
|
63
|
+
"identityHash" : "69beedc2b0c5cf2f3d0484b9c1aa9e4cdcf93",
|
64
|
+
"unit" : "NONE",
|
65
|
+
"type" : "AVAILABILITY",
|
66
|
+
"collectionInterval" : 30,
|
67
|
+
"id" : "Server Availability~Server Availability"
|
68
|
+
},
|
69
|
+
"id" : "AI~R~[<%= feed_uuid %>/Local~~]~AT~Server Availability~Server Availability"
|
70
|
+
} ]
|
71
|
+
http_version:
|
72
|
+
recorded_at: Thu, 28 Jul 2016 00:09:29 GMT
|
73
|
+
recorded_with: VCR 3.0.3
|
@@ -7,7 +7,7 @@
|
|
7
7
|
},
|
8
8
|
{
|
9
9
|
"operation": "write",
|
10
|
-
"data": "
|
10
|
+
"data": "UndeployApplicationRequest={\"resourcePath\":\"/t;hawkular/f;33f22c4a-445a-4f90-a25e-caeff9579a10/r;Local~~\",\"destinationFileName\":\"\hawkular-alerts-actions-email.war\",\"authentication\":{\"username\":\"jdoe\",\"password\":\"password\"}}"
|
11
11
|
},
|
12
12
|
{
|
13
13
|
"operation": "read",
|
@@ -17,7 +17,7 @@
|
|
17
17
|
{
|
18
18
|
"operation": "read",
|
19
19
|
"type": "text",
|
20
|
-
"data": "
|
20
|
+
"data": "UndeployApplicationResponse={\"resourcePath\":\"/t;hawkular/f;33f22c4a-445a-4f90-a25e-caeff9579a10/r;Local~~\",\"destinationFileName\":\"\hawkular-alerts-actions-email.war\",\"destinationSessionId\":\"1j9HQbWoBj9RMQZIR0BwpnU3IkxoMwQ-O9_Cr1Ds\",\"status\":\"OK\",\"message\":\"Performed [Undeploy] on a [DMR Node] given by Inventory path [/t;hawkular/f;33f22c4a-445a-4f90-a25e-caeff9579a10/r;Local~~/r;Local~%2Fdeployment%3Dhawkular-alerts-actions-email.war]\"}"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"operation": "close"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hawkular-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Libor Zoubek
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-08-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|
@@ -75,14 +75,14 @@ dependencies:
|
|
75
75
|
requirements:
|
76
76
|
- - "~>"
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: '3.
|
78
|
+
version: '3.1'
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - "~>"
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: '3.
|
85
|
+
version: '3.1'
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
87
|
name: rake
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -309,6 +309,7 @@ files:
|
|
309
309
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_create_a_resourcetype.yml
|
310
310
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_create_and_delete_feed.yml
|
311
311
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_create_and_get_a_resource.yml
|
312
|
+
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_have_the_same_requested_metric_type_id.yml
|
312
313
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_URLs.yml
|
313
314
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_WildFlys.yml
|
314
315
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_WildFlys_with_props.yml
|
@@ -545,6 +546,7 @@ test_files:
|
|
545
546
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_create_a_resourcetype.yml
|
546
547
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_create_and_delete_feed.yml
|
547
548
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_create_and_get_a_resource.yml
|
549
|
+
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_have_the_same_requested_metric_type_id.yml
|
548
550
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_URLs.yml
|
549
551
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_WildFlys.yml
|
550
552
|
- spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_list_WildFlys_with_props.yml
|