Skip to content

Commit

Permalink
Release v1.4.0.rc1
Browse files Browse the repository at this point in the history
* master: (22 commits)
  Bump version to 1.4.0.rc1
  Remove "bundle exec" from the rake task commands
  Remove rake task "test:acceptance"
  driver: Remove unused method "max_network_adapters"
  network: Set maximum number of network adapters to 16
  driver: Remove unused method "set_mac_address"
  driver: Cleanup syntax
  driver: Fix "compact" method
  driver: Remove unused method "read_vms_paths"
  driver: Move common methods to the base class
  driver: Fix greedy regex in "clone_vm"
  action/import: Fix "linked_clone" option name
  Add acceptance test for linked clones
  action/import: Detect a snapshot ID while creating a linked cone
  driver: Add "create_snapshot" method
  driver: Add "read_current_snapshot" method
  Add support of linked clones for Parallels Desktop 11
  driver: Add class for Parallels Desktop 11
  driver: Replace "export" and "import" with the single "clone_vm" method
  action/network: Fixed dhcp options parsing
  ...
  • Loading branch information
legal90 committed Jun 19, 2015
2 parents a09faf1 + cec7619 commit d4972c9
Show file tree
Hide file tree
Showing 19 changed files with 607 additions and 521 deletions.
8 changes: 7 additions & 1 deletion lib/vagrant-parallels/action/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ def gen_template_name

def export
@env[:ui].info I18n.t('vagrant.actions.vm.export.exporting')
@env[:machine].provider.driver.export(@env['export.temp_dir'], @tpl_name) do |progress|

options = {
template: true,
dst: @env['export.temp_dir'].to_s
}

@env[:machine].provider.driver.clone_vm(@env[:machine].id, @tpl_name, options) do |progress|
@env[:ui].clear_line
@env[:ui].report_progress(progress, 100, false)

Expand Down
38 changes: 35 additions & 3 deletions lib/vagrant-parallels/action/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,25 @@ def template_name(tpl_path)
end

def import(env, tpl_name)
env[:ui].info I18n.t("vagrant.actions.vm.import.importing",
:name => @machine.box.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')

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
else
env[:ui].info I18n.t("vagrant.actions.vm.import.importing",
:name => @machine.box.name)
end

# Import the virtual machine
@machine.id = @machine.provider.driver.import(tpl_name) do |progress|
@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)

Expand All @@ -101,6 +116,23 @@ def import(env, tpl_name)
end
end

def snapshot_id(tpl_name)
snap_id = @machine.provider.driver.read_current_snapshot(tpl_name)

# If there is no current snapshot, just create the new one.
if !snap_id
@logger.info('Create a new snapshot')
opts = {
name: 'vagrant_linked_clone',
desc: 'Snapshot to create linked clones for Vagrant'
}
snap_id = @machine.provider.driver.create_snapshot(tpl_name, opts)
end

@logger.info("User this snapshot ID to create a linked clone: #{snap_id}")
snap_id
end

def unregister_template(tpl_name)
@logger.info("Unregister the box template: '#{tpl_name}'")
@machine.provider.driver.unregister(tpl_name)
Expand Down
16 changes: 8 additions & 8 deletions lib/vagrant-parallels/action/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ def call(env)
# Get the list of network adapters from the configuration
network_adapters_config = env[:machine].provider_config.network_adapters.dup

# Get maximum number of network adapters
max_adapters = env[:machine].provider.driver.max_network_adapters

# Assign the adapter slot for each high-level network
available_slots = Set.new(0...max_adapters)
available_slots = Set.new(0...16)
network_adapters_config.each do |slot, _data|
available_slots.delete(slot)
end
Expand Down Expand Up @@ -197,14 +194,17 @@ def bridged_adapter(config)
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")

# The range of valid choices
valid = Range.new(1, bridgedifs.length)

# The choice that the user has chosen as the bridging interface
choice = nil
while !valid.include?(choice)
choice = @env[:ui].ask("What interface should the network bridge to? Enter a number: ")
choice = @env[:ui].ask(
'Which interface should the network bridge to? Enter a number: ')
choice = choice.to_i
end

Expand Down Expand Up @@ -289,16 +289,16 @@ 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] ||= 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] ||= 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] ||= dhcp_upper.join(".")
dhcp_options[:dhcp_upper] = options[:dhcp_upper] || dhcp_upper.join(".")
end

return {
Expand Down
4 changes: 4 additions & 0 deletions lib/vagrant-parallels/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Config < Vagrant.plugin("2", :config)
attr_accessor :destroy_unused_network_interfaces
attr_accessor :functional_psf
attr_accessor :optimize_power_consumption
attr_accessor :use_linked_clone
attr_accessor :name
attr_reader :network_adapters
attr_accessor :regen_src_uuid
Expand All @@ -22,6 +23,7 @@ def initialize
@customizations = []
@destroy_unused_network_interfaces = UNSET_VALUE
@functional_psf = UNSET_VALUE
@use_linked_clone = UNSET_VALUE
@network_adapters = {}
@name = UNSET_VALUE
@optimize_power_consumption = UNSET_VALUE
Expand Down Expand Up @@ -79,6 +81,8 @@ def finalize!
@optimize_power_consumption = true
end

@use_linked_clone = false if @use_linked_clone == UNSET_VALUE

@name = nil if @name == UNSET_VALUE

@regen_src_uuid = true if @regen_src_uuid == UNSET_VALUE
Expand Down
Loading

0 comments on commit d4972c9

Please # to comment.