smart_proxy_onboard 0.1.4 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 287137bdbaa16cc5fd0750d9b06420d41bf8880c
4
- data.tar.gz: f2094e344141a3284adfce76c203857109397530
3
+ metadata.gz: 4350c3e2df1fca4a18b9d679d3afe6fd68ef1b9c
4
+ data.tar.gz: 3724349522eee2a91e25b74191487b0649abd2e6
5
5
  SHA512:
6
- metadata.gz: a6b1f51e9127ae0106353db4e8ff39cfb30a33090376937864b896f272dc6e5d69e66aaa6988b161e521772390c1c2946f9018d760a179e8e4ba0d8dba1a9fad
7
- data.tar.gz: b44a98bf20cc0c491c775482e7f830858b8179ffca1c19bf14a863a3a3c096036530fd0f186b80c2b6737f65dfb3038eed1f99eec3775e7b0afbc42909f03c9a
6
+ metadata.gz: 38129fb2ee0ea4b87768018335e3a06155cee36b487cd970e6290712ae8111e24cf700fab83d136e3d3ef96d92a74e9a26cbe99d974a00ff80f873937812832f
7
+ data.tar.gz: 6fd55973e8cb54038a929aae626814fb0fbaac5a852a444795f38f78934814831aa4566a570d2e8b8c70f38dccfb9c5fb16ebe3283d4a303a7665430b390a0bc
data/.gitignore CHANGED
@@ -4,7 +4,8 @@
4
4
  /_yardoc/
5
5
  /coverage/
6
6
  /doc/
7
- /logs/
7
+ /logs/*
8
8
  /pkg/
9
9
  /spec/reports/
10
10
  /tmp/
11
+ *.swp
data/.rubocop.yml CHANGED
@@ -4,54 +4,30 @@ Metrics/ClassLength:
4
4
  Exclude:
5
5
  - 'test/**/*'
6
6
 
7
- # Offense count: 11
8
- Lint/AmbiguousRegexpLiteral:
9
- Enabled: false
10
-
11
- # Offense count: 14
12
- # Configuration parameters: AllowSafeAssignment.
13
- Lint/AssignmentInCondition:
14
- Enabled: false
15
-
16
- # Offense count: 3
17
- Lint/Eval:
18
- Enabled: false
19
-
20
- # Offense count: 13
21
- # Cop supports --auto-correct.
22
- Lint/RescueException:
23
- Enabled: false
24
-
25
- # Offense count: 9
26
7
  # Cop supports --auto-correct.
27
8
  Lint/StringConversionInInterpolation:
28
9
  Enabled: true
29
10
 
30
- # Offense count: 9
31
11
  # Cop supports --auto-correct.
32
12
  Lint/UnusedBlockArgument:
33
13
  Enabled: false
34
14
 
35
- # Offense count: 18
36
15
  # Cop supports --auto-correct.
37
16
  Lint/UnusedMethodArgument:
38
17
  Enabled: false
39
18
 
40
- # Offense count: 5
41
- Metrics/BlockNesting:
42
- Max: 4
43
-
44
- Style/SymbolProc:
45
- Enabled: false
19
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
20
+ # URISchemes: http, https
21
+ Metrics/LineLength:
22
+ Max: 165
46
23
 
47
- # Some logging methods need more params than usual
48
- Metrics/ParameterLists:
49
- Max: 8
24
+ # Configuration parameters: CountComments.
25
+ Metrics/MethodLength:
26
+ Max: 21
50
27
 
51
- Style/Lambda:
52
- Enabled: false
28
+ Metrics/AbcSize:
29
+ Exclude:
30
+ - 'test/**/*'
53
31
 
54
- # enable both hash-rocket and ruby19 hashmap syntax
55
- Style/HashSyntax:
32
+ Style/Documentation:
56
33
  Enabled: false
57
-
data/.rubocop_todo.yml CHANGED
@@ -1,520 +1,19 @@
1
1
  # This configuration was generated by
2
- # `rubocop --auto-gen-config --exclude-limit 0`
3
- # on 2016-02-17 11:54:01 -0800 using RuboCop version 0.37.1.
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-09-21 19:29:36 -0500 using RuboCop version 0.50.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
10
- Lint/AmbiguousOperator:
11
- Enabled: false
12
-
13
- # Offense count: 153
9
+ # Offense count: 2
14
10
  Metrics/AbcSize:
15
- Max: 106
16
-
17
- # Offense count: 14
18
- # Configuration parameters: CountComments.
19
- Metrics/ClassLength:
20
- Max: 409
21
-
22
- # Offense count: 30
23
- Metrics/CyclomaticComplexity:
24
11
  Max: 25
25
12
 
26
- # Offense count: 1019
27
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
28
- # URISchemes: http, https
29
- Metrics/LineLength:
30
- Max: 203
31
-
32
- # Offense count: 110
33
- # Configuration parameters: CountComments.
34
- Metrics/MethodLength:
35
- Max: 59
36
-
37
- # Offense count: 3
38
- # Configuration parameters: CountComments.
39
- Metrics/ModuleLength:
40
- Max: 158
41
-
42
- # Offense count: 26
43
- Metrics/PerceivedComplexity:
44
- Max: 22
45
-
46
- # Offense count: 9
47
- # Cop supports --auto-correct.
48
- Performance/StringReplacement:
49
- Enabled: false
50
-
51
- # Offense count: 3
52
- # Cop supports --auto-correct.
53
- # Configuration parameters: EnforcedStyle, SupportedStyles.
54
- # SupportedStyles: prefer_alias, prefer_alias_method
55
- Style/Alias:
56
- Enabled: false
57
-
58
- # Offense count: 1
59
- # Cop supports --auto-correct.
60
- # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
61
- # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
62
- Style/AlignHash:
63
- Enabled: false
64
-
65
- # Offense count: 104
66
- # Cop supports --auto-correct.
67
- # Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth.
68
- # SupportedStyles: case, end
69
- Style/CaseIndentation:
70
- Enabled: false
71
-
72
- # Offense count: 122
73
- # Configuration parameters: EnforcedStyle, SupportedStyles.
74
- # SupportedStyles: nested, compact
75
- Style/ClassAndModuleChildren:
76
- Enabled: false
77
-
78
- # Offense count: 9
79
- Style/ClassVars:
80
- Enabled: false
81
-
82
- # Offense count: 3
83
- # Cop supports --auto-correct.
84
- Style/ClosingParenthesisIndentation:
85
- Enabled: false
86
-
87
- # Offense count: 11
88
- # Cop supports --auto-correct.
89
- Style/ColonMethodCall:
90
- Enabled: false
91
-
92
- # Offense count: 1
93
- # Cop supports --auto-correct.
94
- # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerBackticks.
95
- # SupportedStyles: backticks, percent_x, mixed
96
- Style/CommandLiteral:
97
- Enabled: false
98
-
99
- # Offense count: 3
100
- # Cop supports --auto-correct.
101
- # Configuration parameters: Keywords.
102
- # Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
103
- Style/CommentAnnotation:
104
- Enabled: false
105
-
106
- # Offense count: 4
107
- # Cop supports --auto-correct.
108
- Style/CommentIndentation:
109
- Enabled: false
110
-
111
- # Offense count: 3
112
- # Cop supports --auto-correct.
113
- # Configuration parameters: SingleLineConditionsOnly.
114
- Style/ConditionalAssignment:
115
- Enabled: false
116
-
117
- # Offense count: 1
118
- Style/ConstantName:
119
- Enabled: false
120
-
121
- # Offense count: 6
122
- # Cop supports --auto-correct.
123
- Style/DeprecatedHashMethods:
124
- Enabled: false
125
-
126
- # Offense count: 148
127
- Style/Documentation:
128
- Enabled: false
129
-
130
- # Offense count: 15
131
- # Cop supports --auto-correct.
132
- # Configuration parameters: EnforcedStyle, SupportedStyles.
133
- # SupportedStyles: leading, trailing
134
- Style/DotPosition:
135
- Enabled: false
136
-
137
- # Offense count: 4
138
- Style/DoubleNegation:
139
- Enabled: false
140
-
141
- # Offense count: 5
142
- Style/EachWithObject:
143
- Enabled: false
144
-
145
- # Offense count: 14
146
- # Cop supports --auto-correct.
147
- # Configuration parameters: AllowAdjacentOneLineDefs.
148
- Style/EmptyLineBetweenDefs:
149
- Enabled: false
150
-
151
- # Offense count: 5
152
- # Cop supports --auto-correct.
153
- Style/EmptyLines:
154
- Enabled: false
155
-
156
- # Offense count: 9
157
- # Cop supports --auto-correct.
158
- Style/EmptyLinesAroundAccessModifier:
159
- Enabled: false
160
-
161
- # Offense count: 25
162
- # Cop supports --auto-correct.
163
- # Configuration parameters: EnforcedStyle, SupportedStyles.
164
- # SupportedStyles: empty_lines, no_empty_lines
165
- Style/EmptyLinesAroundClassBody:
166
- Enabled: false
167
-
168
- # Offense count: 4
169
- # Cop supports --auto-correct.
170
- Style/EmptyLinesAroundMethodBody:
171
- Enabled: false
172
-
173
- # Offense count: 6
174
- # Cop supports --auto-correct.
175
- # Configuration parameters: EnforcedStyle, SupportedStyles.
176
- # SupportedStyles: empty_lines, no_empty_lines
177
- Style/EmptyLinesAroundModuleBody:
178
- Enabled: false
179
-
180
- # Offense count: 4
181
- # Cop supports --auto-correct.
182
- Style/EmptyLiteral:
183
- Enabled: false
184
-
185
- # Offense count: 35
186
- # Cop supports --auto-correct.
187
- # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
188
- Style/ExtraSpacing:
189
- Enabled: false
190
-
191
- # Offense count: 4
192
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
193
- Style/FileName:
194
- Enabled: false
195
-
196
- # Offense count: 19
197
- # Cop supports --auto-correct.
198
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
199
- # SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
200
- Style/FirstParameterIndentation:
201
- Enabled: false
202
-
203
- # Offense count: 3
204
- # Configuration parameters: EnforcedStyle, SupportedStyles.
205
- # SupportedStyles: for, each
206
- Style/For:
207
- Enabled: false
208
-
209
- # Offense count: 4
210
- # Configuration parameters: EnforcedStyle, SupportedStyles.
211
- # SupportedStyles: format, sprintf, percent
212
- Style/FormatString:
213
- Enabled: false
214
-
215
- # Offense count: 13
216
- # Configuration parameters: MinBodyLength.
217
- Style/GuardClause:
218
- Enabled: false
219
-
220
- # Offense count: 9
221
- # Cop supports --auto-correct.
222
- # Configuration parameters: MaxLineLength.
223
- Style/IfUnlessModifier:
224
- Enabled: false
225
-
226
- # Offense count: 1
227
- # Cop supports --auto-correct.
228
- # Configuration parameters: SupportedStyles, IndentationWidth.
229
- # SupportedStyles: special_inside_parentheses, consistent, align_brackets
230
- Style/IndentArray:
231
- EnforcedStyle: consistent
232
-
233
- # Offense count: 24
234
- # Cop supports --auto-correct.
235
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
236
- # SupportedStyles: special_inside_parentheses, consistent, align_braces
237
- Style/IndentHash:
238
- Enabled: false
239
-
240
- # Offense count: 9
241
- # Cop supports --auto-correct.
242
- # Configuration parameters: EnforcedStyle, SupportedStyles.
243
- # SupportedStyles: normal, rails
244
- Style/IndentationConsistency:
245
- Enabled: false
246
-
247
- # Offense count: 10
248
- # Cop supports --auto-correct.
249
- # Configuration parameters: Width.
250
- Style/IndentationWidth:
251
- Enabled: false
252
-
253
- # Offense count: 15
254
- # Cop supports --auto-correct.
255
- Style/LeadingCommentSpace:
256
- Enabled: false
257
-
258
- # Offense count: 6
259
- # Cop supports --auto-correct.
260
- Style/MethodCallParentheses:
261
- Enabled: false
262
-
263
- # Offense count: 104
264
- # Cop supports --auto-correct.
265
- # Configuration parameters: EnforcedStyle, SupportedStyles.
266
- # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
267
- Style/MethodDefParentheses:
268
- Enabled: false
269
-
270
- # Offense count: 9
271
- # Configuration parameters: EnforcedStyle, SupportedStyles.
272
- # SupportedStyles: snake_case, camelCase
273
- Style/MethodName:
274
- Enabled: false
275
-
276
- # Offense count: 1
277
- Style/MultilineBlockChain:
278
- Enabled: false
279
-
280
- # Offense count: 4
281
- # Cop supports --auto-correct.
282
- Style/MultilineIfThen:
283
- Enabled: false
284
-
285
- # Offense count: 2
286
- # Cop supports --auto-correct.
287
- # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
288
- # SupportedStyles: aligned, indented
289
- Style/MultilineOperationIndentation:
290
- Enabled: false
291
-
292
- # Offense count: 9
293
- # Cop supports --auto-correct.
294
- Style/MutableConstant:
295
- Enabled: false
296
-
297
- # Offense count: 9
298
- # Cop supports --auto-correct.
299
- Style/NegatedIf:
300
- Enabled: false
301
-
302
- # Offense count: 4
303
- # Cop supports --auto-correct.
304
- # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
305
- # SupportedStyles: skip_modifier_ifs, always
306
- Style/Next:
307
- Enabled: false
308
-
309
- # Offense count: 1
310
- # Cop supports --auto-correct.
311
- Style/Not:
312
- Enabled: false
313
-
314
- # Offense count: 13
315
- # Cop supports --auto-correct.
316
- # Configuration parameters: PreferredDelimiters.
317
- Style/PercentLiteralDelimiters:
318
- Enabled: false
319
-
320
- # Offense count: 37
321
- # Cop supports --auto-correct.
322
- Style/PerlBackrefs:
323
- Enabled: false
324
-
325
13
  # Offense count: 1
326
- # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
327
- # NamePrefix: is_, has_, have_
328
- # NamePrefixBlacklist: is_, has_, have_
329
- # NameWhitelist: is_a?
330
- Style/PredicateName:
331
- Enabled: false
332
-
333
- # Offense count: 47
334
- # Configuration parameters: EnforcedStyle, SupportedStyles.
335
- # SupportedStyles: compact, exploded
336
- Style/RaiseArgs:
337
- Enabled: false
338
-
339
- # Offense count: 13
340
- # Cop supports --auto-correct.
341
- # Configuration parameters: AllowMultipleReturnValues.
342
- Style/RedundantReturn:
343
- Enabled: false
344
-
345
- # Offense count: 9
346
- # Cop supports --auto-correct.
347
- Style/RedundantSelf:
348
- Enabled: false
349
-
350
- # Offense count: 7
351
- # Cop supports --auto-correct.
352
- # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
353
- # SupportedStyles: slashes, percent_r, mixed
354
- Style/RegexpLiteral:
355
- Enabled: false
356
-
357
- # Offense count: 2
358
- # Cop supports --auto-correct.
359
- Style/RescueEnsureAlignment:
360
- Enabled: false
361
-
362
- # Offense count: 16
363
- # Cop supports --auto-correct.
364
- Style/RescueModifier:
365
- Enabled: false
366
-
367
- # Offense count: 2
368
- # Cop supports --auto-correct.
369
- Style/SelfAssignment:
370
- Enabled: false
371
-
372
- # Offense count: 20
373
- # Cop supports --auto-correct.
374
- # Configuration parameters: AllowAsExpressionSeparator.
375
- Style/Semicolon:
376
- Enabled: false
377
-
378
- # Offense count: 4
379
- # Cop supports --auto-correct.
380
- # Configuration parameters: EnforcedStyle, SupportedStyles.
381
- # SupportedStyles: only_raise, only_fail, semantic
382
- Style/SignalException:
383
- Enabled: false
384
-
385
- # Offense count: 6
386
- # Configuration parameters: Methods.
387
- # Methods: {"reduce"=>["a", "e"]}, {"inject"=>["a", "e"]}
388
- Style/SingleLineBlockParams:
389
- Enabled: false
390
-
391
- # Offense count: 2
392
- # Cop supports --auto-correct.
393
- # Configuration parameters: AllowIfMethodIsEmpty.
394
- Style/SingleLineMethods:
395
- Enabled: false
396
-
397
- # Offense count: 114
398
- # Cop supports --auto-correct.
399
- Style/SpaceAfterComma:
400
- Enabled: false
401
-
402
- # Offense count: 2
403
- # Cop supports --auto-correct.
404
- # Configuration parameters: EnforcedStyleInsidePipes, SupportedStyles.
405
- # SupportedStyles: space, no_space
406
- Style/SpaceAroundBlockParameters:
407
- Enabled: false
408
-
409
- # Offense count: 38
410
- # Cop supports --auto-correct.
411
- # Configuration parameters: EnforcedStyle, SupportedStyles.
412
- # SupportedStyles: space, no_space
413
- Style/SpaceAroundEqualsInParameterDefault:
414
- Enabled: false
415
-
416
- # Offense count: 134
417
- # Cop supports --auto-correct.
418
- # Configuration parameters: AllowForAlignment.
419
- Style/SpaceAroundOperators:
420
- Enabled: false
421
-
422
- # Offense count: 21
423
- # Cop supports --auto-correct.
424
- # Configuration parameters: EnforcedStyle, SupportedStyles.
425
- # SupportedStyles: space, no_space
426
- Style/SpaceBeforeBlockBraces:
427
- Enabled: false
428
-
429
- # Offense count: 90
430
- # Cop supports --auto-correct.
431
- # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
432
- # SupportedStyles: space, no_space
433
- Style/SpaceInsideBlockBraces:
434
- Enabled: false
435
-
436
- # Offense count: 20
437
- # Cop supports --auto-correct.
438
- Style/SpaceInsideBrackets:
439
- Enabled: false
440
-
441
- # Offense count: 145
442
- # Cop supports --auto-correct.
443
- # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
444
- # SupportedStyles: space, no_space
445
- Style/SpaceInsideHashLiteralBraces:
446
- Enabled: false
447
-
448
- # Offense count: 2
449
- # Cop supports --auto-correct.
450
- Style/SpaceInsideParens:
451
- Enabled: false
452
-
453
- # Offense count: 14
454
- # Cop supports --auto-correct.
455
- # Configuration parameters: EnforcedStyle, SupportedStyles.
456
- # SupportedStyles: use_perl_names, use_english_names
457
- Style/SpecialGlobalVars:
458
- Enabled: false
459
-
460
- # Offense count: 1896
461
- # Cop supports --auto-correct.
462
- # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
463
- # SupportedStyles: single_quotes, double_quotes
464
- Style/StringLiterals:
465
- Enabled: false
466
-
467
- # Offense count: 7
468
- # Cop supports --auto-correct.
469
- # Configuration parameters: EnforcedStyle, SupportedStyles.
470
- # SupportedStyles: single_quotes, double_quotes
471
- Style/StringLiteralsInInterpolation:
472
- Enabled: false
473
-
474
- # Offense count: 19
475
- # Cop supports --auto-correct.
476
- # Configuration parameters: EnforcedStyle, SupportedStyles.
477
- # SupportedStyles: final_newline, final_blank_line
478
- Style/TrailingBlankLines:
479
- Enabled: false
480
-
481
- # Offense count: 9
482
- # Cop supports --auto-correct.
483
- # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
484
- # SupportedStyles: comma, consistent_comma, no_comma
485
- Style/TrailingCommaInLiteral:
486
- Enabled: false
487
-
488
- # Offense count: 3
489
- # Cop supports --auto-correct.
490
- # Configuration parameters: AllowNamedUnderscoreVariables.
491
- Style/TrailingUnderscoreVariable:
492
- Enabled: false
493
-
494
- # Offense count: 10
495
- # Cop supports --auto-correct.
496
- Style/TrailingWhitespace:
497
- Enabled: false
14
+ Metrics/CyclomaticComplexity:
15
+ Max: 8
498
16
 
499
17
  # Offense count: 1
500
- # Cop supports --auto-correct.
501
- # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
502
- # Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
503
- Style/TrivialAccessors:
504
- Enabled: false
505
-
506
- # Offense count: 4
507
- Style/UnlessElse:
508
- Enabled: false
509
-
510
- # Offense count: 9
511
- # Cop supports --auto-correct.
512
- Style/UnneededPercentQ:
513
- Enabled: false
514
-
515
- # Offense count: 28
516
- # Cop supports --auto-correct.
517
- # Configuration parameters: EnforcedStyle, SupportedStyles, MinSize, WordRegex.
518
- # SupportedStyles: percent, brackets
519
- Style/WordArray:
520
- Enabled: false
18
+ Metrics/PerceivedComplexity:
19
+ Max: 10
data/Gemfile CHANGED
@@ -6,5 +6,10 @@ gemspec
6
6
  group :development do
7
7
  gem 'smart_proxy',
8
8
  git: 'https://github.com/theforeman/smart-proxy.git',
9
- branch: '1.15-stable'
9
+ branch: 'develop'
10
+ end
11
+
12
+ group :test do
13
+ gem 'rubocop', require: false
14
+ gem 'simplecov', require: false
10
15
  end
data/README.md CHANGED
@@ -33,7 +33,8 @@ This plugin is made for the following combination of software:
33
33
 
34
34
  ### Currently Implemented
35
35
 
36
- - IPMI IP range scanner
36
+ - Scan IP ranges for IPMI appliances
37
+ - Clear FreeIPMI sensor data repository (SDR) cache
37
38
 
38
39
  ### Planned
39
40
 
@@ -103,3 +104,42 @@ Sample output for `/onboard/bmc/scan/cidr/10.246.0.65/29`:
103
104
  "10.246.0.71"
104
105
  ]
105
106
  }
107
+
108
+ ### `DELETE /onboard/bmc/sdr_cache`
109
+
110
+ (_FreeIPMI only_) Deletes the sensor data repository (SDR) cache from the Smart Proxy. This is useful when you run something like `GET /bmc/10.246.0.69/fru/list` with `bmc_provider=freeipmi` and you get a reply like this:
111
+
112
+ {
113
+ "action": "list",
114
+ "result": {
115
+ "": {
116
+ "sdr_cache_'/tmp/.freeipmi-foreman-proxy/.freeipmi/sdr-cache/sdr-cache-smartproxyhostname.10.246.0.69'_invalid": "Please flush the cache and regenerate it"
117
+ }
118
+ }
119
+ }
120
+
121
+ Instead of manually logging in to the Smart Proxy and deleting `/tmp/.freeipmi-foreman-proxy/.freeipmi/sdr-cache`, just run this method, and you'll get this reply:
122
+
123
+ {
124
+ "result": true,
125
+ "message": "SDR cache deleted"
126
+ }
127
+
128
+ If there's no SDR cache present, you'll see:
129
+
130
+ {
131
+ "result": true,
132
+ "message": "No SDR cache to delete"
133
+ }
134
+
135
+ If the deletion failed, you'll see something like this:
136
+
137
+ {
138
+ "errors": [
139
+ "Permission denied @ dir_s_rmdir - /tmp/.freeipmi-foreman-proxy/.freeipmi/sdr-cache"
140
+ ],
141
+ "result": false,
142
+ "message": "Failed to delete one or more SDR cache location candidates"
143
+ }
144
+
145
+ As long as `{"result":true}`, you will not encounter the `sdr_cache_…_invalid` error next time.
@@ -6,7 +6,7 @@ module Proxy
6
6
  module BMC
7
7
  # This is the interface for scanning BMC IP address ranges.
8
8
  class BaseScanner
9
- def initialize(args = { })
9
+ def initialize(args = {})
10
10
  if args.key? :address_first
11
11
  address_first = IPAddr.new args[:address_first]
12
12
  address_last = IPAddr.new args[:address_last]
@@ -18,34 +18,34 @@ module Proxy
18
18
  end
19
19
  # Disallow range too large
20
20
  scanner_max_range_size = max_range_size
21
- if @range.first(scanner_max_range_size+1).size > scanner_max_range_size
21
+ if @range.first(scanner_max_range_size + 1).size > scanner_max_range_size
22
22
  @range = nil
23
23
  @invalid_reason = "Range too large. Batch supports only #{scanner_max_range_size} IP addresses at a time."
24
24
  end
25
- rescue
25
+ rescue StandardError
26
26
  @range = nil
27
- if args.is_a?(Hash) && args.key?(:address)
28
- @invalid_reason = "Invalid CIDR provided"
29
- else
30
- @invalid_reason = "Invalid IP address provided"
31
- end
27
+ @invalid_reason = if args.is_a?(Hash) && args.key?(:address)
28
+ 'Invalid CIDR provided'
29
+ else
30
+ 'Invalid IP address provided'
31
+ end
32
32
  end
33
-
33
+
34
34
  def valid?
35
35
  @range.is_a? Range
36
36
  end
37
-
37
+
38
38
  def error_string
39
39
  @invalid_reason
40
40
  end
41
-
41
+
42
42
  def max_range_size
43
43
  Proxy::Onboard::Plugin.settings.bmc_scanner_max_range_size || 65_536
44
44
  end
45
-
45
+
46
46
  # Run the scanner and return results as array
47
47
  def scan_to_list
48
- raise NotImplementedError.new
48
+ raise NotImplementedError
49
49
  end
50
50
  end
51
51
  end
@@ -7,13 +7,13 @@ module Proxy
7
7
  class IPMIScanner < BaseScanner
8
8
  include Proxy::Log
9
9
  include Proxy::Util
10
-
10
+
11
11
  # This is an IPMI ping, not an ICMP ping.
12
12
  def address_pings?(address)
13
13
  begin
14
14
  socket = UDPSocket.new
15
15
  rescue Errno::EMFILE
16
- logger.warn "IPMIScanner: Ran out of free file descriptors while creating UDPSocket! Consider increasing file open limit."
16
+ logger.warn 'IPMIScanner: Ran out of free file descriptors while creating UDPSocket! Consider increasing file open limit.'
17
17
  retry
18
18
  end
19
19
  socket.connect(address.to_s, 623)
@@ -22,59 +22,52 @@ module Proxy
22
22
  socket.close
23
23
  !selections.nil?
24
24
  end
25
-
25
+
26
26
  # Not used because of slowness
27
27
  def scan_unthreaded_to_list
28
- return false if !valid?
29
- pinged = Array.new
28
+ return false unless valid?
29
+ pinged = []
30
30
  @range.each do |address|
31
- if address_pings?(address)
32
- pinged << address
33
- end
31
+ pinged << address if address_pings?(address)
34
32
  end
35
33
  pinged
36
34
  end
37
-
35
+
38
36
  # Determine maximum number of threads
39
37
  def calculate_max_threads
40
38
  max_threads = Proxy::Onboard::Plugin.settings.bmc_scanner_max_threads_per_request || 500
41
39
  begin
42
- sockets = Array.new
40
+ sockets = []
43
41
  # @range.first(max_threads).size performs much better than @range.count if @range is large.
44
42
  (1..[max_threads, @range.first(max_threads).size].min).each do
45
- socket = UDPSocket.new
46
- sockets << socket
43
+ sockets << UDPSocket.new
47
44
  end
48
45
  rescue Errno::EMFILE
49
46
  # Running low on free file descriptors; only allow use of half of the remaining
50
47
  max_threads = [sockets.length / 2, 1].max
51
48
  # Clean up sockets
52
- sockets.each do |sock|
53
- sock.close
54
- end
49
+ sockets.each(&:close)
55
50
  logger.warn "IPMIScanner: Running low on free file descriptors! Can only allocate #{sockets.length}, so using #{max_threads} to avoid hitting the limit."
56
51
  end
57
52
  max_threads
58
53
  end
59
-
54
+
60
55
  def scan_threaded_to_list
61
- return false if !valid?
62
- pinged = Array.new
56
+ return false unless valid?
57
+ pinged = []
63
58
  pool = Concurrent::ThreadPoolExecutor.new(max_threads: calculate_max_threads)
64
59
  @range.each do |address|
65
60
  pool.post do
66
- if address_pings?(address)
67
- pinged << address
68
- end
61
+ pinged << address if address_pings?(address)
69
62
  end
70
63
  end
71
64
  pool.shutdown
72
65
  pool.wait_for_termination
73
66
  pinged
74
67
  end
75
-
68
+
76
69
  def scan_to_list
77
- return false if !valid?
70
+ return false unless valid?
78
71
  scan_threaded_to_list
79
72
  end
80
73
  end
@@ -0,0 +1,68 @@
1
+ require 'smart_proxy_onboard'
2
+ require 'fileutils'
3
+
4
+ module Proxy
5
+ module Onboard
6
+ module BMC
7
+ class SDRCache
8
+ include Proxy::Log
9
+ include Proxy::Util
10
+
11
+ # Determined from
12
+ # https://git.savannah.gnu.org/cgit/freeipmi.git/tree/common/toolcommon/tool-sdr-cache-common.c?h=Release-1_4_11
13
+ def possible_paths
14
+ paths = []
15
+ sdr_cache_directory = sdr_cache_directory_from_freeipmi_conf
16
+ paths << sdr_cache_directory unless sdr_cache_directory.nil?
17
+ etc = Etc.getpwuid(Process.uid)
18
+ paths + [
19
+ "#{etc.dir}/.freeipmi/sdr-cache",
20
+ "/tmp/.freeipmi-#{etc.name}/.freeipmi/sdr-cache"
21
+ ]
22
+ end
23
+
24
+ def existing_possible_paths
25
+ paths = []
26
+ possible_paths.each do |path|
27
+ paths << path if File.exist?(path)
28
+ end
29
+ paths
30
+ end
31
+
32
+ def present?
33
+ !existing_possible_paths.empty?
34
+ end
35
+
36
+ def delete
37
+ errors = []
38
+ existing_possible_paths.each do |path|
39
+ begin
40
+ FileUtils.remove_entry_secure(path)
41
+ rescue Errno::ENOENT
42
+ next
43
+ rescue SystemCallError => e
44
+ errors << e
45
+ next
46
+ end
47
+ end
48
+ return { errors: errors } unless errors.empty?
49
+ true
50
+ end
51
+
52
+ private
53
+
54
+ def sdr_cache_directory_from_freeipmi_conf
55
+ freeipmi_conf_handle = File.open('/etc/freeipmi/freeipmi.conf', 'r')
56
+ match = %r{^[[:blank:]]*sdr-cache-directory[[:blank:]]+\/}
57
+ freeipmi_conf_handle.grep(match).last.gsub(match, '/').gsub(/\n$/, '')
58
+ rescue SystemCallError
59
+ logger.debug 'Cannot determine sdr-cache-directory from FreeIPMI configuration file'
60
+ nil
61
+ rescue NoMethodError
62
+ logger.debug 'FreeIPMI configuration file does not contain sdr-cache-directory'
63
+ nil
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -1,50 +1,63 @@
1
1
  require 'smart_proxy'
2
2
  require 'bmc/ipmiscanner'
3
+ require 'bmc/sdr_cache'
3
4
 
4
- module Proxy::Onboard
5
- class ApiBmc < Sinatra::Base
6
- helpers ::Proxy::Helpers
7
-
8
- # Scan IP range for BMC hosts
9
- # Returns a list of available scanning options
10
- get "/scan" do
11
- { :available_resources => %w[range cidr] }.to_json
12
- end
5
+ module Proxy
6
+ module Onboard
7
+ class ApiBmc < Sinatra::Base
8
+ helpers ::Proxy::Helpers
13
9
 
14
- # Returns a helpful message that the user should supply a beginning IP and ending IP
15
- get "/scan/range" do
16
- { :message => "You need to supply a range with /onboard/bmc/scan/range/:address_first/:address_last"}.to_json
17
- end
10
+ # Scan IP range for BMC hosts
11
+ # Returns a list of available scanning options
12
+ get '/scan' do
13
+ { available_resources: %w[range cidr] }.to_json
14
+ end
18
15
 
19
- # Returns a helpful message that the user should supply a CIDR
20
- get "/scan/cidr" do
21
- { :message => "You need to supply a CIDR with /onboard/bmc/scan/cidr/:address/:netmask (e.g. \"192.168.1.1/24\" or \"192.168.1.1/255.255.255.0\")"}.to_json
22
- end
16
+ # Returns a helpful message that the user should supply a beginning IP and ending IP
17
+ get '/scan/range' do
18
+ { message: 'You need to supply a range with /onboard/bmc/scan/range/:address_first/:address_last' }.to_json
19
+ end
23
20
 
24
- ["/scan/range/:address_first/?:address_last?",
25
- "/scan/cidr/:address/?:netmask?"].each do |path|
26
- get path do
27
- scanner_setup
28
- if !@scanner.valid?
29
- { :error => @scanner.error_string}.to_json
30
- else
31
- { :result => @scanner.scan_to_list}.to_json
21
+ # Returns a helpful message that the user should supply a CIDR
22
+ get '/scan/cidr' do
23
+ { message: 'You need to supply a CIDR with /onboard/bmc/scan/cidr/:address/:netmask (e.g. "192.168.1.1/24" or "192.168.1.1/255.255.255.0")' }.to_json
24
+ end
25
+
26
+ ['/scan/range/:address_first/?:address_last?',
27
+ '/scan/cidr/:address/?:netmask?'].each do |path|
28
+ get path do
29
+ scanner_setup
30
+ if !@scanner.valid?
31
+ { error: @scanner.error_string }.to_json
32
+ else
33
+ { result: @scanner.scan_to_list }.to_json
34
+ end
32
35
  end
33
36
  end
34
- end
35
37
 
36
- def scanner_setup
37
- args = {}
38
- # /scan/cidr/:address/:netmask
39
- if params.key? "address"
40
- args = { :address => params[:address],
41
- :netmask => params[:netmask] }
42
- # /scan/range/:address_first/:address_last
43
- elsif params.key? "address_first"
44
- args = { :address_first => params[:address_first],
45
- :address_last => params[:address_last] }
38
+ def scanner_setup
39
+ args = {}
40
+ # /scan/cidr/:address/:netmask
41
+ if params.key? 'address'
42
+ args = { address: params[:address],
43
+ netmask: params[:netmask] }
44
+ # /scan/range/:address_first/:address_last
45
+ elsif params.key? 'address_first'
46
+ args = { address_first: params[:address_first],
47
+ address_last: params[:address_last] }
48
+ end
49
+ @scanner = Proxy::Onboard::BMC::IPMIScanner.new(args)
50
+ end
51
+
52
+ # Clear the SDR cache
53
+ delete '/sdr_cache' do
54
+ sdr_cache = Proxy::Onboard::BMC::SDRCache.new
55
+ return { result: true, message: 'No SDR cache to delete' }.to_json unless sdr_cache.present?
56
+ result = sdr_cache.delete
57
+ return result.merge(result: false, message: 'Failed to delete one or more SDR cache location candidates').to_json if result.is_a? Hash
58
+ return { result: true, message: 'SDR cache deleted' }.to_json if result == true
59
+ return { result: false, message: 'Unexpected response from delete function' }.to_json
46
60
  end
47
- @scanner = Proxy::Onboard::BMC::IPMIScanner.new(args)
48
61
  end
49
62
  end
50
63
  end
@@ -1,13 +1,15 @@
1
- module Proxy::Onboard
2
- # Plugin definition
3
- class Plugin < ::Proxy::Plugin
4
- plugin :onboard, Proxy::Onboard::VERSION
5
- default_settings bmc_scanner_max_range_size: 65_536,
6
- bmc_scanner_max_threads_per_request: 500,
7
- bmc_scanner_socket_timeout_seconds: 1
1
+ module Proxy
2
+ module Onboard
3
+ # Plugin definition
4
+ class Plugin < ::Proxy::Plugin
5
+ plugin :onboard, Proxy::Onboard::VERSION
6
+ default_settings bmc_scanner_max_range_size: 65_536,
7
+ bmc_scanner_max_threads_per_request: 500,
8
+ bmc_scanner_socket_timeout_seconds: 1
8
9
 
9
- http_rackup_path File.expand_path('http_config.ru', File.expand_path('../', __FILE__))
10
- https_rackup_path File.expand_path('http_config.ru', File.expand_path('../', __FILE__))
11
- default_settings node_scheme: 'https', node_port: 8443
10
+ http_rackup_path File.expand_path('http_config.ru', File.expand_path('../', __FILE__))
11
+ https_rackup_path File.expand_path('http_config.ru', File.expand_path('../', __FILE__))
12
+ default_settings node_scheme: 'https', node_port: 8443
13
+ end
12
14
  end
13
15
  end
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module Onboard
3
- VERSION = '0.1.4'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'smart_proxy_onboard/version'
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Nick Liu']
10
10
  spec.email = ['deltik@gmx.com']
11
11
 
12
- spec.summary = %q{Support functions for onboarding new servers into Foreman}
13
- spec.description = %q{This plugin exposes API calls that can be used to onboard new hosts in bulk into Foreman through PXE boot and the foreman_discovery image.}
12
+ spec.summary = 'Support functions for onboarding new servers into Foreman'
13
+ spec.description = 'This plugin exposes API calls that can be used to onboard new hosts in bulk into Foreman through PXE boot and the foreman_discovery image.'
14
14
  spec.homepage = 'https://github.com/theforeman/smart_proxy_onboard'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.bindir = 'exe'
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
- spec.license = 'GPLv3'
22
+ spec.license = 'GPL-3.0'
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.14'
25
25
  spec.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_onboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Liu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-28 00:00:00.000000000 Z
11
+ date: 2017-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,6 +142,7 @@ files:
142
142
  - bin/setup
143
143
  - lib/bmc/basescanner.rb
144
144
  - lib/bmc/ipmiscanner.rb
145
+ - lib/bmc/sdr_cache.rb
145
146
  - lib/smart_proxy_onboard.rb
146
147
  - lib/smart_proxy_onboard/api_bmc.rb
147
148
  - lib/smart_proxy_onboard/http_config.ru
@@ -151,7 +152,7 @@ files:
151
152
  - smart_proxy_onboard.gemspec
152
153
  homepage: https://github.com/theforeman/smart_proxy_onboard
153
154
  licenses:
154
- - GPLv3
155
+ - GPL-3.0
155
156
  metadata: {}
156
157
  post_install_message:
157
158
  rdoc_options: []
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  version: '0'
170
171
  requirements: []
171
172
  rubyforge_project:
172
- rubygems_version: 2.6.12
173
+ rubygems_version: 2.5.1
173
174
  signing_key:
174
175
  specification_version: 4
175
176
  summary: Support functions for onboarding new servers into Foreman