-
Notifications
You must be signed in to change notification settings - Fork 70
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
Fix the VM Provisioning issue with auto replacement in selected dvPortGroup network. #78
Conversation
_log.info("Filtering hosts with the following network: <#{vlan_name}>") | ||
shared = !vlan_name.match(/dvs_/).nil? | ||
vlan_name.sub!(/^dvs_/, '') if shared | ||
all_hosts.select { |h| h.lans.any? { |lan| lan.name == vlan_name && lan.switch.shared == shared } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think lan.switch.shared == shared
will work since we don't set switch.shared
to false, its just nil
: https://github.com/ManageIQ/manageiq-providers-vmware/blob/master/app/models/manageiq/providers/vmware/infra_manager/refresh_parser.rb#L428-L438
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really "clean" but you could do && !!lan.switch.shared == shared
so a nil
is treated as false
let(:s13) { FactoryGirl.create(:switch, :name => "C") } | ||
let(:s11) { FactoryGirl.create(:switch, :name => "A", :shared => false) } | ||
let(:s12) { FactoryGirl.create(:switch, :name => "B", :shared => false) } | ||
let(:s13) { FactoryGirl.create(:switch, :name => "C", :shared => false) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably leave shared nil
in the tests since that matches what we'll see on a real system.
_log.info("Filtering hosts with the following network: <#{vlan_name}>") | ||
shared = !vlan_name.match(/dvs_/).nil? | ||
vlan_name.sub!(/^dvs_/, '') if shared | ||
all_hosts.select { |h| h.lans.any? { |lan| lan.name == vlan_name && !lan.switch.shared.nil? == shared } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well now this counts on switch.shared
being nil and will break if we update the parser in the future to (I think) correctly set shared to false.
!!lan.switch.shared
will treat nil and false as "falsy" which is what we want.
_log.info("Filtering hosts with the following network: <#{vlan_name}>") | ||
shared = !vlan_name.match(/dvs_/).nil? | ||
vlan_name.sub!(/^dvs_/, '') if shared | ||
all_hosts.select { |h| h.lans.any? { |lan| lan.name == vlan_name && !lan.switch.shared.blank? == shared } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this doing n+1 queries possibly (n+1)^2 ? Or all_hosts already has all_hosts.include(:lans => switch).references(:lans => switch)
#haven't tested the query
Checked commit lfu@4b7cddc with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Fix the VM Provisioning issue with auto replacement in selected dvPortGroup network. (cherry picked from commit 5e17387) https://bugzilla.redhat.com/show_bug.cgi?id=1478562
Fine backport details:
|
Add rake release task
Fix the VM Provisioning issue with auto replacement in selected dvPortGroup network.
Issue is introduced in ManageIQ/manageiq#14946.
https://bugzilla.redhat.com/show_bug.cgi?id=1467399
@miq-bot assign @gmcculloug
@miq-bot add_label bug, fine/yes