Skip to content

Commit

Permalink
Add specs for nic_settings customization
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Nov 12, 2024
1 parent 28af5dc commit 049b18d
Showing 1 changed file with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
vh['nicSettingMap'] = []
vh
end
let(:nic_settings_map) { [] }
let(:new_spec) do
{
"identity" => {
Expand All @@ -86,7 +87,7 @@
}
},
"globalIPSettings" => {},
"nicSettingMap" => [],
"nicSettingMap" => nic_settings_map,
"options" => {}
}
end
Expand Down Expand Up @@ -129,5 +130,43 @@
expect(prov_vm).not_to receive(:load_customization_spec)
expect(prov_vm.build_customization_spec).to(eq(new_spec))
end

context "with network options" do
context "set at the top level of options" do
let(:ip_addr) { "192.168.1.10" }
let(:gateway) { "192.168.1.1" }
let(:dns_domain) { "localdomain" }
let(:nic_settings_map) { [{"adapter" => {"dnsDomain" => "localdomain", "gateway" => [gateway], "ip" => {"ipAddress" => ip_addr}}}] }

it 'sets the nicSettingMap on the new spec' do
options[:sysprep_custom_spec] = ''
options[:sysprep_full_name] = 'sysprep_full_name_value'
options[:sysprep_organization] = 'sysprep_organization_value'
options[:requested_network_adapter_count] = 1
options[:ip_addr] = ip_addr
options[:gateway] = gateway
options[:dns_domain] = dns_domain

expect(prov_vm).not_to receive(:load_customization_spec)
expect(prov_vm.build_customization_spec).to(eq(new_spec))
end
end

context "with a nic_settings array in options" do
let(:nic_settings_map) { [{"adapter" => {"ip" => {"ipAddress" => "192.168.1.10"}}}, {"adapter" => {"ip" => {"ipAddress" => "192.168.2.10"}}}] }

it 'sets network settings for multiple nics' do
options[:sysprep_custom_spec] = ''
options[:sysprep_full_name] = 'sysprep_full_name_value'
options[:sysprep_organization] = 'sysprep_organization_value'
options[:requested_network_adapter_count] = 2
options[:ip_addr] = "192.168.1.10" # NOTE: Shouldn't have to set nic_settings and ip_addr
options[:nic_settings] = [{:ip_addr => "192.168.1.10"}, {:ip_addr => "192.168.2.10"}]

expect(prov_vm).not_to receive(:load_customization_spec)
expect(prov_vm.build_customization_spec).to(eq(new_spec))
end
end
end
end
end

0 comments on commit 049b18d

Please sign in to comment.