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

Fixes ProvisionWorkflow#available_vlans_and_hosts #269

Merged
Merged
Show file tree
Hide file tree
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
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