specinfra 2.43.3 → 2.43.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/specinfra/backend/ssh.rb +1 -1
- data/lib/specinfra/command/linux/base/inventory.rb +5 -0
- data/lib/specinfra/host_inventory.rb +1 -0
- data/lib/specinfra/host_inventory/block_device.rb +35 -0
- data/lib/specinfra/version.rb +1 -1
- data/spec/command/linux/inventory_spec.rb +5 -0
- data/spec/host_inventory/linux/block_device_spec.rb +46 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 703f43204811bef2b8d6a652f6bff4884af76f35
|
4
|
+
data.tar.gz: 25566911bfc3b5053e8de83f5dfa915974c9d7d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d25a4b8f3518d8fb00bea86c135c0205a3921eebcc9fafe687eca9dd036a276a6c49265a5df849377ab78d6b36333576261c5678cfb42454a2f75df22c3f7687
|
7
|
+
data.tar.gz: a6ef7fca60dd9e51a3085ec50b3fa5b24e9f09c503a4258074c9b57fb9efb147099ae6ae0bf03d10b17d80629ba4b8f5e90d90cf8dc567ca84c53799cbe51261
|
@@ -121,7 +121,7 @@ module Specinfra
|
|
121
121
|
abort "FAILED: couldn't execute command (ssh.channel.exec)" if !success
|
122
122
|
channel.on_data do |ch, data|
|
123
123
|
if data.match retry_prompt
|
124
|
-
abort
|
124
|
+
abort "Wrong sudo password! Please confirm your password on #{get_config(:host)}."
|
125
125
|
elsif data.match /^#{prompt}/
|
126
126
|
channel.send_data "#{get_config(:sudo_password)}\n"
|
127
127
|
else
|
@@ -27,5 +27,10 @@ class Specinfra::Command::Linux::Base::Inventory < Specinfra::Command::Base::Inv
|
|
27
27
|
def get_kernel
|
28
28
|
'uname -s -r'
|
29
29
|
end
|
30
|
+
|
31
|
+
def get_block_device
|
32
|
+
block_device_dirs = '/sys/block/*/{size,removable,device/{model,rev,state,timeout,vendor},queue/rotational}'
|
33
|
+
"for f in $(ls #{block_device_dirs}); do echo -e \"${f}\t$(cat ${f})\"; done"
|
34
|
+
end
|
30
35
|
end
|
31
36
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Specinfra
|
2
|
+
class HostInventory
|
3
|
+
class BlockDevice < Base
|
4
|
+
# examples:
|
5
|
+
# /sys/block/sda/size 10000
|
6
|
+
# /sys/block/sr0/device/model CD-ROM
|
7
|
+
BLOCK_DEVICE_REGEX = %r|\A/sys/block/(\w+)/(\w+)(?:/(\w+))?\t(.+)\z|
|
8
|
+
|
9
|
+
def get
|
10
|
+
cmd = backend.command.get(:get_inventory_block_device)
|
11
|
+
ret = backend.run_command(cmd)
|
12
|
+
if ret.exit_status == 0
|
13
|
+
parse(ret.stdout)
|
14
|
+
else
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
def parse(ret)
|
19
|
+
block_device = {}
|
20
|
+
ret.each_line do |line|
|
21
|
+
line.strip!
|
22
|
+
if m = line.match(BLOCK_DEVICE_REGEX)
|
23
|
+
device = m[1].to_s
|
24
|
+
check = m[3].nil? ? m[2].to_s : m[3].to_s
|
25
|
+
value = m[4].to_s
|
26
|
+
|
27
|
+
block_device[device] = {} if block_device[device].nil?
|
28
|
+
block_device[device][check] = value
|
29
|
+
end
|
30
|
+
end
|
31
|
+
block_device
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/specinfra/version.rb
CHANGED
@@ -13,3 +13,8 @@ end
|
|
13
13
|
describe get_command(:get_inventory_kernel) do
|
14
14
|
it { should eq 'uname -s -r' }
|
15
15
|
end
|
16
|
+
|
17
|
+
describe get_command(:get_inventory_block_device) do
|
18
|
+
block_device_dirs = '/sys/block/*/{size,removable,device/{model,rev,state,timeout,vendor},queue/rotational}'
|
19
|
+
it { should eq "for f in $(ls #{block_device_dirs}); do echo -e \"${f}\t$(cat ${f})\"; done" }
|
20
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
## Output from:
|
4
|
+
#
|
5
|
+
# for f in $(ls /sys/block/*/{size,removable,device/{model,rev,state,timeout,vendor},queue/rotational}); do
|
6
|
+
# echo -e "${f}\t$(cat ${f})"
|
7
|
+
# done
|
8
|
+
str = <<-EOH
|
9
|
+
/sys/block/loop0/queue/rotational 1
|
10
|
+
/sys/block/loop0/removable 0
|
11
|
+
/sys/block/loop0/size 0
|
12
|
+
/sys/block/sda/device/model HARDDISK
|
13
|
+
/sys/block/sda/device/rev 1.0
|
14
|
+
/sys/block/sda/device/state running
|
15
|
+
/sys/block/sda/device/timeout 30
|
16
|
+
/sys/block/sda/device/vendor ATA
|
17
|
+
/sys/block/sda/queue/rotational 1
|
18
|
+
/sys/block/sda/removable 0
|
19
|
+
/sys/block/sda/size 40960000
|
20
|
+
EOH
|
21
|
+
|
22
|
+
describe Specinfra::HostInventory::BlockDevice do
|
23
|
+
let(:host_inventory) { nil }
|
24
|
+
describe 'Example of CentOS 6.6 Kernel version 2.6.32-504.23.4.el6.i686' do
|
25
|
+
ret = Specinfra::HostInventory::BlockDevice.new(host_inventory).parse(str)
|
26
|
+
example "/sys/block/loop0" do
|
27
|
+
expect(ret["loop0"]).to include(
|
28
|
+
"rotational" => "1",
|
29
|
+
"removable" => "0",
|
30
|
+
"size" => "0"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
example "/sys/block/sda" do
|
34
|
+
expect(ret["sda"]).to include(
|
35
|
+
"model" => "HARDDISK",
|
36
|
+
"rev" => "1.0",
|
37
|
+
"state" => "running",
|
38
|
+
"timeout" => "30",
|
39
|
+
"vendor" => "ATA",
|
40
|
+
"rotational" => "1",
|
41
|
+
"removable" => "0",
|
42
|
+
"size" => "40960000"
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.43.
|
4
|
+
version: 2.43.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-scp
|
@@ -437,6 +437,7 @@ files:
|
|
437
437
|
- lib/specinfra/helper/set.rb
|
438
438
|
- lib/specinfra/host_inventory.rb
|
439
439
|
- lib/specinfra/host_inventory/base.rb
|
440
|
+
- lib/specinfra/host_inventory/block_device.rb
|
440
441
|
- lib/specinfra/host_inventory/cpu.rb
|
441
442
|
- lib/specinfra/host_inventory/domain.rb
|
442
443
|
- lib/specinfra/host_inventory/ec2.rb
|
@@ -517,6 +518,7 @@ files:
|
|
517
518
|
- spec/host_inventory/aix/filesystem_spec.rb
|
518
519
|
- spec/host_inventory/darwin/filesystem_spec.rb
|
519
520
|
- spec/host_inventory/freebsd/filesystem_spec.rb
|
521
|
+
- spec/host_inventory/linux/block_device_spec.rb
|
520
522
|
- spec/host_inventory/linux/cpu_spec.rb
|
521
523
|
- spec/host_inventory/linux/filesystem_spec.rb
|
522
524
|
- spec/host_inventory/linux/kernel_spec.rb
|
@@ -617,6 +619,7 @@ test_files:
|
|
617
619
|
- spec/host_inventory/aix/filesystem_spec.rb
|
618
620
|
- spec/host_inventory/darwin/filesystem_spec.rb
|
619
621
|
- spec/host_inventory/freebsd/filesystem_spec.rb
|
622
|
+
- spec/host_inventory/linux/block_device_spec.rb
|
620
623
|
- spec/host_inventory/linux/cpu_spec.rb
|
621
624
|
- spec/host_inventory/linux/filesystem_spec.rb
|
622
625
|
- spec/host_inventory/linux/kernel_spec.rb
|
@@ -626,3 +629,4 @@ test_files:
|
|
626
629
|
- spec/host_inventory/openbsd/filesystem_spec.rb
|
627
630
|
- spec/host_inventory/solaris/filesystem_spec.rb
|
628
631
|
- spec/spec_helper.rb
|
632
|
+
has_rdoc:
|