Skip to content

Commit

Permalink
discard inactive VMs from the master list right off the bat
Browse files Browse the repository at this point in the history
That being done, we don't need the `vm.active?` check in `vm_migration_status` again

https://bugzilla.redhat.com/show_bug.cgi?id=1639239
  • Loading branch information
AparnaKarve committed Nov 8, 2018
1 parent e98690e commit 0d8fdaf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/models/transformation_mapping/vm_migration_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def identify_vms
next
end

if vm_objects.select { |vm| vm.name == vm_name && !vm.active? }.any?
invalid_list << VmMigrateStruct.new(vm_name, nil, VM_INVALID, VM_INACTIVE)
next
end

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?
Expand Down Expand Up @@ -90,8 +95,6 @@ def validate_vm(vm, quick = true)
end

def vm_migration_status(vm)
return VM_INACTIVE unless vm.active?

vm_as_resources = ServiceResource.joins(:service_template).where(:resource => vm, :service_templates => {:type => 'ServiceTemplateTransformationPlan'})

# VM has not been migrated before
Expand Down

0 comments on commit 0d8fdaf

Please sign in to comment.