From 7049afad7da0c907d1122eb43c70f15eb6bbae10 Mon Sep 17 00:00:00 2001 From: Alona Kaplan Date: Tue, 6 Jun 2017 09:42:00 +0300 Subject: [PATCH] ovirt-networking: using profiles This patch fixes some issues in oVirt vm provision network tab. 1. Changing the 'vLan' label to 'Network' 2. Displaying the vnic profiles instead of the host/hosts networks (only profiles configured in the cluster). 3. Using OvirtSDK4. Changes relevant to version 4 only. --- app/models/miq_provision_virt_workflow.rb | 22 ++++++++++++++++--- ...miq_provision_redhat_dialogs_template.yaml | 4 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/models/miq_provision_virt_workflow.rb b/app/models/miq_provision_virt_workflow.rb index cf12a426685..a0a52de7867 100644 --- a/app/models/miq_provision_virt_workflow.rb +++ b/app/models/miq_provision_virt_workflow.rb @@ -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 @@ -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? diff --git a/product/dialogs/miq_dialogs/miq_provision_redhat_dialogs_template.yaml b/product/dialogs/miq_dialogs/miq_provision_redhat_dialogs_template.yaml index 6a964c6614e..3087e29940c 100644 --- a/product/dialogs/miq_dialogs/miq_provision_redhat_dialogs_template.yaml +++ b/product/dialogs/miq_dialogs/miq_provision_redhat_dialogs_template.yaml @@ -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: