Skip to content

Commit

Permalink
Merge pull request #269 from NickLaMuro/fix_lan_lookup_in_provision_v…
Browse files Browse the repository at this point in the history
…irt_workflow

Fixes ProvisionWorkflow#available_vlans_and_hosts
  • Loading branch information
agrare authored May 19, 2018
2 parents c9f366b + c0a5a9e commit 5b7c527
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,15 @@ def available_vlans_and_hosts(options = {})
# dvportgroups key-value transformed
if options[:dvs]
dvlans = Hash.new { |h, k| h[k] = [] }
shared_lans = Lan.distinct.select(:id, :switch_id, :name)
.includes(:switch)
.joins(:switch => :host_switches)
.where(:host_switches => {:host_id => hosts.map(&:id)})
.merge(Switch.shareable)

shared_lans.each { |l| dvlans[l.name] << l.switch.name }
unless hosts.nil?
shared_lans = Lan.distinct.select(:id, :switch_id, :name)
.includes(:switch)
.joins(:switch => :host_switches)
.where(:host_switches => {:host_id => hosts.map(&:id)})
.merge(Switch.shareable)

shared_lans.each { |l| dvlans[l.name] << l.switch.name }
end
dvlans.each do |l, v|
vlans["dvs_#{l}"] = "#{l} (#{v.sort.uniq.join('/')})"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@
end
end

describe "#init_from_dialog" do
let(:user) { FactoryGirl.create(:user_with_email, :role => 'super_administrator', :password => 'x') }
let(:ems) { FactoryGirl.create(:ems_vmware_with_authentication) }
let(:template) { FactoryGirl.create(:template_vmware, :ext_management_system => ems) }
let(:req) { FactoryGirl.create(:miq_provision_request, :requester => user, :source => template) }
let(:options) { req.get_options.merge(:org_controller=>"vm") }

subject { req.workflow(options) }

before do
EvmSpecHelper.create_guid_miq_server_zone
MiqDialog.seed
end

it "does not raise an error" do
expect { subject.init_from_dialog(options) }.to_not raise_error
end
end

describe "#make_request" do
let(:alt_user) { FactoryGirl.create(:user_with_group) }
it "creates and update a request" do
Expand Down

0 comments on commit 5b7c527

Please sign in to comment.