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

Report accurate status on inactive VM #18181

Merged
Merged
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
12 changes: 8 additions & 4 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,13 @@ def identify_vms
next
end

vms = vm_objects.select { |vm| vm.name == vm_name }
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.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 Expand Up @@ -89,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