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 +4 -4
- data/Rakefile +1 -1
- data/appveyor.yml +0 -1
- data/lib/specinfra/command/linux/base/inventory.rb +4 -0
- data/lib/specinfra/command/module/ss.rb +7 -6
- data/lib/specinfra/host_inventory/kernel.rb +15 -0
- data/lib/specinfra/version.rb +1 -1
- data/spec/command/linux/inventory_spec.rb +4 -0
- data/spec/command/module/ss_spec.rb +17 -6
- data/spec/host_inventory/linux/kernel_spec.rb +33 -0
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 69a45c26015f312d20024e8ac669efc4a45832eb
         | 
| 4 | 
            +
              data.tar.gz: 074bd53241292533b4f7f99218108e173d31fdfa
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 22bc007008faf15f07afe3d0d12dc34e61eba875b8e748b4616a78dc1da080cccd3cd56de9b08e4fcea7aa0628a912d5a2f19b7e1eb32321d8a68462c89daee6
         | 
| 7 | 
            +
              data.tar.gz: e5bca1a7d5f6c32275a69c8ee599cae8adb44da320612640ad42a55e2c05b9152a2ef4c086dc373a940aab837a55ff114eb42c77ca06bea81810953f6bbf7f4e
         | 
    
        data/Rakefile
    CHANGED
    
    
    
        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,13 +23,14 @@ module Specinfra | |
| 23 23 | 
             
                    end
         | 
| 24 24 |  | 
| 25 25 | 
             
                    def command_options(protocol)
         | 
| 26 | 
            -
                      case protocol
         | 
| 27 | 
            -
                      when  | 
| 28 | 
            -
             | 
| 29 | 
            -
                      when  | 
| 30 | 
            -
             | 
| 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 | 
            -
                        " | 
| 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
         | 
    
        data/lib/specinfra/version.rb
    CHANGED
    
    
| @@ -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 | 
            -
             | 
| 10 | 
            -
              it { expect(klass.check_is_listening('80', options={:protocol => ' | 
| 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 - | 
| 13 | 
            -
              it { expect(klass.check_is_listening('80', options={:local_address => '0.0.0.0', :protocol => ' | 
| 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 - | 
| 16 | 
            -
              it { expect(klass.check_is_listening('80', options={:local_address => '1.2.3.4', :protocol => ' | 
| 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. | 
| 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- | 
| 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: 
         |