kpm 0.7.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +138 -0
- data/Gemfile +2 -0
- data/README.adoc +144 -107
- data/Rakefile +2 -1
- data/bin/kpm +4 -2
- data/kpm.gemspec +11 -8
- data/lib/kpm.rb +3 -0
- data/lib/kpm/account.rb +268 -338
- data/lib/kpm/base_artifact.rb +33 -39
- data/lib/kpm/base_installer.rb +69 -83
- data/lib/kpm/blob.rb +29 -0
- data/lib/kpm/cli.rb +3 -1
- data/lib/kpm/coordinates.rb +10 -12
- data/lib/kpm/database.rb +94 -113
- data/lib/kpm/diagnostic_file.rb +126 -147
- data/lib/kpm/formatter.rb +76 -48
- data/lib/kpm/inspector.rb +24 -34
- data/lib/kpm/installer.rb +53 -46
- data/lib/kpm/kaui_artifact.rb +4 -3
- data/lib/kpm/killbill_plugin_artifact.rb +10 -7
- data/lib/kpm/killbill_server_artifact.rb +13 -12
- data/lib/kpm/migrations.rb +26 -11
- data/lib/kpm/nexus_helper/actions.rb +52 -9
- data/lib/kpm/nexus_helper/cloudsmith_api_calls.rb +83 -0
- data/lib/kpm/nexus_helper/github_api_calls.rb +70 -0
- data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +130 -108
- data/lib/kpm/nexus_helper/nexus_facade.rb +5 -3
- data/lib/kpm/plugins_directory.rb +9 -8
- data/lib/kpm/plugins_directory.yml +14 -173
- data/lib/kpm/plugins_manager.rb +29 -24
- data/lib/kpm/sha1_checker.rb +31 -18
- data/lib/kpm/system.rb +104 -135
- data/lib/kpm/system_helpers/cpu_information.rb +56 -55
- data/lib/kpm/system_helpers/disk_space_information.rb +60 -63
- data/lib/kpm/system_helpers/entropy_available.rb +37 -39
- data/lib/kpm/system_helpers/memory_information.rb +52 -51
- data/lib/kpm/system_helpers/os_information.rb +45 -47
- data/lib/kpm/system_helpers/system_proxy.rb +10 -10
- data/lib/kpm/tasks.rb +381 -438
- data/lib/kpm/tenant_config.rb +68 -83
- data/lib/kpm/tomcat_manager.rb +10 -8
- data/lib/kpm/trace_logger.rb +18 -16
- data/lib/kpm/uninstaller.rb +81 -14
- data/lib/kpm/utils.rb +13 -14
- data/lib/kpm/version.rb +3 -1
- data/packaging/Gemfile +2 -0
- data/pom.xml +211 -40
- data/spec/kpm/remote/base_artifact_spec.rb +20 -20
- data/spec/kpm/remote/base_installer_spec.rb +35 -34
- data/spec/kpm/remote/cloudsmith_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/installer_spec.rb +80 -79
- data/spec/kpm/remote/kaui_artifact_spec.rb +7 -6
- data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +25 -30
- data/spec/kpm/remote/killbill_server_artifact_spec.rb +17 -16
- data/spec/kpm/remote/migrations_spec.rb +12 -11
- data/spec/kpm/remote/nexus_facade_spec.rb +32 -28
- data/spec/kpm/remote/tenant_config_spec.rb +30 -29
- data/spec/kpm/remote/tomcat_manager_spec.rb +4 -3
- data/spec/kpm/unit/actions_spec.rb +52 -0
- data/spec/kpm/unit/base_artifact_spec.rb +19 -18
- data/spec/kpm/unit/cpu_information_spec.rb +67 -0
- data/spec/kpm/unit/disk_space_information_spec.rb +47 -0
- data/spec/kpm/unit/entropy_information_spec.rb +36 -0
- data/spec/kpm/unit/formatter_spec.rb +163 -0
- data/spec/kpm/unit/inspector_spec.rb +34 -42
- data/spec/kpm/unit/installer_spec.rb +7 -6
- data/spec/kpm/unit/memory_information_spec.rb +102 -0
- data/spec/kpm/unit/os_information_spec.rb +38 -0
- data/spec/kpm/unit/plugins_directory_spec.rb +38 -22
- data/spec/kpm/unit/plugins_manager_spec.rb +62 -66
- data/spec/kpm/unit/sha1_checker_spec.rb +107 -60
- data/spec/kpm/unit/uninstaller_spec.rb +118 -72
- data/spec/kpm/unit_mysql/account_spec.rb +127 -142
- data/spec/spec_helper.rb +20 -18
- data/tasks/package.rake +18 -18
- metadata +42 -22
@@ -1,72 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module KPM
|
2
4
|
module SystemProxy
|
3
|
-
|
4
|
-
|
5
|
-
def fetch
|
6
|
-
cpu_info = nil
|
7
|
-
if OS.windows?
|
8
|
-
cpu_info = fetch_windows
|
9
|
-
elsif OS.linux?
|
10
|
-
cpu_info = fetch_linux
|
11
|
-
elsif OS.mac?
|
12
|
-
cpu_info = fetch_mac
|
13
|
-
end
|
5
|
+
class CpuInformation
|
6
|
+
attr_reader :cpu_info, :labels
|
14
7
|
|
15
|
-
|
16
|
-
|
8
|
+
def initialize
|
9
|
+
@cpu_info = fetch
|
10
|
+
@labels = [{ label: :cpu_detail },
|
11
|
+
{ label: :value }]
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
def fetch
|
17
|
+
cpu_info = nil
|
18
|
+
if OS.windows?
|
19
|
+
cpu_info = fetch_windows
|
20
|
+
elsif OS.linux?
|
21
|
+
cpu_info = fetch_linux
|
22
|
+
elsif OS.mac?
|
23
|
+
cpu_info = fetch_mac
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
cpu_data = `cat /proc/cpuinfo 2>&1`.gsub("\t",'')
|
27
|
-
cpu = get_hash(cpu_data)
|
28
|
-
cpu
|
29
|
-
end
|
26
|
+
cpu_info
|
27
|
+
end
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
29
|
+
def fetch_linux
|
30
|
+
cpu_data = `cat /proc/cpuinfo 2>&1`.gsub("\t", '')
|
31
|
+
build_hash(cpu_data)
|
32
|
+
end
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
cpu_device_id = `wmic cpu get DeviceId`.split("\n\n")
|
42
|
-
cpu_status = `wmic cpu get Status`.split("\n\n")
|
34
|
+
def fetch_mac
|
35
|
+
cpu_data = `system_profiler SPHardwareDataType | grep -e "Processor" -e "Cores" -e "Cache" 2>&1`
|
36
|
+
build_hash(cpu_data)
|
37
|
+
end
|
43
38
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
def fetch_windows
|
40
|
+
cpu_name = `wmic cpu get Name`.split("\n\n")
|
41
|
+
cpu_caption = `wmic cpu get Caption`.split("\n\n")
|
42
|
+
cpu_max_clock_speed = `wmic cpu get MaxClockSpeed`.split("\n\n")
|
43
|
+
cpu_device_id = `wmic cpu get DeviceId`.split("\n\n")
|
44
|
+
cpu_status = `wmic cpu get Status`.split("\n\n")
|
50
45
|
|
51
|
-
|
52
|
-
|
46
|
+
cpu = {}
|
47
|
+
cpu[cpu_name[0].to_s.strip] = { cpu_detail: cpu_name[0].to_s.strip, value: cpu_name[1].to_s.strip }
|
48
|
+
cpu[cpu_caption[0].to_s.strip] = { cpu_detail: cpu_caption[0].to_s.strip, value: cpu_caption[1].to_s.strip }
|
49
|
+
cpu[cpu_max_clock_speed[0].to_s.strip] = { cpu_detail: cpu_max_clock_speed[0].to_s.strip, value: cpu_max_clock_speed[1].to_s.strip }
|
50
|
+
cpu[cpu_device_id[0].to_s.strip] = { cpu_detail: cpu_device_id[0].to_s.strip, value: cpu_device_id[1].to_s.strip }
|
51
|
+
cpu[cpu_status[0].to_s.strip] = { cpu_detail: cpu_status[0].to_s.strip, value: cpu_status[1].to_s.strip }
|
53
52
|
|
54
|
-
|
55
|
-
|
53
|
+
cpu
|
54
|
+
end
|
56
55
|
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
def build_hash(data)
|
57
|
+
cpu = {}
|
58
|
+
return cpu if data.nil?
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
60
|
+
data.split("\n").each do |info|
|
61
|
+
infos = info.split(':')
|
66
62
|
|
67
|
-
|
68
|
-
|
63
|
+
key = infos[0].to_s.strip
|
64
|
+
next if key.empty? || key.eql?('flags')
|
65
|
+
|
66
|
+
cpu[key] = { cpu_detail: key, value: infos[1].to_s.strip }
|
69
67
|
end
|
68
|
+
|
69
|
+
cpu
|
70
|
+
end
|
70
71
|
end
|
71
72
|
end
|
72
|
-
end
|
73
|
+
end
|
@@ -1,84 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module KPM
|
2
4
|
module SystemProxy
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
elsif OS.mac?
|
13
|
-
disk_space_info = fetch_linux_mac(8)
|
14
|
-
end
|
5
|
+
class DiskSpaceInformation
|
6
|
+
attr_reader :disk_space_info, :labels
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
data_keys = []
|
10
|
+
@disk_space_info = fetch(data_keys)
|
11
|
+
@labels = []
|
12
|
+
data_keys.each { |key| @labels.push(label: key.gsub(' ', '_').to_sym) }
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
end
|
15
|
+
private
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
def fetch(data_keys)
|
18
|
+
disk_space_info = nil
|
19
|
+
if OS.windows?
|
20
|
+
disk_space_info = fetch_windows(data_keys)
|
21
|
+
elsif OS.linux?
|
22
|
+
disk_space_info = fetch_linux_mac(5, data_keys)
|
23
|
+
elsif OS.mac?
|
24
|
+
disk_space_info = fetch_linux_mac(8, data_keys)
|
23
25
|
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
disk_space_info = `df 2>&1`
|
28
|
-
disk_space = get_hash(disk_space_info,cols_count,true)
|
29
|
-
disk_space
|
30
|
-
end
|
27
|
+
disk_space_info
|
28
|
+
end
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
30
|
+
def fetch_linux_mac(cols_count, data_keys)
|
31
|
+
disk_space_info = `df 2>&1`
|
32
|
+
build_hash(disk_space_info, cols_count, true, data_keys)
|
33
|
+
end
|
37
34
|
|
38
|
-
|
39
|
-
|
35
|
+
def fetch_windows(data_keys)
|
36
|
+
disk_space_info = `wmic logicaldisk get size,freespace,caption 2>&1`
|
37
|
+
build_hash(disk_space_info, 3, false, data_keys)
|
38
|
+
end
|
40
39
|
|
41
|
-
|
40
|
+
def build_hash(data, cols_count, merge_last_two_columns, data_keys)
|
41
|
+
disk_space = {}
|
42
42
|
|
43
|
-
|
43
|
+
unless data.nil?
|
44
44
|
|
45
|
-
|
45
|
+
data_table = data.split("\n")
|
46
46
|
|
47
|
-
|
48
|
-
@@data_keys[@@data_keys.length - 2] = @@data_keys[@@data_keys.length - 2] + ' ' + @@data_keys[@@data_keys.length - 1]
|
49
|
-
@@data_keys.delete_at(@@data_keys.length - 1)
|
50
|
-
end
|
47
|
+
data_keys.concat(data_table[0].split(' '))
|
51
48
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
unless cols[0].to_s.eql?(@@data_keys[0])
|
57
|
-
key = 'DiskInfo_'+row_num.to_s
|
58
|
-
disk_space[key] = Hash.new
|
59
|
-
cols.each_index do |idx|
|
60
|
-
if idx > cols_count
|
61
|
-
break
|
62
|
-
end
|
63
|
-
|
64
|
-
value = cols[idx].to_s.strip
|
65
|
-
if idx == cols_count && cols.length - 1 > idx
|
66
|
-
for i in cols_count+1..cols.length
|
67
|
-
value += ' ' + cols[i].to_s.strip
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
disk_space[key][@@data_keys[idx].gsub(' ','_').to_sym] = value
|
72
|
-
end
|
73
|
-
end
|
49
|
+
if merge_last_two_columns
|
50
|
+
data_keys[data_keys.length - 2] = data_keys[data_keys.length - 2] + ' ' + data_keys[data_keys.length - 1]
|
51
|
+
data_keys.delete_at(data_keys.length - 1)
|
52
|
+
end
|
74
53
|
|
54
|
+
row_num = 0
|
55
|
+
data_table.each do |row|
|
56
|
+
cols = row.split(' ')
|
57
|
+
row_num += 1
|
58
|
+
next if cols[0].to_s.eql?(data_keys[0])
|
59
|
+
|
60
|
+
key = 'DiskInfo_' + row_num.to_s
|
61
|
+
disk_space[key] = {}
|
62
|
+
cols.each_index do |idx|
|
63
|
+
break if idx > cols_count
|
64
|
+
|
65
|
+
value = cols[idx].to_s.strip
|
66
|
+
if idx == cols_count && cols.length - 1 > idx
|
67
|
+
(cols_count + 1..cols.length).each do |i|
|
68
|
+
value += ' ' + cols[i].to_s.strip
|
69
|
+
end
|
75
70
|
end
|
76
|
-
end
|
77
71
|
|
78
|
-
|
72
|
+
disk_space[key][data_keys[idx].gsub(' ', '_').to_sym] = value
|
73
|
+
end
|
79
74
|
end
|
75
|
+
end
|
80
76
|
|
77
|
+
disk_space
|
81
78
|
end
|
82
79
|
end
|
83
80
|
end
|
84
|
-
end
|
81
|
+
end
|
@@ -1,52 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module KPM
|
2
4
|
module SystemProxy
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
entropy_available = fetch_mac
|
14
|
-
end
|
15
|
-
|
16
|
-
entropy_available
|
17
|
-
end
|
5
|
+
class EntropyAvailable
|
6
|
+
attr_reader :entropy_available, :labels
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@entropy_available = fetch
|
10
|
+
@labels = [{ label: :entropy },
|
11
|
+
{ label: :value }]
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def fetch
|
17
|
+
entropy_available = nil
|
18
|
+
if OS.windows?
|
19
|
+
entropy_available = fetch_windows
|
20
|
+
elsif OS.linux?
|
21
|
+
entropy_available = fetch_linux
|
22
|
+
elsif OS.mac?
|
23
|
+
entropy_available = fetch_mac
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
entropy_available_data = `cat /proc/sys/kernel/random/entropy_avail 2>&1`.gsub("\n",'')
|
28
|
-
entropy_available = get_hash(entropy_available_data)
|
29
|
-
entropy_available
|
30
|
-
end
|
26
|
+
entropy_available
|
27
|
+
end
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
def fetch_linux
|
30
|
+
entropy_available_data = `cat /proc/sys/kernel/random/entropy_avail 2>&1`.gsub("\n", '')
|
31
|
+
build_hash(entropy_available_data)
|
32
|
+
end
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
34
|
+
def fetch_mac
|
35
|
+
build_hash('-')
|
36
|
+
end
|
41
37
|
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
def fetch_windows
|
39
|
+
build_hash('-')
|
40
|
+
end
|
45
41
|
|
46
|
-
|
47
|
-
|
42
|
+
def build_hash(data)
|
43
|
+
entropy_available = {}
|
44
|
+
entropy_available['entropy_available'] = { entropy: 'available', value: data }
|
48
45
|
|
46
|
+
entropy_available
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
52
|
-
end
|
50
|
+
end
|
@@ -1,71 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module KPM
|
2
4
|
module SystemProxy
|
3
|
-
|
4
|
-
|
5
|
+
class MemoryInformation
|
6
|
+
attr_reader :memory_info, :labels
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
memory_info = fetch_linux
|
12
|
-
elsif OS.mac?
|
13
|
-
memory_info = fetch_mac
|
14
|
-
end
|
8
|
+
def initialize
|
9
|
+
@memory_info = fetch
|
10
|
+
@labels = [{ label: :memory_detail },
|
11
|
+
{ label: :value }]
|
12
|
+
end
|
15
13
|
|
16
|
-
|
17
|
-
end
|
14
|
+
private
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def fetch
|
17
|
+
memory_info = nil
|
18
|
+
if OS.windows?
|
19
|
+
memory_info = fetch_windows
|
20
|
+
elsif OS.linux?
|
21
|
+
memory_info = fetch_linux
|
22
|
+
elsif OS.mac?
|
23
|
+
memory_info = fetch_mac
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
mem_data = `cat /proc/meminfo 2>&1`.gsub("\t",'')
|
28
|
-
mem = get_hash(mem_data)
|
29
|
-
mem
|
30
|
-
end
|
26
|
+
memory_info
|
27
|
+
end
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
def fetch_linux
|
30
|
+
mem_data = `cat /proc/meminfo 2>&1`.gsub("\t", '')
|
31
|
+
build_hash(mem_data)
|
32
|
+
end
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
def fetch_mac
|
35
|
+
mem_data = `vm_stat 2>&1`.gsub('.', '')
|
36
|
+
mem_total_data = `system_profiler SPHardwareDataType | grep " Memory:" 2>&1`
|
37
|
+
build_hash_mac(mem_data, mem_total_data)
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
def build_hash_mac(mem_data, mem_total_data)
|
41
|
+
mem = build_hash(mem_data)
|
43
42
|
|
44
|
-
|
43
|
+
mem.each_key do |key|
|
44
|
+
mem[key][:value] = ((mem[key][:value].to_i * 4096) / 1024 / 1024).to_s + 'MB'
|
45
|
+
mem[key][:memory_detail] = mem[key][:memory_detail].gsub('Pages', 'Memory')
|
46
|
+
end
|
45
47
|
|
46
|
-
|
47
|
-
end
|
48
|
+
mem_total = build_hash(mem_total_data)
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
mem = get_hash(mem_data)
|
52
|
-
mem
|
53
|
-
end
|
50
|
+
mem_total.merge(mem)
|
51
|
+
end
|
54
52
|
|
55
|
-
|
56
|
-
|
53
|
+
def fetch_windows
|
54
|
+
mem_data = `systeminfo | findstr /C:"Total Physical Memory" /C:"Available Physical Memory"`
|
55
|
+
build_hash(mem_data)
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
mem[infos[0].to_s.strip] = {:memory_detail => infos[0].to_s.strip, :value => infos[1].to_s.strip}
|
62
|
-
end
|
63
|
-
end
|
58
|
+
def build_hash(data)
|
59
|
+
mem = {}
|
60
|
+
return mem if data.nil?
|
64
61
|
|
65
|
-
|
66
|
-
|
62
|
+
data.split("\n").each do |info|
|
63
|
+
infos = info.split(':')
|
64
|
+
key = infos[0].to_s.strip.gsub('"', '')
|
65
|
+
mem[key] = { memory_detail: key, value: infos[1].to_s.strip }
|
66
|
+
end
|
67
67
|
|
68
|
+
mem
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
71
|
-
end
|
72
|
+
end
|