Sha256: bfefe8dd95f71634a561920fde06db0fdc311db24939f1277eaf4b118bc24682

Contents?: true

Size: 1.69 KB

Versions: 5

Compression:

Stored size: 1.69 KB

Contents

module RemoteUnix
  module Common
    def set_platform
      @platform = {}
      nav_path = [
                   {:execute => "uname -a",
                    :expected_output => /linux/i, :timeout => 1}
                 ]
  
      uname = @ssh.navigate(nav_path).last.grep(/linux/i).first
      uname_split = uname.split(' ')[2].split(".").last
  
      # RHEL/CentOS
      if uname_split =~ /el[0-5]/
        @platform[:distro] = 'RH'
        @platform[:prompt] = "]#"
        @platform[:iscsi_packages] = ['iscsi-initiator-utils', 'sg3_utils.i386']
        @platform[:install_iscsi_cmd] = "yum install -y"
      # debian based
      elsif uname =~ /ubuntu/i
        @platform[:distro] = 'DEB'
        @platform[:prompt] = "$"
        @platform[:iscsi_packages] = ['open-iscsi', 'iscsitarget']
        @platform[:install_iscsi_cmd] = "sudo apt-get install -y"
        
      # TODO: check for /etc/redhat-release
      # can't detec for SL as custom kernel without RH in uname -a
      else
        @platform[:distro] = 'DEB'
        @platform[:prompt] = "#"
        @platform[:iscsi_packages] = ['open-iscsi', 'iscsitarget']
        @platform[:install_iscsi_cmd] = "apt-get install -y"
        
        nav_path = [
             {:execute => "if [ -f /etc/redhat-release ] ; then echo \"RH\"; else echo \"DEB\"; fi",
              :timeout => 2}
           ]
  
        version = @ssh.navigate(nav_path).last.grep(/linux/i).first
 
        if version =~ /RH/
          @platform[:distro] = 'RH'
        elsif version =~ /DEB/
          @platform[:distro] = 'DEB'
        end
      end
      @expected_prompt = Regexp.escape(@platform[:prompt].to_s)
    end
  
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
qa_robusta-0.1.9 remote_unix/lib/common.rb
qa_robusta-0.1.8 remote_unix/lib/common.rb
qa_robusta-0.1.5 remote_unix/lib/common.rb
qa_robusta-0.1.4 remote_unix/lib/common.rb
qa_robusta-0.1.3 remote_unix/lib/common.rb