Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2V - Workaround for network mappings storage #470

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def populate_factory_config

def main
raise 'Preflight check has failed' unless @task.preflight_check
# TODO(fdupont-redhat): Find why network mappings are not stored
# by call to preflight_check.
@task.set_option(:network_mappings, @task.network_mappings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fdupont-redhat Seems odd to take the method data from a task and put it "into the task options hash for later consumption". Is this so it can be used through the API later? If so it would be better to expose it there then to store the data that the object already generates.

cc @roliveri @agrare

Copy link
Author

@ghost ghost Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a workaround until I find why it's not set by the call to preflight_check. Without it, migration fails and blocks QE.

@gmcculloug I've added a TODO comment to revisit later. Sorry for the technical debt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fdupont-redhat I need to understand what this really means:

why it's not set by the call to preflight_check`

I suggest we focus on this a little before jumping right to this work-around. We can discuss.

%w(task_options factory_config).each { |ci| send("populate_#{ci}") }
rescue => e
@handle.set_state_var(:ae_state_progress, 'message' => e.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
let(:task) { FactoryGirl.create(:service_template_transformation_plan_task) }
let(:src_ems_vmware) { FactoryGirl.create(:ems_vmware) }
let(:src_cluster_vmware) { FactoryGirl.create(:ems_cluster, :ext_management_system => src_ems_vmware) }
let(:src_vm_vmware) { FactoryGirl.create(:vm_vmware, :ext_management_system => src_ems_vmware, :ems_cluster => src_cluster_vmware) }
let(:src_vm_vmware) { FactoryGirl.create(:vm_vmware, :ext_management_system => src_ems_vmware, :ems_cluster => src_cluster_vmware, :hardware => src_hardware) }
let(:src_storage_1) { FactoryGirl.create(:storage) }
let(:src_storage_2) { FactoryGirl.create(:storage) }
let(:src_lan_1) { FactoryGirl.create(:lan) }
let(:src_lan_2) { FactoryGirl.create(:lan) }
let(:hardware) { FactoryGirl.create(:hardware) }
let(:nic_1) { FactoryGirl.create(:guest_device_nic) }
let(:nic_2) { FactoryGirl.create(:guest_device_nic) }
let(:src_hardware) { FactoryGirl.create(:hardware, :nics => [src_nic_1, src_nic_2]) }
let(:src_nic_1) { FactoryGirl.create(:guest_device_nic, :lan => src_lan_1) }
let(:src_nic_2) { FactoryGirl.create(:guest_device_nic, :lan => src_lan_2) }

let(:svc_model_user) { MiqAeMethodService::MiqAeServiceUser.find(user.id) }
let(:svc_model_group) { MiqAeMethodService::MiqAeServiceMiqGroup.find(group.id) }
Expand All @@ -26,19 +26,19 @@
let(:svc_model_src_storage_2) { MiqAeMethodService::MiqAeServiceStorage.find(src_storage_2) }
let(:svc_model_src_lan_1) { MiqAeMethodService::MiqAeServiceLan.find(src_lan_1) }
let(:svc_model_src_lan_2) { MiqAeMethodService::MiqAeServiceLan.find(src_lan_2) }
let(:svc_model_hardware) { MiqAeMethodService::MiqAeServiceHardware.find(hardware) }
let(:svc_model_src_hardware) { MiqAeMethodService::MiqAeServiceHardware.find(src_hardware) }
let(:svc_model_guest_device_1) { MiqAeMethodService::MiqAeServiceGuestDevice.find(guest_device_1) }
let(:svc_model_guest_device_2) { MiqAeMethodService::MiqAeServiceGuestDevice.find(guest_device_2) }
let(:svc_model_nic_1) { MiqAeMethodService::MiqAeServiceGuestDevice.find(nic_1) }
let(:svc_model_nic_2) { MiqAeMethodService::MiqAeServiceGuestDevice.find(nic_2) }
let(:svc_model_src_nic_1) { MiqAeMethodService::MiqAeServiceGuestDevice.find(src_nic_1) }
let(:svc_model_src_nic_2) { MiqAeMethodService::MiqAeServiceGuestDevice.find(src_nic_2) }

let(:disk_1) { instance_double("disk", :device_name => "Hard disk 1", :device_type => "disk", :filename => "[datastore12] test_vm/test_vm.vmdk", :size => 17_179_869_184) }
let(:disk_2) { instance_double("disk", :device_name => "Hard disk 2", :device_type => "disk", :filename => "[datastore12] test_vm/test_vm-2.vmdk", :size => 17_179_869_184) }

let(:virtv2v_networks) do
[
{ :source => svc_model_src_lan_1.name, :destination => svc_model_dst_lan_1.name, :mac_address => svc_model_nic_1.address },
{ :source => svc_model_src_lan_2.name, :destination => svc_model_dst_lan_2.name, :mac_address => svc_model_nic_2.address },
{ :source => svc_model_src_lan_1.name, :destination => svc_model_dst_lan_1.name, :mac_address => svc_model_src_nic_1.address },
{ :source => svc_model_src_lan_2.name, :destination => svc_model_dst_lan_2.name, :mac_address => svc_model_src_nic_2.address },
]
end

Expand Down Expand Up @@ -70,18 +70,18 @@
allow(ManageIQ::Automate::Transformation::Common::Utils).to receive(:task).and_return(svc_model_task)
allow(ManageIQ::Automate::Transformation::Common::Utils).to receive(:source_vm).and_return(svc_model_src_vm)

allow(svc_model_src_vm).to receive(:hardware).and_return(svc_model_hardware)
allow(svc_model_src_vm).to receive(:hardware).and_return(svc_model_src_hardware)
allow(disk_1).to receive(:storage).and_return(svc_model_src_storage_1)
allow(disk_2).to receive(:storage).and_return(svc_model_src_storage_2)
allow(svc_model_nic_1).to receive(:lan).and_return(svc_model_src_lan_1)
allow(svc_model_nic_2).to receive(:lan).and_return(svc_model_src_lan_2)
end

before(:each) do
ManageIQ::Automate::Transformation::Common::AssessTransformation.instance_variable_set(:@task, nil)
ManageIQ::Automate::Transformation::Common::AssessTransformation.instance_variable_set(:@source_cluster, nil)
ManageIQ::Automate::Transformation::Common::AssessTransformation.instance_variable_set(:@source_ems, nil)
ManageIQ::Automate::Transformation::Common::AssessTransformation.instance_variable_set(:@destination_cluster, nil)
ManageIQ::Automate::Transformation::Common::AssessTransformation.instance_variable_set(:@destination_ems, nil)
svc_model_task.set_option(:network_mappings, nil)
end

context "populate factory config" do
Expand Down Expand Up @@ -122,9 +122,11 @@

shared_examples_for "main" do
it "global summary test" do
task.reload
allow(svc_model_src_vm).to receive(:power_state).and_return("on")
allow(svc_model_task).to receive(:preflight_check).and_return(true)
described_class.new(ae_service).main
expect(svc_model_task[:options][:network_mappings]).to eq(task.network_mappings)
expect(svc_model_task.get_option(:source_vm_power_state)).to eq("on")
expect(svc_model_task.get_option(:collapse_snapshots)).to be true
expect(svc_model_task.get_option(:power_off)).to be true
Expand Down Expand Up @@ -188,7 +190,7 @@
let(:svc_model_src_vm) { svc_model_src_vm_vmware }
let(:svc_model_src_ems) { svc_model_src_ems_vmware }

let(:dst_ems) { FactoryGirl.create(:ems_openstack_infra) }
let(:dst_ems) { FactoryGirl.create(:ems_openstack) }
let(:svc_model_dst_ems) { MiqAeMethodService::MiqAeServiceExtManagementSystem.find(dst_ems.id) }
let(:dst_cloud_tenant) { FactoryGirl.create(:cloud_tenant, :ext_management_system => dst_ems) }
let(:svc_model_dst_cloud_tenant) { MiqAeMethodService::MiqAeServiceCloudTenant.find(dst_cluster.id) }
Expand Down