specinfra 2.23.0 → 2.24.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/lib/specinfra/backend/base.rb +4 -0
- data/lib/specinfra/backend/ssh.rb +1 -1
- data/lib/specinfra/ec2_metadata.rb +6 -4
- data/lib/specinfra/host_inventory.rb +27 -21
- data/lib/specinfra/host_inventory/base.rb +14 -0
- data/lib/specinfra/host_inventory/cpu.rb +5 -5
- data/lib/specinfra/host_inventory/domain.rb +4 -4
- data/lib/specinfra/host_inventory/ec2.rb +3 -3
- data/lib/specinfra/host_inventory/filesystem.rb +4 -4
- data/lib/specinfra/host_inventory/fqdn.rb +4 -4
- data/lib/specinfra/host_inventory/hostname.rb +4 -4
- data/lib/specinfra/host_inventory/memory.rb +4 -4
- data/lib/specinfra/host_inventory/platform.rb +3 -3
- data/lib/specinfra/host_inventory/platform_version.rb +3 -3
- data/lib/specinfra/version.rb +1 -1
- data/spec/host_inventory/cpu_spec.rb +2 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36304d05e8dc32b0aca739dc27b5794b4ad98d33
|
4
|
+
data.tar.gz: 9df5c5f46c9eb95cb2127ca6afd2fac5df8acda8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3e754f052c2814056e1f0eb1a461454376df60abbf48a5117f88ae6a0070a7385adb352325d85a78de1e8c710e5abe6015ff248790dbfdb938a2e7060b99999
|
7
|
+
data.tar.gz: 508181175062039ba2c075706fb22b8de1530fb17019f52d2562f6f24a412a523fee756ff43e155b5034f181abe11f143bd967d678cb1e4cc21c0197b3a455a9
|
@@ -90,7 +90,7 @@ module Specinfra::Backend
|
|
90
90
|
tmp = File.join('/tmp', File.basename(to))
|
91
91
|
scp = get_config(:scp)
|
92
92
|
scp.upload!(from, tmp, opt)
|
93
|
-
run_command(
|
93
|
+
run_command(command.get(:move_file, tmp, to))
|
94
94
|
end
|
95
95
|
|
96
96
|
def ssh_exec!(command)
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
module Specinfra
|
3
3
|
class Ec2Metadata
|
4
|
-
def initialize
|
4
|
+
def initialize(host_inventory)
|
5
|
+
@host_inventory = host_inventory
|
6
|
+
|
5
7
|
@base_uri = 'http://169.254.169.254/latest/meta-data/'
|
6
8
|
@metadata = {}
|
7
9
|
end
|
@@ -16,7 +18,7 @@ module Specinfra
|
|
16
18
|
begin
|
17
19
|
require "specinfra/ec2_metadata/#{key}"
|
18
20
|
inventory_class = Specinfra::Ec2Metadata.const_get(key.to_s.to_camel_case)
|
19
|
-
@metadata[key] = inventory_class.get
|
21
|
+
@metadata[key] = inventory_class.new(@host_inventory).get
|
20
22
|
rescue LoadError
|
21
23
|
@metadata[key] = nil
|
22
24
|
end
|
@@ -59,7 +61,7 @@ module Specinfra
|
|
59
61
|
def get_metadata(path='')
|
60
62
|
metadata = {}
|
61
63
|
|
62
|
-
keys =
|
64
|
+
keys = @host_inventory.backend.run_command("curl -s #{@base_uri}#{path}").stdout.split("\n")
|
63
65
|
|
64
66
|
keys.each do |key|
|
65
67
|
if key =~ %r{/$}
|
@@ -79,7 +81,7 @@ module Specinfra
|
|
79
81
|
end
|
80
82
|
|
81
83
|
def get_endpoint(path)
|
82
|
-
ret =
|
84
|
+
ret = @host_inventory.backend.run_command("curl -s #{@base_uri}#{path}")
|
83
85
|
if ret.success?
|
84
86
|
ret.stdout
|
85
87
|
else
|
@@ -1,11 +1,29 @@
|
|
1
1
|
module Specinfra
|
2
2
|
class HostInventory
|
3
|
-
|
3
|
+
KEYS = %w{
|
4
|
+
memory
|
5
|
+
ec2
|
6
|
+
hostname
|
7
|
+
domain
|
8
|
+
fqdn
|
9
|
+
platform
|
10
|
+
platform_version
|
11
|
+
filesystem
|
12
|
+
cpu
|
13
|
+
}
|
14
|
+
|
4
15
|
include Enumerable
|
5
16
|
|
6
|
-
|
17
|
+
attr_reader :backend
|
18
|
+
|
19
|
+
def self.instance
|
7
20
|
property[:host_inventory] ||= {}
|
8
|
-
|
21
|
+
self.new(Specinfra.backend, property[:host_inventory])
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(backend, inventory = {})
|
25
|
+
@backend = backend
|
26
|
+
@inventory = inventory
|
9
27
|
end
|
10
28
|
|
11
29
|
def [](key)
|
@@ -13,7 +31,7 @@ module Specinfra
|
|
13
31
|
if @inventory[key.to_sym].empty?
|
14
32
|
begin
|
15
33
|
inventory_class = Specinfra::HostInventory.const_get(key.to_s.to_camel_case)
|
16
|
-
@inventory[key.to_sym] = inventory_class.get
|
34
|
+
@inventory[key.to_sym] = inventory_class.new(self).get
|
17
35
|
rescue
|
18
36
|
@inventory[key.to_sym] = nil
|
19
37
|
end
|
@@ -22,39 +40,27 @@ module Specinfra
|
|
22
40
|
end
|
23
41
|
|
24
42
|
def each
|
25
|
-
|
43
|
+
KEYS.each do |k|
|
26
44
|
yield k, self[k]
|
27
45
|
end
|
28
46
|
end
|
29
47
|
|
30
48
|
def each_key
|
31
|
-
|
49
|
+
KEYS.each do |k|
|
32
50
|
yield k
|
33
51
|
end
|
34
52
|
end
|
35
53
|
|
36
54
|
def each_value
|
37
|
-
|
55
|
+
KEYS.each do |k|
|
38
56
|
yield self[k]
|
39
57
|
end
|
40
58
|
end
|
41
59
|
|
42
|
-
def keys
|
43
|
-
%w{
|
44
|
-
memory
|
45
|
-
ec2
|
46
|
-
hostname
|
47
|
-
domain
|
48
|
-
fqdn
|
49
|
-
platform
|
50
|
-
platform_version
|
51
|
-
filesystem
|
52
|
-
cpu
|
53
|
-
}
|
54
|
-
end
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
58
|
-
|
63
|
+
require "specinfra/host_inventory/base"
|
64
|
+
Specinfra::HostInventory::KEYS.each do |k|
|
59
65
|
require "specinfra/host_inventory/#{k}"
|
60
66
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Specinfra
|
2
2
|
class HostInventory
|
3
|
-
class Cpu
|
4
|
-
def
|
5
|
-
cmd =
|
6
|
-
ret =
|
3
|
+
class Cpu < Base
|
4
|
+
def get
|
5
|
+
cmd = backend.command.get(:get_inventory_cpu)
|
6
|
+
ret = backend.run_command(cmd).stdout
|
7
7
|
parse(ret)
|
8
8
|
end
|
9
|
-
def
|
9
|
+
def parse(cmd_ret)
|
10
10
|
cpuinfo = {}
|
11
11
|
cpus = cmd_ret.split(/[^^]processor/)
|
12
12
|
cpuinfo['total'] = cpus.length.to_s
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Specinfra
|
2
2
|
class HostInventory
|
3
|
-
class Domain
|
4
|
-
def
|
5
|
-
cmd =
|
6
|
-
|
3
|
+
class Domain < Base
|
4
|
+
def get
|
5
|
+
cmd = backend.command.get(:get_inventory_domain)
|
6
|
+
backend.run_command(cmd).stdout.strip
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Specinfra
|
2
2
|
class HostInventory
|
3
|
-
class Filesystem
|
4
|
-
def
|
5
|
-
cmd =
|
3
|
+
class Filesystem < Base
|
4
|
+
def get
|
5
|
+
cmd = backend.command.get(:get_inventory_filesystem)
|
6
6
|
filesystem = {}
|
7
|
-
|
7
|
+
backend.run_command(cmd).stdout.lines do |line|
|
8
8
|
next if line =~ /^Filesystem\s+/
|
9
9
|
if line =~ /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
10
10
|
device = $1
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Specinfra
|
2
2
|
class HostInventory
|
3
|
-
class Fqdn
|
4
|
-
def
|
5
|
-
cmd =
|
6
|
-
|
3
|
+
class Fqdn < Base
|
4
|
+
def get
|
5
|
+
cmd = backend.command.get(:get_inventory_fqdn)
|
6
|
+
backend.run_command(cmd).stdout.strip
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Specinfra
|
2
2
|
class HostInventory
|
3
|
-
class Hostname
|
4
|
-
def
|
5
|
-
cmd =
|
6
|
-
|
3
|
+
class Hostname < Base
|
4
|
+
def get
|
5
|
+
cmd = backend.command.get(:get_inventory_hostname)
|
6
|
+
backend.run_command(cmd).stdout.strip
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Specinfra
|
2
2
|
class HostInventory
|
3
|
-
class Memory
|
4
|
-
def
|
5
|
-
cmd =
|
6
|
-
ret =
|
3
|
+
class Memory < Base
|
4
|
+
def get
|
5
|
+
cmd = backend.command.get(:get_inventory_memory)
|
6
|
+
ret = backend.run_command(cmd).stdout
|
7
7
|
memory = { 'swap' => {} }
|
8
8
|
ret.each_line do |line|
|
9
9
|
case line
|
data/lib/specinfra/version.rb
CHANGED
@@ -55,8 +55,9 @@ power management:
|
|
55
55
|
EOH
|
56
56
|
|
57
57
|
describe Specinfra::HostInventory::Cpu do
|
58
|
+
let(:host_inventory) { nil }
|
58
59
|
describe 'Example of Ubuntu 14.04.1 LTS Kernel version 3.13.11' do
|
59
|
-
ret = Specinfra::HostInventory::Cpu.parse(str)
|
60
|
+
ret = Specinfra::HostInventory::Cpu.new(host_inventory).parse(str)
|
60
61
|
example do
|
61
62
|
expect(ret["0"]).to include(
|
62
63
|
"vendor_id" => "GenuineIntel",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
@@ -356,6 +356,7 @@ files:
|
|
356
356
|
- lib/specinfra/helper/properties.rb
|
357
357
|
- lib/specinfra/helper/set.rb
|
358
358
|
- lib/specinfra/host_inventory.rb
|
359
|
+
- lib/specinfra/host_inventory/base.rb
|
359
360
|
- lib/specinfra/host_inventory/cpu.rb
|
360
361
|
- lib/specinfra/host_inventory/domain.rb
|
361
362
|
- lib/specinfra/host_inventory/ec2.rb
|