kanrisuru 0.15.0 → 0.16.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/CHANGELOG.md +9 -0
- data/kanrisuru.gemspec +7 -3
- data/lib/kanrisuru/command.rb +5 -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/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/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/system_spec.rb +135 -0
- data/spec/functional/core/user_spec.rb +97 -0
- data/spec/functional/result_spec.rb +91 -44
- data/spec/helper/stub_network.rb +6 -2
- data/spec/unit/command_spec.rb +2 -0
- data/spec/unit/core/ip_spec.rb +12 -0
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dcfedf8792427fccd9a7210d3f8dab6f95d2f1ba1b196ed90205c0d4a5b2c4f
|
4
|
+
data.tar.gz: 9e5d940a569f7b4c964aaf2a8869a07b4194a2aa9699dff9de780184403f65a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f90832958572df546c18e49f8354b3014dea58b780a4540bbd204196be96562652ea0768283912005aa025fc97a85d39ff9d96dd0c48f104f89bb10d086fb64
|
7
|
+
data.tar.gz: df414f1782efeb27eef49133c3af0c13e6966489adc19115403e3d78c69b6fe07aedaca8b21f78417bdd921860d455df9dbe7735823f2cdaeb427c55576e8a4d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## Kanrisuru 0.16.0 (December 14, 2021) ##
|
2
|
+
* Fix `append_array` for the `Kanrisuru::Command` class with negated check on Array type.
|
3
|
+
* Add `to_f` method for `Kanrisuru::Command` and `Kanrisuru::Result` with unit test cases.
|
4
|
+
* Refactor `lsblk_version` into seperate command namespace with it's own parser.
|
5
|
+
* Add functional test cases for several core modules.
|
6
|
+
* Add `return_value` option to `stub_command!` method for non-result return methods. These are few and far between, but need to be tested appropriately.
|
7
|
+
* Refactor several core modules with use of `command` calls for legibility.
|
8
|
+
* Fix several issues with `create_user`, `update_user`, and `delete_user`.
|
9
|
+
|
1
10
|
## Kanrisuru 0.15.0 (December 13, 2021) ##
|
2
11
|
* Add opts for `ip` command.
|
3
12
|
* Refactor `ip` object commands into smaller methods. Refactor `version` for consistent use and stub ability in funcitonal test cases.
|
data/kanrisuru.gemspec
CHANGED
@@ -8,9 +8,12 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.author = 'Ryan Mammina'
|
9
9
|
gem.email = 'ryan@avamia.com'
|
10
10
|
gem.license = 'MIT'
|
11
|
-
gem.summary = 'Manage remote servers over ssh with ruby.'
|
12
|
-
gem.description = 'Kanrisuru helps manage remote servers with objected oriented ruby. Results come back as structured data, parsed, prepared and ready.'
|
13
11
|
gem.homepage = 'https://github.com/avamia/kanrisuru'
|
12
|
+
gem.summary = 'Manage remote servers over ssh with ruby.'
|
13
|
+
gem.description = <<-EOF
|
14
|
+
Kanrisuru helps manage remote servers with objected oriented ruby.#{' '}
|
15
|
+
Results come back as structured data, parsed, prepared and ready.
|
16
|
+
EOF
|
14
17
|
|
15
18
|
gem.required_ruby_version = '>= 2.5.0'
|
16
19
|
|
@@ -30,6 +33,7 @@ Gem::Specification.new do |gem|
|
|
30
33
|
|
31
34
|
gem.metadata = {
|
32
35
|
'source_code_uri' => 'https://github.com/avamia/kanrisuru/',
|
33
|
-
'changelog_uri' => 'https://github.com/avamia/kanrisuru/blob/main/CHANGELOG.md'
|
36
|
+
'changelog_uri' => 'https://github.com/avamia/kanrisuru/blob/main/CHANGELOG.md',
|
37
|
+
'rubygems_mfa_required' => 'true'
|
34
38
|
}
|
35
39
|
end
|
data/lib/kanrisuru/command.rb
CHANGED
@@ -23,6 +23,10 @@ module Kanrisuru
|
|
23
23
|
to_a.join.to_i
|
24
24
|
end
|
25
25
|
|
26
|
+
def to_f
|
27
|
+
to_a.join.to_f
|
28
|
+
end
|
29
|
+
|
26
30
|
def to_s
|
27
31
|
to_a.join(' ')
|
28
32
|
end
|
@@ -87,7 +91,7 @@ module Kanrisuru
|
|
87
91
|
def append_array(value)
|
88
92
|
return unless Kanrisuru::Util.present?(value)
|
89
93
|
|
90
|
-
value = [value]
|
94
|
+
value = [value] unless value.instance_of?(Array)
|
91
95
|
append_value(value.join(' '))
|
92
96
|
end
|
93
97
|
|
@@ -10,12 +10,12 @@ module Kanrisuru
|
|
10
10
|
|
11
11
|
command = Kanrisuru::Command.new('lsblk')
|
12
12
|
|
13
|
-
version = lsblk_version
|
13
|
+
version = lsblk_version.to_f
|
14
14
|
|
15
15
|
## lsblk after version 2.26 handles json parsing.
|
16
16
|
## TODO: parse nested children for earlier version of lsblk
|
17
|
-
if version >=
|
18
|
-
command.append_flag('--json') if version >=
|
17
|
+
if version >= LSBK_VERSION
|
18
|
+
command.append_flag('--json') if version >= LSBK_VERSION
|
19
19
|
else
|
20
20
|
command.append_flag('-i')
|
21
21
|
command.append_flag('-P')
|
@@ -40,14 +40,9 @@ module Kanrisuru
|
|
40
40
|
command = Kanrisuru::Command.new('lsblk --version')
|
41
41
|
execute(command)
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
raise 'lsblk command not found' if command.failure?
|
47
|
-
|
48
|
-
version = command.to_s.scan(regex)[0].to_f unless regex.match(command.to_s).nil?
|
49
|
-
|
50
|
-
version
|
43
|
+
Kanrisuru::Result.new(command) do |cmd|
|
44
|
+
Parser::LsblkVersion.parse(cmd)
|
45
|
+
end
|
51
46
|
end
|
52
47
|
end
|
53
48
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module Disk
|
6
|
+
module Parser
|
7
|
+
class LsblkVersion
|
8
|
+
def self.parse(command)
|
9
|
+
version = 0.00
|
10
|
+
regex = Regexp.new(/\d+(?:[,.]\d+)?/)
|
11
|
+
|
12
|
+
raise 'lsblk command not found' if command.failure?
|
13
|
+
|
14
|
+
version = command.to_s.scan(regex)[0].to_f unless regex.match(command.to_s).nil?
|
15
|
+
version
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/kanrisuru/core/disk.rb
CHANGED
@@ -7,7 +7,7 @@ module Kanrisuru
|
|
7
7
|
recursive = opts[:recursive]
|
8
8
|
|
9
9
|
command =
|
10
|
-
if mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
|
10
|
+
if mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode)) && mode.length < 10
|
11
11
|
Kanrisuru::Command.new("chmod #{mode} #{path}")
|
12
12
|
elsif mode.instance_of?(Kanrisuru::Mode)
|
13
13
|
Kanrisuru::Command.new("chmod #{mode.numeric} #{path}")
|
@@ -29,9 +29,7 @@ module Kanrisuru
|
|
29
29
|
if opts[:preserve].instance_of?(TrueClass)
|
30
30
|
command.append_flag('-p')
|
31
31
|
elsif Kanrisuru::Util.present?(opts[:preserve])
|
32
|
-
preserve =
|
33
|
-
(opts[:preserve].join(',') if opts[:preserve].instance_of?(Array))
|
34
|
-
|
32
|
+
preserve = Kanrisuru::Util.array_join_string(opts[:preserve], ',')
|
35
33
|
command << "--preserve=#{preserve}"
|
36
34
|
end
|
37
35
|
|
@@ -8,16 +8,21 @@ module Kanrisuru
|
|
8
8
|
group = opts[:group]
|
9
9
|
recursive = opts[:recursive]
|
10
10
|
|
11
|
-
command = Kanrisuru::Command.new(
|
11
|
+
command = Kanrisuru::Command.new('mkdir')
|
12
|
+
|
13
|
+
command.append_array(path)
|
12
14
|
command.append_flag('-p', opts[:silent])
|
13
15
|
|
14
16
|
if Kanrisuru::Util.present?(opts[:mode])
|
15
17
|
mode = opts[:mode]
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
|
19
|
+
mode = if mode.instance_of?(Kanrisuru::Mode)
|
20
|
+
mode.numeric
|
21
|
+
elsif mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
|
22
|
+
mode
|
23
|
+
else
|
24
|
+
Kanrisuru::Mode.new(mode).numeric
|
25
|
+
end
|
21
26
|
|
22
27
|
command.append_arg('-m', mode)
|
23
28
|
end
|
@@ -10,7 +10,10 @@ module Kanrisuru
|
|
10
10
|
raise ArgumentError, "Can't delete root path" if path == '/' || realpath(path).path == '/'
|
11
11
|
end
|
12
12
|
|
13
|
-
command = Kanrisuru::Command.new(
|
13
|
+
command = Kanrisuru::Command.new('rm')
|
14
|
+
command.append_array(paths)
|
15
|
+
|
16
|
+
command.append_flag('--preserve-root')
|
14
17
|
command.append_flag('-f', opts[:force])
|
15
18
|
command.append_flag('-r', opts[:recursive])
|
16
19
|
|
@@ -7,7 +7,8 @@ module Kanrisuru
|
|
7
7
|
date = opts[:date]
|
8
8
|
|
9
9
|
paths = [paths] if paths.instance_of?(String)
|
10
|
-
command = Kanrisuru::Command.new(
|
10
|
+
command = Kanrisuru::Command.new('touch')
|
11
|
+
command.append_array(paths)
|
11
12
|
|
12
13
|
command.append_flag('-a', opts[:atime])
|
13
14
|
command.append_flag('-m', opts[:mtime])
|
@@ -4,33 +4,25 @@ module Kanrisuru
|
|
4
4
|
module Core
|
5
5
|
module User
|
6
6
|
def create_user(user, opts = {})
|
7
|
-
uid = opts[:uid]
|
8
7
|
group = opts[:group]
|
9
8
|
groups = opts[:groups]
|
10
|
-
home = opts[:home]
|
11
9
|
shell = opts[:shell] || '/bin/false'
|
12
|
-
createhome = opts[:createhome]
|
13
|
-
system_opt = opts[:system]
|
14
|
-
skeleton = opts[:skeleton]
|
15
|
-
non_unique = opts[:non_unique]
|
16
|
-
password = opts[:password]
|
17
|
-
expires = opts[:expires] ## YYYY-MM-DD
|
18
10
|
|
19
11
|
command = Kanrisuru::Command.new("useradd #{user}")
|
20
12
|
|
21
|
-
if Kanrisuru::Util.present?(uid)
|
22
|
-
command.append_arg('-u', uid)
|
23
|
-
command.append_flag('-o', non_unique)
|
13
|
+
if Kanrisuru::Util.present?(opts[:uid])
|
14
|
+
command.append_arg('-u', opts[:uid])
|
15
|
+
command.append_flag('-o', opts[:non_unique])
|
24
16
|
end
|
25
17
|
|
26
|
-
command.append_flag('-r',
|
18
|
+
command.append_flag('-r', opts[:system])
|
27
19
|
command.append_arg('-s', shell)
|
28
|
-
command.append_arg('-d', home)
|
20
|
+
command.append_arg('-d', opts[:home])
|
29
21
|
|
30
|
-
case createhome
|
22
|
+
case opts[:createhome]
|
31
23
|
when true
|
32
24
|
command.append_flag('-m')
|
33
|
-
command.append_arg('-k', skeleton)
|
25
|
+
command.append_arg('-k', opts[:skeleton])
|
34
26
|
when false
|
35
27
|
command.append_flag('-M')
|
36
28
|
end
|
@@ -43,8 +35,8 @@ module Kanrisuru
|
|
43
35
|
|
44
36
|
command.append_arg('-G', groups.join(',')) if Kanrisuru::Util.present?(groups)
|
45
37
|
|
46
|
-
command.append_arg('-p', password)
|
47
|
-
command.append_arg('-e', expires)
|
38
|
+
command.append_arg('-p', opts[:password])
|
39
|
+
command.append_arg('-e', opts[:expires]) ## YYYY-MM-DD
|
48
40
|
|
49
41
|
execute_shell(command)
|
50
42
|
|
@@ -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)
|
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
|