manageiq-smartstate 0.2.13 → 0.2.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ded56aab7da85194a4cfb42fd399aeef40a462a
4
- data.tar.gz: 327141ab0608d81e88f9466327ec06c886e017b2
3
+ metadata.gz: 3b2a69c35013227fbededdcfef2bed9796a0c53f
4
+ data.tar.gz: fe7ba8f2036accdce13806943d28111f242e2c7c
5
5
  SHA512:
6
- metadata.gz: 80634305627950a300e82c2a6842004d56819b1cb768012c529a80eb27f11815ad2bd416c8d60a21073f10e287f0df3c71ce45314520d77274a14214e875848d
7
- data.tar.gz: 711cd483bd832b40c95ae5e26e883a4dd366436096d2cf062c6d08a3c3ea1bd5d98849e824c2939f185df9609cfde5520b28940607c0ee586e25d2657dcb669c
6
+ metadata.gz: 16acbf991c60b44a496b5cb2c58dec958aeb58153d3b0c52d77f6bad3c2881e8406b15873a45653b24cbd38865ffa5dbfe983bd543a3f2526c9a72fb242f78e8
7
+ data.tar.gz: 32c7792c1a7d8cbe76ec19023d3be90760782de2e804aabe485c1fd5f8e6d21e8923d881316316b3485c7c843e6f04c083d5a10f779bb5001d814d3599b15e73
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module Smartstate
3
- VERSION = "0.2.13".freeze
3
+ VERSION = "0.2.14".freeze
4
4
  end
5
5
  end
@@ -117,7 +117,7 @@ module MiqLinux
117
117
  end
118
118
 
119
119
  def self.parse_systemctl_list(lines)
120
- return [] if lines.nil? || lines.empty?
120
+ return [] if lines.blank?
121
121
 
122
122
  lines.each_line.map do |line|
123
123
  line = line.chomp
@@ -141,6 +141,27 @@ module MiqLinux
141
141
  end.compact
142
142
  end
143
143
 
144
+ def self.parse_docker_ps_list(lines)
145
+ return [] if lines.blank?
146
+
147
+ lines.each_line.map do |line|
148
+ line = line.chomp
149
+ parts = line.split(/^(\S+)\s/)
150
+
151
+ name, = parts[1]
152
+
153
+ {:name => name,
154
+ :systemd_load => 'container',
155
+ :systemd_active => parts[2]&.strip&.start_with?('Up') ? 'active' : 'failed',
156
+ :systemd_sub => parts[2]&.strip&.start_with?('Up') ? 'running' : 'failed',
157
+ :typename => 'docker_container',
158
+ :description => parts[1] + ' ' + parts[2].strip,
159
+ :enable_run_level => nil,
160
+ :disable_run_level => nil,
161
+ :running => parts[2]&.strip&.start_with?('Up')}
162
+ end.compact
163
+ end
164
+
144
165
  def self.collect_interface(interfaces, interface)
145
166
  mac_addr = interface[:mac_address]
146
167
  return if mac_addr.blank?
@@ -177,21 +198,79 @@ module MiqLinux
177
198
  end
178
199
 
179
200
  def self.parse_openstack_status(lines)
180
- lines.to_s.split("\n").reject{|t| t.include? "="}.group_by{|t| t.gsub(/openstack\-([a-z]+).*/i, '\1')}.map do |title, services|
201
+ lines = lines.to_s.split("\n").reject { |t| t.include?("=") }.group_by { |t| t.gsub(/openstack\-([a-z]+).*/i, '\1') }
202
+ lines.map do |title, services|
203
+ services = services.map { |service_line| service_line.split(/[:\(\)]/).map(&:strip) } # split service line by :, ( and ) and strip white space from results
204
+
205
+ services = services.map do |service|
206
+ {
207
+ 'name' => service.first,
208
+ 'active' => service[1] == 'active',
209
+ 'enabled' => service[2] !~ /disabled/
210
+ }
211
+ end
212
+
181
213
  {
182
214
  'name' => title.capitalize,
183
- 'services' => services.map do |service_line|
184
- # split service line by :, ( and ) and strip white space from results
185
- service_line.split(/[:\(\)]/).map(&:strip)
186
- end.map do |service|
187
- {
188
- 'name' => service.first,
189
- 'active' => service[1] == 'active',
190
- 'enabled' => !(service[2] =~ /disabled/)
191
- }
192
- end
215
+ 'services' => services
216
+ }
217
+ end
218
+ end
219
+
220
+ def self.parse_openstack_container_status(lines)
221
+ containers = lines.to_s.split("\n").group_by do |t|
222
+ if t.include?('_')
223
+ t.split("_")[0]
224
+ elsif t.start_with?('openstack')
225
+ t.split("-")[1]
226
+ elsif t.include?('-')
227
+ t.split("-")[0]
228
+ else
229
+ t.split(" ")[0]
230
+ end
231
+ end
232
+
233
+ containers.map do |title, services|
234
+ services = services.map { |service_line| service_line.split(/^(\S+)\s/) } # split service line by first space and strip white space from results
235
+
236
+ services = services.map do |service|
237
+ {
238
+ 'name' => service[1],
239
+ 'active' => service[2].strip.start_with?('Up'),
240
+ 'enabled' => true
241
+ }
242
+ end
243
+
244
+ {
245
+ 'name' => title.capitalize,
246
+ 'services' => services
193
247
  }
194
248
  end
195
249
  end
250
+
251
+ def self.merge_openstack_services(systemctl_services, containerized_services)
252
+ # Merge outputs 2 arrays with systemctl and containerized services, example:
253
+ # systemctl_services = [{"name"=>"Swift", "services"=> [{"name"=>"openstack-swift-proxy", "active"=>true, "enabled"=>true}]
254
+ # containerized_services = [{"name"=>"Swift", "services"=> [{"name"=>"swift_container_auditor", "active"=>true, "enabled"=>true}]
255
+ # result is [{"name"=>"Swift", "services"=> [{"name"=>"openstack-swift-proxy", "active"=>true, "enabled"=>true},
256
+ # {"name"=>"swift_container_auditor", "active"=>true, "enabled"=>true}]
257
+
258
+ all_services = systemctl_services + containerized_services
259
+
260
+ service_names = all_services.map { |service| service['name'] }.uniq
261
+
262
+ service_names.each do |name|
263
+ merged_service = { "name" => name, "services" => [] }
264
+ common_services = all_services.select { |service| service['name'] == name }
265
+
266
+ common_services.each do |common_service|
267
+ merged_service["services"].concat(common_service["services"])
268
+ all_services.delete(common_service)
269
+ end
270
+ all_services << merged_service
271
+ end
272
+
273
+ all_services
274
+ end
196
275
  end
197
276
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-smartstate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-23 00:00:00.000000000 Z
11
+ date: 2018-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: azure-armrest
@@ -584,7 +584,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
584
584
  version: '0'
585
585
  requirements: []
586
586
  rubyforge_project:
587
- rubygems_version: 2.6.13
587
+ rubygems_version: 2.6.12
588
588
  signing_key:
589
589
  specification_version: 4
590
590
  summary: ManageIQ SmartState Analysis