specinfra 2.39.1 → 2.40.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c455c30dee44a48bc7b869cc369e7885963a5fce
4
- data.tar.gz: 7c866f042201d3844a8fb1d4eb72eed3e5de2356
3
+ metadata.gz: 69a45c26015f312d20024e8ac669efc4a45832eb
4
+ data.tar.gz: 074bd53241292533b4f7f99218108e173d31fdfa
5
5
  SHA512:
6
- metadata.gz: c9443ecf7e5f2548c8d62b197a0f7a396bce804989fb5505be520c180a1810b31ed5ec8e5b79b3f5641f7563312b83417e2c5f4e5a49b9629c8c276a340cfec5
7
- data.tar.gz: f243f37ed9de43d32db9e31e86ef85f38120345ff4824e449d86315c61d21c537c4a1ee032c84875710786a8926906a13bdbddcdaa817509a4144f4a72335d21
6
+ metadata.gz: 22bc007008faf15f07afe3d0d12dc34e61eba875b8e748b4616a78dc1da080cccd3cd56de9b08e4fcea7aa0628a912d5a2f19b7e1eb32321d8a68462c89daee6
7
+ data.tar.gz: e5bca1a7d5f6c32275a69c8ee599cae8adb44da320612640ad42a55e2c05b9152a2ef4c086dc373a940aab837a55ff114eb42c77ca06bea81810953f6bbf7f4e
data/Rakefile CHANGED
@@ -37,7 +37,7 @@ if defined?(RSpec)
37
37
  end
38
38
 
39
39
  RSpec::Core::RakeTask.new(:host_inventory) do |t|
40
- t.pattern = "spec/host_inventory/*_spec.rb"
40
+ t.pattern = "spec/host_inventory/**/*_spec.rb"
41
41
  end
42
42
  end
43
43
  end
data/appveyor.yml CHANGED
@@ -33,7 +33,6 @@ cache:
33
33
  install:
34
34
  - git submodule update --init --recursive
35
35
  - ps: Enable-PSRemoting -Force
36
- - ps: Set-ExecutionPolicy RemoteSigned
37
36
  - winrm quickconfig -q
38
37
  - winrm set winrm/config/client @{TrustedHosts="*"}
39
38
  - winrm set winrm/config/client/auth @{Basic="true"}
@@ -23,5 +23,9 @@ class Specinfra::Command::Linux::Base::Inventory < Specinfra::Command::Base::Inv
23
23
  def get_filesystem
24
24
  'df -P'
25
25
  end
26
+
27
+ def get_kernel
28
+ 'uname -s -r'
29
+ end
26
30
  end
27
31
  end
@@ -23,13 +23,14 @@ module Specinfra
23
23
  end
24
24
 
25
25
  def command_options(protocol)
26
- case protocol
27
- when /\Atcp/
28
- "-tnl"
29
- when /\Audp/
30
- "-unl"
26
+ case protocol.to_s
27
+ when 'tcp' then "-tnl4"
28
+ when 'tcp6' then "-tnl6"
29
+ when 'udp' then "-unl4"
30
+ when 'udp6' then "-unl6"
31
+ when '' then "-tunl"
31
32
  else
32
- "-tunl"
33
+ raise ArgumentError, "Unknown protocol [#{protocol}]"
33
34
  end
34
35
  end
35
36
  end
@@ -5,8 +5,23 @@ module Specinfra
5
5
  kernel = {}
6
6
  kernel['machine'] = backend.os_info[:arch]
7
7
 
8
+ cmd = backend.command.get(:get_inventory_kernel)
9
+ ret = backend.run_command(cmd)
10
+ if ret.exit_status == 0
11
+ kernel = kernel.merge(parse_uname(ret.stdout))
12
+ end
8
13
  kernel
9
14
  end
15
+
16
+ def parse_uname(ret)
17
+ match = ret.match(/^(\w+) (((\d+\.\d+)\.\d+).*)$/)
18
+ if match
19
+ name, release, version, major = match.captures
20
+ Hash['name', name, "release", release, "version", version, "version_major", major]
21
+ else
22
+ nil
23
+ end
24
+ end
10
25
  end
11
26
  end
12
27
  end
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.39.1"
2
+ VERSION = "2.40.0"
3
3
  end
@@ -9,3 +9,7 @@ end
9
9
  describe get_command(:get_inventory_cpu) do
10
10
  it { should eq 'cat /proc/cpuinfo' }
11
11
  end
12
+
13
+ describe get_command(:get_inventory_kernel) do
14
+ it { should eq 'uname -s -r' }
15
+ end
@@ -6,12 +6,23 @@ describe Specinfra::Command::Module::Ss do
6
6
  end
7
7
  let(:klass) { Specinfra::Command::Module::Ss::Test }
8
8
  it { expect(klass.check_is_listening('80')).to eq 'ss -tunl | grep -- :80\ ' }
9
- it { expect(klass.check_is_listening('80', options={:protocol => 'tcp'})).to eq 'ss -tnl | grep -- :80\ ' }
10
- it { expect(klass.check_is_listening('80', options={:protocol => 'udp'})).to eq 'ss -unl | grep -- :80\ ' }
9
+
10
+ it { expect(klass.check_is_listening('80', options={:protocol => 'tcp'})).to eq 'ss -tnl4 | grep -- :80\ ' }
11
+ it { expect(klass.check_is_listening('80', options={:protocol => 'tcp6'})).to eq 'ss -tnl6 | grep -- :80\ ' }
12
+ it { expect(klass.check_is_listening('80', options={:protocol => 'udp'})).to eq 'ss -unl4 | grep -- :80\ ' }
13
+ it { expect(klass.check_is_listening('80', options={:protocol => 'udp6'})).to eq 'ss -unl6 | grep -- :80\ ' }
14
+
11
15
  it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0'})).to eq 'ss -tunl | grep -- \ \*:80\ ' }
12
- it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'tcp'})).to eq 'ss -tnl | grep -- \ \*:80\ ' }
13
- it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'udp'})).to eq 'ss -unl | grep -- \ \*:80\ ' }
16
+ it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'tcp'})).to eq 'ss -tnl4 | grep -- \ \*:80\ ' }
17
+ it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'tcp6'})).to eq 'ss -tnl6 | grep -- \ \*:80\ ' }
18
+ it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'udp'})).to eq 'ss -unl4 | grep -- \ \*:80\ ' }
19
+ it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => 'udp6'})).to eq 'ss -unl6 | grep -- \ \*:80\ ' }
20
+
14
21
  it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4'})).to eq 'ss -tunl | grep -- \ 1.2.3.4:80\ ' }
15
- it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'tcp'})).to eq 'ss -tnl | grep -- \ 1.2.3.4:80\ ' }
16
- it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'udp'})).to eq 'ss -unl | grep -- \ 1.2.3.4:80\ ' }
22
+ it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'tcp'})).to eq 'ss -tnl4 | grep -- \ 1.2.3.4:80\ ' }
23
+ it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'tcp6'})).to eq 'ss -tnl6 | grep -- \ 1.2.3.4:80\ ' }
24
+ it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'udp'})).to eq 'ss -unl4 | grep -- \ 1.2.3.4:80\ ' }
25
+ it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => 'udp6'})).to eq 'ss -unl6 | grep -- \ 1.2.3.4:80\ ' }
26
+
27
+ it { expect{klass.check_is_listening('80', options={:protocol => 'bad_proto'})}.to raise_error(ArgumentError, 'Unknown protocol [bad_proto]') }
17
28
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Specinfra::HostInventory::Kernel do
4
+ describe 'Example of CentOS 6.6 Kernel version 2.6.32-504.30.3.el6.x86_64' do
5
+ str = 'Linux 2.6.32-504.30.3.el6.x86_64'
6
+
7
+ let(:host_inventory) { nil }
8
+ ret = Specinfra::HostInventory::Kernel.new(host_inventory).parse_uname(str)
9
+ example "name" do
10
+ expect(ret["name"]).to eq("Linux")
11
+ end
12
+ example "release" do
13
+ expect(ret["release"]).to eq("2.6.32-504.30.3.el6.x86_64")
14
+ end
15
+ example "version" do
16
+ expect(ret["version"]).to eq("2.6.32")
17
+ end
18
+ example "major" do
19
+ expect(ret["version_major"]).to eq("2.6")
20
+ end
21
+ end
22
+
23
+ describe 'Example of unparseable output' do
24
+ str = 'unparseable output'
25
+
26
+ let(:host_inventory) { nil }
27
+ ret = Specinfra::HostInventory::Kernel.new(host_inventory).parse_uname(str)
28
+
29
+ example 'is nil' do
30
+ expect(ret).to be(nil)
31
+ end
32
+ end
33
+ 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.39.1
4
+ version: 2.40.0
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-07-29 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp
@@ -496,6 +496,7 @@ files:
496
496
  - spec/host_inventory/freebsd/filesystem_spec.rb
497
497
  - spec/host_inventory/linux/cpu_spec.rb
498
498
  - spec/host_inventory/linux/filesystem_spec.rb
499
+ - spec/host_inventory/linux/kernel_spec.rb
499
500
  - spec/host_inventory/linux/memory_spec.rb
500
501
  - spec/host_inventory/linux/virtualization_docker_spec.rb
501
502
  - spec/host_inventory/linux/virtualization_kvm_spec.rb
@@ -585,10 +586,10 @@ test_files:
585
586
  - spec/host_inventory/freebsd/filesystem_spec.rb
586
587
  - spec/host_inventory/linux/cpu_spec.rb
587
588
  - spec/host_inventory/linux/filesystem_spec.rb
589
+ - spec/host_inventory/linux/kernel_spec.rb
588
590
  - spec/host_inventory/linux/memory_spec.rb
589
591
  - spec/host_inventory/linux/virtualization_docker_spec.rb
590
592
  - spec/host_inventory/linux/virtualization_kvm_spec.rb
591
593
  - spec/host_inventory/openbsd/filesystem_spec.rb
592
594
  - spec/host_inventory/solaris/filesystem_spec.rb
593
595
  - spec/spec_helper.rb
594
- has_rdoc: