Sha256: f00516968f236d7a612e37bb97d0e89f04e767db208dbceb090bc2a671bbabbe

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

require 'log4r'

module VagrantPlugins
  module Parallels
    module Action
      class SaneDefaults
        include VagrantPlugins::Parallels::Util::Common

        def initialize(app, env)
          @logger = Log4r::Logger.new('vagrant_parallels::action::sanedefaults')
          @app = app
        end

        def call(env)
          # Set the env on an instance variable so we can access it in
          # helpers.
          @env = env

          @env[:ui].info I18n.t('vagrant_parallels.actions.vm.sane_defaults.setting')

          default_settings.each do |setting, value|
            @env[:machine].provider.driver.execute_prlctl(
              'set', @env[:machine].id, "--#{setting.to_s.gsub('_','-')}", value)
          end

          @app.call(env)
        end

        private

        def default_settings
          # Options defined below are not supported for `*.macvm` VMs
          return {} if is_macvm(@env)

          {
            tools_autoupdate: 'no',
            on_shutdown: 'close',
            on_window_close: 'keep-running',
            auto_share_camera: 'off',
            smart_guard: 'off',
            longer_battery_life: 'on',
            shared_cloud: 'off',
            shared_profile: 'off',
            smart_mount: 'off',
            sh_app_guest_to_host: 'off',
            sh_app_host_to_guest: 'off',
            startup_view: 'headless',
            time_sync: 'on',
            disable_timezone_sync: 'on',
            shf_host_defined: 'off'
          }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-parallels-2.3.1 lib/vagrant-parallels/action/sane_defaults.rb
vagrant-parallels-2.3.0 lib/vagrant-parallels/action/sane_defaults.rb
vagrant-parallels-2.2.6 lib/vagrant-parallels/action/sane_defaults.rb