Sha256: 689df1681077505c3e6b0a107d0718f7d20213587d8202763f7295d475ce77cb

Contents?: true

Size: 1.22 KB

Versions: 28

Compression:

Stored size: 1.22 KB

Contents

module Serverspec::Type
  class Service < Base
    def enabled?(level)
      if level
        @runner.check_service_is_enabled(@name, level)
      else
        @runner.check_service_is_enabled(@name)
      end
    end

    def installed?(name, version)
      @runner.check_service_is_installed(@name)
    end

    def has_start_mode?(mode)
      @runner.check_service_has_start_mode(@name, mode)
    end

    def running?(under)
      if under
        check_method = "check_service_is_running_under_#{under}".to_sym
        @runner.send(check_method, @name)
      else
        @runner.check_service_is_running(@name)
      end
    end

    def monitored_by?(monitor)
      check_method = "check_service_is_monitored_by_#{monitor}".to_sym
      res = @runner.send(check_method, @name)
    end

    def has_property?(property)
      @runner.check_service_has_property(@name, property)
    end

    def property
      get_property if @property.nil?
      @property
    end

    private
    def get_property
      @property = {}
      props = @runner.get_service_property(@name).stdout
      props.split(/\n/).each do |line|
        property, _type, *value = line.split(/\s+/)
        @property[property] = value.join(' ')
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
serverspec-ruby19-2.24.3 lib/serverspec/type/service.rb
serverspec-2.29.2 lib/serverspec/type/service.rb
serverspec-2.29.1 lib/serverspec/type/service.rb
serverspec-2.29.0 lib/serverspec/type/service.rb
serverspec-2.28.0 lib/serverspec/type/service.rb
serverspec-2.27.0 lib/serverspec/type/service.rb
serverspec-2.26.0 lib/serverspec/type/service.rb
serverspec-2.25.0 lib/serverspec/type/service.rb
serverspec-2.24.3 lib/serverspec/type/service.rb
serverspec-2.24.2 lib/serverspec/type/service.rb
serverspec-2.24.1 lib/serverspec/type/service.rb
serverspec-2.24.0 lib/serverspec/type/service.rb
serverspec-2.23.1 lib/serverspec/type/service.rb
serverspec-2.23.0 lib/serverspec/type/service.rb
serverspec-2.22.0 lib/serverspec/type/service.rb
serverspec-2.21.1 lib/serverspec/type/service.rb
serverspec-2.21.0 lib/serverspec/type/service.rb
serverspec-2.20.0 lib/serverspec/type/service.rb
serverspec-2.19.0 lib/serverspec/type/service.rb
serverspec-2.18.0 lib/serverspec/type/service.rb