Skip to content

Commit

Permalink
maintain a master list of all VMs filtered by name in vm_objects
Browse files Browse the repository at this point in the history
This master list will have no other clauses on selection

apply the selection criteria just before VM validation
  • Loading branch information
AparnaKarve committed Nov 13, 2018
1 parent f489784 commit 7fda4a3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/transformation_mapping/vm_migration_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def identify_vms
conflict_list = []

vm_names = @vm_list.collect { |row| row['name'] }
vm_objects = Vm.where(:name => vm_names, :ems_cluster => mapped_clusters).includes(:lans, :storages, :host, :ext_management_system)
vm_objects = Vm.where(:name => vm_names).includes(:ems_cluster, :lans, :storages, :host, :ext_management_system)

@vm_list.each do |row|
vm_name = row['name']
Expand All @@ -47,7 +47,8 @@ def identify_vms
next
end

vms = vm_objects.select { |vm| vm.name == vm_name }
vms = vm_objects.includes(:lans, :storages, :host, :ext_management_system).select { |vm| mapped_clusters.include?(vm.ems_cluster) }
vms = vms.select { |vm| vm.name == vm_name }
vms = vms.select { |vm| vm.uid_ems == row['uid_ems'] } if row['uid_ems'].present?
vms = vms.select { |vm| vm.host.name == row['host'] } if row['host'].present?
vms = vms.select { |vm| vm.ext_management_system.name == row['provider'] } if row['provider'].present?
Expand Down

0 comments on commit 7fda4a3

Please sign in to comment.