Skip to content

Commit

Permalink
Release v1.6.3
Browse files Browse the repository at this point in the history
* master: (23 commits)
  gemspec: Specify file list explicitly
  license: Update copyright year
  Bump version to 1.6.3
  Update changelog
  action/network: Fix an exception when the host is not connected to host-only interface
  driver: Skip fetching DHCP details in #read_host_only_interfaces
  action: Check the host is connected to Shared network
  driver: Prepare for the host could be disconnected from Shared and Host-Only networks
  Reduce CLI calls on "clean_forwarded_ports" action
  driver: Hardcode "Shared" network name
  test/unit: Fix RSpec expectation config
  travis: Use Bundler 1.12.5 and Ruby 2.2.3
  Support for packaging linked clones
  action/box_unregister: Fix #recover for layered envs
  Fix unit tests for provider configuration
  config: Add warning message about deprecated options
  driver: Add retries for snapshot commands
  website: Delete Rakefile
  website: update gems
  Add middleman build directory to  the root .gitignore
  ...
  • Loading branch information
legal90 committed Jul 11, 2016
2 parents 365cfaa + 1aa882d commit 365cb10
Show file tree
Hide file tree
Showing 30 changed files with 608 additions and 192 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ acceptance_config.yml
boxes/*
/Vagrantfile
.vagrant
/website/docs/build
vagrant-spec.config.rb

# Bundler/Rubygems
*.gem
.bundle
pkg/*
tags
Gemfile.lock
/Gemfile.lock
test/tmp/
/vendor

Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ sudo: false

cache: bundler

before_install:
- gem install bundler -v '1.12.5'

rvm:
- 2.0.0
- 2.2.3

script: bundle exec rake test:unit
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
## 1.6.3 (July 11, 2016)
DEPRECATIONS:
- The following provider options was renamed:
- `regen_box_uuid` was renamed to `regen_src_uuid`
- `use_linked_clone` was renamed to `linked clone`

Old names are still supported, but will be removed in `vagrant-parallels` v1.7.0.
[[GH-260](https://github.com/Parallels/vagrant-parallels/pull/260)]

IMPROVEMENTS:
- Allow to package linked clones with `vagrant package`. External disk images
will be automatically copied, so the resulted box become a full-sized
standalone VM. [[GH-262](https://github.com/Parallels/vagrant-parallels/pull/262)]
- Handle the situation when host machine is not connected to Shared network.
With Parallels Desktop 11.2.1+ Vagrant will connect it automatically. With earlier
versions, the human-readable error message will be displayed.
[[GH-266](https://github.com/Parallels/vagrant-parallels/pull/266)]
- Disable home folder sharing by default (Parallels Desktop 11+).
[[GH-257](https://github.com/Parallels/vagrant-parallels/pull/257)]

BUG FIXES:
- action/box_unregister: Fix `#recover` method for layered environments.
[[GH-261](https://github.com/Parallels/vagrant-parallels/pull/261)]
- action/network: Fix an exception when option "Connect Mac to
this network" is disabled. [[GH-268](https://github.com/Parallels/vagrant-parallels/pull/268)]
- commands/snapshot: Add retries for snapshot commands to avoid `prlctl`
failures. [[GH-259](https://github.com/Parallels/vagrant-parallels/pull/259)]


## 1.6.2 (March 23, 2016)
BUG FIXES:
- Fix unsupported action error for `vagrant snapshot` commands [[GH-254](https://github.com/Parallels/vagrant-parallels/pull/254)]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2013 Youssef Shahin
Copyright (c) 2013-2015 Parallels IP Holdings GmbH.
Copyright (c) 2013-2016 Parallels IP Holdings GmbH.

MIT License

Expand Down
7 changes: 7 additions & 0 deletions lib/vagrant-parallels/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Action
# a bootup (i.e. not saved).
def self.action_boot
Vagrant::Action::Builder.new.tap do |b|
b.use CheckSharedInterface
b.use SetName
b.use ClearForwardedPorts
b.use Provision
Expand Down Expand Up @@ -74,6 +75,7 @@ def self.action_destroy
def self.action_halt
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use CheckSharedInterface
b.use Call, IsState, :not_created do |env1, b1|
if env1[:result]
b1.use Message, I18n.t('vagrant.commands.common.vm_not_created')
Expand Down Expand Up @@ -122,6 +124,7 @@ def self.action_package
def self.action_provision
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use CheckSharedInterface
b.use Call, IsState, :not_created do |env1, b1|
if env1[:result]
b1.use Message, I18n.t('vagrant.commands.common.vm_not_created')
Expand Down Expand Up @@ -163,6 +166,7 @@ def self.action_reload
def self.action_resume
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use CheckSharedInterface
b.use Call, IsState, :not_created do |env1, b1|
if env1[:result]
b1.use Message, I18n.t('vagrant.commands.common.vm_not_created')
Expand Down Expand Up @@ -227,6 +231,7 @@ def self.action_snapshot_save
def self.action_ssh
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use CheckSharedInterface
b.use Call, IsState, :not_created do |env1, b1|
if env1[:result]
b1.use Message, I18n.t('vagrant.commands.common.vm_not_created')
Expand All @@ -248,6 +253,7 @@ def self.action_ssh
def self.action_ssh_run
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use CheckSharedInterface
b.use Call, IsState, :not_created do |env1, b1|
if env1[:result]
b1.use Message, I18n.t('vagrant.commands.common.vm_not_created')
Expand Down Expand Up @@ -389,6 +395,7 @@ def self.action_sync_folders
autoload :BoxUnregister, File.expand_path('../action/box_unregister', __FILE__)
autoload :HandleGuestTools, File.expand_path('../action/handle_guest_tools', __FILE__)
autoload :HandleForwardedPortCollisions, File.expand_path('../action/handle_forwarded_port_collisions.rb', __FILE__)
autoload :CheckSharedInterface, File.expand_path('../action/check_shared_interface', __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__)
Expand Down
3 changes: 3 additions & 0 deletions lib/vagrant-parallels/action/box_unregister.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def call(env)
end

def recover(env)
# If we don't have a box, nothing to do
return if !env[:machine].box

unregister_box(env)
end

Expand Down
29 changes: 29 additions & 0 deletions lib/vagrant-parallels/action/check_shared_interface.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module VagrantPlugins
module Parallels
module Action
class CheckSharedInterface
def initialize(app, env)
@app = app
end

def call(env)
shared_iface = env[:machine].provider.driver.read_shared_interface

# Shared interface is connected. Just exit
return @app.call(env) if shared_iface[:status] == 'Up'

# Since PD 11.2.1 Vagrant can fix this automatically
if !env[:machine].provider.pd_version_satisfies?('>= 11.2.1')
raise Errors::SharedInterfaceDisconnected
end

env[:ui].info I18n.t('vagrant_parallels.actions.vm.check_shared_interface.connecting')
iface_name = env[:machine].provider.driver.read_shared_network_id
env[:machine].provider.driver.connect_network_interface(iface_name)

@app.call(env)
end
end
end
end
end
5 changes: 3 additions & 2 deletions lib/vagrant-parallels/action/clear_forwarded_ports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ def call(env)
return @app.call(env)
end

if !env[:machine].provider.driver.read_forwarded_ports.empty?
ports = env[:machine].provider.driver.read_forwarded_ports
if !ports.empty?
env[:ui].info I18n.t('vagrant.actions.vm.clear_forward_ports.deleting')
env[:machine].provider.driver.clear_forwarded_ports
env[:machine].provider.driver.clear_forwarded_ports(ports)
end

@app.call(env)
Expand Down
75 changes: 69 additions & 6 deletions lib/vagrant-parallels/action/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ def call(env)
raise Vagrant::Errors::VMPowerOffToPackage
end

# Clone source VM to the temporary copy
clone(env)
@home_path = env[:machine].provider.driver.read_settings(env[:package_box_id]).fetch('Home')
@hdd_list = Dir.glob(File.join(@home_path, '*.hdd'))

# Convert to full-sized VM, copy all external and linked disks (if any)
convert_to_full(env)

# Compact all virtual disks
compact(env)

# Preparations completed. Unregister before packaging
unregister_vm(env)

@app.call(env)
Expand Down Expand Up @@ -71,16 +81,69 @@ def clone(env)
env[:ui].clear_line
end

def convert_to_full(env)
is_linked = false

@hdd_list.each do |hdd_dir|
disk_desc = File.join(hdd_dir, 'DiskDescriptor.xml')
xml = Nokogiri::XML(File.open disk_desc)

linked_images = xml.xpath('//Parallels_disk_image/StorageData/Storage/Image/File').select do |hds|
Pathname.new(hds).absolute?
end

# If this is a regular, not linked HDD, then skip it. Otherwise,
# remember this VM as a linked clone.
next if linked_images.empty?
is_linked = true


env[:ui].info I18n.t('vagrant_parallels.actions.vm.export.copying_linked_disks')
linked_images.each do |hds|
hds_path = hds.text

if !File.exist?(hds_path)
raise VagrantPlugins::Parallels::Errors::ExternalDiskNotFound,
path: hds_path
end

FileUtils.cp(hds_path, hdd_dir, preserve: true)

# Save relative hds path to the XML file
hds.content = File.basename(hds_path)
end

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

# Flush elements LinkedVmUuid, LinkedSnapshotUuid from "config.pvs"
if is_linked
@logger.debug 'Converting linked clone to the regular VM'
config_pvs = File.join(@home_path, 'config.pvs')

xml = Nokogiri::XML(File.open(config_pvs))
xml.xpath('//ParallelsVirtualMachine/Identification/LinkedVmUuid').first.content = ''
xml.xpath('//ParallelsVirtualMachine/Identification/LinkedSnapshotUuid').first.content = ''

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

def compact(env)
env[:ui].info I18n.t('vagrant_parallels.actions.vm.export.compacting')
env[:machine].provider.driver.compact(env[:package_box_id]) do |progress|
@hdd_list.each do |hdd|
env[:machine].provider.driver.compact_hdd(hdd) do |progress|
env[:ui].clear_line
env[:ui].report_progress(progress, 100, false)
end
# Clear the line a final time so the next data can appear
# alone on the line.
env[:ui].clear_line
env[:ui].report_progress(progress, 100, false)
end

# Clear the line a final time so the next data can appear
# alone on the line.
env[:ui].clear_line
end

def unregister_vm(env)
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-parallels/action/forward_ports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def call(env)

def forward_ports
all_rules = @env[:machine].provider.driver.read_forwarded_ports(true)
names_in_use = all_rules.collect { |r| r[:rule_name] }
names_in_use = all_rules.collect { |r| r[:name] }
ports = []

@env[:forwarded_ports].each do |fp|
Expand Down
18 changes: 8 additions & 10 deletions lib/vagrant-parallels/action/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,20 +444,18 @@ def hostonly_create_network(config)

# This finds a matching host only network for the given configuration.
def hostonly_find_matching_network(config)
existing = @env[:machine].provider.driver.read_host_only_interfaces
this_netaddr = network_address(config[:ip], config[:netmask])

if config[:name]
# Search networks strongly by specified name
matched_iface = existing.detect { |i| config[:name] == i[:name] }
else
# Name is not specified - search by network address
this_netaddr = network_address(config[:ip], config[:netmask])
matched_iface = existing.detect do |i|
this_netaddr == network_address(i[:ip], i[:netmask])
@env[:machine].provider.driver.read_host_only_interfaces.each do |interface|
return interface if config[:name] && config[:name] == interface[:name]

if interface[:ip]
return interface if this_netaddr == \
network_address(interface[:ip], interface[:netmask])
end
end

matched_iface || nil
nil
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/vagrant-parallels/action/sane_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def default_settings
settings.merge!(
startup_view: 'headless',
time_sync: 'on',
disable_timezone_sync: 'on'
disable_timezone_sync: 'on',
shf_host_defined: 'off'
)

settings
Expand Down
1 change: 0 additions & 1 deletion lib/vagrant-parallels/cap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def self.forwarded_ports(machine)
#
# @return [String] Host's IP address
def self.host_address(machine)

shared_iface = machine.provider.driver.read_shared_interface
return shared_iface[:ip] if shared_iface

Expand Down
26 changes: 18 additions & 8 deletions lib/vagrant-parallels/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class Config < Vagrant.plugin('2', :config)
attr_accessor :regen_src_uuid
attr_accessor :update_guest_tools

# Deprecated options
attr_accessor :regen_box_uuid
attr_accessor :use_linked_clone

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

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

def initialize
@check_guest_tools = UNSET_VALUE
@customizations = []
Expand All @@ -34,6 +34,10 @@ def initialize
@update_guest_tools = UNSET_VALUE

network_adapter(0, :shared)

# Deprecated options
@regen_box_uuid = UNSET_VALUE
@use_linked_clone = UNSET_VALUE
end

def customize(*command)
Expand All @@ -55,10 +59,6 @@ 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 All @@ -68,6 +68,16 @@ def merge(other)
end

def finalize!
if @regen_box_uuid != UNSET_VALUE
puts "Parallels provider: Vagrantfile option 'regen_box_uuid' is deprecated and will be removed. Please, use 'regen_src_uuid' instead"
@regen_src_uuid = @regen_box_uuid if @regen_src_uuid == UNSET_VALUE
end

if @use_linked_clone != UNSET_VALUE
puts "Parallels provider: Vagrantfile option 'use_linked_clone' is deprecated and will be removed. Please, use 'linked_clone' instead"
@linked_clone = @use_linked_clone if @linked_clone == UNSET_VALUE
end

if @check_guest_tools == UNSET_VALUE
@check_guest_tools = true
end
Expand Down
Loading

0 comments on commit 365cb10

Please sign in to comment.