Skip to content

Commit

Permalink
Release v1.3.5
Browse files Browse the repository at this point in the history
* master:
  Version bumped to 1.3.5
  Gemfile: Constraint vagrant revision by tag
  Fixed unit tests
  config: Renamed option 'regen_box_uuid' to 'regen_src_uuid'
  action/import: Regen SourceVmUuid by nokogiri
  handle_guest_tools: Last chance to get the actual state of Parallels Tools
  Fixed invalid state of Parallels Tools
  • Loading branch information
legal90 committed Dec 20, 2014
2 parents d42ed19 + 90a992f commit 4be4811
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ group :development do
# We depend on Vagrant for development, but we don't add it as a
# gem dependency because we expect to be installed within the
# Vagrant environment itself using `vagrant plugin`.
gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git'
gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.7.1'
end
20 changes: 19 additions & 1 deletion lib/vagrant-parallels/action/handle_guest_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def call(env)

env[:ui].output(I18n.t("vagrant_parallels.actions.vm.handle_guest_tools.checking"))

tools_state = @machine.provider.driver.read_guest_tools_state
tools_state = parallels_tools_state

if tools_state == :installed
@logger.info("The proper version of Parallels Tools is already installed")
Expand Down Expand Up @@ -50,6 +50,24 @@ def call(env)
@app.call(env)
end

private

# Determines the state of Parallels Tools
#
# @return [Symbol] Parallels Tools state (ex. :installed, :outdated,
# :not_installed, :possibly_installed)
def parallels_tools_state
# Sometimes tools can define their state with a little delay.
# If it is 'possibly_installed', then just wait a bit and try again.
3.times do
state = @machine.provider.driver.read_guest_tools_state
return state if state != :possibly_installed
sleep 2
end

@machine.provider.driver.read_guest_tools_state
end

end
end
end
Expand Down
9 changes: 6 additions & 3 deletions lib/vagrant-parallels/action/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def recover(env)

def register_template(tpl_path_s)
@logger.info("Register the box template: '#{tpl_path_s}'")
regen_uuid = @machine.provider_config.regen_box_uuid

@machine.provider.driver.register(tpl_path_s, regen_uuid)
@machine.provider.driver.register(tpl_path_s)
end

def template_path
Expand Down Expand Up @@ -96,6 +94,11 @@ 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
end

def unregister_template(tpl_name)
Expand Down
13 changes: 10 additions & 3 deletions lib/vagrant-parallels/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ class Config < Vagrant.plugin("2", :config)
attr_accessor :optimize_power_consumption
attr_accessor :name
attr_reader :network_adapters
attr_accessor :regen_box_uuid
attr_accessor :regen_src_uuid
attr_accessor :update_guest_tools

# Compatibility with virtualbox provider's syntax
alias :check_guest_additions= :check_guest_tools=

# Compatibility with old names
alias :regen_box_uuid= :regen_src_uuid=

def initialize
@check_guest_tools = UNSET_VALUE
@customizations = []
Expand All @@ -22,7 +25,7 @@ def initialize
@network_adapters = {}
@name = UNSET_VALUE
@optimize_power_consumption = UNSET_VALUE
@regen_box_uuid = UNSET_VALUE
@regen_src_uuid = UNSET_VALUE
@update_guest_tools = UNSET_VALUE

network_adapter(0, :shared)
Expand All @@ -47,6 +50,10 @@ def cpus=(count)
customize("pre-boot", ["set", :id, "--cpus", count.to_i])
end

def regen_box_uuid=(value)
@regen_src_uuid = value
end

def merge(other)
super.tap do |result|
c = customizations.dup
Expand Down Expand Up @@ -74,7 +81,7 @@ def finalize!

@name = nil if @name == UNSET_VALUE

@regen_box_uuid = true if @regen_box_uuid == UNSET_VALUE
@regen_src_uuid = true if @regen_src_uuid == UNSET_VALUE

if @update_guest_tools == UNSET_VALUE
@update_guest_tools = false
Expand Down
10 changes: 6 additions & 4 deletions lib/vagrant-parallels/driver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,15 @@ def read_vm_option(option, uuid=@uuid)
def read_vms
end

# Regenerates 'SourceVmUuid' to avoid SMBIOS UUID collision [GH-113]
#
def regenerate_src_uuid
end

# Registers the virtual machine
#
# @param [String] pvm_file Path to the machine image (*.pvm)
# @param [Boolean] regen_src_uuid Regenerate 'SourceVmUuid' to avoid
# SMBIOS UUID collision, or let it unchanged to keep activation status
# for Windows-based guests [GH-113]
def register(pvm_file, regen_src_uuid)
def register(pvm_file)
end

# Resumes the virtual machine.
Expand Down
1 change: 1 addition & 0 deletions lib/vagrant-parallels/driver/meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def initialize(uuid=nil)
:read_vms,
:read_vms_info,
:read_vms_paths,
:regenerate_src_uuid,
:register,
:resume,
:set_power_consumption_mode,
Expand Down
19 changes: 17 additions & 2 deletions lib/vagrant-parallels/driver/pd_8.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'log4r'
require 'nokogiri'
require 'securerandom'

require 'vagrant/util/platform'

Expand Down Expand Up @@ -430,9 +432,22 @@ def read_vms_paths
list
end

def register(pvm_file, regen_src_uuid=false)
def regenerate_src_uuid
settings = read_settings
vm_config = File.join(settings.fetch('Home'), 'config.pvs')

# Generate and put new SourceVmUuid
xml = Nokogiri::XML(File.open(vm_config))
p = '//ParallelsVirtualMachine/Identification/SourceVmUuid'
xml.xpath(p).first.content = "{#{SecureRandom.uuid}}"

File.open(vm_config, 'w') do |f|
f.write xml.to_xml
end
end

def register(pvm_file)
args = ['prlctl', 'register', pvm_file]
args << '--regenerate-src-uuid' if regen_src_uuid

3.times do
result = raw(*args)
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module VagrantPlugins
module Parallels
VERSION = "1.3.4"
VERSION = '1.3.5'
end
end
9 changes: 0 additions & 9 deletions test/unit/support/shared/pd_driver_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,6 @@

subject.register("/path/to/vm_image.pvm")
end

it "registers specified virtual machine or template and regen src uuid" do
subprocess.should_receive(:execute).
with("prlctl", "register", an_instance_of(String),
"--regenerate-src-uuid", an_instance_of(Hash)).
and_return(subprocess_result(exit_code: 0))

subject.register("/path/to/vm_image.pvm", regen_src_uuid=true)
end
end

describe "set_mac_address" do
Expand Down

0 comments on commit 4be4811

Please sign in to comment.