Skip to content

Commit

Permalink
Merge pull request ManageIQ#14991 from AlonaKaplan/ovirt_networking_2
Browse files Browse the repository at this point in the history
ovirt-networking: using profiles
  • Loading branch information
agrare authored Jun 6, 2017
2 parents 0debdf0 + 7049afa commit e831cbe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
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

0 comments on commit e831cbe

Please sign in to comment.