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

ovirt-networking: using profiles #14991

Merged
merged 1 commit into from
Jun 6, 2017
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
22 changes: 19 additions & 3 deletions app/models/miq_provision_virt_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ def update_field_read_only(options = {})

def allowed_hosts_obj(options = {})
all_hosts = super
filter_allowed_hosts(all_hosts)
end

def filter_allowed_hosts(all_hosts)
filter_hosts_by_vlan_name(all_hosts)
end

def filter_hosts_by_vlan_name(all_hosts)
vlan_name = get_value(@values[:vlan])
return all_hosts unless vlan_name

Expand Down Expand Up @@ -225,15 +233,23 @@ def available_vlans_and_hosts(options = {})
rails_logger('allowed_vlans', 0)
# TODO: Use Active Record to preload this data?
MiqPreloader.preload(hosts, :switches => :lans)
hosts.each do |h|
h.lans.each { |l| vlans[l.name] = l.name unless l.switch.shared? }
end
load_allowed_vlans(hosts, vlans)
rails_logger('allowed_vlans', 1)
end

return vlans, hosts
end

def load_allowed_vlans(hosts, vlans)
load_hosts_vlans(hosts, vlans)
end

def load_hosts_vlans(hosts, vlans)
hosts.each do |h|
h.lans.each { |l| vlans[l.name] = l.name unless l.switch.shared? }
end
end

def filter_by_tags(target, options)
opt_filters = options[:tag_filters]
return target if opt_filters.blank?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@
:dvs: true
:vlans: true
:method: :allowed_vlans
:description: vLan
:required: true
:description: Network
:required: false
:display: :edit
:data_type: :string
:mac_address:
Expand Down