Skip to content

Commit

Permalink
Add IP address to network mapping (required for OpenStack)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiendupont committed Oct 17, 2018
1 parent 74e87c7 commit dbb9fc9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/models/service_template_transformation_plan_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def network_mappings
{
:source => source_network.name,
:destination => destination_network_ref(destination_network),
:mac_address => nic.address
:mac_address => nic.address,
:ip_address => nic.network.try(:ipaddress)
}
end
end
Expand Down
11 changes: 7 additions & 4 deletions spec/models/service_template_transformation_plan_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,15 @@
let(:src_vm_1) { FactoryGirl.create(:vm_vmware, :ext_management_system => src_ems, :ems_cluster => src_cluster, :host => src_host, :hardware => src_hardware) }
let(:src_vm_2) { FactoryGirl.create(:vm_vmware, :ext_management_system => src_ems, :ems_cluster => src_cluster, :host => src_host) }

let(:src_network) { FactoryGirl.create(:network, :ipaddress => '10.0.0.1') }

# Disks have to be stubbed because there's no factory for Disk class
before do
allow(src_hardware).to receive(:disks).and_return([src_disk_1, src_disk_2])
allow(src_disk_1).to receive(:storage).and_return(src_storage)
allow(src_disk_2).to receive(:storage).and_return(src_storage)
allow(src_vm_1).to receive(:allocated_disk_storage).and_return(34_359_738_368)
allow(src_nic_1).to receive(:network).and_return(src_network)
allow(src_host).to receive(:thumbprint_sha1).and_return('01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67')
allow(src_host).to receive(:authentication_userid).and_return('esx_user')
allow(src_host).to receive(:authentication_password).and_return('esx_passwd')
Expand Down Expand Up @@ -451,8 +454,8 @@
it "checks network mappings and generates network_mappings hash" do
expect(task_1.network_mappings).to eq(
[
{ :source => src_lan_1.name, :destination => dst_lan_1.name, :mac_address => src_nic_1.address },
{ :source => src_lan_2.name, :destination => dst_lan_2.name, :mac_address => src_nic_2.address }
{ :source => src_lan_1.name, :destination => dst_lan_1.name, :mac_address => src_nic_1.address, :ip_address => '10.0.0.1' },
{ :source => src_lan_2.name, :destination => dst_lan_2.name, :mac_address => src_nic_2.address, :ip_address => nil }
]
)
end
Expand Down Expand Up @@ -540,8 +543,8 @@
it "checks network mappings and generates network_mappings hash" do
expect(task_1.network_mappings).to eq(
[
{ :source => src_lan_1.name, :destination => dst_cloud_network_1.ems_ref, :mac_address => src_nic_1.address },
{ :source => src_lan_2.name, :destination => dst_cloud_network_2.ems_ref, :mac_address => src_nic_2.address }
{ :source => src_lan_1.name, :destination => dst_cloud_network_1.ems_ref, :mac_address => src_nic_1.address, :ip_address => '10.0.0.1' },
{ :source => src_lan_2.name, :destination => dst_cloud_network_2.ems_ref, :mac_address => src_nic_2.address, :ip_address => nil }
]
)
end
Expand Down

0 comments on commit dbb9fc9

Please sign in to comment.