kanrisuru 0.14.0 → 0.16.2
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/CHANGELOG.md +27 -0
- data/README.md +5 -5
- data/kanrisuru.gemspec +7 -3
- data/lib/kanrisuru/command.rb +16 -3
- data/lib/kanrisuru/core/apt/parsers/base.rb +1 -1
- data/lib/kanrisuru/core/disk/commands/lsblk.rb +6 -11
- data/lib/kanrisuru/core/disk/constants.rb +9 -0
- data/lib/kanrisuru/core/disk/parser.rb +1 -0
- data/lib/kanrisuru/core/disk/parsers/lsblk_version.rb +21 -0
- data/lib/kanrisuru/core/disk.rb +1 -0
- data/lib/kanrisuru/core/dmi/commands/dmi.rb +1 -1
- data/lib/kanrisuru/core/file/commands/chmod.rb +1 -1
- data/lib/kanrisuru/core/file/commands/copy.rb +1 -3
- data/lib/kanrisuru/core/file/commands/mkdir.rb +11 -6
- data/lib/kanrisuru/core/file/commands/rm.rb +4 -1
- data/lib/kanrisuru/core/file/commands/touch.rb +2 -1
- data/lib/kanrisuru/core/ip/commands/address.rb +64 -47
- data/lib/kanrisuru/core/ip/commands/address_label.rb +32 -16
- data/lib/kanrisuru/core/ip/commands/link.rb +96 -54
- data/lib/kanrisuru/core/ip/commands/link_set_opts.rb +61 -0
- data/lib/kanrisuru/core/ip/commands/link_type_opts.rb +313 -0
- data/lib/kanrisuru/core/ip/commands/maddress.rb +22 -13
- data/lib/kanrisuru/core/ip/commands/neighbour.rb +49 -32
- data/lib/kanrisuru/core/ip/commands/route.rb +130 -93
- data/lib/kanrisuru/core/ip/commands/rule.rb +37 -22
- data/lib/kanrisuru/core/ip/commands.rb +5 -3
- data/lib/kanrisuru/core/ip/constants.rb +12 -0
- data/lib/kanrisuru/core/ip/parser.rb +1 -0
- data/lib/kanrisuru/core/ip/parsers/version.rb +15 -0
- data/lib/kanrisuru/core/ip.rb +10 -7
- data/lib/kanrisuru/core/system/commands/kill.rb +1 -1
- data/lib/kanrisuru/core/user/commands/create_user.rb +9 -17
- data/lib/kanrisuru/core/user/commands/delete_user.rb +1 -1
- data/lib/kanrisuru/core/user/commands/update_user.rb +14 -23
- data/lib/kanrisuru/core/zypper/commands/add_repo.rb +1 -8
- data/lib/kanrisuru/core/zypper/commands/add_service.rb +4 -2
- data/lib/kanrisuru/core/zypper/commands/info.rb +1 -2
- data/lib/kanrisuru/core/zypper/commands/install.rb +2 -3
- data/lib/kanrisuru/core/zypper/commands/modify_repo.rb +1 -7
- data/lib/kanrisuru/core/zypper/commands/modify_service.rb +3 -1
- data/lib/kanrisuru/core/zypper/commands/remove.rb +1 -2
- data/lib/kanrisuru/core/zypper/commands/remove_repo.rb +3 -3
- data/lib/kanrisuru/core/zypper/commands/remove_service.rb +6 -1
- data/lib/kanrisuru/core/zypper/commands/search.rb +1 -3
- data/lib/kanrisuru/core/zypper/commands/source_install.rb +2 -0
- data/lib/kanrisuru/core/zypper/commands.rb +10 -1
- data/lib/kanrisuru/os_package.rb +2 -0
- data/lib/kanrisuru/remote/host.rb +1 -3
- data/lib/kanrisuru/result.rb +15 -0
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/archive_spec.rb +1 -1
- data/spec/functional/core/disk_spec.rb +77 -0
- data/spec/functional/core/dmi_spec.rb +78 -0
- data/spec/functional/core/file_spec.rb +284 -0
- data/spec/functional/core/group_spec.rb +62 -0
- data/spec/functional/core/ip_address_label_spec.rb +81 -0
- data/spec/functional/core/ip_address_spec.rb +95 -0
- data/spec/functional/core/ip_link_spec.rb +814 -0
- data/spec/functional/core/ip_maddress_spec.rb +78 -0
- data/spec/functional/core/ip_neighbour_spec.rb +119 -0
- data/spec/functional/core/ip_route_spec.rb +174 -0
- data/spec/functional/core/ip_rule_spec.rb +75 -0
- data/spec/functional/core/ip_spec.rb +27 -0
- data/spec/functional/core/system_spec.rb +135 -0
- data/spec/functional/core/user_spec.rb +97 -0
- data/spec/functional/core/zypper_spec.rb +708 -0
- data/spec/functional/result_spec.rb +91 -44
- data/spec/helper/stub_network.rb +7 -3
- data/spec/support/shared_examples/integration/core/transfer.rb +1 -1
- data/spec/unit/command_spec.rb +2 -0
- data/spec/unit/core/ip_spec.rb +12 -0
- metadata +25 -4
@@ -4,52 +4,43 @@ module Kanrisuru
|
|
4
4
|
module Core
|
5
5
|
module User
|
6
6
|
def update_user(user, opts = {})
|
7
|
-
uid = opts[:uid]
|
8
7
|
group = opts[:group]
|
9
8
|
groups = opts[:groups]
|
10
|
-
append = opts[:append]
|
11
|
-
home = opts[:home]
|
12
|
-
move_home = opts[:move_home]
|
13
|
-
shell = opts[:shell] || '/bin/false'
|
14
|
-
non_unique = opts[:non_unique]
|
15
|
-
password = opts[:password]
|
16
|
-
expires = opts[:expires] ## YYYY-MM-DD
|
17
|
-
locked = opts[:locked]
|
18
9
|
|
19
10
|
command = Kanrisuru::Command.new("usermod #{user}")
|
20
11
|
|
21
|
-
if Kanrisuru::Util.present?(home)
|
22
|
-
command.append_arg('-d', home)
|
23
|
-
command.append_flag('-m', move_home)
|
12
|
+
if Kanrisuru::Util.present?(opts[:home])
|
13
|
+
command.append_arg('-d', opts[:home])
|
14
|
+
command.append_flag('-m', opts[:move_home])
|
24
15
|
end
|
25
16
|
|
26
|
-
command.append_arg('-s', shell)
|
17
|
+
command.append_arg('-s', opts[:shell])
|
27
18
|
|
28
|
-
if Kanrisuru::Util.present?(uid)
|
29
|
-
command.append_arg('-u', uid)
|
30
|
-
command.append_flag('-o', non_unique)
|
19
|
+
if Kanrisuru::Util.present?(opts[:uid])
|
20
|
+
command.append_arg('-u', opts[:uid])
|
21
|
+
command.append_flag('-o', opts[:non_unique])
|
31
22
|
end
|
32
23
|
|
33
|
-
command.append_arg('-g', group) if Kanrisuru::Util.present?(group) &&
|
24
|
+
command.append_arg('-g', group) if Kanrisuru::Util.present?(group) && group?(group)
|
34
25
|
|
35
26
|
if Kanrisuru::Util.present?(groups)
|
36
|
-
command.append_arg('-G',
|
37
|
-
command.append_flag('-a', append)
|
27
|
+
command.append_arg('-G', Kanrisuru::Util.array_join_string(groups, ','))
|
28
|
+
command.append_flag('-a', opts[:append])
|
38
29
|
end
|
39
30
|
|
40
|
-
case locked
|
31
|
+
case opts[:locked]
|
41
32
|
when true
|
42
33
|
command.append_flag('-L')
|
43
34
|
command.append_arg('-e', 1)
|
44
35
|
when false
|
45
|
-
command.
|
36
|
+
command.append_flag('-U')
|
46
37
|
command.append_arg('-e', 99_999)
|
47
38
|
else
|
48
39
|
## Ensure expires isn't added twice.
|
49
|
-
command.append_arg('-e', expires)
|
40
|
+
command.append_arg('-e', opts[:expires]) ## YYYY-MM-DD
|
50
41
|
|
51
42
|
## Can't use password with lock / unlock flag.
|
52
|
-
command.append_arg('-p', password)
|
43
|
+
command.append_arg('-p', opts[:password])
|
53
44
|
end
|
54
45
|
|
55
46
|
execute_shell(command)
|
@@ -17,16 +17,9 @@ module Kanrisuru
|
|
17
17
|
command.append_flag('--no-refresh', opts[:no_refresh])
|
18
18
|
command.append_flag('--keep-packages', opts[:keep_packages])
|
19
19
|
command.append_flag('--no-keep-packages', opts[:no_keep_packages])
|
20
|
-
command.append_flag('--gpgcheck', opts[:gpgcheck])
|
21
|
-
command.append_flag('--gpgcheck-strict', opts[:gpgcheck_strict])
|
22
|
-
command.append_flag('--gpgcheck-allow-unsigned', opts[:gpgcheck_allow_unsigned])
|
23
|
-
command.append_flag('--gpgcheck-allow-unsigned-repo', opts[:gpgcheck_allow_unsigned_repo])
|
24
|
-
command.append_flag('--gpgcheck-allow-unsigned-package', opts[:gpgcheck_allow_unsigned_package])
|
25
|
-
command.append_flag('--no-gpgcheck', opts[:no_gpgcheck])
|
26
|
-
command.append_flag('--default-gpgcheck', opts[:default_gpgcheck])
|
27
|
-
|
28
20
|
command.append_arg('--priority', opts[:priority])
|
29
21
|
|
22
|
+
zypper_gpg_opts(command, opts)
|
30
23
|
zypper_repos_opt(command, opts)
|
31
24
|
|
32
25
|
execute_shell(command)
|
@@ -8,14 +8,16 @@ module Kanrisuru
|
|
8
8
|
zypper_global_opts(command, opts)
|
9
9
|
command << 'addservice'
|
10
10
|
|
11
|
-
|
11
|
+
name = ("'#{opts[:name]}'" if Kanrisuru::Util.present?(opts[:name]))
|
12
12
|
|
13
|
+
command.append_arg('--name', name)
|
13
14
|
command.append_flag('--enable', opts[:enable])
|
14
15
|
command.append_flag('--disable', opts[:disable])
|
15
16
|
command.append_flag('--refresh', opts[:refresh])
|
16
17
|
command.append_flag('--no-refresh', opts[:no_refresh])
|
17
18
|
|
18
|
-
command
|
19
|
+
command << opts[:service]
|
20
|
+
command << opts[:alias]
|
19
21
|
|
20
22
|
execute_shell(command)
|
21
23
|
|
@@ -11,8 +11,7 @@ module Kanrisuru
|
|
11
11
|
zypper_repos_opt(command, opts)
|
12
12
|
zypper_package_type_opt(command, opts)
|
13
13
|
|
14
|
-
|
15
|
-
command << packages
|
14
|
+
command.append_array(opts[:packages])
|
16
15
|
|
17
16
|
execute_shell(command)
|
18
17
|
|
@@ -12,7 +12,7 @@ module Kanrisuru
|
|
12
12
|
zypper_package_type_opt(command, opts)
|
13
13
|
|
14
14
|
command.append_arg('-n', opts[:name])
|
15
|
-
command.
|
15
|
+
command.append_flag('-f', opts[:force])
|
16
16
|
command.append_flag('--oldpackage', opts[:oldpackage])
|
17
17
|
command.append_arg('--from', opts[:from])
|
18
18
|
command.append_arg('--capability', opts[:capability])
|
@@ -27,8 +27,7 @@ module Kanrisuru
|
|
27
27
|
zypper_download_and_install_opts(command, opts)
|
28
28
|
zypper_expert_opts(command, opts)
|
29
29
|
|
30
|
-
|
31
|
-
command << packages
|
30
|
+
command.append_array(opts[:packages])
|
32
31
|
|
33
32
|
execute_shell(command)
|
34
33
|
|
@@ -19,13 +19,7 @@ module Kanrisuru
|
|
19
19
|
command.append_flag('--keep-packages', opts[:keep_packages])
|
20
20
|
command.append_flag('--no-keep-packages', opts[:no_keep_packages])
|
21
21
|
|
22
|
-
command
|
23
|
-
command.append_flag('--gpgcheck-strict', opts[:gpgcheck_strict])
|
24
|
-
command.append_flag('--gpgcheck-allow-unsigned', opts[:gpgcheck_allow_unsigned])
|
25
|
-
command.append_flag('--gpgcheck-allow-unsigned-repo', opts[:gpgcheck_allow_unsigned_repo])
|
26
|
-
command.append_flag('--gpgcheck-allow-unsigned-package', opts[:gpgcheck_allow_unsigned_package])
|
27
|
-
command.append_flag('--no-gpgcheck', opts[:no_gpgcheck])
|
28
|
-
command.append_flag('--default-gpgcheck', opts[:default_gpgcheck])
|
22
|
+
zypper_gpg_opts(command, opts)
|
29
23
|
|
30
24
|
command.append_flag('--all', opts[:all])
|
31
25
|
command.append_flag('--local', opts[:local])
|
@@ -8,8 +8,8 @@ module Kanrisuru
|
|
8
8
|
zypper_global_opts(command, opts)
|
9
9
|
|
10
10
|
command << 'modifyservice'
|
11
|
-
command.append_arg('--name', opts[:name])
|
12
11
|
|
12
|
+
command.append_arg('--name', opts[:name])
|
13
13
|
command.append_flag('--enable', opts[:enable])
|
14
14
|
command.append_flag('--disable', opts[:disable])
|
15
15
|
command.append_flag('--refresh', opts[:refresh])
|
@@ -31,6 +31,8 @@ module Kanrisuru
|
|
31
31
|
command.append_arg('--medium-type', opts[:medium_type])
|
32
32
|
end
|
33
33
|
|
34
|
+
command << opts[:service] if Kanrisuru::Util.present?(opts[:service])
|
35
|
+
|
34
36
|
execute_shell(command)
|
35
37
|
|
36
38
|
Kanrisuru::Result.new(command)
|
@@ -15,8 +15,7 @@ module Kanrisuru
|
|
15
15
|
zypper_package_type_opt(command, opts)
|
16
16
|
zypper_solver_opts(command, opts)
|
17
17
|
|
18
|
-
|
19
|
-
command << packages
|
18
|
+
command.append_array(opts[:packages])
|
20
19
|
|
21
20
|
execute_shell(command)
|
22
21
|
Kanrisuru::Result.new(command)
|
@@ -15,10 +15,10 @@ module Kanrisuru
|
|
15
15
|
command.append_flag('--local', opts[:local])
|
16
16
|
command.append_flag('--remote', opts[:remote])
|
17
17
|
|
18
|
-
if Kanrisuru::Util.present?(opts[:
|
19
|
-
raise ArgumentError, 'Invalid media type' unless
|
18
|
+
if Kanrisuru::Util.present?(opts[:medium_type])
|
19
|
+
raise ArgumentError, 'Invalid media type' unless MEDIUM_TYPES.include?(opts[:medium_type])
|
20
20
|
|
21
|
-
command.append_arg('--
|
21
|
+
command.append_arg('--medium-type', opts[:medium_type])
|
22
22
|
end
|
23
23
|
|
24
24
|
command.append_array(opts[:repos])
|
@@ -4,13 +4,18 @@ module Kanrisuru
|
|
4
4
|
module Core
|
5
5
|
module Zypper
|
6
6
|
def zypper_remove_service(opts)
|
7
|
+
service = opts[:service]
|
8
|
+
|
7
9
|
command = Kanrisuru::Command.new('zypper')
|
8
10
|
zypper_global_opts(command, opts)
|
9
11
|
|
10
12
|
command << 'removeservice'
|
11
13
|
command.append_flag('--loose-auth', opts[:loose_auth])
|
12
14
|
command.append_flag('--loose-query', opts[:loose_query])
|
13
|
-
|
15
|
+
|
16
|
+
service = "'#{service}'" if service.match(/\s/)
|
17
|
+
|
18
|
+
command << service
|
14
19
|
|
15
20
|
execute_shell(command)
|
16
21
|
|
@@ -37,9 +37,7 @@ module Kanrisuru
|
|
37
37
|
|
38
38
|
zypper_repos_opt(command, opts)
|
39
39
|
zypper_package_type_opt(command, opts)
|
40
|
-
|
41
|
-
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
42
|
-
command << packages
|
40
|
+
command.append_array(opts[:packages])
|
43
41
|
|
44
42
|
execute_shell(command)
|
45
43
|
|
@@ -76,6 +76,16 @@ module Kanrisuru
|
|
76
76
|
command.append_flag('--no-allow-vendor-change', opts[:no_allow_vendor_change])
|
77
77
|
end
|
78
78
|
|
79
|
+
def zypper_gpg_opts(command, opts)
|
80
|
+
command.append_flag('--gpgcheck', opts[:gpgcheck])
|
81
|
+
command.append_flag('--gpgcheck-strict', opts[:gpgcheck_strict])
|
82
|
+
command.append_flag('--gpgcheck-allow-unsigned', opts[:gpgcheck_allow_unsigned])
|
83
|
+
command.append_flag('--gpgcheck-allow-unsigned-repo', opts[:gpgcheck_allow_unsigned_repo])
|
84
|
+
command.append_flag('--gpgcheck-allow-unsigned-package', opts[:gpgcheck_allow_unsigned_package])
|
85
|
+
command.append_flag('--no-gpgcheck', opts[:no_gpgcheck])
|
86
|
+
command.append_flag('--default-gpgcheck', opts[:default_gpgcheck])
|
87
|
+
end
|
88
|
+
|
79
89
|
def zypper_repos_opt(command, opts)
|
80
90
|
zypper_array_opt(command, opts[:repos], '--repo')
|
81
91
|
end
|
@@ -101,7 +111,6 @@ module Kanrisuru
|
|
101
111
|
|
102
112
|
def zypper_package_type_opt(command, opts)
|
103
113
|
type = opts[:type]
|
104
|
-
|
105
114
|
command.append_arg('-t', type) if Kanrisuru::Util.present?(type) && PACKAGE_TYPES.include?(type)
|
106
115
|
end
|
107
116
|
end
|
data/lib/kanrisuru/os_package.rb
CHANGED
@@ -135,6 +135,7 @@ module Kanrisuru
|
|
135
135
|
end
|
136
136
|
|
137
137
|
ch.on_data do |_, data|
|
138
|
+
Kanrisuru.logger.debug { data.strip }
|
138
139
|
command.handle_data(data)
|
139
140
|
end
|
140
141
|
|
@@ -145,9 +146,6 @@ module Kanrisuru
|
|
145
146
|
end
|
146
147
|
|
147
148
|
channel.wait
|
148
|
-
|
149
|
-
Kanrisuru.logger.debug { command.to_a }
|
150
|
-
|
151
149
|
command
|
152
150
|
rescue Net::SSH::ConnectionTimeout, Net::SSH::Timeout => e
|
153
151
|
if retry_attempts > 1
|
data/lib/kanrisuru/result.rb
CHANGED
@@ -39,6 +39,21 @@ module Kanrisuru
|
|
39
39
|
@data.instance_of?(Array) ? @data : [@data]
|
40
40
|
end
|
41
41
|
|
42
|
+
def to_f
|
43
|
+
case @data
|
44
|
+
when Numeric
|
45
|
+
@data
|
46
|
+
when String
|
47
|
+
@data.to_f
|
48
|
+
when Array
|
49
|
+
@data.map(&:to_f)
|
50
|
+
when NilClass
|
51
|
+
nil
|
52
|
+
else
|
53
|
+
raise NoMethodError, "(undefined method `to_f' for Kanrisuru::Result)"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
42
57
|
def to_i
|
43
58
|
case @data
|
44
59
|
when Integer
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Kanrisuru::Core::Disk do
|
6
|
+
before(:all) do
|
7
|
+
StubNetwork.stub!
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
StubNetwork.unstub!
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:host) do
|
15
|
+
Kanrisuru::Remote::Host.new(
|
16
|
+
host: 'localhost',
|
17
|
+
username: 'ubuntu',
|
18
|
+
keys: ['id_rsa']
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'prepares blkid command' do
|
23
|
+
expect_command(host.blkid, 'blkid -o export')
|
24
|
+
expect_command(host.blkid(device: '/dev/vda1'), 'blkid -pio export /dev/vda1')
|
25
|
+
expect_command(host.blkid(label: 'UEFI'), 'blkid -L UEFI')
|
26
|
+
expect_command(host.blkid(uuid: '26F2-56F9'), 'blkid -U 26F2-56F9')
|
27
|
+
expect_command(host.blkid(label: 'UEFI', uuid: '26F2-56F9'), 'blkid -L UEFI -U 26F2-56F9')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'prepares df command' do
|
31
|
+
expect_command(host.df, "df -PT | awk '{print $1, $2, $3, $5, $6, $7}'")
|
32
|
+
expect_command(host.df(inodes: true, path: '/dev/vda1'),
|
33
|
+
"df -PT -i /dev/vda1 | awk '{print $1, $2, $3, $5, $6, $7}'")
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'prepares du command' do
|
37
|
+
expect_command(host.du, "du | awk '{print \\$1, \\$2}'")
|
38
|
+
expect_command(host.du(summarize: true, path: '/etc'), "du -s /etc | awk '{print \\$1, \\$2}'")
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with json support' do
|
42
|
+
before(:all) do
|
43
|
+
StubNetwork.stub_command!(:lsblk_version) do
|
44
|
+
Kanrisuru::Core::Disk::LSBK_VERSION
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
after(:all) do
|
49
|
+
StubNetwork.unstub_command!(:lsblk_version)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'prepares lsblk command' do
|
53
|
+
expect_command(host.lsblk, 'lsblk --json -o NAME,FSTYPE,MAJ:MIN,MOUNTPOINT,SIZE,UUID,RO,RM,OWNER,GROUP,MODE,TYPE')
|
54
|
+
expect_command(host.lsblk(all: true, paths: true, nodeps: true),
|
55
|
+
'lsblk --json -a -p -d -o NAME,FSTYPE,MAJ:MIN,MOUNTPOINT,SIZE,UUID,RO,RM,OWNER,GROUP,MODE,TYPE')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'without json support' do
|
60
|
+
before(:all) do
|
61
|
+
StubNetwork.stub_command!(:lsblk_version) do
|
62
|
+
Kanrisuru::Core::Disk::LSBK_VERSION - 0.1
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
after(:all) do
|
67
|
+
StubNetwork.unstub_command!(:lsblk_version)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'prepares lsblk command' do
|
71
|
+
expect_command(host.lsblk,
|
72
|
+
'lsblk -i -P --noheadings -o NAME,FSTYPE,MAJ:MIN,MOUNTPOINT,SIZE,UUID,RO,RM,OWNER,GROUP,MODE,TYPE')
|
73
|
+
expect_command(host.lsblk(all: true, paths: true, nodeps: true),
|
74
|
+
'lsblk -i -P --noheadings -a -p -d -o NAME,FSTYPE,MAJ:MIN,MOUNTPOINT,SIZE,UUID,RO,RM,OWNER,GROUP,MODE,TYPE')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Kanrisuru::Core::Dmi do
|
6
|
+
before(:all) do
|
7
|
+
StubNetwork.stub!
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
StubNetwork.unstub!
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:host) do
|
15
|
+
Kanrisuru::Remote::Host.new(
|
16
|
+
host: 'localhost',
|
17
|
+
username: 'ubuntu',
|
18
|
+
keys: ['id_rsa']
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'prepares dmi command' do
|
23
|
+
expect_command(host.dmi, 'dmidecode')
|
24
|
+
expect_command(host.dmi(types: 'BIOS'), 'dmidecode --type 0')
|
25
|
+
expect_command(host.dmi(types: 1), 'dmidecode --type 1')
|
26
|
+
|
27
|
+
expect do
|
28
|
+
host.dmi(types: 'hello')
|
29
|
+
end.to raise_error(ArgumentError)
|
30
|
+
|
31
|
+
expect_command(host.dmi(types: [
|
32
|
+
'BIOS',
|
33
|
+
'System',
|
34
|
+
'Baseboard',
|
35
|
+
'Chassis',
|
36
|
+
'Processor',
|
37
|
+
'Memory Controller',
|
38
|
+
'Memory Module',
|
39
|
+
'Cache',
|
40
|
+
'Port Connector',
|
41
|
+
'System Slots',
|
42
|
+
'On Board Devices',
|
43
|
+
'OEM Strings',
|
44
|
+
'System Configuration Options',
|
45
|
+
'BIOS Language',
|
46
|
+
'Group Associations',
|
47
|
+
'System Event Log',
|
48
|
+
'Physical Memory Array',
|
49
|
+
'Memory Device',
|
50
|
+
'32-bit Memory Error',
|
51
|
+
'Memory Array Mapped Address',
|
52
|
+
'Memory Device Mapped Address',
|
53
|
+
'Built-in Pointing Device',
|
54
|
+
'Portable Battery',
|
55
|
+
'System Reset',
|
56
|
+
'Hardware Security',
|
57
|
+
'System Power Controls',
|
58
|
+
'Voltage Probe',
|
59
|
+
'Cooling Device',
|
60
|
+
'Temperature Probe',
|
61
|
+
'Electrical Current Probe',
|
62
|
+
'Out-of-band Remote Access',
|
63
|
+
'Boot Integrity Services',
|
64
|
+
'System Boot',
|
65
|
+
'64-bit Memory Error',
|
66
|
+
'Management Device',
|
67
|
+
'Management Device Component',
|
68
|
+
'Management Device Threshold Data',
|
69
|
+
'Memory Channel',
|
70
|
+
'IPMI Device',
|
71
|
+
'System Power Supply',
|
72
|
+
'Additional Information',
|
73
|
+
'Onboard Devices Extended Information',
|
74
|
+
'Management Controller Host Interface',
|
75
|
+
'TPM Device'
|
76
|
+
]), 'dmidecode --type 0 --type 1 --type 2 --type 3 --type 4 --type 5 --type 6 --type 7 --type 8 --type 9 --type 10 --type 11 --type 12 --type 13 --type 14 --type 15 --type 16 --type 17 --type 18 --type 19 --type 20 --type 21 --type 22 --type 23 --type 24 --type 25 --type 26 --type 27 --type 28 --type 29 --type 30 --type 31 --type 32 --type 33 --type 34 --type 35 --type 36 --type 37 --type 38 --type 39 --type 40 --type 41 --type 42 --type 43')
|
77
|
+
end
|
78
|
+
end
|