Module: VagrantWindows::Helper

Constant Summary collapse

@@logger =
Log4r::Logger.new("vagrant_windows::helper")

Instance Method Summary collapse

Instance Method Details

#wait_if_rebooting(windows_machine, wait_in_seconds = 10) ⇒ Object

Check to see if the guest is rebooting, if its rebooting then wait until its ready

Parameters:

  • The (WindowsMachine)

    windows machine instance

  • The (Int)

    time in seconds to wait between checks



31
32
33
34
35
36
37
# File 'lib/vagrant-windows/helper.rb', line 31

def wait_if_rebooting(windows_machine, wait_in_seconds=10)
  @@logger.info('Checking guest reboot status')
  while windows_machine.is_rebooting? 
    @@logger.debug('Guest is rebooting, waiting 10 seconds...')
    sleep(wait_in_seconds)
  end
end

#win_friendly_path(path) ⇒ String

Makes a path Windows guest friendly. Turns ‘/vagrant’ into ‘c:vagrant’

Returns:

  • (String)


11
12
13
14
15
16
17
# File 'lib/vagrant-windows/helper.rb', line 11

def win_friendly_path(path)
  if path
    new_path = path.gsub('/', '\\')
    new_path = "c:#{new_path}" if new_path =~ /^\\/
  end
  new_path
end

#win_friendly_share_id(shared_folder_name) ⇒ String

Makes Vagrant share names Windows guest friendly. Turns ‘/vagrant’ into ‘vagrant’ or turns ”/a/b/c/d/e’ into ‘a_b_c_d_e’

Returns:

  • (String)


23
24
25
# File 'lib/vagrant-windows/helper.rb', line 23

def win_friendly_share_id(shared_folder_name)
  return shared_folder_name.gsub(/[\/\/]/,'_').sub(/^_/, '')
end