Class: Windows::Host

Inherits:
Unix::Host show all
Includes:
Exec, File, Group, Pkg, User
Defined in:
lib/beaker/host/windows.rb

Overview

A windows host with cygwin tools installed

Direct Known Subclasses

PSWindows::Host

Constant Summary

Constants included from Exec

Exec::ABS_CMD, Exec::CMD

Constants inherited from Beaker::Host

Beaker::Host::SELECT_TIMEOUT

Instance Attribute Summary collapse

Attributes included from Beaker::CommandFactory

#assertions

Attributes inherited from Beaker::Host

#host_hash, #logger, #name, #options

Instance Method Summary collapse

Methods included from Pkg

#check_for_command, #check_for_package, #determine_if_x86_64, #install_package, #uninstall_package

Methods included from Beaker::CommandFactory

#execute, #fail_test

Methods included from Exec

#append_commands, #cygwin_installed?, #echo, #get_ip, #mkdir_p, #mv, #path, #ping, #prepend_commands, #reboot, #selinux_enabled?, #ssh_permit_user_environment, #ssh_service_restart, #touch

Methods included from File

#chgrp, #chmod, #chown, #file_exist?, #ls_ld, #path_split, #scp_path, #system_temp_path, #tmpdir, #tmpfile

Methods included from Group

#group_absent, #group_get, #group_gid, #group_list, #group_present

Methods included from User

#user_absent, #user_get, #user_list, #user_present

Methods inherited from Unix::Host

#skip_set_env?, #validate_setup

Methods included from Unix::Pkg

#check_for_command, #check_for_package, #determine_if_x86_64, #extract_rpm_proxy_options, #install_local_package, #install_package, #install_package_with_rpm, #pkg_initialize, #solaris_install_local_package, #uncompress_local_tarball, #uninstall_package, #update_apt_if_needed, #update_pacman_if_needed, #upgrade_package

Methods included from Unix::Exec

#add_env_var, #append_commands, #clear_env_var, #delete_env_var, #echo, #enable_remote_rsyslog, #environment_string, #environment_variable_string_pair_array, #get_env_var, #get_ip, #mirror_env_to_profile_d, #mkdir_p, #modified_at, #mv, #path, #ping, #prepend_commands, #reboot, #rm_rf, #selinux_enabled?, #ssh_permit_user_environment, #ssh_service_restart, #ssh_set_user_environment, #touch, #which

Methods included from Unix::File

#cat, #chgrp, #chmod, #chown, #file_exist?, #ls_ld, #noask_file_text, #package_config_dir, #path_split, #repo_filename, #repo_type, #scp_path, #system_temp_path, #tmpdir, #tmpfile

Methods included from Unix::Group

#group_absent, #group_get, #group_gid, #group_list, #group_present

Methods included from Unix::User

#user_absent, #user_get, #user_list, #user_present

Methods inherited from Beaker::Host

#+, #[], #[]=, #add_env_var, #close, #connection, create, #delete, #do_rsync_to, #do_scp_from, #do_scp_to, #exec, #fips_mode?, #get_ip, #get_public_ip, #has_key?, #hostname, #install_package, #ip, #is_cygwin?, #is_pe?, #is_powershell?, #is_x86_64?, #log_prefix, #node_name, #path_split, #pkg_initialize, #platform, #port_open?, #puppet_configprint, #reachable_name, #rm_rf, #tmpdir, #tmpfile, #to_s, #to_str, #up?, #wait_for_port

Methods included from Beaker::DSL::Patterns

#block_on

Methods included from Beaker::DSL::Helpers::HoconHelpers

#hocon_file_edit_in_place_on, #hocon_file_edit_on, #hocon_file_read_on

Methods included from Beaker::DSL::Helpers::WebHelpers

#link_exists?, #port_open_within?

Methods included from Beaker::DSL::Helpers::TestHelpers

#current_step_name, #current_test_filename, #current_test_name, #set_current_step_name, #set_current_test_filename, #set_current_test_name

Methods included from Beaker::DSL::Helpers::HostHelpers

#add_system32_hosts_entry, #archive_file_from, #backup_the_file, #check_for_package, #create_remote_file, #curl_on, #curl_with_retries, #directory_exists_on, #echo_on, #execute_powershell_script_on, #file_contents_on, #file_exists_on, #install_package, #link_exists_on, #on, #retry_on, #rsync_to, #run_script, #run_script_on, #scp_from, #scp_to, #shell, #uninstall_package, #upgrade_package, #win_ads_path

Constructor Details

#initialize(name, host_hash, options) ⇒ Host

Returns a new instance of Host.



54
55
56
57
58
59
60
# File 'lib/beaker/host/windows.rb', line 54

def initialize name, host_hash, options
  super

  @ssh_server         = nil
  @scp_separator      = '\\'
  @external_copy_base = nil
end

Instance Attribute Details

#scp_separatorObject (readonly)

Returns the value of attribute scp_separator.



52
53
54
# File 'lib/beaker/host/windows.rb', line 52

def scp_separator
  @scp_separator
end

Instance Method Details

#determine_ssh_serverSymbol

Determines which SSH Server is in use on this host

Returns:

  • (Symbol)

    Value for the SSH Server in use (:bitvise or :openssh at this point).



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/beaker/host/windows.rb', line 38

def determine_ssh_server
  return @ssh_server if @ssh_server

  @ssh_server = :openssh
  status = execute('cmd.exe /c sc query BvSshServer', :accept_all_exit_codes => true)
  if status&.include?('4  RUNNING')
    @ssh_server = :bitvise
  else
    status = execute('cmd.exe /c sc qc sshd', :accept_all_exit_codes => true)
    @ssh_server = :win32_openssh if status&.include?('C:\\Windows\\System32\\OpenSSH\\sshd.exe')
  end
  @ssh_server
end

#external_copy_baseObject



27
28
29
30
31
32
# File 'lib/beaker/host/windows.rb', line 27

def external_copy_base
  return @external_copy_base if @external_copy_base

  @external_copy_base = execute('echo `cygpath -smF 35`/')
  @external_copy_base
end

#platform_defaultsObject



18
19
20
21
22
23
24
25
# File 'lib/beaker/host/windows.rb', line 18

def platform_defaults
  h = Beaker::Options::OptionsHash.new
  h.merge({
            'user' => 'Administrator',
            'group' => 'Administrators',
            'pathseparator' => ';',
          })
end