BUG: Solved problems that happened in unit test "VagrantPlugins::HyperV::Action::Configure", "should call the app on success". The problems occured because controllers was being called when it wasn't defined. Solved by implementing if test for this.
This commit is contained in:
parent
e5641c826f
commit
7a44cf58c7
|
@ -17,7 +17,7 @@ module VagrantPlugins
|
||||||
def call(env)
|
def call(env)
|
||||||
vm_dir = env[:machine].box.directory.join("Virtual Machines")
|
vm_dir = env[:machine].box.directory.join("Virtual Machines")
|
||||||
hd_dir = env[:machine].box.directory.join("Virtual Hard Disks")
|
hd_dir = env[:machine].box.directory.join("Virtual Hard Disks")
|
||||||
controllers = env[:machine].provider_config.controllers
|
|
||||||
if !vm_dir.directory? || !hd_dir.directory?
|
if !vm_dir.directory? || !hd_dir.directory?
|
||||||
@logger.error("Required virtual machine directory not found!")
|
@logger.error("Required virtual machine directory not found!")
|
||||||
raise Errors::BoxInvalid, name: env[:machine].name
|
raise Errors::BoxInvalid, name: env[:machine].name
|
||||||
|
@ -61,34 +61,37 @@ module VagrantPlugins
|
||||||
env[:ui].output("Importing a Hyper-V instance")
|
env[:ui].output("Importing a Hyper-V instance")
|
||||||
dest_path = env[:machine].data_dir.join("Virtual Hard Disks").join(image_path.basename).to_s
|
dest_path = env[:machine].data_dir.join("Virtual Hard Disks").join(image_path.basename).to_s
|
||||||
|
|
||||||
disks_to_create = []
|
if defined? env[:machine].provider_config.controllers
|
||||||
data_dir = env[:machine].data_dir
|
controllers = env[:machine].provider_config.controllers
|
||||||
# This can happen when creating new on up.
|
disks_to_create = []
|
||||||
controllers.delete_if &:empty?
|
data_dir = env[:machine].data_dir
|
||||||
|
# This can happen when creating new on up.
|
||||||
controllers.each { |controller|
|
controllers.delete_if &:empty?
|
||||||
next_is_size = false
|
|
||||||
disk_name = ''
|
controllers.each { |controller|
|
||||||
controller[:disks].each { |i|
|
next_is_size = false
|
||||||
if !next_is_size
|
disk_name = ''
|
||||||
if File.file?(i)
|
controller[:disks].each { |i|
|
||||||
create_disk = false
|
if !next_is_size
|
||||||
filename_for_disk = i
|
if File.file?(i)
|
||||||
next_is_size = false
|
create_disk = false
|
||||||
|
filename_for_disk = i
|
||||||
@logger.error("Attaching disks is not implemented yet")
|
next_is_size = false
|
||||||
|
|
||||||
|
@logger.error("Attaching disks is not implemented yet")
|
||||||
|
else
|
||||||
|
create_disk = true
|
||||||
|
disk_name = i
|
||||||
|
disk_name = data_dir.join("#{disk_name}.vhdx").to_s.gsub("/", "\\")
|
||||||
|
next_is_size = true
|
||||||
|
end
|
||||||
else
|
else
|
||||||
create_disk = true
|
disks_to_create << { name: disk_name, size: i}
|
||||||
disk_name = i
|
|
||||||
disk_name = data_dir.join("#{disk_name}.vhdx").to_s.gsub("/", "\\")
|
|
||||||
next_is_size = true
|
|
||||||
end
|
end
|
||||||
else
|
}
|
||||||
disks_to_create << { name: disk_name, size: i}
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
disks_to_create_json = disks_to_create.to_json.to_s.gsub('"', '"""')
|
||||||
disks_to_create_json = disks_to_create.to_json.to_s.gsub('"', '"""')
|
end
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
"VMConfigFile" => Vagrant::Util::Platform.wsl_to_windows_path(config_path).gsub("/", "\\"),
|
"VMConfigFile" => Vagrant::Util::Platform.wsl_to_windows_path(config_path).gsub("/", "\\"),
|
||||||
|
|
Loading…
Reference in New Issue