kanrisuru 0.8.21 → 0.9.1
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 +16 -0
- data/lib/kanrisuru/core/yum.rb +2 -2
- data/lib/kanrisuru/remote/cluster.rb +33 -1
- data/lib/kanrisuru/remote/cpu.rb +3 -3
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/apt_spec.rb +96 -0
- data/spec/functional/core/yum_spec.rb +159 -0
- data/spec/functional/remote/cluster_spec.rb +57 -0
- data/spec/helper/stub_network.rb +40 -9
- data/spec/unit/remote/cpu_spec.rb +50 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a0ae74abc67963114dc04cc67783eaaab104ad77de4bba9dc497cd2307c92e7c
|
|
4
|
+
data.tar.gz: 94ba0cb2da9fa973cbcf5ff0e866931b64fdd8b529f44e35e0ede06edcd47581
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46b7fa66b9fceb225536604774a655f8ad332a1f1565a10005d8ba679fb2d14c894d16862535a98a555ba5a669e1f43674b61c77f8c718fea36efd4071523194
|
|
7
|
+
data.tar.gz: b97bbdbf4a2ed6ceb0aef10f63bfc1dad44559d825bdffcc095b979aad2aa9ca3cfdab5c5a0270eb3f96b67cdd93b63d4dad032c8601dc4372ebf54209b127ca
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## Kanrisuru 0.9.1 (November 29, 2021)
|
|
2
|
+
* Fix type on `address_sizes` for `Kanrisuru::Remote::Cpu` class.
|
|
3
|
+
* Add unit test cases for the `cpu` class.
|
|
4
|
+
|
|
5
|
+
## Kanrisuru 0.9.0 (November 23, 2021)
|
|
6
|
+
* Add `delete` to `Kanrisuru::Remote::Cluster` class to allow removal of hosts from cluster.
|
|
7
|
+
* Add functional test cases for remote cluster class.
|
|
8
|
+
|
|
9
|
+
## Kanrisuru 0.8.23 (November 19, 2021)
|
|
10
|
+
* Add functional test cases for `yum` command
|
|
11
|
+
* Add stub by operating system method, with support for `ubuntu` and `centos` os types.
|
|
12
|
+
* Fix `ArgumentError` typo in yum commands, `erase` and `remove`.
|
|
13
|
+
|
|
14
|
+
## Kanrisuru 0.8.22 (November 18, 2021)
|
|
15
|
+
* Add functional test cases for `apt` command
|
|
16
|
+
|
|
1
17
|
## Kanrisuru 0.8.21 (November 15, 2021)
|
|
2
18
|
* Fix bug with `Kanrisuru::Mode` class, lookup table had incorrect value for execute only symbolic to numeric field.
|
|
3
19
|
|
data/lib/kanrisuru/core/yum.rb
CHANGED
|
@@ -137,7 +137,7 @@ module Kanrisuru
|
|
|
137
137
|
command.append_flag('-y')
|
|
138
138
|
|
|
139
139
|
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
140
|
-
raise
|
|
140
|
+
raise ArgumentError, "can't remove yum" if packages.include?('yum')
|
|
141
141
|
|
|
142
142
|
command << packages
|
|
143
143
|
|
|
@@ -173,7 +173,7 @@ module Kanrisuru
|
|
|
173
173
|
command.append_flag('-y')
|
|
174
174
|
|
|
175
175
|
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
176
|
-
raise
|
|
176
|
+
raise ArgumentError, "can't erase yum" if packages.include?('yum')
|
|
177
177
|
|
|
178
178
|
command << packages
|
|
179
179
|
|
|
@@ -13,6 +13,10 @@ module Kanrisuru
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def hosts
|
|
17
|
+
@hosts.values
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
def [](hostname)
|
|
17
21
|
@hosts[hostname]
|
|
18
22
|
end
|
|
@@ -21,6 +25,10 @@ module Kanrisuru
|
|
|
21
25
|
add_host(host_opts)
|
|
22
26
|
end
|
|
23
27
|
|
|
28
|
+
def delete(host)
|
|
29
|
+
remove_host(host)
|
|
30
|
+
end
|
|
31
|
+
|
|
24
32
|
def execute(command)
|
|
25
33
|
@hosts.map do |host_addr, host|
|
|
26
34
|
## Need to evaluate each host independently for the command.
|
|
@@ -81,13 +89,37 @@ module Kanrisuru
|
|
|
81
89
|
end
|
|
82
90
|
end
|
|
83
91
|
|
|
92
|
+
def remove_host(host)
|
|
93
|
+
if host.instance_of?(Kanrisuru::Remote::Host)
|
|
94
|
+
removed = false
|
|
95
|
+
|
|
96
|
+
if @hosts.key?(host.host)
|
|
97
|
+
removed = true
|
|
98
|
+
@hosts.delete(host.host)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
removed
|
|
102
|
+
elsif host.instance_of?(String)
|
|
103
|
+
removed = false
|
|
104
|
+
|
|
105
|
+
if @hosts.key?(host)
|
|
106
|
+
removed = true
|
|
107
|
+
@hosts.delete(host)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
removed
|
|
111
|
+
else
|
|
112
|
+
raise ArgumentError, 'Invalid host type'
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
84
116
|
def add_host(host_opts)
|
|
85
117
|
if host_opts.instance_of?(Hash)
|
|
86
118
|
@hosts[host_opts[:host]] = Kanrisuru::Remote::Host.new(host_opts)
|
|
87
119
|
elsif host_opts.instance_of?(Kanrisuru::Remote::Host)
|
|
88
120
|
@hosts[host_opts.host] = host_opts
|
|
89
121
|
else
|
|
90
|
-
raise '
|
|
122
|
+
raise ArgumentError, 'Invalid host option'
|
|
91
123
|
end
|
|
92
124
|
end
|
|
93
125
|
end
|
data/lib/kanrisuru/remote/cpu.rb
CHANGED
|
@@ -75,8 +75,8 @@ module Kanrisuru
|
|
|
75
75
|
@cpu_architecture.byte_order
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
def
|
|
79
|
-
@cpu_architecture.
|
|
78
|
+
def address_sizes
|
|
79
|
+
@cpu_architecture.address_sizes
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def cpu_mhz
|
|
@@ -103,7 +103,7 @@ module Kanrisuru
|
|
|
103
103
|
@cpu_architecture.flags
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
def hyperthreading?
|
|
107
107
|
threads_per_core > 1
|
|
108
108
|
end
|
|
109
109
|
|
data/lib/kanrisuru/version.rb
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Kanrisuru::Core::Apt 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 apt list command' do
|
|
23
|
+
expect_command(host.apt('list'), 'apt list')
|
|
24
|
+
expect_command(host.apt('list',
|
|
25
|
+
installed: true,
|
|
26
|
+
upgradeable: true,
|
|
27
|
+
all_versions: true,
|
|
28
|
+
), 'apt list --installed --upgradeable --all-versions')
|
|
29
|
+
|
|
30
|
+
expect_command(host.apt('list', package_name: 'nginx'), 'apt list -a nginx')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'prepares apt update command' do
|
|
34
|
+
expect_command(host.apt('update'), 'apt-get update -y')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'prepares apt upgrade command' do
|
|
38
|
+
expect_command(host.apt('upgrade'), 'apt-get upgrade -y')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'prepares apt full-upgrade command' do
|
|
42
|
+
expect_command(host.apt('full-upgrade'), 'apt full-upgrade -y')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'prepares apt install command' do
|
|
46
|
+
expect_command(host.apt('install',
|
|
47
|
+
packages: 'nginx'
|
|
48
|
+
),
|
|
49
|
+
'apt-get install -y nginx'
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
expect_command(host.apt('install',
|
|
53
|
+
packages: 'monit',
|
|
54
|
+
no_upgrade: true,
|
|
55
|
+
reinstall: true
|
|
56
|
+
),
|
|
57
|
+
'apt-get install -y --no-upgrade --reinstall monit'
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
expect_command(host.apt('install',
|
|
61
|
+
packages: ['build-essential', 'manpages-dev'],
|
|
62
|
+
only_upgrade: true,
|
|
63
|
+
),
|
|
64
|
+
'apt-get install -y --only-upgrade build-essential manpages-dev'
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'prepares apt remove command' do
|
|
69
|
+
expect_command(host.apt('remove', packages: ['python']), 'apt-get remove -y python')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'prepares apt purge command' do
|
|
73
|
+
expect_command(host.apt('purge', packages: ['python']), 'apt-get purge -y python')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'prepares apt autoremove command' do
|
|
77
|
+
expect_command(host.apt('autoremove'), 'apt-get autoremove -y')
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'prepares apt search command' do
|
|
81
|
+
expect_command(host.apt('search', query: 'ruby'), 'apt search ruby')
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'prepares apt show command' do
|
|
85
|
+
expect_command(host.apt('show', packages: 'ruby'), 'apt show -a ruby')
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'prepares apt clean command' do
|
|
89
|
+
expect_command(host.apt('clean'), 'apt-get clean')
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'prepares apt autoclean command' do
|
|
93
|
+
expect_command(host.apt('autoclean'), 'apt-get autoclean')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Kanrisuru::Core::Yum do
|
|
6
|
+
before(:all) do
|
|
7
|
+
StubNetwork.stub!(:centos)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after(:all) do
|
|
11
|
+
StubNetwork.unstub!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:host) do
|
|
15
|
+
Kanrisuru::Remote::Host.new(
|
|
16
|
+
host: 'centos-host',
|
|
17
|
+
username: 'centos',
|
|
18
|
+
keys: ['id_rsa']
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'prepares yum install command' do
|
|
23
|
+
expect_command(host.yum('install', packages: 'nginx'),
|
|
24
|
+
'yum install -y nginx'
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
expect_command(host.yum('install', packages: ['nginx', 'apache2']),
|
|
28
|
+
'yum install -y nginx apache2'
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'prepares yum localinstall command' do
|
|
33
|
+
expect_command(host.yum('localinstall', repos: 'foo.rpm'),
|
|
34
|
+
'yum localinstall -y foo.rpm'
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
expect_command(host.yum('localinstall',
|
|
38
|
+
repos: ['foo.rpm', 'bar.rpm', 'baz.rpm'],
|
|
39
|
+
disable_repo: '*'
|
|
40
|
+
),
|
|
41
|
+
'yum localinstall --disablerepo=* -y foo.rpm bar.rpm baz.rpm'
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'prepares yum list command' do
|
|
46
|
+
expect_command(host.yum('list'),
|
|
47
|
+
"yum list | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
expect_command(host.yum('list', all: true, query: 'ruby*'),
|
|
51
|
+
"yum list all ruby* | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
expect_command(host.yum('list',
|
|
55
|
+
available: true,
|
|
56
|
+
updates: true,
|
|
57
|
+
installed: true,
|
|
58
|
+
extras: true,
|
|
59
|
+
obsoletes: true,
|
|
60
|
+
disable_repo: '*'
|
|
61
|
+
),
|
|
62
|
+
"yum list --disablerepo=* available updates installed extras obsoletes | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'prepares yum search command' do
|
|
67
|
+
expect_command(host.yum('search',
|
|
68
|
+
packages: 'redis'
|
|
69
|
+
),
|
|
70
|
+
"yum search redis | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
expect_command(host.yum('search',
|
|
74
|
+
packages: ['package1', 'package2', 'package3'],
|
|
75
|
+
all: true
|
|
76
|
+
),
|
|
77
|
+
"yum search all package1 package2 package3 | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'prepares yum info command' do
|
|
82
|
+
expect_command(host.yum('info',
|
|
83
|
+
packages: 'redis'
|
|
84
|
+
),
|
|
85
|
+
"yum info --quiet redis"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
expect_command(host.yum('info',
|
|
89
|
+
packages: ['package1', 'package2', 'package3'],
|
|
90
|
+
installed: true
|
|
91
|
+
),
|
|
92
|
+
"yum info --quiet installed package1 package2 package3"
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'prepares yum repolist command' do
|
|
97
|
+
expect_command(host.yum('repolist'),
|
|
98
|
+
"yum repolist --verbose"
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
expect_command(host.yum('repolist', repos: 'repo1'),
|
|
102
|
+
"yum repolist --verbose repo1"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
expect_command(host.yum('repolist', repos: ['repo1', 'repo2', 'repo3']),
|
|
106
|
+
"yum repolist --verbose repo1 repo2 repo3"
|
|
107
|
+
)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'prepares yum clean command' do
|
|
111
|
+
expect_command(host.yum('clean'), 'yum clean')
|
|
112
|
+
expect_command(host.yum('clean', all: true), 'yum clean all')
|
|
113
|
+
expect_command(host.yum('clean',
|
|
114
|
+
dbcache: true,
|
|
115
|
+
expire_cache: true,
|
|
116
|
+
metadata: true,
|
|
117
|
+
packages: true,
|
|
118
|
+
headers: true,
|
|
119
|
+
rpmdb: true
|
|
120
|
+
),
|
|
121
|
+
"yum clean dbcache expire-cache metadata packages headers rpmdb"
|
|
122
|
+
)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'prepares yum remove command' do
|
|
126
|
+
expect_command(host.yum('remove', packages: 'gcc'), 'yum remove -y gcc')
|
|
127
|
+
expect_command(host.yum('remove', packages: ['p1', 'p2', 'p3']),
|
|
128
|
+
'yum remove -y p1 p2 p3'
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
expect {
|
|
132
|
+
host.yum('remove', packages: 'yum')
|
|
133
|
+
}.to raise_error(ArgumentError)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 'prepares yum autoremove command' do
|
|
137
|
+
expect_command(host.yum('autoremove'), 'yum autoremove -y')
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'prepares yum erase command' do
|
|
141
|
+
expect_command(host.yum('erase', packages: 'gcc'), 'yum erase -y gcc')
|
|
142
|
+
expect_command(host.yum('erase', packages: ['p1', 'p2', 'p3']),
|
|
143
|
+
'yum erase -y p1 p2 p3'
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
expect {
|
|
147
|
+
host.yum('erase', packages: 'yum')
|
|
148
|
+
}.to raise_error(ArgumentError)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'prepares yum update command' do
|
|
152
|
+
expect_command(host.yum('update'), 'yum update -y')
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it 'prepares yum upgrade command' do
|
|
156
|
+
expect_command(host.yum('upgrade'), 'yum upgrade -y')
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Kanrisuru::Remote::Cluster do
|
|
6
|
+
before(:all) do
|
|
7
|
+
StubNetwork.stub!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after(:all) do
|
|
11
|
+
StubNetwork.unstub!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:host1) do
|
|
15
|
+
Kanrisuru::Remote::Host.new(
|
|
16
|
+
host: 'localhost',
|
|
17
|
+
username: 'ubuntu',
|
|
18
|
+
keys: ['id_rsa']
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
let(:host2) do
|
|
23
|
+
Kanrisuru::Remote::Host.new(
|
|
24
|
+
host: 'ubuntu-host',
|
|
25
|
+
username: 'ubuntu',
|
|
26
|
+
keys: ['id_rsa']
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'adds host to a cluster' do
|
|
31
|
+
cluster = Kanrisuru::Remote::Cluster.new(host1)
|
|
32
|
+
expect(cluster.hosts.length).to eq(1)
|
|
33
|
+
expect(cluster.count).to eq(1)
|
|
34
|
+
expect(cluster[host1.host]).to eq(host1)
|
|
35
|
+
expect(cluster.hosts).to include(host1)
|
|
36
|
+
|
|
37
|
+
cluster << host2
|
|
38
|
+
expect(cluster.hosts.length).to eq(2)
|
|
39
|
+
expect(cluster.count).to eq(2)
|
|
40
|
+
expect(cluster[host2.host]).to eq(host2)
|
|
41
|
+
expect(cluster.hosts).to include(host1)
|
|
42
|
+
expect(cluster.hosts).to include(host2)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'removes a host from a cluster' do
|
|
46
|
+
cluster = Kanrisuru::Remote::Cluster.new(host1, host2)
|
|
47
|
+
expect(cluster.count).to eq(2)
|
|
48
|
+
|
|
49
|
+
cluster.delete(host2)
|
|
50
|
+
expect(cluster.count).to eq(1)
|
|
51
|
+
expect(cluster.hosts).not_to include(host2)
|
|
52
|
+
|
|
53
|
+
cluster.delete(host1.host)
|
|
54
|
+
expect(cluster.count).to eq(0)
|
|
55
|
+
expect(cluster.hosts).not_to include(host1)
|
|
56
|
+
end
|
|
57
|
+
end
|
data/spec/helper/stub_network.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
class StubNetwork
|
|
4
4
|
class << self
|
|
5
|
-
def stub!
|
|
5
|
+
def stub!(os_type = 'ubuntu')
|
|
6
6
|
unless Kanrisuru::Remote::Host.instance_methods(false).include?(:execute_with_retries_alias)
|
|
7
7
|
Kanrisuru::Remote::Host.class_eval do
|
|
8
8
|
alias_method :execute_with_retries_alias, :execute_with_retries
|
|
@@ -18,16 +18,16 @@ class StubNetwork
|
|
|
18
18
|
unless Kanrisuru::Remote::Os.instance_methods(false).include?(:initialize_alias)
|
|
19
19
|
Kanrisuru::Remote::Os.class_eval do
|
|
20
20
|
alias_method :initialize_alias, :initialize
|
|
21
|
-
|
|
21
|
+
define_method :initialize do |host|
|
|
22
22
|
@host = host
|
|
23
23
|
|
|
24
|
-
@kernel_name =
|
|
25
|
-
@kernel_version =
|
|
26
|
-
@operating_system =
|
|
27
|
-
@hardware_platform =
|
|
28
|
-
@processor =
|
|
29
|
-
@release =
|
|
30
|
-
@version =
|
|
24
|
+
@kernel_name = StubNetwork.send(:os_defaults, os_type, :kernel_name)
|
|
25
|
+
@kernel_version = StubNetwork.send(:os_defaults, os_type, :kernel_version)
|
|
26
|
+
@operating_system = StubNetwork.send(:os_defaults, os_type, :operating_system)
|
|
27
|
+
@hardware_platform = StubNetwork.send(:os_defaults, os_type, :hardware_platform)
|
|
28
|
+
@processor = StubNetwork.send(:os_defaults, os_type, :processor)
|
|
29
|
+
@release = StubNetwork.send(:os_defaults, os_type, :release)
|
|
30
|
+
@version = StubNetwork.send(:os_defaults, os_type, :version)
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -59,5 +59,36 @@ class StubNetwork
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def os_defaults(name, property)
|
|
65
|
+
name = name.to_sym
|
|
66
|
+
|
|
67
|
+
defaults = {
|
|
68
|
+
ubuntu: {
|
|
69
|
+
kernel_name: 'Linux',
|
|
70
|
+
kernel_version: '#91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021',
|
|
71
|
+
operating_system: 'GNU/Linux',
|
|
72
|
+
hardware_platform: 'x86_64',
|
|
73
|
+
processor: 'x86_64',
|
|
74
|
+
release: 'ubuntu',
|
|
75
|
+
version: 20.0
|
|
76
|
+
},
|
|
77
|
+
centos: {
|
|
78
|
+
kernel_name: 'Linux',
|
|
79
|
+
kernel_version: '"#1 SMP Wed Jul 21 11:57:15 UTC 2021"',
|
|
80
|
+
operating_system: 'GNU/Linux',
|
|
81
|
+
hardware_platform: 'x86_64',
|
|
82
|
+
processor: 'x86_64',
|
|
83
|
+
release: 'centos',
|
|
84
|
+
version: 7.0
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
defaults[name].key?(property) ?
|
|
90
|
+
defaults[name][property] : nil
|
|
91
|
+
end
|
|
92
|
+
|
|
62
93
|
end
|
|
63
94
|
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Kanrisuru::Remote::Cpu do
|
|
6
|
+
before(:all) do
|
|
7
|
+
StubNetwork.stub!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after(:all) do
|
|
11
|
+
StubNetwork.unstub!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:host1) do
|
|
15
|
+
Kanrisuru::Remote::Host.new(
|
|
16
|
+
host: 'localhost',
|
|
17
|
+
username: 'ubuntu',
|
|
18
|
+
keys: ['id_rsa']
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'responds to methods' do
|
|
23
|
+
cpu = Kanrisuru::Remote::Cpu.new(host1)
|
|
24
|
+
|
|
25
|
+
expect(cpu).to respond_to(:load_average)
|
|
26
|
+
expect(cpu).to respond_to(:load_average1)
|
|
27
|
+
expect(cpu).to respond_to(:load_average5)
|
|
28
|
+
expect(cpu).to respond_to(:load_average15)
|
|
29
|
+
expect(cpu).to respond_to(:sockets)
|
|
30
|
+
expect(cpu).to respond_to(:cores)
|
|
31
|
+
expect(cpu).to respond_to(:total)
|
|
32
|
+
expect(cpu).to respond_to(:count)
|
|
33
|
+
expect(cpu).to respond_to(:threads_per_core)
|
|
34
|
+
expect(cpu).to respond_to(:cores_per_socket)
|
|
35
|
+
expect(cpu).to respond_to(:numa_nodes)
|
|
36
|
+
expect(cpu).to respond_to(:vendor_id)
|
|
37
|
+
expect(cpu).to respond_to(:cpu_family)
|
|
38
|
+
expect(cpu).to respond_to(:model)
|
|
39
|
+
expect(cpu).to respond_to(:model_name)
|
|
40
|
+
expect(cpu).to respond_to(:byte_order)
|
|
41
|
+
expect(cpu).to respond_to(:address_sizes)
|
|
42
|
+
expect(cpu).to respond_to(:cpu_mhz)
|
|
43
|
+
expect(cpu).to respond_to(:cpu_max_mhz)
|
|
44
|
+
expect(cpu).to respond_to(:cpu_min_mhz)
|
|
45
|
+
expect(cpu).to respond_to(:hypervisor)
|
|
46
|
+
expect(cpu).to respond_to(:virtualization_type)
|
|
47
|
+
expect(cpu).to respond_to(:flags)
|
|
48
|
+
expect(cpu).to respond_to(:hyperthreading?)
|
|
49
|
+
end
|
|
50
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kanrisuru
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Mammina
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-11-
|
|
11
|
+
date: 2021-11-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -173,13 +173,16 @@ files:
|
|
|
173
173
|
- lib/kanrisuru/util/os_family.rb
|
|
174
174
|
- lib/kanrisuru/util/signal.rb
|
|
175
175
|
- lib/kanrisuru/version.rb
|
|
176
|
+
- spec/functional/core/apt_spec.rb
|
|
176
177
|
- spec/functional/core/find_spec.rb
|
|
177
178
|
- spec/functional/core/path_spec.rb
|
|
178
179
|
- spec/functional/core/socket_spec.rb
|
|
179
180
|
- spec/functional/core/stat_spec.rb
|
|
180
181
|
- spec/functional/core/stream_spec.rb
|
|
181
182
|
- spec/functional/core/transfer_spec.rb
|
|
183
|
+
- spec/functional/core/yum_spec.rb
|
|
182
184
|
- spec/functional/os_package_spec.rb
|
|
185
|
+
- spec/functional/remote/cluster_spec.rb
|
|
183
186
|
- spec/helper/expect_helpers.rb
|
|
184
187
|
- spec/helper/stub_network.rb
|
|
185
188
|
- spec/helper/test_hosts.rb
|
|
@@ -229,6 +232,7 @@ files:
|
|
|
229
232
|
- spec/unit/fstab_spec.rb
|
|
230
233
|
- spec/unit/kanrisuru_spec.rb
|
|
231
234
|
- spec/unit/mode_spec.rb
|
|
235
|
+
- spec/unit/remote/cpu_spec.rb
|
|
232
236
|
- spec/unit/template_spec.rb
|
|
233
237
|
- spec/unit/util_spec.rb
|
|
234
238
|
- spec/zz_reboot_spec.rb
|