diff --git a/README.md b/README.md index d61320d0..c88848d4 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,22 @@ This is a plugin for [Vagrant](http://www.vagrantup.com), allowing to power [Parallels Desktop for Mac](http://www.parallels.com/products/desktop/) based virtual machines. -If you're just getting started with Vagrant, it is highly recommended that you -read the official [Vagrant documentation](http://docs.vagrantup.com/v2/) first. - ### Requirements - [Vagrant v1.5](http://www.vagrantup.com) or higher - [Parallels Desktop 8 for Mac](http://www.parallels.com/products/desktop/) or higher -**Attention for Parallels Desktop 11 users!** - -This plugin is compatible only with *Pro* and *Business* editions of Parallels -Desktop 11. Standard edition doesn't have a command line functionality and can -not be used with Vagrant. +*Note:* In [**Parallels Desktop 11 for Mac**](http://www.parallels.com/products/desktop/), +only **Pro** and **Business** editions are compatible with this Vagrant provider. +Standard edition doesn't have a command line functionality and can not be used +with Vagrant. ## Features The Parallels provider supports all basic Vagrant features, including shared folders, private and public networks, forwarded ports and so on. +If you're just getting started with Vagrant, it is highly recommended that you +read the official [Vagrant documentation](http://docs.vagrantup.com/v2/) first. + ## Installation First, make sure that you have [Parallels Desktop for Mac](http://www.parallels.com/products/desktop/) and [Vagrant](http://www.vagrantup.com/downloads) properly installed. diff --git a/Rakefile b/Rakefile index a23801c8..f251fabe 100644 --- a/Rakefile +++ b/Rakefile @@ -13,9 +13,9 @@ $stderr.sync = true # allows us to nicely separate rake tasks into individual files # based on their role, which makes development and debugging easier # than one monolithic file. -task_dir = File.expand_path("../tasks", __FILE__) +task_dir = File.expand_path('../tasks', __FILE__) Dir["#{task_dir}/**/*.rake"].each do |task_file| load task_file end -task :default => "test:unit" +task :default => 'test:unit' diff --git a/config/i18n-tasks.yml.erb b/config/i18n-tasks.yml.erb deleted file mode 100644 index d858f7b5..00000000 --- a/config/i18n-tasks.yml.erb +++ /dev/null @@ -1,18 +0,0 @@ -base_locale: en - -# skip checking 'providers_hyperv' and 'synced_folder_smb' locales -locales: [] - -search: - paths: - - "lib/" -data: - adapter: file_system - read: - - "locales/%{locale}.yml" - - "<%= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml" - write: - - "locales/%{locale}.yml" -ignore_unused: - - "vagrant_parallels.errors.*" - - "vagrant.*" diff --git a/lib/vagrant-parallels.rb b/lib/vagrant-parallels.rb index d32744c8..14be6401 100644 --- a/lib/vagrant-parallels.rb +++ b/lib/vagrant-parallels.rb @@ -1,56 +1,19 @@ -require "pathname" +require 'pathname' -require "vagrant-parallels/plugin" -require "vagrant-parallels/version" +require 'vagrant-parallels/plugin' +require 'vagrant-parallels/version' module VagrantPlugins module Parallels - lib_path = Pathname.new(File.expand_path("../vagrant-parallels", __FILE__)) - autoload :Action, lib_path.join("action") - autoload :Errors, lib_path.join("errors") + lib_path = Pathname.new(File.expand_path('../vagrant-parallels', __FILE__)) + autoload :Action, lib_path.join('action') + autoload :Errors, lib_path.join('errors') # This returns the path to the source of this plugin. # # @return [Pathname] def self.source_root - @source_root ||= Pathname.new(File.expand_path("../../", __FILE__)) + @source_root ||= Pathname.new(File.expand_path('../../', __FILE__)) end - - # This initializes the internationalization strings. - def self.setup_i18n - I18n.load_path << File.expand_path("locales/en.yml", Parallels.source_root) - I18n.reload! - end - - # This sets up our log level to be whatever VAGRANT_LOG is. - def self.setup_logging - require "log4r" - - level = nil - begin - level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase) - rescue NameError - # This means that the logging constant wasn't found, - # which is fine. We just keep `level` as `nil`. But - # we tell the user. - level = nil - end - - # Some constants, such as "true" resolve to booleans, so the - # above error checking doesn't catch it. This will check to make - # sure that the log level is an integer, as Log4r requires. - level = nil if !level.is_a?(Integer) - - # Set the logging level on all "vagrant" namespaced - # logs as long as we have a valid level. - if level - logger = Log4r::Logger.new("vagrant_parallels") - logger.outputters = Log4r::Outputter.stderr - logger.level = level - logger = nil - end - end - Parallels.setup_logging - Parallels.setup_i18n end end diff --git a/lib/vagrant-parallels/action.rb b/lib/vagrant-parallels/action.rb index 23adee51..7700248d 100644 --- a/lib/vagrant-parallels/action.rb +++ b/lib/vagrant-parallels/action.rb @@ -1,4 +1,4 @@ -require "vagrant/action/builder" +require 'vagrant/action/builder' module VagrantPlugins module Parallels @@ -25,11 +25,11 @@ def self.action_boot b.use ForwardPorts b.use SetHostname b.use SaneDefaults - b.use Customize, "pre-boot" + b.use Customize, 'pre-boot' b.use Boot - b.use Customize, "post-boot" + b.use Customize, 'post-boot' b.use WaitForCommunicator, [:starting, :running] - b.use Customize, "post-comm" + b.use Customize, 'post-comm' b.use HandleGuestTools end end @@ -41,13 +41,13 @@ def self.action_destroy b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end b1.use Call, DestroyConfirm do |env2, b2| if !env2[:result] - b2.use Message, I18n.t("vagrant.commands.destroy.will_not_destroy", + b2.use Message, I18n.t('vagrant.commands.destroy.will_not_destroy', :name => env2[:machine].name) next end @@ -71,7 +71,7 @@ def self.action_halt b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end @@ -98,7 +98,7 @@ def self.action_package b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end @@ -119,13 +119,13 @@ def self.action_provision b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end b1.use Call, IsState, :running do |env2, b2| if !env2[:result] - b2.use Message, I18n.t("vagrant.commands.common.vm_not_running") + b2.use Message, I18n.t('vagrant.commands.common.vm_not_running') next end @@ -143,7 +143,7 @@ def self.action_reload b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end @@ -160,7 +160,7 @@ def self.action_resume b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end @@ -179,7 +179,7 @@ def self.action_ssh b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end @@ -200,7 +200,7 @@ def self.action_ssh_run b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end @@ -223,7 +223,7 @@ def self.action_start b.use Call, IsState, :running do |env1, b1| # If the VM is running, then our work here is done, exit if env1[:result] - b1.use Message, I18n.t("vagrant_parallels.commands.common.vm_already_running") + b1.use Message, I18n.t('vagrant_parallels.commands.common.vm_already_running') next end @@ -249,7 +249,7 @@ def self.action_suspend b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end @@ -276,7 +276,7 @@ def self.action_up b.use Call, IsState, :not_created do |env1, b1| # If the VM is NOT created yet, then do the setup steps if env1[:result] - b1.use Customize, "pre-import" + b1.use Customize, 'pre-import' b1.use Import b1.use Customize, 'post-import' end @@ -295,11 +295,11 @@ def self.action_simple_reboot end end - b.use Customize, "pre-boot" + b.use Customize, 'pre-boot' b.use Boot - b.use Customize, "post-boot" + b.use Customize, 'post-boot' b.use WaitForCommunicator, [:starting, :running] - b.use Customize, "post-comm" + b.use Customize, 'post-comm' end end @@ -311,13 +311,13 @@ def self.action_sync_folders b.use ConfigValidate b.use Call, IsState, :not_created do |env1, b1| if env1[:result] - b1.use Message, I18n.t("vagrant.commands.common.vm_not_created") + b1.use Message, I18n.t('vagrant.commands.common.vm_not_created') next end b1.use Call, IsState, :running do |env2, b2| if !env2[:result] - b2.use Message, I18n.t("vagrant.commands.common.vm_not_running") + b2.use Message, I18n.t('vagrant.commands.common.vm_not_running') next end b2.use PrepareNFSValidIds @@ -329,29 +329,29 @@ def self.action_sync_folders end - autoload :Boot, File.expand_path("../action/boot", __FILE__) - autoload :HandleGuestTools, File.expand_path("../action/handle_guest_tools", __FILE__) - autoload :HandleForwardedPortCollisions, File.expand_path("../action/handle_forwarded_port_collisions.rb", __FILE__) - autoload :ClearNetworkInterfaces, File.expand_path("../action/clear_network_interfaces", __FILE__) - autoload :ClearForwardedPorts, File.expand_path("../action/clear_forwarded_ports", __FILE__) - autoload :Customize, File.expand_path("../action/customize", __FILE__) - autoload :Destroy, File.expand_path("../action/destroy", __FILE__) - autoload :DestroyUnusedNetworkInterfaces, File.expand_path("../action/destroy_unused_network_interfaces", __FILE__) - autoload :Export, File.expand_path("../action/export", __FILE__) - autoload :ForcedHalt, File.expand_path("../action/forced_halt", __FILE__) - autoload :ForwardPorts, File.expand_path("../action/forward_ports", __FILE__) - autoload :Import, File.expand_path("../action/import", __FILE__) - autoload :Network, File.expand_path("../action/network", __FILE__) - autoload :Package, File.expand_path("../action/package", __FILE__) - autoload :PackageConfigFiles, File.expand_path("../action/package_config_files", __FILE__) - autoload :PrepareForwardedPortCollisionParams, File.expand_path("../action/prepare_forwarded_port_collision_params", __FILE__) - autoload :PrepareNFSSettings, File.expand_path("../action/prepare_nfs_settings", __FILE__) - autoload :PrepareNFSValidIds, File.expand_path("../action/prepare_nfs_valid_ids", __FILE__) - autoload :Resume, File.expand_path("../action/resume", __FILE__) - autoload :SaneDefaults, File.expand_path("../action/sane_defaults",__FILE__) - autoload :SetupPackageFiles, File.expand_path("../action/setup_package_files", __FILE__) - autoload :SetName, File.expand_path("../action/set_name", __FILE__) - autoload :Suspend, File.expand_path("../action/suspend", __FILE__) + autoload :Boot, File.expand_path('../action/boot', __FILE__) + autoload :HandleGuestTools, File.expand_path('../action/handle_guest_tools', __FILE__) + autoload :HandleForwardedPortCollisions, File.expand_path('../action/handle_forwarded_port_collisions.rb', __FILE__) + autoload :ClearNetworkInterfaces, File.expand_path('../action/clear_network_interfaces', __FILE__) + autoload :ClearForwardedPorts, File.expand_path('../action/clear_forwarded_ports', __FILE__) + autoload :Customize, File.expand_path('../action/customize', __FILE__) + autoload :Destroy, File.expand_path('../action/destroy', __FILE__) + autoload :DestroyUnusedNetworkInterfaces, File.expand_path('../action/destroy_unused_network_interfaces', __FILE__) + autoload :Export, File.expand_path('../action/export', __FILE__) + autoload :ForcedHalt, File.expand_path('../action/forced_halt', __FILE__) + autoload :ForwardPorts, File.expand_path('../action/forward_ports', __FILE__) + autoload :Import, File.expand_path('../action/import', __FILE__) + autoload :Network, File.expand_path('../action/network', __FILE__) + autoload :Package, File.expand_path('../action/package', __FILE__) + autoload :PackageConfigFiles, File.expand_path('../action/package_config_files', __FILE__) + autoload :PrepareForwardedPortCollisionParams, File.expand_path('../action/prepare_forwarded_port_collision_params', __FILE__) + autoload :PrepareNFSSettings, File.expand_path('../action/prepare_nfs_settings', __FILE__) + autoload :PrepareNFSValidIds, File.expand_path('../action/prepare_nfs_valid_ids', __FILE__) + autoload :Resume, File.expand_path('../action/resume', __FILE__) + autoload :SaneDefaults, File.expand_path('../action/sane_defaults',__FILE__) + autoload :SetupPackageFiles, File.expand_path('../action/setup_package_files', __FILE__) + autoload :SetName, File.expand_path('../action/set_name', __FILE__) + autoload :Suspend, File.expand_path('../action/suspend', __FILE__) end end end diff --git a/lib/vagrant-parallels/action/boot.rb b/lib/vagrant-parallels/action/boot.rb index b66b23e1..ea7a492e 100644 --- a/lib/vagrant-parallels/action/boot.rb +++ b/lib/vagrant-parallels/action/boot.rb @@ -9,12 +9,11 @@ def initialize(app, env) def call(env) @env = env - env[:ui].info I18n.t("vagrant.actions.vm.boot.booting") + env[:ui].info I18n.t('vagrant.actions.vm.boot.booting') env[:machine].provider.driver.start @app.call(env) end - end end end diff --git a/lib/vagrant-parallels/action/clear_network_interfaces.rb b/lib/vagrant-parallels/action/clear_network_interfaces.rb index 94f74e7f..7518a118 100644 --- a/lib/vagrant-parallels/action/clear_network_interfaces.rb +++ b/lib/vagrant-parallels/action/clear_network_interfaces.rb @@ -8,7 +8,7 @@ def initialize(app, env) def call(env) # Delete all disabled network adapters - env[:ui].info I18n.t("vagrant.actions.vm.clear_network_interfaces.deleting") + env[:ui].info I18n.t('vagrant.actions.vm.clear_network_interfaces.deleting') env[:machine].provider.driver.delete_disabled_adapters @app.call(env) diff --git a/lib/vagrant-parallels/action/customize.rb b/lib/vagrant-parallels/action/customize.rb index 33617ecb..d9a688cf 100644 --- a/lib/vagrant-parallels/action/customize.rb +++ b/lib/vagrant-parallels/action/customize.rb @@ -16,7 +16,7 @@ def call(env) end if !customizations.empty? - env[:ui].info I18n.t("vagrant.actions.vm.customize.running", event: @event) + env[:ui].info I18n.t('vagrant.actions.vm.customize.running', event: @event) # Execute each customization command. customizations.each do |command| diff --git a/lib/vagrant-parallels/action/destroy.rb b/lib/vagrant-parallels/action/destroy.rb index 2da03a8c..e82b38dd 100644 --- a/lib/vagrant-parallels/action/destroy.rb +++ b/lib/vagrant-parallels/action/destroy.rb @@ -7,7 +7,7 @@ def initialize(app, env) end def call(env) - env[:ui].info I18n.t("vagrant.actions.vm.destroy.destroying") + env[:ui].info I18n.t('vagrant.actions.vm.destroy.destroying') env[:machine].provider.driver.delete env[:machine].id = nil diff --git a/lib/vagrant-parallels/action/destroy_unused_network_interfaces.rb b/lib/vagrant-parallels/action/destroy_unused_network_interfaces.rb index bec414ee..01dcc9f1 100644 --- a/lib/vagrant-parallels/action/destroy_unused_network_interfaces.rb +++ b/lib/vagrant-parallels/action/destroy_unused_network_interfaces.rb @@ -1,4 +1,4 @@ -require "log4r" +require 'log4r' module VagrantPlugins module Parallels @@ -10,7 +10,7 @@ def initialize(app, env) def call(env) if env[:machine].provider_config.destroy_unused_network_interfaces - env[:ui].info I18n.t("vagrant.actions.vm.destroy_network.destroying") + env[:ui].info I18n.t('vagrant.actions.vm.destroy_network.destroying') env[:machine].provider.driver.delete_unused_host_only_networks end diff --git a/lib/vagrant-parallels/action/forced_halt.rb b/lib/vagrant-parallels/action/forced_halt.rb index 2bbdacb0..bd9b52ef 100644 --- a/lib/vagrant-parallels/action/forced_halt.rb +++ b/lib/vagrant-parallels/action/forced_halt.rb @@ -9,7 +9,7 @@ def initialize(app, env) def call(env) current_state = env[:machine].state.id if current_state == :running - env[:ui].info I18n.t("vagrant.actions.vm.halt.force") + env[:ui].info I18n.t('vagrant.actions.vm.halt.force') env[:machine].provider.driver.halt(:force) end @app.call(env) diff --git a/lib/vagrant-parallels/action/forward_ports.rb b/lib/vagrant-parallels/action/forward_ports.rb index f93adfa0..b40cbcf3 100644 --- a/lib/vagrant-parallels/action/forward_ports.rb +++ b/lib/vagrant-parallels/action/forward_ports.rb @@ -2,7 +2,7 @@ module VagrantPlugins module Parallels module Action class ForwardPorts - include Util::CompileForwardedPorts + include VagrantPlugins::Parallels::Util::CompileForwardedPorts def initialize(app, env) @app = app @@ -40,7 +40,7 @@ def forward_ports # because the VM is using Shared networking. Host-only and # bridged networking don't require port-forwarding and establishing # forwarded ports on these attachment types has uncertain behaviour. - @env[:ui].detail(I18n.t("vagrant_parallels.actions.vm.forward_ports.forwarding_entry", + @env[:ui].detail(I18n.t('vagrant_parallels.actions.vm.forward_ports.forwarding_entry', message_attributes)) # Add the options to the ports array to send to the driver later diff --git a/lib/vagrant-parallels/action/handle_guest_tools.rb b/lib/vagrant-parallels/action/handle_guest_tools.rb index 1e1720ac..73eebf71 100644 --- a/lib/vagrant-parallels/action/handle_guest_tools.rb +++ b/lib/vagrant-parallels/action/handle_guest_tools.rb @@ -11,39 +11,39 @@ def call(env) @machine = env[:machine] if !@machine.provider_config.check_guest_tools - @logger.info("Not checking Parallels Tools because of configuration") + @logger.info('Not checking Parallels Tools because of configuration') return @app.call(env) end - env[:ui].output(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.checking")) + env[:ui].output(I18n.t('vagrant_parallels.actions.vm.handle_guest_tools.checking')) tools_state = parallels_tools_state if tools_state == :installed - @logger.info("The proper version of Parallels Tools is already installed") + @logger.info('The proper version of Parallels Tools is already installed') return @app.call(env) elsif tools_state == :outdated - env[:ui].warn(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.outdated")) + env[:ui].warn(I18n.t('vagrant_parallels.actions.vm.handle_guest_tools.outdated')) else - env[:ui].warn(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.not_detected")) + env[:ui].warn(I18n.t('vagrant_parallels.actions.vm.handle_guest_tools.not_detected')) end if !@machine.provider_config.update_guest_tools - @logger.info("Not updating Parallels Tools because of configuration") + @logger.info('Not updating Parallels Tools because of configuration') return @app.call(env) end # Update/Install Parallels Tools if @machine.guest.capability?(:install_parallels_tools) - env[:ui].output(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.installing")) + env[:ui].output(I18n.t('vagrant_parallels.actions.vm.handle_guest_tools.installing')) @machine.guest.capability(:install_parallels_tools) # The VM should be rebooted to enable kernel modules # bundled with Parallels Tools. - env[:ui].output(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.rebooting")) + env[:ui].output(I18n.t('vagrant_parallels.actions.vm.handle_guest_tools.rebooting')) @machine.action(:simple_reboot) else - env[:ui].warn(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.cant_install")) + env[:ui].warn(I18n.t('vagrant_parallels.actions.vm.handle_guest_tools.cant_install')) end # Continue @@ -67,7 +67,6 @@ def parallels_tools_state @machine.provider.driver.read_guest_tools_state end - end end end diff --git a/lib/vagrant-parallels/action/import.rb b/lib/vagrant-parallels/action/import.rb index 4d15a418..f0f9d375 100644 --- a/lib/vagrant-parallels/action/import.rb +++ b/lib/vagrant-parallels/action/import.rb @@ -38,8 +38,8 @@ def recover(env) unregister_template(tpl_name) if @machine.state.id != :not_created - return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError) - return if env["vagrant_parallels.error"].is_a?(Errors::VagrantParallelsError) + return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError) + return if env['vagrant_parallels.error'].is_a?(Errors::VagrantParallelsError) # If we're not supposed to destroy on error then just return return if !env[:destroy_on_error] @@ -79,24 +79,48 @@ def template_name(tpl_path) end def import(env, tpl_name) - # Generate virtual machine name - vm_name = "#{tpl_name}_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}" - opts = {} - # Linked clones are supported only for PD 11 and higher - if @machine.provider_config.use_linked_clone && - @machine.provider.pd_version_satisfies?('>= 11') + if @machine.provider_config.use_linked_clone \ + && @machine.provider.pd_version_satisfies?('>= 11') env[:ui].info I18n.t('vagrant_parallels.actions.vm.import.importing_linked', :name => @machine.box.name) - opts[:snapshot_id] = snapshot_id(tpl_name) - opts[:linked] = true + opts = { + snapshot_id: snapshot_id(tpl_name), + linked: true + } + # Linked clone creation should not be concurrent [GH-206] + begin + @machine.env.lock("parallels_linked_clone") do + clone(env, tpl_name, opts) + end + rescue Vagrant::Errors::EnvironmentLockedError + sleep 1 + retry + end else - env[:ui].info I18n.t("vagrant.actions.vm.import.importing", + env[:ui].info I18n.t('vagrant.actions.vm.import.importing', :name => @machine.box.name) + clone(env, tpl_name) + end + + if @machine.provider_config.regen_src_uuid + @logger.info('Regenerate SourceVmUuid') + @machine.provider.driver.regenerate_src_uuid end - # Import the virtual machine + # Remove 'Icon\r' file from VM home (bug in PD 11.0.0) + if @machine.provider.pd_version_satisfies?('= 11.0.0') + vm_home = @machine.provider.driver.read_settings.fetch('Home') + broken_icns = Dir[File.join(vm_home, 'Icon*')] + FileUtils.rm(broken_icns, :force => true) + end + end + + def clone(env, tpl_name, opts={}) + # Generate virtual machine name + vm_name = "#{tpl_name}_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}" + @machine.id = @machine.provider.driver.clone_vm(tpl_name, vm_name, opts) do |progress| env[:ui].clear_line env[:ui].report_progress(progress, 100, false) @@ -109,18 +133,6 @@ def import(env, tpl_name) # Clear the line one last time since the progress meter doesn't disappear # immediately. env[:ui].clear_line - - if @machine.provider_config.regen_src_uuid - @logger.info("Regenerate SourceVmUuid") - @machine.provider.driver.regenerate_src_uuid - end - - # Remove 'Icon\r' file from VM home (bug in PD 11.0.0) - if @machine.provider.pd_version_satisfies?('= 11.0.0') - vm_home = @machine.provider.driver.read_settings.fetch('Home') - broken_icns = Dir[File.join(vm_home, 'Icon*')] - FileUtils.rm(broken_icns, :force => true) - end end def snapshot_id(tpl_name) diff --git a/lib/vagrant-parallels/action/network.rb b/lib/vagrant-parallels/action/network.rb index 12792592..f84b0c1b 100644 --- a/lib/vagrant-parallels/action/network.rb +++ b/lib/vagrant-parallels/action/network.rb @@ -1,9 +1,9 @@ -require "set" +require 'set' -require "log4r" +require 'log4r' -require "vagrant/util/network_ip" -require "vagrant/util/scoped_hash_override" +require 'vagrant/util/network_ip' +require 'vagrant/util/scoped_hash_override' module VagrantPlugins module Parallels @@ -36,7 +36,7 @@ def call(env) end @logger.debug("Available slots for high-level adapters: #{available_slots.inspect}") - @logger.info("Determining network adapters required for high-level configuration...") + @logger.info('Determining network adapters required for high-level configuration...') available_slots = available_slots.to_a.sort env[:machine].config.vm.networks.each do |type, options| # We only handle private and public networks @@ -69,7 +69,7 @@ def call(env) network_adapters_config[slot] = data end - @logger.info("Determining adapters and compiling network configuration...") + @logger.info('Determining adapters and compiling network configuration...') adapters = [] networks = [] network_adapters_config.each do |slot, data| @@ -107,14 +107,14 @@ def call(env) if !adapters.empty? # Enable the adapters - @logger.info("Enabling adapters...") - env[:ui].output(I18n.t("vagrant.actions.vm.network.preparing")) + @logger.info('Enabling adapters...') + env[:ui].output(I18n.t('vagrant.actions.vm.network.preparing')) adapters.each do |adapter| env[:ui].detail(I18n.t( - "vagrant_parallels.parallels.network_adapter", + 'vagrant_parallels.parallels.network_adapter', adapter: adapter[:adapter].to_s, type: adapter[:type].to_s, - extra: "", + extra: '', )) end @@ -132,14 +132,14 @@ def call(env) # Only configure the networks the user requested us to configure networks_to_configure = networks.select { |n| n[:auto_config] } if !networks_to_configure.empty? - env[:ui].info I18n.t("vagrant.actions.vm.network.configuring") + env[:ui].info I18n.t('vagrant.actions.vm.network.configuring') env[:machine].guest.capability(:configure_networks, networks_to_configure) end end end def bridged_config(options) - return { + { auto_config: true, bridge: nil, mac: nil, @@ -151,7 +151,7 @@ def bridged_config(options) def bridged_adapter(config) # Find the bridged interfaces that are available bridgedifs = @env[:machine].provider.driver.read_bridged_interfaces - bridgedifs.delete_if { |interface| interface[:status] == "Down" } + bridgedifs.delete_if { |interface| interface[:status] == 'Down' } # The name of the chosen bridge interface will be assigned to this # variable. @@ -163,7 +163,7 @@ def bridged_adapter(config) # Search for a matching bridged interface bridgedifs.each do |interface| if interface[:name].downcase == config[:bridge].downcase - @logger.debug("Specific bridge found as configured in the Vagrantfile. Using it.") + @logger.debug('Specific bridge found as configured in the Vagrantfile. Using it.') chosen_bridge = interface[:name] break end @@ -171,7 +171,7 @@ def bridged_adapter(config) # If one wasn't found, then we notify the user here. if !chosen_bridge - @env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.specific_not_found", + @env[:ui].info I18n.t('vagrant.actions.vm.bridged_networking.specific_not_found', :bridge => config[:bridge]) end end @@ -184,18 +184,18 @@ def bridged_adapter(config) if bridgedifs.length == 1 # One bridgable interface? Just use it. chosen_bridge = bridgedifs[0][:name] - @logger.debug("Only one bridged interface available. Using it by default.") + @logger.debug('Only one bridged interface available. Using it by default.') else # More than one bridgable interface requires a user decision, so # show options to choose from. - @env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.available", + @env[:ui].info I18n.t('vagrant.actions.vm.bridged_networking.available', :prefix => false) bridgedifs.each_index do |index| interface = bridgedifs[index] @env[:ui].info("#{index + 1}) #{interface[:name]}", :prefix => false) end @env[:ui].info(I18n.t( - "vagrant.actions.vm.bridged_networking.choice_help")+"\n") + 'vagrant.actions.vm.bridged_networking.choice_help')+"\n") # The range of valid choices valid = Range.new(1, bridgedifs.length) @@ -215,7 +215,7 @@ def bridged_adapter(config) @logger.info("Bridging adapter #{config[:adapter]} to #{chosen_bridge}") # Given the choice we can now define the adapter we're using - return { + { adapter: config[:adapter], type: :bridged, bridge: chosen_bridge, @@ -229,14 +229,14 @@ def bridged_network_config(config) options = { auto_config: true, mac: nil, - netmask: "255.255.255.0", + netmask: '255.255.255.0', type: :static }.merge(config) options[:type] = options[:type].to_sym return options end - return { + { type: :dhcp, use_dhcp_assigned_default_route: config[:use_dhcp_assigned_default_route] } @@ -248,7 +248,7 @@ def hostonly_config(options) mac: nil, name: nil, nic_type: nil, - netmask: "255.255.255.0", + netmask: '255.255.255.0', type: :static }.merge(options) @@ -256,7 +256,7 @@ def hostonly_config(options) options[:type] = options[:type].to_sym # Default IP is in the 20-bit private network block for DHCP based networks - options[:ip] = "10.37.129.1" if options[:type] == :dhcp && !options[:ip] + options[:ip] = '10.37.129.1' if options[:type] == :dhcp && !options[:ip] # Calculate our network address for the given IP/netmask netaddr = network_address(options[:ip], options[:netmask]) @@ -271,17 +271,17 @@ def hostonly_config(options) @env[:machine].provider.driver.read_bridged_interfaces.each do |interface| that_netaddr = network_address(interface[:ip], interface[:netmask]) raise Vagrant::Errors::NetworkCollision if \ - netaddr == that_netaddr && interface[:status] != "Down" + netaddr == that_netaddr && interface[:status] != 'Down' end # Split the IP address into its components - ip_parts = netaddr.split(".").map { |i| i.to_i } + ip_parts = netaddr.split('.').map { |i| i.to_i } # Calculate the adapter IP, which we assume is the IP ".1" at # the end usually. adapter_ip = ip_parts.dup adapter_ip[3] += 1 - options[:adapter_ip] ||= adapter_ip.join(".") + options[:adapter_ip] ||= adapter_ip.join('.') dhcp_options = {} if options[:type] == :dhcp @@ -289,19 +289,19 @@ def hostonly_config(options) # with the final octet + 1. So "172.28.0.0" turns into "172.28.0.1" dhcp_ip = ip_parts.dup dhcp_ip[3] += 1 - dhcp_options[:dhcp_ip] = options[:dhcp_ip] || dhcp_ip.join(".") + dhcp_options[:dhcp_ip] = options[:dhcp_ip] || dhcp_ip.join('.') # Calculate the lower and upper bound for the DHCP server dhcp_lower = ip_parts.dup dhcp_lower[3] += 2 - dhcp_options[:dhcp_lower] = options[:dhcp_lower] || dhcp_lower.join(".") + dhcp_options[:dhcp_lower] = options[:dhcp_lower] || dhcp_lower.join('.') dhcp_upper = ip_parts.dup dhcp_upper[3] = 254 - dhcp_options[:dhcp_upper] = options[:dhcp_upper] || dhcp_upper.join(".") + dhcp_options[:dhcp_upper] = options[:dhcp_upper] || dhcp_upper.join('.') end - return { + { adapter_ip: options[:adapter_ip], auto_config: options[:auto_config], ip: options[:ip], @@ -318,14 +318,14 @@ def hostonly_adapter(config) interface = hostonly_find_matching_network(config) if !interface - @logger.info("Network not found. Creating if we can.") + @logger.info('Network not found. Creating if we can.') # Create a new network interface = hostonly_create_network(config) @logger.info("Created network: #{interface[:name]}") end - return { + { adapter: config[:adapter], hostonly: interface[:name], mac_address: config[:mac], @@ -335,7 +335,7 @@ def hostonly_adapter(config) end def hostonly_network_config(config) - return { + { type: config[:type], adapter_ip: config[:adapter_ip], ip: config[:ip], @@ -345,20 +345,20 @@ def hostonly_network_config(config) def shared_config(options) - return { + { auto_config: false } end def shared_adapter(config) - return { + { adapter: config[:adapter], type: :shared } end def shared_network_config(config) - return {} + {} end #----------------------------------------------------------------- @@ -408,7 +408,7 @@ def next_network_id end if net_nums.empty? - "vagrant-vnet0" + 'vagrant-vnet0' else net_nums.sort! if net_nums free_names = Array(0..net_nums.last.next) - net_nums diff --git a/lib/vagrant-parallels/action/package.rb b/lib/vagrant-parallels/action/package.rb index ad8e47c5..c33fb2c0 100644 --- a/lib/vagrant-parallels/action/package.rb +++ b/lib/vagrant-parallels/action/package.rb @@ -12,13 +12,13 @@ class Package < Vagrant::Action::General::Package def call(env) # Setup the temporary directory @temp_dir = env[:tmp_path].join(Time.now.to_i.to_s) - env["export.temp_dir"] = @temp_dir - FileUtils.mkpath(env["export.temp_dir"]) + env['export.temp_dir'] = @temp_dir + FileUtils.mkpath(env['export.temp_dir']) # Just match up a couple environmental variables so that # the superclass will do the right thing. Then, call the # superclass - env["package.directory"] = env["export.temp_dir"] + env['package.directory'] = env['export.temp_dir'] general_call(env) diff --git a/lib/vagrant-parallels/action/package_config_files.rb b/lib/vagrant-parallels/action/package_config_files.rb index 4cd5f313..d8e1afb8 100644 --- a/lib/vagrant-parallels/action/package_config_files.rb +++ b/lib/vagrant-parallels/action/package_config_files.rb @@ -18,12 +18,13 @@ def call(env) end def create_metadata - File.open(File.join(@env["export.temp_dir"], "metadata.json"), "w") do |f| + File.open(File.join(@env['export.temp_dir'], 'metadata.json'), 'w') do |f| f.write(template_metadatafile) end end - private + private + def template_metadatafile %Q({"provider": "parallels"}\n) end diff --git a/lib/vagrant-parallels/action/prepare_nfs_settings.rb b/lib/vagrant-parallels/action/prepare_nfs_settings.rb index ee43ce16..9f2aa575 100644 --- a/lib/vagrant-parallels/action/prepare_nfs_settings.rb +++ b/lib/vagrant-parallels/action/prepare_nfs_settings.rb @@ -1,5 +1,5 @@ require 'ipaddr' -require "vagrant/action/builtin/mixin_synced_folders" +require 'vagrant/action/builtin/mixin_synced_folders' module VagrantPlugins module Parallels @@ -25,7 +25,7 @@ def call(env) folders = synced_folders(env[:machine], **opts) if folders.has_key?(:nfs) - @logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP") + @logger.info('Using NFS, preparing NFS settings by reading host IP and machine IP') add_ips_to_env!(env) end end diff --git a/lib/vagrant-parallels/action/resume.rb b/lib/vagrant-parallels/action/resume.rb index b0d3d084..fcd40e20 100644 --- a/lib/vagrant-parallels/action/resume.rb +++ b/lib/vagrant-parallels/action/resume.rb @@ -10,7 +10,7 @@ def call(env) current_state = env[:machine].state.id if current_state == :suspended - env[:ui].info I18n.t("vagrant.actions.vm.resume.resuming") + env[:ui].info I18n.t('vagrant.actions.vm.resume.resuming') env[:machine].provider.driver.resume end diff --git a/lib/vagrant-parallels/action/sane_defaults.rb b/lib/vagrant-parallels/action/sane_defaults.rb index 652597e7..21ad8bb3 100644 --- a/lib/vagrant-parallels/action/sane_defaults.rb +++ b/lib/vagrant-parallels/action/sane_defaults.rb @@ -48,7 +48,6 @@ def set_power_consumption @env[:machine].provider.driver.set_power_consumption_mode(new_val) end end - end end end diff --git a/lib/vagrant-parallels/action/set_name.rb b/lib/vagrant-parallels/action/set_name.rb index 7f5fd559..7d759677 100644 --- a/lib/vagrant-parallels/action/set_name.rb +++ b/lib/vagrant-parallels/action/set_name.rb @@ -1,4 +1,4 @@ -require "log4r" +require 'log4r' module VagrantPlugins module Parallels @@ -13,16 +13,16 @@ def call(env) name = env[:machine].provider_config.name # If we already set the name before, then don't do anything - sentinel = env[:machine].data_dir.join("action_set_name") + sentinel = env[:machine].data_dir.join('action_set_name') if !name && sentinel.file? - @logger.info("Default name was already set before, not doing it again.") + @logger.info('Default name was already set before, not doing it again.') return @app.call(env) end # If no name was manually set, then use a default if !name prefix = "#{env[:root_path].basename.to_s}_#{env[:machine].name}" - prefix.gsub!(/[^-a-z0-9_]/i, "") + prefix.gsub!(/[^-a-z0-9_]/i, '') # milliseconds + random number suffix to allow for simultaneous `vagrant up` of the same box in different dirs name = prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}" end @@ -33,15 +33,15 @@ def call(env) vms_names.has_key?(name) && vms_names[name] != env[:machine].id if vms_names.has_key?(name) - @logger.info("Not setting the name because our name is already set.") + @logger.info('Not setting the name because our name is already set.') else env[:ui].info(I18n.t( - "vagrant.actions.vm.set_name.setting_name", name: name)) + 'vagrant.actions.vm.set_name.setting_name', name: name)) env[:machine].provider.driver.set_name(name) end # Create the sentinel - sentinel.open("w") do |f| + sentinel.open('w') do |f| f.write(Time.now.to_i.to_s) end diff --git a/lib/vagrant-parallels/action/setup_package_files.rb b/lib/vagrant-parallels/action/setup_package_files.rb index e975975d..1188eae7 100644 --- a/lib/vagrant-parallels/action/setup_package_files.rb +++ b/lib/vagrant-parallels/action/setup_package_files.rb @@ -5,13 +5,13 @@ class SetupPackageFiles def initialize(app, env) @app = app - env["package.include"] ||= [] - env["package.vagrantfile"] ||= nil + env['package.include'] ||= [] + env['package.vagrantfile'] ||= nil end def call(env) files = {} - env["package.include"].each do |file| + env['package.include'].each do |file| source = Pathname.new(file) # If the source is relative then we add the file as-is to the include @@ -28,9 +28,9 @@ def call(env) files[file] = dest end - if env["package.vagrantfile"] + if env['package.vagrantfile'] # Vagrantfiles are treated special and mapped to a specific file - files[env["package.vagrantfile"]] = "_Vagrantfile" + files[env['package.vagrantfile']] = '_Vagrantfile' end # Verify the mapping @@ -40,7 +40,7 @@ def call(env) end # Save the mapping - env["package.files"] = files + env['package.files'] = files @app.call(env) end diff --git a/lib/vagrant-parallels/action/suspend.rb b/lib/vagrant-parallels/action/suspend.rb index 1407dee1..86975cfa 100644 --- a/lib/vagrant-parallels/action/suspend.rb +++ b/lib/vagrant-parallels/action/suspend.rb @@ -8,7 +8,7 @@ def initialize(app, env) def call(env) if env[:machine].state.id == :running - env[:ui].info I18n.t("vagrant.actions.vm.suspend.suspending") + env[:ui].info I18n.t('vagrant.actions.vm.suspend.suspending') env[:machine].provider.driver.suspend end diff --git a/lib/vagrant-parallels/config.rb b/lib/vagrant-parallels/config.rb index b210d515..228762ef 100644 --- a/lib/vagrant-parallels/config.rb +++ b/lib/vagrant-parallels/config.rb @@ -1,6 +1,6 @@ module VagrantPlugins module Parallels - class Config < Vagrant.plugin("2", :config) + class Config < Vagrant.plugin('2', :config) attr_accessor :check_guest_tools attr_reader :customizations attr_accessor :destroy_unused_network_interfaces @@ -34,7 +34,7 @@ def initialize end def customize(*command) - event = command.first.is_a?(String) ? command.shift : "pre-boot" + event = command.first.is_a?(String) ? command.shift : 'pre-boot' command = command[0] @customizations << [event, command] end @@ -45,11 +45,11 @@ def network_adapter(slot, type, **opts) # @param size [Integer, String] the memory size in MB def memory=(size) - customize("pre-boot", ["set", :id, "--memsize", size.to_s]) + customize('pre-boot', ['set', :id, '--memsize', size.to_s]) end def cpus=(count) - customize("pre-boot", ["set", :id, "--cpus", count.to_i]) + customize('pre-boot', ['set', :id, '--cpus', count.to_i]) end def regen_box_uuid=(value) @@ -97,21 +97,19 @@ def validate(machine) valid_events = ['pre-import', 'post-import', 'pre-boot', 'post-boot', 'post-comm'] @customizations.each do |event, _| if !valid_events.include?(event) - errors << I18n.t("vagrant_parallels.config.invalid_event", + errors << I18n.t('vagrant_parallels.config.invalid_event', event: event.to_s, - valid_events: valid_events.join(", ")) + valid_events: valid_events.join(', ')) end end @customizations.each do |event, command| - if event == "pre-import" && command.index(:id) - errors << I18n.t("vagrant_parallels.config.id_in_pre_import") + if event == 'pre-import' && command.index(:id) + errors << I18n.t('vagrant_parallels.config.id_in_pre_import') end end - { "Parallels Provider" => errors } - + { 'Parallels Provider' => errors } end - end end end diff --git a/lib/vagrant-parallels/driver/meta.rb b/lib/vagrant-parallels/driver/meta.rb index c4f5bedb..b82c8ea6 100644 --- a/lib/vagrant-parallels/driver/meta.rb +++ b/lib/vagrant-parallels/driver/meta.rb @@ -1,7 +1,7 @@ require 'forwardable' require 'log4r' -require File.expand_path('../base', __FILE__) +require_relative 'base' module VagrantPlugins module Parallels diff --git a/lib/vagrant-parallels/driver/pd_10.rb b/lib/vagrant-parallels/driver/pd_10.rb index 671f449c..ea4b91b8 100644 --- a/lib/vagrant-parallels/driver/pd_10.rb +++ b/lib/vagrant-parallels/driver/pd_10.rb @@ -2,7 +2,7 @@ require 'vagrant/util/platform' -require File.expand_path('../pd_9', __FILE__) +require_relative 'pd_9' module VagrantPlugins module Parallels diff --git a/lib/vagrant-parallels/driver/pd_11.rb b/lib/vagrant-parallels/driver/pd_11.rb index 7869dcbf..e38d733c 100644 --- a/lib/vagrant-parallels/driver/pd_11.rb +++ b/lib/vagrant-parallels/driver/pd_11.rb @@ -2,7 +2,7 @@ require 'vagrant/util/platform' -require File.expand_path('../pd_10', __FILE__) +require_relative 'pd_10' module VagrantPlugins module Parallels diff --git a/lib/vagrant-parallels/driver/pd_8.rb b/lib/vagrant-parallels/driver/pd_8.rb index ddb2dfa7..62f5ef3c 100644 --- a/lib/vagrant-parallels/driver/pd_8.rb +++ b/lib/vagrant-parallels/driver/pd_8.rb @@ -4,7 +4,7 @@ require 'vagrant/util/platform' -require File.expand_path("../base", __FILE__) +require_relative 'base' module VagrantPlugins module Parallels @@ -23,7 +23,7 @@ def delete_unused_host_only_networks # 'Shared'(vnic0) and 'Host-Only'(vnic1) are default in Parallels Desktop # They should not be deleted anyway. networks.keep_if do |net| - net['Type'] == "host-only" && + net['Type'] == 'host-only' && net['Bound To'].match(/^(?>vnic|Parallels Host-Only #)(\d+)$/)[1].to_i >= 2 end @@ -58,9 +58,9 @@ def enable_adapters(adapters) adapters.each do |adapter| args = [] if existing_adapters.include? "net#{adapter[:adapter]}" - args.concat(["--device-set","net#{adapter[:adapter]}", "--enable"]) + args.concat(['--device-set',"net#{adapter[:adapter]}", '--enable']) else - args.concat(["--device-add", "net"]) + args.concat(['--device-add', 'net']) end if adapter[:type] == :hostonly @@ -73,28 +73,28 @@ def enable_adapters(adapters) # The only difference is the destination interface: # - in host-only (private) network it will be bridged to the 'vnicX' device # - in real bridge (public) network it will be bridged to the assigned device - args.concat(["--type", "bridged", "--iface", net_info['Bound To']]) + args.concat(['--type', 'bridged', '--iface', net_info['Bound To']]) elsif adapter[:type] == :bridged - args.concat(["--type", "bridged", "--iface", adapter[:bridge]]) + args.concat(['--type', 'bridged', '--iface', adapter[:bridge]]) elsif adapter[:type] == :shared - args.concat(["--type", "shared"]) + args.concat(['--type', 'shared']) end if adapter[:mac_address] - args.concat(["--mac", adapter[:mac_address]]) + args.concat(['--mac', adapter[:mac_address]]) end if adapter[:nic_type] - args.concat(["--adapter-type", adapter[:nic_type].to_s]) + args.concat(['--adapter-type', adapter[:nic_type].to_s]) end - execute_prlctl("set", @uuid, *args) + execute_prlctl('set', @uuid, *args) end end def read_host_only_interfaces net_list = read_virtual_networks - net_list.keep_if { |net| net['Type'] == "host-only" } + net_list.keep_if { |net| net['Type'] == 'host-only' } hostonly_ifaces = [] net_list.each do |iface| @@ -105,7 +105,7 @@ def read_host_only_interfaces info[:ip] = net_info['Parallels adapter']['IP address'] info[:netmask] = net_info['Parallels adapter']['Subnet mask'] # Such interfaces are always in 'Up' - info[:status] = "Up" + info[:status] = 'Up' # There may be a fake DHCPv4 parameters # We can trust them only if adapter IP and DHCP IP are in the same subnet @@ -128,23 +128,23 @@ def read_network_interfaces # Get enabled VM's network interfaces ifaces = read_settings.fetch('Hardware', {}).keep_if do |dev, params| - dev.start_with?('net') and params.fetch("enabled", true) + dev.start_with?('net') and params.fetch('enabled', true) end ifaces.each do |name, params| adapter = name.match(/^net(\d+)$/)[1].to_i nics[adapter] ||= {} - if params['type'] == "shared" + if params['type'] == 'shared' nics[adapter][:type] = :shared - elsif params['type'] == "host" + elsif params['type'] == 'host' # It is PD internal host-only network and it is bounded to 'vnic1' nics[adapter][:type] = :hostonly - nics[adapter][:hostonly] = "vnic1" - elsif params['type'] == "bridged" and params.fetch('iface','').start_with?('vnic') + nics[adapter][:hostonly] = 'vnic1' + elsif params['type'] == 'bridged' and params.fetch('iface','').start_with?('vnic') # Bridged to the 'vnicXX'? Then it is a host-only, actually. nics[adapter][:type] = :hostonly nics[adapter][:hostonly] = params.fetch('iface','') - elsif params['type'] == "bridged" + elsif params['type'] == 'bridged' nics[adapter][:type] = :bridged nics[adapter][:bridge] = params.fetch('iface','') end @@ -160,7 +160,7 @@ def read_shared_interface name: net_info['Bound To'], ip: net_info['Parallels adapter']['IP address'], netmask: net_info['Parallels adapter']['Subnet mask'], - status: "Up" + status: 'Up' } if net_info.key?('DHCPv4 server') diff --git a/lib/vagrant-parallels/driver/pd_9.rb b/lib/vagrant-parallels/driver/pd_9.rb index d44d8fb4..622ec035 100644 --- a/lib/vagrant-parallels/driver/pd_9.rb +++ b/lib/vagrant-parallels/driver/pd_9.rb @@ -2,7 +2,7 @@ require 'vagrant/util/platform' -require File.expand_path('../pd_8', __FILE__) +require_relative 'pd_8' module VagrantPlugins module Parallels diff --git a/lib/vagrant-parallels/errors.rb b/lib/vagrant-parallels/errors.rb index b658f3c7..c9322230 100644 --- a/lib/vagrant-parallels/errors.rb +++ b/lib/vagrant-parallels/errors.rb @@ -1,10 +1,10 @@ -require "vagrant" +require 'vagrant' module VagrantPlugins module Parallels module Errors class VagrantParallelsError < Vagrant::Errors::VagrantError - error_namespace("vagrant_parallels.errors") + error_namespace('vagrant_parallels.errors') end class DhcpLeasesNotAccessible < VagrantParallelsError diff --git a/lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb b/lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb index 1b12df21..fb94067e 100644 --- a/lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb +++ b/lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb @@ -7,14 +7,14 @@ def self.install_parallels_tools(machine) if ptiagent_usable?(machine) # Argument '--info' means that Parallels Tools version will be # checked before the installing. - machine.communicate.sudo("ptiagent-cmd --info") + machine.communicate.sudo('ptiagent-cmd --info') else machine.communicate.tap do |comm| tools_iso_path = File.expand_path( - machine.provider.driver.read_guest_tools_iso_path("linux"), + machine.provider.driver.read_guest_tools_iso_path('linux'), machine.env.root_path ) - remote_file = "/tmp/prl-tools-lin.iso" + remote_file = '/tmp/prl-tools-lin.iso' mount_point = "/media/prl-tools-lin_#{rand(100000)}/" comm.upload(tools_iso_path, remote_file) @@ -44,8 +44,8 @@ def self.ptiagent_usable?(machine) # 'ptiagent-cmd' binary should be available on the guest machine.provider_name == :parallels && - Gem::Version.new(machine.provider.driver.version) >= Gem::Version.new("9") && - machine.communicate.test("which ptiagent-cmd", :sudo => true) + Gem::Version.new(machine.provider.driver.version) >= Gem::Version.new('9') && + machine.communicate.test('which ptiagent-cmd', :sudo => true) end end end diff --git a/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb b/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb index 0fefe47c..482bb978 100644 --- a/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb +++ b/lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb @@ -36,12 +36,12 @@ def self.mount_parallels_shared_folder(machine, name, guestpath, options) # First mount command uses getent to get the group mount_options = "-o uid=#{mount_uid},gid=#{mount_gid}" - mount_options += ",#{options[:mount_options].join(",")}" if options[:mount_options] + mount_options += ",#{options[:mount_options].join(',')}" if options[:mount_options] mount_commands << "mount -t prl_fs #{mount_options} #{name} #{expanded_guest_path}" # Second mount command uses the old style `id -g` mount_options = "-o uid=#{mount_uid},gid=#{mount_gid_old}" - mount_options += ",#{options[:mount_options].join(",")}" if options[:mount_options] + mount_options += ",#{options[:mount_options].join(',')}" if options[:mount_options] mount_commands << "mount -t prl_fs #{mount_options} #{name} #{expanded_guest_path}" # Clear prior symlink if exists @@ -80,7 +80,7 @@ def self.mount_parallels_shared_folder(machine, name, guestpath, options) end # Emit an upstart event if we can - if machine.communicate.test("test -x /sbin/initctl") + if machine.communicate.test('test -x /sbin/initctl') machine.communicate.sudo( "/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{expanded_guest_path}") end diff --git a/lib/vagrant-parallels/model/forwarded_port.rb b/lib/vagrant-parallels/model/forwarded_port.rb index f7306094..4d20a0ef 100644 --- a/lib/vagrant-parallels/model/forwarded_port.rb +++ b/lib/vagrant-parallels/model/forwarded_port.rb @@ -37,7 +37,7 @@ def initialize(id, host_port, guest_port, options) options ||= {} @auto_correct = false @auto_correct = options[:auto_correct] if options.has_key?(:auto_correct) - @protocol = options[:protocol] || "tcp" + @protocol = options[:protocol] || 'tcp' end # This corrects the host port and changes it to the given new port. diff --git a/lib/vagrant-parallels/plugin.rb b/lib/vagrant-parallels/plugin.rb index 9014e1d5..a053f7d0 100644 --- a/lib/vagrant-parallels/plugin.rb +++ b/lib/vagrant-parallels/plugin.rb @@ -1,105 +1,140 @@ begin - require "vagrant" + require 'vagrant' rescue LoadError - raise "The Vagrant Parallels plugin must be run within Vagrant." + raise 'The Vagrant Parallels plugin must be run within Vagrant.' end # This is a sanity check to make sure no one is attempting to install # this into an early Vagrant version. -if Vagrant::VERSION < "1.5.0" - raise "The Vagrant Parallels plugin is only compatible with Vagrant 1.5+" +if Vagrant::VERSION < '1.5.0' + raise 'The Vagrant Parallels plugin is only compatible with Vagrant 1.5+' end module VagrantPlugins module Parallels - - class Plugin < Vagrant.plugin("2") - name "vagrant-parallels" + class Plugin < Vagrant.plugin('2') + name 'vagrant-parallels' description <<-EOF The Parallels provider allows Vagrant to manage and control - Parallels-based virtual machines. + Parallels Desktop virtual machines. EOF provider(:parallels, parallel: true, priority: 7) do - require File.expand_path("../provider", __FILE__) + # Setup logging and i18n + setup_logging + setup_i18n + + require_relative 'provider' Provider end config(:parallels, :provider) do - require File.expand_path("../config", __FILE__) + require_relative 'config' Config end guest_capability(:darwin, :mount_parallels_shared_folder) do - require_relative "guest_cap/darwin/mount_parallels_shared_folder" + require_relative 'guest_cap/darwin/mount_parallels_shared_folder' GuestDarwinCap::MountParallelsSharedFolder end guest_capability(:darwin, :unmount_parallels_shared_folder) do - require_relative "guest_cap/darwin/mount_parallels_shared_folder" + require_relative 'guest_cap/darwin/mount_parallels_shared_folder' GuestDarwinCap::MountParallelsSharedFolder end guest_capability(:linux, :mount_parallels_shared_folder) do - require_relative "guest_cap/linux/mount_parallels_shared_folder" + require_relative 'guest_cap/linux/mount_parallels_shared_folder' GuestLinuxCap::MountParallelsSharedFolder end guest_capability(:linux, :unmount_parallels_shared_folder) do - require_relative "guest_cap/linux/mount_parallels_shared_folder" + require_relative 'guest_cap/linux/mount_parallels_shared_folder' GuestLinuxCap::MountParallelsSharedFolder end guest_capability(:linux, :prepare_psf_services) do - require_relative "guest_cap/linux/mount_parallels_shared_folder" + require_relative 'guest_cap/linux/mount_parallels_shared_folder' GuestLinuxCap::MountParallelsSharedFolder end guest_capability(:linux, :install_parallels_tools) do - require_relative "guest_cap/linux/install_parallels_tools" + require_relative 'guest_cap/linux/install_parallels_tools' GuestLinuxCap::InstallParallelsTools end provider_capability(:parallels, :public_address) do - require_relative "cap/public_address" + require_relative 'cap/public_address' Cap::PublicAddress end provider_capability(:parallels, :host_address) do - require_relative "cap/host_address" + require_relative 'cap/host_address' Cap::HostAddress end provider_capability(:parallels, :nic_mac_addresses) do - require_relative "cap/nic_mac_addresses" + require_relative 'cap/nic_mac_addresses' Cap::NicMacAddresses end synced_folder(:parallels) do - require File.expand_path("../synced_folder", __FILE__) + require_relative 'synced_folder' SyncedFolder end - end + # This initializes the internationalization strings. + def self.setup_i18n + I18n.load_path << File.expand_path('locales/en.yml', Parallels.source_root) + I18n.reload! + end - autoload :Action, File.expand_path("../action", __FILE__) + # This sets up our log level to be whatever VAGRANT_LOG is. + def self.setup_logging + require 'log4r' + + level = nil + begin + level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase) + rescue NameError + # This means that the logging constant wasn't found, + # which is fine. We just keep `level` as `nil`. But + # we tell the user. + level = nil + end + + # Some constants, such as "true" resolve to booleans, so the + # above error checking doesn't catch it. This will check to make + # sure that the log level is an integer, as Log4r requires. + level = nil if !level.is_a?(Integer) + + # Set the logging level on all "vagrant" namespaced + # logs as long as we have a valid level. + if level + logger = Log4r::Logger.new('vagrant_parallels') + logger.outputters = Log4r::Outputter.stderr + logger.level = level + logger = nil + end + end + end # Drop some autoloads in here to optimize the performance of loading # our drivers only when they are needed. module Driver - autoload :Meta, File.expand_path("../driver/meta", __FILE__) - autoload :PD_8, File.expand_path("../driver/pd_8", __FILE__) - autoload :PD_9, File.expand_path("../driver/pd_9", __FILE__) - autoload :PD_10, File.expand_path("../driver/pd_10", __FILE__) - autoload :PD_11, File.expand_path("../driver/pd_11", __FILE__) + autoload :Meta, File.expand_path('../driver/meta', __FILE__) + autoload :PD_8, File.expand_path('../driver/pd_8', __FILE__) + autoload :PD_9, File.expand_path('../driver/pd_9', __FILE__) + autoload :PD_10, File.expand_path('../driver/pd_10', __FILE__) + autoload :PD_11, File.expand_path('../driver/pd_11', __FILE__) end module Model - autoload :ForwardedPort, File.expand_path("../model/forwarded_port", __FILE__) + autoload :ForwardedPort, File.expand_path('../model/forwarded_port', __FILE__) end module Util - autoload :CompileForwardedPorts, File.expand_path("../util/compile_forwarded_ports", __FILE__) + autoload :CompileForwardedPorts, File.expand_path('../util/compile_forwarded_ports', __FILE__) end end -end \ No newline at end of file +end diff --git a/lib/vagrant-parallels/provider.rb b/lib/vagrant-parallels/provider.rb index 2b12fb07..c0b9e920 100644 --- a/lib/vagrant-parallels/provider.rb +++ b/lib/vagrant-parallels/provider.rb @@ -1,9 +1,9 @@ -require "log4r" -require "vagrant" +require 'log4r' +require 'vagrant' module VagrantPlugins module Parallels - class Provider < Vagrant.plugin("2", :provider) + class Provider < Vagrant.plugin('2', :provider) attr_reader :driver def self.usable?(raise_error=false) @@ -21,7 +21,7 @@ def self.usable?(raise_error=false) end def initialize(machine) - @logger = Log4r::Logger.new("vagrant::provider::parallels") + @logger = Log4r::Logger.new('vagrant::provider::parallels') @machine = machine # This method will load in our driver, so we call it now to @@ -50,7 +50,7 @@ def machine_id_changed rescue VagrantPlugins::Parallels::Driver::Meta::VMNotFound # The virtual machine doesn't exist, so we probably have a stale # ID. Just clear the id out of the machine and reload it. - @logger.debug("VM not found! Clearing saved machine ID and reloading.") + @logger.debug('VM not found! Clearing saved machine ID and reloading.') id = nil retry end @@ -68,7 +68,7 @@ def ssh_info return nil if !detected_ip # Return ip from running machine, use ip from config if available - return { + { host: detected_ip, port: @driver.ssh_port(@machine.config.ssh.guest_port) } @@ -86,7 +86,7 @@ def state state_id = :unknown if !state_id # Translate into short/long descriptions - short = state_id.to_s.gsub("_", " ") + short = state_id.to_s.gsub('_', ' ') long = I18n.t("vagrant_parallels.commands.status.#{state_id}") # If machine is not created, then specify the special ID flag @@ -113,7 +113,7 @@ def pd_version_satisfies?(*constraints) # # @return [String] def to_s - id = @machine.id ? @machine.id : "new VM" + id = @machine.id ? @machine.id : 'new VM' "Parallels (#{id})" end end diff --git a/lib/vagrant-parallels/synced_folder.rb b/lib/vagrant-parallels/synced_folder.rb index b4abec1d..3f615caf 100644 --- a/lib/vagrant-parallels/synced_folder.rb +++ b/lib/vagrant-parallels/synced_folder.rb @@ -1,8 +1,8 @@ -require "vagrant/util/platform" +require 'vagrant/util/platform' module VagrantPlugins module Parallels - class SyncedFolder < Vagrant.plugin("2", :synced_folder) + class SyncedFolder < Vagrant.plugin('2', :synced_folder) def usable?(machine, raise_errors=false) # These synced folders only work if the provider is Parallels machine.provider_name == :parallels && @@ -48,7 +48,7 @@ def enable(machine, folders, _opts) end # Go through each folder and mount - machine.ui.output(I18n.t("vagrant.actions.vm.share_folders.mounting")) + machine.ui.output(I18n.t('vagrant.actions.vm.share_folders.mounting')) folders.each do |_ , data| # Parallels specific: get id from the VM setting # It allows to mount one host folder more then one time [GH-105] @@ -56,7 +56,7 @@ def enable(machine, folders, _opts) if data[:guestpath] and id # Guest path specified, so mount the folder to specified point - machine.ui.detail(I18n.t("vagrant.actions.vm.share_folders.mounting_entry", + machine.ui.detail(I18n.t('vagrant.actions.vm.share_folders.mounting_entry', guestpath: data[:guestpath], hostpath: data[:hostpath])) @@ -73,7 +73,7 @@ def enable(machine, folders, _opts) :mount_parallels_shared_folder, id, data[:guestpath], data) else # If no guest path is specified, then automounting is disabled - machine.ui.detail(I18n.t("vagrant.actions.vm.share_folders.nomount_entry", + machine.ui.detail(I18n.t('vagrant.actions.vm.share_folders.nomount_entry', :hostpath => data[:hostpath])) end end @@ -94,7 +94,7 @@ def disable(machine, folders, _opts) end def cleanup(machine, opts) - driver(machine).clear_shared_folders if machine.id && machine.id != "" + driver(machine).clear_shared_folders if machine.id && machine.id != '' end protected diff --git a/lib/vagrant-parallels/util/compile_forwarded_ports.rb b/lib/vagrant-parallels/util/compile_forwarded_ports.rb index 54185dfa..5f82f9f0 100644 --- a/lib/vagrant-parallels/util/compile_forwarded_ports.rb +++ b/lib/vagrant-parallels/util/compile_forwarded_ports.rb @@ -15,7 +15,7 @@ def compile_forwarded_ports(config) if type == :forwarded_port guest_port = options[:guest] host_port = options[:host] - protocol = options[:protocol] || "tcp" + protocol = options[:protocol] || 'tcp' options = scoped_hash_override(options, :parallels) id = options[:id] diff --git a/lib/vagrant-parallels/version.rb b/lib/vagrant-parallels/version.rb index 968078eb..a8ac16c3 100644 --- a/lib/vagrant-parallels/version.rb +++ b/lib/vagrant-parallels/version.rb @@ -1,5 +1,5 @@ module VagrantPlugins module Parallels - VERSION = '1.4.2' + VERSION = '1.4.3' end end diff --git a/tasks/acceptance.rake b/tasks/acceptance.rake index c78f63aa..b56cb2de 100644 --- a/tasks/acceptance.rake +++ b/tasks/acceptance.rake @@ -1,10 +1,10 @@ namespace :acceptance do - desc "shows components that can be tested separately" + desc 'shows components that can be tested separately' task :components do - exec("vagrant-spec components") + exec('vagrant-spec components') end - desc "runs acceptance tests using vagrant-spec" + desc 'runs acceptance tests using vagrant-spec' task :run do components = %w( basic @@ -19,7 +19,7 @@ namespace :acceptance do package ).map{ |s| "provider/parallels/#{s}" } - command = "vagrant-spec test --components=#{components.join(" ")}" + command = "vagrant-spec test --components=#{components.join(' ')}" puts command puts exec(command) diff --git a/tasks/test.rake b/tasks/test.rake index 6fae3cd4..a1c699f4 100644 --- a/tasks/test.rake +++ b/tasks/test.rake @@ -3,6 +3,6 @@ require 'rspec/core/rake_task' namespace :test do RSpec::Core::RakeTask.new(:unit) do |t| - t.pattern = "test/unit/**/*_test.rb" + t.pattern = 'test/unit/**/*_test.rb' end end diff --git a/test/acceptance/base.rb b/test/acceptance/base.rb index 5075df3f..a98539cd 100644 --- a/test/acceptance/base.rb +++ b/test/acceptance/base.rb @@ -1,2 +1,2 @@ -require "vagrant-spec/acceptance" -require_relative "shared/context_parallels" +require 'vagrant-spec/acceptance' +require_relative 'shared/context_parallels' diff --git a/test/acceptance/provider/linked_clone_spec.rb b/test/acceptance/provider/linked_clone_spec.rb index 44ec0bec..19be525a 100644 --- a/test/acceptance/provider/linked_clone_spec.rb +++ b/test/acceptance/provider/linked_clone_spec.rb @@ -18,8 +18,8 @@ end it 'creates machine as linked clone' do - status("Test: machine is running after up") - result = execute("vagrant", "ssh", "-c", "echo foo") + status('Test: machine is running after up') + result = execute('vagrant', 'ssh', '-c', 'echo foo') expect(result).to exit_with(0) expect(result.stdout).to match(/foo\n$/) end diff --git a/test/acceptance/shared/context_parallels.rb b/test/acceptance/shared/context_parallels.rb index 1753d746..b649342c 100644 --- a/test/acceptance/shared/context_parallels.rb +++ b/test/acceptance/shared/context_parallels.rb @@ -1,2 +1,2 @@ -shared_context "provider-context/parallels" do +shared_context 'provider-context/parallels' do end diff --git a/test/acceptance/skeletons/linked_clone/Vagrantfile b/test/acceptance/skeletons/linked_clone/Vagrantfile index 16853219..270a456e 100644 --- a/test/acceptance/skeletons/linked_clone/Vagrantfile +++ b/test/acceptance/skeletons/linked_clone/Vagrantfile @@ -1,7 +1,7 @@ -Vagrant.configure("2") do |config| - config.vm.box = "basic" +Vagrant.configure('2') do |config| + config.vm.box = 'basic' - config.vm.provider "parallels" do |prl| + config.vm.provider 'parallels' do |prl| prl.use_linked_clone = true end end diff --git a/test/unit/base.rb b/test/unit/base.rb index a837036b..eb553809 100644 --- a/test/unit/base.rb +++ b/test/unit/base.rb @@ -1,17 +1,17 @@ -require "rubygems" -require "rspec/autorun" +require 'rubygems' +require 'rspec/autorun' # Require Vagrant itself so we can reference the proper # classes to test. -require "vagrant" +require 'vagrant' require 'vagrant-parallels' # Add the test directory to the load path -$:.unshift File.expand_path("../../", __FILE__) +$:.unshift File.expand_path('../../', __FILE__) # Load in helpers -require "unit/support/shared/parallels_context" -require "unit/support/shared/pd_driver_examples" +require 'unit/support/shared/parallels_context' +require 'unit/support/shared/pd_driver_examples' # Do not buffer output $stdout.sync = true diff --git a/test/unit/config_test.rb b/test/unit/config_test.rb index fe94fdf7..b935eb3d 100644 --- a/test/unit/config_test.rb +++ b/test/unit/config_test.rb @@ -1,9 +1,9 @@ -require_relative "base" +require_relative 'base' require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/config') describe VagrantPlugins::Parallels::Config do - let(:machine) { double("machine") } + let(:machine) { double('machine') } def assert_invalid errors = subject.validate(machine) @@ -20,23 +20,23 @@ def assert_valid end def valid_defaults - subject.image = "foo" + subject.image = 'foo' end before do - vm_config = double("vm_config") + vm_config = double('vm_config') vm_config.stub(networks: []) - config = double("config") + config = double('config') config.stub(vm: vm_config) machine.stub(config: config) end - its "valid by default" do + its 'valid by default' do subject.finalize! assert_valid end - context "defaults" do + context 'defaults' do before { subject.finalize! } it { expect(subject.check_guest_additions).to be_true } @@ -44,45 +44,45 @@ def valid_defaults it { expect(subject.functional_psf).to be_true } it { expect(subject.optimize_power_consumption).to be_true } - it "should have one Shared adapter" do + it 'should have one Shared adapter' do expect(subject.network_adapters).to eql({ 0 => [:shared, {}], }) end end - describe "#merge" do + describe '#merge' do let(:one) { described_class.new } let(:two) { described_class.new } subject { one.merge(two) } - it "merges the customizations" do - one.customize ["foo"] - two.customize ["bar"] + it 'merges the customizations' do + one.customize ['foo'] + two.customize ['bar'] expect(subject.customizations).to eq([ - ["pre-boot", ["foo"]], - ["pre-boot", ["bar"]]]) + ['pre-boot', ['foo']], + ['pre-boot', ['bar']]]) end end - describe "memory=" do - it "configures memory size (in Mb)" do + describe 'memory=' do + it 'configures memory size (in Mb)' do subject.memory=(1024) - expect(subject.customizations).to include(["pre-boot", ["set", :id, "--memsize", '1024']]) + expect(subject.customizations).to include(['pre-boot', ['set', :id, '--memsize', '1024']]) end end - describe "cpus=" do - it "configures count of cpus" do + describe 'cpus=' do + it 'configures count of cpus' do subject.cpus=('4') - expect(subject.customizations).to include(["pre-boot", ["set", :id, "--cpus", 4]]) + expect(subject.customizations).to include(['pre-boot', ['set', :id, '--cpus', 4]]) end end - describe "#network_adapter" do - it "configures additional adapters" do + describe '#network_adapter' do + it 'configures additional adapters' do subject.network_adapter(2, :bridged, auto_config: true) expect(subject.network_adapters[2]).to eql( [:bridged, auto_config: true]) diff --git a/test/unit/driver/pd_10_test.rb b/test/unit/driver/pd_10_test.rb index 12e86883..e4118b16 100644 --- a/test/unit/driver/pd_10_test.rb +++ b/test/unit/driver/pd_10_test.rb @@ -1,17 +1,17 @@ -require_relative "../base" +require_relative '../base' describe VagrantPlugins::Parallels::Driver::PD_10 do - include_context "parallels" - let(:parallels_version) { "10" } + include_context 'parallels' + let(:parallels_version) { '10' } subject { VagrantPlugins::Parallels::Driver::Meta.new(uuid) } - it_behaves_like "parallels desktop driver" + it_behaves_like 'parallels desktop driver' - describe "set_power_consumption_mode" do + describe 'set_power_consumption_mode' do it "turns 'longer-battery-life' on" do subprocess.should_receive(:execute). - with("prlctl", "set", uuid, "--longer-battery-life", "on", + with('prlctl', 'set', uuid, '--longer-battery-life', 'on', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -20,7 +20,7 @@ it "turns 'longer-battery-life' off" do subprocess.should_receive(:execute). - with("prlctl", "set", uuid, "--longer-battery-life", "off", + with('prlctl', 'set', uuid, '--longer-battery-life', 'off', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) diff --git a/test/unit/driver/pd_8_test.rb b/test/unit/driver/pd_8_test.rb index 8c6a2634..8c87cc07 100644 --- a/test/unit/driver/pd_8_test.rb +++ b/test/unit/driver/pd_8_test.rb @@ -1,10 +1,10 @@ -require_relative "../base" +require_relative '../base' describe VagrantPlugins::Parallels::Driver::PD_8 do - include_context "parallels" - let(:parallels_version) { "8" } + include_context 'parallels' + let(:parallels_version) { '8' } subject { VagrantPlugins::Parallels::Driver::Meta.new(uuid) } - it_behaves_like "parallels desktop driver" + it_behaves_like 'parallels desktop driver' end diff --git a/test/unit/driver/pd_9_test.rb b/test/unit/driver/pd_9_test.rb index cc3f3838..f6edb270 100644 --- a/test/unit/driver/pd_9_test.rb +++ b/test/unit/driver/pd_9_test.rb @@ -1,16 +1,16 @@ -require_relative "../base" +require_relative '../base' describe VagrantPlugins::Parallels::Driver::PD_9 do - include_context "parallels" + include_context 'parallels' subject { VagrantPlugins::Parallels::Driver::Meta.new(uuid) } - it_behaves_like "parallels desktop driver" + it_behaves_like 'parallels desktop driver' - describe "set_power_consumption_mode" do + describe 'set_power_consumption_mode' do it "turns 'longer-battery-life' on" do subprocess.should_receive(:execute). - with("prlctl", "set", uuid, "--longer-battery-life", "on", + with('prlctl', 'set', uuid, '--longer-battery-life', 'on', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -19,7 +19,7 @@ it "turns 'longer-battery-life' off" do subprocess.should_receive(:execute). - with("prlctl", "set", uuid, "--longer-battery-life", "off", + with('prlctl', 'set', uuid, '--longer-battery-life', 'off', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) diff --git a/test/unit/locales/locales_test.rb b/test/unit/locales/locales_test.rb deleted file mode 100644 index af603287..00000000 --- a/test/unit/locales/locales_test.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'i18n/tasks' -require 'i18n/tasks/base_task' - -describe 'locales' do - let(:i18n) { I18n::Tasks::BaseTask.new } - - it 'are all used' do - i18n.unused_keys.should have(0).keys - end - - it 'are all present' do - i18n.missing_keys.should have(0).keys - end -end \ No newline at end of file diff --git a/test/unit/support/shared/pd_driver_examples.rb b/test/unit/support/shared/pd_driver_examples.rb index 5cea090d..0229e90a 100644 --- a/test/unit/support/shared/pd_driver_examples.rb +++ b/test/unit/support/shared/pd_driver_examples.rb @@ -1,35 +1,35 @@ -shared_examples "parallels desktop driver" do |options| +shared_examples 'parallels desktop driver' do |options| before do - raise ArgumentError, "Need parallels context to use these shared examples." unless defined? parallels_context + raise ArgumentError, 'Need parallels context to use these shared examples.' unless defined? parallels_context end - describe "compact" do - settings = {"Hardware" => {"hdd0" => {"image" => "/path/to/disk0.hdd"}, - "hdd1" => {"image" => "/path/to/disk1.hdd"}}} - it "compacts the VM disk drives" do + describe 'compact' do + settings = {'Hardware' => {'hdd0' => {'image' => '/path/to/disk0.hdd'}, + 'hdd1' => {'image' => '/path/to/disk1.hdd'}}} + it 'compacts the VM disk drives' do driver.should_receive(:read_settings).and_return(settings) subprocess.should_receive(:execute).exactly(2).times. - with("prl_disk_tool", 'compact', '--hdd', /^\/path\/to\/disk(0|1).hdd$/, + with('prl_disk_tool', 'compact', '--hdd', /^\/path\/to\/disk(0|1).hdd$/, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.compact(uuid) end end - describe "clear_shared_folders" do - it "deletes every shared folder assigned to the VM" do + describe 'clear_shared_folders' do + it 'deletes every shared folder assigned to the VM' do subprocess.should_receive(:execute).at_least(2).times. - with("prlctl", "set", uuid, "--shf-host-del", an_instance_of(String), + with('prlctl', 'set', uuid, '--shf-host-del', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.clear_shared_folders end end - describe "create_host_only_network" do + describe 'create_host_only_network' do let(:hostonly_iface) {'vnic12'} - it "creates host-only NIC with dhcp server configured" do + it 'creates host-only NIC with dhcp server configured' do vnic_opts = { network_id: 'vagrant_vnic8', adapter_ip: '11.11.11.11', @@ -42,16 +42,16 @@ } subprocess.should_receive(:execute). - with("prlsrvctl", "net", "add", vnic_opts[:network_id], - "--type", "host-only", an_instance_of(Hash)). + with('prlsrvctl', 'net', 'add', vnic_opts[:network_id], + '--type', 'host-only', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subprocess.should_receive(:execute). - with("prlsrvctl", "net", "set", vnic_opts[:network_id], - "--ip", "#{vnic_opts[:adapter_ip]}/#{vnic_opts[:netmask]}", - "--dhcp-ip", vnic_opts[:dhcp][:ip], - "--ip-scope-start", vnic_opts[:dhcp][:lower], - "--ip-scope-end", vnic_opts[:dhcp][:upper], an_instance_of(Hash)). + with('prlsrvctl', 'net', 'set', vnic_opts[:network_id], + '--ip', "#{vnic_opts[:adapter_ip]}/#{vnic_opts[:netmask]}", + '--dhcp-ip', vnic_opts[:dhcp][:ip], + '--ip-scope-start', vnic_opts[:dhcp][:lower], + '--ip-scope-end', vnic_opts[:dhcp][:upper], an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) interface = subject.create_host_only_network(vnic_opts) @@ -64,7 +64,7 @@ # interface[:name].should =~ /^(vnic(\d+))$/ end - it "creates host-only NIC without dhcp" do + it 'creates host-only NIC without dhcp' do vnic_options = { network_id: 'vagrant_vnic3', adapter_ip: '22.22.22.22', @@ -72,13 +72,13 @@ } subprocess.should_receive(:execute). - with("prlsrvctl", "net", "add", vnic_options[:network_id], - "--type", "host-only", an_instance_of(Hash)). + with('prlsrvctl', 'net', 'add', vnic_options[:network_id], + '--type', 'host-only', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subprocess.should_receive(:execute). - with("prlsrvctl", "net", "set", vnic_options[:network_id], - "--ip", "#{vnic_options[:adapter_ip]}/#{vnic_options[:netmask]}", + with('prlsrvctl', 'net', 'set', vnic_options[:network_id], + '--ip', "#{vnic_options[:adapter_ip]}/#{vnic_options[:netmask]}", an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -93,69 +93,69 @@ end end - describe "delete" do - it "deletes the VM" do + describe 'delete' do + it 'deletes the VM' do subprocess.should_receive(:execute). - with("prlctl", "delete", uuid, an_instance_of(Hash)). + with('prlctl', 'delete', uuid, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.delete end end - describe "delete_disabled_adapters" do - it "deletes disabled networks adapters from VM config" do - settings = {"Hardware" => {"net0" => {"enabled" => false}, - "net1" => {"enabled" => false}}} + describe 'delete_disabled_adapters' do + it 'deletes disabled networks adapters from VM config' do + settings = {'Hardware' => {'net0' => {'enabled' => false}, + 'net1' => {'enabled' => false}}} driver.should_receive(:read_settings).and_return(settings) subprocess.should_receive(:execute).exactly(2).times. - with("prlctl", "set", uuid, "--device-del", /^net(0|1)$/, + with('prlctl', 'set', uuid, '--device-del', /^net(0|1)$/, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.delete_disabled_adapters end end - describe "clone_vm" do - it "clones VM to the new one" do + describe 'clone_vm' do + it 'clones VM to the new one' do subprocess.should_receive(:execute). - with("prlctl", "clone", tpl_uuid, "--name", vm_name, + with('prlctl', 'clone', tpl_uuid, '--name', vm_name, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.clone_vm(tpl_uuid, vm_name).should == uuid end - it "clones VM to template" do + it 'clones VM to template' do subprocess.should_receive(:execute). - with("prlctl", "clone", uuid, "--name", tpl_name, - "--template", "--dst", an_instance_of(String), + with('prlctl', 'clone', uuid, '--name', tpl_name, + '--template', '--dst', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.clone_vm(uuid, tpl_name, - {dst: "/path/to/template", template: true}). + {dst: '/path/to/template', template: true}). should == tpl_uuid end end - describe "halt" do - it "stops the VM" do + describe 'halt' do + it 'stops the VM' do subprocess.should_receive(:execute). - with("prlctl", "stop", uuid, an_instance_of(Hash)). + with('prlctl', 'stop', uuid, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.halt end - it "stops the VM force" do + it 'stops the VM force' do subprocess.should_receive(:execute). - with("prlctl", "stop", uuid, "--kill", an_instance_of(Hash)). + with('prlctl', 'stop', uuid, '--kill', an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.halt(force=true) end end - describe "read_guest_tools_state" do + describe 'read_guest_tools_state' do let(:tools_state) {'outdated'} - it "returns Guest Tools state as a symbol" do + it 'returns Guest Tools state as a symbol' do subject.read_guest_tools_state.should be(:outdated) end @@ -165,46 +165,46 @@ end end - describe "read_guest_tools_iso_path" do + describe 'read_guest_tools_iso_path' do before do subprocess.stub(:execute). - with("mdfind", /^kMDItemCFBundleIdentifier ==/, an_instance_of(Hash)). - and_return(subprocess_result(stdout: "/Applications/Parallels Desktop.app")) + with('mdfind', /^kMDItemCFBundleIdentifier ==/, an_instance_of(Hash)). + and_return(subprocess_result(stdout: '/Applications/Parallels Desktop.app')) end - it "returns a valid path to the ISO" do + it 'returns a valid path to the ISO' do File.stub(:exist?).and_return(true) - iso_path = subject.read_guest_tools_iso_path("linux") + iso_path = subject.read_guest_tools_iso_path('linux') iso_path.should be_kind_of(String) iso_path.should match(/prl-tools-lin\.iso$/) end - it "raises an exception if ISO file does not exists" do + it 'raises an exception if ISO file does not exists' do File.stub(:exist?).and_return(false) - expect { subject.read_guest_tools_iso_path("windows") }. + expect { subject.read_guest_tools_iso_path('windows') }. to raise_error(VagrantPlugins::Parallels::Errors::ParallelsToolsIsoNotFound) end - it "returns nil if guest OS is unsupported or invalid" do - subject.read_guest_tools_iso_path("").should be_nil - subject.read_guest_tools_iso_path("bolgenos").should be_nil + it 'returns nil if guest OS is unsupported or invalid' do + subject.read_guest_tools_iso_path('').should be_nil + subject.read_guest_tools_iso_path('bolgenos').should be_nil end end - describe "read_mac_addresses" do - it "returns MAC addresses of all network interface cards" do + describe 'read_mac_addresses' do + it 'returns MAC addresses of all network interface cards' do subject.read_mac_addresses.should be_kind_of(Array) subject.read_mac_addresses.should include('001C42B4B074') subject.read_mac_addresses.should include('001C42B4B090') end end - describe "read_settings" do - it "returns a hash with detailed info about the VM" do + describe 'read_settings' do + it 'returns a hash with detailed info about the VM' do subject.read_settings.should be_kind_of(Hash) - subject.read_settings.should include("ID" => uuid) - subject.read_settings.should include("Hardware") - subject.read_settings.should include("GuestTools") + subject.read_settings.should include('ID' => uuid) + subject.read_settings.should include('Hardware') + subject.read_settings.should include('GuestTools') end end @@ -229,16 +229,16 @@ end end - describe "read_vms" do - it "returns the list of all registered VMs and templates" do + describe 'read_vms' do + it 'returns the list of all registered VMs and templates' do subject.read_vms.should be_kind_of(Hash) subject.read_vms.should have_at_least(2).items subject.read_vms.should include(vm_name => uuid) end end - describe "read_vms_info" do - it "returns detailed info about all registered VMs and templates" do + describe 'read_vms_info' do + it 'returns detailed info about all registered VMs and templates' do subject.read_vms_info.should be_kind_of(Array) subject.read_vms_info.should have_at_least(2).items @@ -248,20 +248,20 @@ end end - describe "register" do - it "registers specified virtual machine or template" do + describe 'register' do + it 'registers specified virtual machine or template' do subprocess.should_receive(:execute). - with("prlctl", "register", an_instance_of(String), an_instance_of(Hash)). + with('prlctl', 'register', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) - subject.register("/path/to/vm_image.pvm") + subject.register('/path/to/vm_image.pvm') end end - describe "set_name" do - it "sets new name for the VM" do + describe 'set_name' do + it 'sets new name for the VM' do subprocess.should_receive(:execute). - with("prlctl", "set", uuid, '--name', an_instance_of(String), + with('prlctl', 'set', uuid, '--name', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) @@ -269,19 +269,19 @@ end end - describe "ssh_ip" do + describe 'ssh_ip' do let(:content) {'10.200.0.100="1394546410,1800,001c420000ff,01001c420000ff 10.200.0.99="1394547632,1800,001c420000ff,01001c420000ff"'} - it "returns an IP address assigned to the specified MAC" do - driver.should_receive(:read_mac_address).and_return("001C420000FF") + it 'returns an IP address assigned to the specified MAC' do + driver.should_receive(:read_mac_address).and_return('001C420000FF') File.should_receive(:open).with(an_instance_of(String)). and_return(StringIO.new(content)) - subject.ssh_ip.should == "10.200.0.99" + subject.ssh_ip.should == '10.200.0.99' end - it "rises DhcpLeasesNotAccessible exception when file is not accessible" do + it 'rises DhcpLeasesNotAccessible exception when file is not accessible' do File.stub(:open).and_call_original File.should_receive(:open).with(an_instance_of(String)). and_raise(Errno::EACCES) @@ -290,51 +290,51 @@ end end - describe "start" do - it "starts the VM" do + describe 'start' do + it 'starts the VM' do subprocess.should_receive(:execute). - with("prlctl", "start", uuid, an_instance_of(Hash)). + with('prlctl', 'start', uuid, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.start end end - describe "suspend" do - it "suspends the VM" do + describe 'suspend' do + it 'suspends the VM' do subprocess.should_receive(:execute). - with("prlctl", "suspend", uuid, an_instance_of(Hash)). + with('prlctl', 'suspend', uuid, an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) subject.suspend end end - describe "unregister" do - it "suspends the VM" do + describe 'unregister' do + it 'suspends the VM' do subprocess.should_receive(:execute). - with("prlctl", "unregister", an_instance_of(String), + with('prlctl', 'unregister', an_instance_of(String), an_instance_of(Hash)). and_return(subprocess_result(exit_code: 0)) - subject.unregister("template_or_vm_uuid") + subject.unregister('template_or_vm_uuid') end end - describe "version" do - it "parses the version from output" do + describe 'version' do + it 'parses the version from output' do subject.version.should match(/^#{parallels_version}.\d+\.\d+$/) end - it "raises an exception for unsupported version" do + it 'raises an exception for unsupported version' do subprocess.should_receive(:execute). - with("prlctl", "--version", an_instance_of(Hash)). - and_return(subprocess_result(stdout: "prlctl version 7.0.12345")) + with('prlctl', '--version', an_instance_of(Hash)). + and_return(subprocess_result(stdout: 'prlctl version 7.0.12345')) expect { subject.version }. to raise_error(VagrantPlugins::Parallels::Errors::ParallelsUnsupportedVersion) end - it "raises an exception for invalid version output" do + it 'raises an exception for invalid version output' do subprocess.should_receive(:execute). - with("prlctl", "--version", an_instance_of(Hash)). - and_return(subprocess_result(stdout: "prlctl version 1.2.foo.bar")) + with('prlctl', '--version', an_instance_of(Hash)). + and_return(subprocess_result(stdout: 'prlctl version 1.2.foo.bar')) expect { subject.version }. to raise_error(VagrantPlugins::Parallels::Errors::ParallelsInvalidVersion) end diff --git a/test/unit/synced_folder_test.rb b/test/unit/synced_folder_test.rb index ae771508..bbfa8d7d 100644 --- a/test/unit/synced_folder_test.rb +++ b/test/unit/synced_folder_test.rb @@ -1,12 +1,12 @@ -require "vagrant" -require_relative "base" +require 'vagrant' +require_relative 'base' -require VagrantPlugins::Parallels.source_root.join("lib/vagrant-parallels/config") +require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/config') require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/synced_folder') describe VagrantPlugins::Parallels::SyncedFolder do let(:machine) do - double("machine").tap do |m| + double('machine').tap do |m| m.stub(provider_config: VagrantPlugins::Parallels::Config.new) m.stub(provider_name: :parallels) end @@ -18,31 +18,31 @@ machine.provider_config.finalize! end - describe "usable" do - it "should be with parallels provider" do + describe 'usable' do + it 'should be with parallels provider' do machine.stub(provider_name: :parallels) subject.should be_usable(machine) end - it "should not be with another provider" do + it 'should not be with another provider' do machine.stub(provider_name: :virtualbox) subject.should_not be_usable(machine) end - it "should not be usable if not functional psf" do + it 'should not be usable if not functional psf' do machine.provider_config.functional_psf = false expect(subject).to_not be_usable(machine) end end - describe "prepare" do - let(:driver) { double("driver") } + describe 'prepare' do + let(:driver) { double('driver') } before do machine.stub(driver: driver) end - it "should share the folders" do + it 'should share the folders' do pending end end diff --git a/vagrant-parallels.gemspec b/vagrant-parallels.gemspec index 5f4353bc..b2be1419 100644 --- a/vagrant-parallels.gemspec +++ b/vagrant-parallels.gemspec @@ -1,27 +1,25 @@ # coding: utf-8 -$:.unshift File.expand_path("../lib", __FILE__) +$:.unshift File.expand_path('../lib', __FILE__) require 'vagrant-parallels/version' Gem::Specification.new do |spec| - spec.name = "vagrant-parallels" + spec.name = 'vagrant-parallels' spec.version = VagrantPlugins::Parallels::VERSION spec.platform = Gem::Platform::RUBY - spec.authors = ["Mikhail Zholobov", "Youssef Shahin"] - spec.email = ["mzholobov@parallels.com", "yshahin@gmail.com"] + spec.authors = ['Mikhail Zholobov', 'Youssef Shahin'] + spec.email = ['mzholobov@parallels.com', 'yshahin@gmail.com'] spec.summary = %q{Parallels provider for Vagrant.} spec.description = %q{Enables Vagrant to manage Parallels virtual machines.} - spec.homepage = "http://github.com/Parallels/vagrant-parallels" - spec.license = "MIT" + spec.homepage = 'http://github.com/Parallels/vagrant-parallels' + spec.license = 'MIT' - spec.required_rubygems_version = ">= 1.3.6" - spec.rubyforge_project = "vagrant-parallels" + spec.required_rubygems_version = '>= 1.3.6' + spec.rubyforge_project = 'vagrant-parallels' - spec.add_development_dependency "bundler", ">= 1.5.2" - spec.add_development_dependency "rake" - spec.add_development_dependency "minitest" - spec.add_development_dependency "nokogiri" - spec.add_development_dependency "rspec", "~> 2.14.0" - spec.add_development_dependency "i18n-tasks", "~> 0.3.9" + spec.add_development_dependency 'bundler', '>= 1.5.2' + spec.add_development_dependency 'rake' + spec.add_development_dependency 'nokogiri' + spec.add_development_dependency 'rspec', '~> 2.14.0' # The following block of code determines the files that should be included # in the gem. It does this by reading all the files in the directory where @@ -29,10 +27,10 @@ Gem::Specification.new do |spec| # Note that the entire gitignore(5) syntax is not supported, specifically # the "!" syntax, but it should mostly work correctly. root_path = File.dirname(__FILE__) - all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") } - all_files.reject! { |file| [".", ".."].include?(File.basename(file)) } - all_files.reject! { |file| file.start_with?("website/") } - gitignore_path = File.join(root_path, ".gitignore") + all_files = Dir.chdir(root_path) { Dir.glob('**/{*,.*}') } + all_files.reject! { |file| ['.', '..'].include?(File.basename(file)) } + all_files.reject! { |file| file.start_with?('website/') } + gitignore_path = File.join(root_path, '.gitignore') gitignore = File.readlines(gitignore_path) gitignore.map! { |line| line.chomp.strip } gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ } @@ -57,5 +55,5 @@ Gem::Specification.new do |spec| spec.files = unignored_files spec.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact - spec.require_path = "lib" + spec.require_path = 'lib' end diff --git a/website/docs/Gemfile b/website/docs/Gemfile index 77a7f090..528db83e 100644 --- a/website/docs/Gemfile +++ b/website/docs/Gemfile @@ -1,13 +1,13 @@ -source "https://rubygems.org" +source 'https://rubygems.org' -gem "less", "~> 2.2.2" -gem "middleman", "~> 3.2.0" -gem "middleman-deploy", "~> 1.0" -gem "rack-contrib", "~> 1.1.0" -gem "redcarpet", "~> 2.2.2" -gem "therubyracer", "~> 0.12.0" -gem "thin", "~> 1.5.0" +gem 'less', '~> 2.2.2' +gem 'middleman', '~> 3.2.0' +gem 'middleman-deploy', '~> 1.0' +gem 'rack-contrib', '~> 1.1.0' +gem 'redcarpet', '~> 2.2.2' +gem 'therubyracer', '~> 0.12.0' +gem 'thin', '~> 1.5.0' group :development do - gem "highline", "~> 1.6.15" + gem 'highline', '~> 1.6.15' end diff --git a/website/docs/config.rb b/website/docs/config.rb index bcd9888f..6dfaeb13 100644 --- a/website/docs/config.rb +++ b/website/docs/config.rb @@ -19,7 +19,7 @@ end activate :deploy do |deploy| - deploy.remote = "origin" + deploy.remote = 'origin' deploy.method = :git - deploy.branch = "gh-pages" + deploy.branch = 'gh-pages' end diff --git a/website/docs/config.ru b/website/docs/config.ru index a0d8de1e..ddaf37a4 100644 --- a/website/docs/config.ru +++ b/website/docs/config.ru @@ -1,10 +1,10 @@ -require "rack" -require "rack/contrib/not_found" -require "rack/contrib/response_headers" -require "rack/contrib/static_cache" -require "rack/contrib/try_static" +require 'rack' +require 'rack/contrib/not_found' +require 'rack/contrib/response_headers' +require 'rack/contrib/static_cache' +require 'rack/contrib/try_static' -require File.expand_path("../lib/redirect_to_docs", __FILE__) +require File.expand_path('../lib/redirect_to_docs', __FILE__) # Properly compress the output if the client can handle it. use Rack::Deflater @@ -16,8 +16,8 @@ use HashiCorp::Rack::RedirectToDocs # we hash the contents of the assets to determine filenames, this is safe # to do. use Rack::StaticCache, - root: "build", - urls: ["/images", "/javascripts", "/stylesheets"], + root: 'build', + urls: ['/images', '/javascripts', '/stylesheets'], duration: 2, versioning: false @@ -25,15 +25,15 @@ use Rack::StaticCache, # for Fastly so that we can quickly purge all the pages without touching # the static assets. use Rack::ResponseHeaders do |headers| - headers["Surrogate-Key"] = "page" + headers['Surrogate-Key'] = 'page' end # Try to find a static file that matches our request, since Middleman # statically generates everything. use Rack::TryStatic, - root: "build", - urls: ["/"], - try: [".html", "index.html", "/index.html"] + root: 'build', + urls: ['/'], + try: ['.html', 'index.html', '/index.html'] # 404 if we reached this point. Sad times. -run Rack::NotFound.new(File.expand_path("../build/404.html", __FILE__)) +run Rack::NotFound.new(File.expand_path('../build/404.html', __FILE__)) diff --git a/website/docs/helpers/sidebar_helpers.rb b/website/docs/helpers/sidebar_helpers.rb index a1666035..7b73810c 100644 --- a/website/docs/helpers/sidebar_helpers.rb +++ b/website/docs/helpers/sidebar_helpers.rb @@ -7,14 +7,14 @@ def sidebar_current(expected) #|| sidebar_section == expected return " class=\"current\"" else - return "" + return '' end end # This returns the overall section of the documentation we're on. def sidebar_section current = current_page.data.sidebar_current - return "" if !current - current.split("-")[0] + return '' if !current + current.split('-')[0] end end diff --git a/website/docs/lib/redirect_to_docs.rb b/website/docs/lib/redirect_to_docs.rb index 5ed5a57c..fec3c61f 100644 --- a/website/docs/lib/redirect_to_docs.rb +++ b/website/docs/lib/redirect_to_docs.rb @@ -7,13 +7,13 @@ def initialize(app) end def call(env) - if env["PATH_INFO"] =~ /^\/$/ + if env['PATH_INFO'] =~ /^\/$/ headers = { - "Content-Type" => "text/html", - "Location" => "/docs/", - "Surrogate-Key" => "page" + 'Content-Type' => 'text/html', + 'Location' => '/docs/', + 'Surrogate-Key' => 'page' } - message = "Redirecting to new URL..." + message = 'Redirecting to new URL...' return [301, headers, [message]] end diff --git a/website/docs/source/404.html.erb b/website/docs/source/404.html.erb index aed8b210..102013b6 100644 --- a/website/docs/source/404.html.erb +++ b/website/docs/source/404.html.erb @@ -1,4 +1,4 @@ -

Page Not Found

+

Page Not Found

Sorry, the page you tried to visit doesn't exist. This could be our fault, diff --git a/website/docs/source/docs/configuration.html.md b/website/docs/source/docs/configuration.html.md index 27e0e8b4..761f8955 100755 --- a/website/docs/source/docs/configuration.html.md +++ b/website/docs/source/docs/configuration.html.md @@ -18,27 +18,65 @@ Vagrantfile plus a timestamp of when the machine was created. To change the name, set the `name` property to the desired value: ```ruby -config.vm.provider "parallels" do |v| - v.name = "my_vm" +config.vm.provider "parallels" do |prl| + prl.name = "my_vm" end ``` +## Create VM as a Linked Clone +

+

+ Note: This feature is available only with Parallels + Desktop 11 or higher. +

+
+ +When you run `vagrant up` for the first time, the new virtual machine +will be created by cloning the box image. By default the Parallels provider +creates a regular clone, e.q. the full copy of the box image. + +You can configure it to create a linked clone instead: + +```ruby +config.vm.provider "parallels" do |prl| + prl.use_linked_clone = true +end +``` + +Difference between linked and regular clones: + +- Linked clone creation is extremely faster than the regular cloning, because +there is no image copying process. +- Linked clone require much less disk space, because its hard disk image is less +than 1Mb initially (it is bound to the parent's snapshot). +- Regular clone is a full image copy, which is independent from the box. +The linked clone is bound to the specific snapshot of the box image. It means +that box deletion will cause all its linked clones being corrupted. Then please, +delete your boxes carefully! + ## Parallels Tools Auto-Update +
+

+ Note: This feature makes sense to Linux guests only. + In Windows and Mac OS guests Parallels Tools will be always updated + automatically by the special installation agent running in GUI mode. +

+
+ Parallels Tools is a set of Parallels utilities that ensures a high level of integration between the host and the guest operating systems (read more: [Parallels Tools Overview](http://download.parallels.com/desktop/v9/ga/docs/en_US/Parallels%20Desktop%20User's%20Guide/32789.htm)). -By default, the Parallels provider checks the status of Parallels Tools after +By default the Parallels provider checks the status of Parallels Tools after booting the machine. If they are outdated or newer, a warning message will be displayed. - You can configure the Parallels provider to update Parallels Tools automatically: ```ruby -config.vm.provider "parallels" do |v| - v.update_guest_tools = true +config.vm.provider "parallels" do |prl| + prl.update_guest_tools = true end ``` @@ -49,38 +87,29 @@ version mismatch. Also, you can completely disable the Parallels Tools version check, if you want: ```ruby -config.vm.provider "parallels" do |v| - v.check_guest_tools = false +config.vm.provider "parallels" do |prl| + prl.check_guest_tools = false end ``` In this case the both of Parallels Tools status check and an automatic update procedure will be skipped as well. -
-

- Note: The feature of Parallels Tools Auto-Update is - related to Linux guest OS only. - In Windows and Mac OS guests Parallels Tools will be always updated - automatically by the special installation agent running in GUI mode. -

-
- ## Power Consumption Mode The Parallels provider sets power consumption method as "Longer Battery Life" by default. You can override it to "Better Performance" using this customisation parameter: ```ruby -config.vm.provider "parallels" do |v| - v.optimize_power_consumption = false +config.vm.provider "parallels" do |prl| + prl.optimize_power_consumption = false end ``` P.s. Read more about power consumption modes in Parallels Desktop: [KB #9607] (http://kb.parallels.com/en/9607) -## prlctl Customization +## Customization with prlctl Parallels Desktop includes the `prlctl` command-line utility that can be used to modify the virtual machines settings. @@ -90,8 +119,8 @@ The Parallels provider allows to execute the prlctl command with any of the available options just prior to booting the virtual machine: ```ruby -config.vm.provider "parallels" do |v| - v.customize ["set", :id, "--device-set", "cdrom0", "--image", +config.vm.provider "parallels" do |prl| + prl.customize ["set", :id, "--device-set", "cdrom0", "--image", "/path/to/disk.iso", "--connect"] end ``` @@ -106,9 +135,9 @@ executed in the given order. A simple way is provided to change the memory and CPU settings: ```ruby -config.vm.provider "parallels" do |v| - v.memory = 1024 - v.cpus = 2 +config.vm.provider "parallels" do |prl| + prl.memory = 1024 + prl.cpus = 2 end ``` diff --git a/website/docs/source/docs/index.html.md b/website/docs/source/docs/index.html.md index 5db7d120..34f8a517 100755 --- a/website/docs/source/docs/index.html.md +++ b/website/docs/source/docs/index.html.md @@ -6,7 +6,7 @@ sidebar_current: "overview" Welcome to the Parallels provider for Vagrant documentation! This site documents the Parallels provider, which allows Vagrant to power -[Parallels Desktop for Mac](http://www.parallels.com/downloads/desktop/) based +[Parallels Desktop for Mac](http://www.parallels.com/products/desktop/) based virtual machines. If you're just getting started with Vagrant, it is highly recommended you start @@ -25,11 +25,12 @@ Vagrant ships out of the box with support for VirtualBox and HyperV only. The Parallels provider for Vagrant is a plugin officially supported by [Parallels](http://www.parallels.com/). The plugin allows Vagrant to power -[Parallels Desktop for Mac](http://www.parallels.com/downloads/desktop/) based +[Parallels Desktop for Mac](http://www.parallels.com/products/desktop/) based virtual machines and take advantage of the world's bestselling, top-rated, and most trusted solution for running virtual machines in Mac OS X. The Parallels provider is free and open for contributions on the [GitHub](https://github.com/Parallels/vagrant-parallels). +It is compatible with the following versions of Parallels Desktop: -It is compatible with Parallels Desktop 8, 9 and 10 for Mac. -Parallels Desktop must be purchased and installed prior to using the provider. +* Parallels Desktop 8, 9, 10 for Mac +* Parallels Desktop 11 for Mac - only "Pro" and "Business" editions diff --git a/website/docs/source/docs/installation/index.html.md b/website/docs/source/docs/installation/index.html.md index 65eec3f3..b2a6c081 100755 --- a/website/docs/source/docs/installation/index.html.md +++ b/website/docs/source/docs/installation/index.html.md @@ -18,5 +18,12 @@ The Vagrant plugin installer will automatically download and install `vagrant-parallels` plugin. ## Requirements -- Parallels Desktop for Mac version 8 or higher - Vagrant v1.5 or higher +- Parallels Desktop for Mac version 8 or higher + +
+

+ In Parallels Desktop 11 for Mac only Pro and + Business editions can be used with this Vagrant provider. +

+
diff --git a/website/docs/source/docs/networking/forwarded_ports.html.md b/website/docs/source/docs/networking/forwarded_ports.html.md index 6edb4d19..bc76dd41 100644 --- a/website/docs/source/docs/networking/forwarded_ports.html.md +++ b/website/docs/source/docs/networking/forwarded_ports.html.md @@ -10,7 +10,7 @@ sidebar_current: "networking-fp"

- "Forwarded ports" feature is available only with Parallels Desktop 10 for Mac. + "Forwarded ports" feature is available only with Parallels Desktop 10 and higher.

diff --git a/website/docs/source/layouts/layout.erb b/website/docs/source/layouts/layout.erb index 7b84315a..a13e49a5 100644 --- a/website/docs/source/layouts/layout.erb +++ b/website/docs/source/layouts/layout.erb @@ -3,20 +3,20 @@ - <%= current_page.data.page_title ? " #{current_page.data.page_title} - " : "" %>Vagrant Parallels Provider Documentation + <%= current_page.data.page_title ? " #{current_page.data.page_title} - " : '' %>Vagrant Parallels Provider Documentation - <%= stylesheet_link_tag "bootstrap", "vagrant-parallels" %> + <%= stylesheet_link_tag 'bootstrap', 'vagrant-parallels' %> - <%= javascript_include_tag "jquery" %> - <%= javascript_include_tag "modernizr" %> - <%= javascript_include_tag "bootstrap.min" %> - <%= javascript_include_tag "backstretch" %> - <%= javascript_include_tag "vagrant-parallels" %> + <%= javascript_include_tag 'jquery' %> + <%= javascript_include_tag 'modernizr' %> + <%= javascript_include_tag 'bootstrap.min' %> + <%= javascript_include_tag 'backstretch' %> + <%= javascript_include_tag 'vagrant-parallels' %> @@ -53,43 +53,43 @@ @@ -118,7 +118,7 @@

Vagrant

- +
  • Parallels Desktop

  • diff --git a/website/docs/source/stylesheets/_sidebar.less b/website/docs/source/stylesheets/_sidebar.less index 6a7928b6..e3ad7959 100644 --- a/website/docs/source/stylesheets/_sidebar.less +++ b/website/docs/source/stylesheets/_sidebar.less @@ -65,7 +65,7 @@ ul.sub { //subnav list styles border-top: none; list-style-type: none; - margin: 0 0 0 inherit; + margin: 0 0 0 12px; li { font-size: 18px;