From 8829e85ee709b029332a05281bd257d61e9fa9cb Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Wed, 13 Jun 2018 17:21:11 -0400 Subject: [PATCH 01/11] Remove hacked resource relation and update column_name --- app/models/miq_schedule.rb | 11 +++-------- app/models/service_template.rb | 6 +----- spec/models/miq_schedule_spec.rb | 6 +++--- spec/models/service_template_spec.rb | 3 +-- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/app/models/miq_schedule.rb b/app/models/miq_schedule.rb index 52a679c1f8eb..fd7c2cace3a4 100644 --- a/app/models/miq_schedule.rb +++ b/app/models/miq_schedule.rb @@ -1,6 +1,6 @@ class MiqSchedule < ApplicationRecord - include ReservedMixin - reserve_attribute :resource_id, :big_integer + include DeprecationMixin + deprecate_attribute :towhat, :resource_type validates :name, :uniqueness => {:scope => [:userid, :towhat]} validates :name, :description, :towhat, :run_at, :presence => true @@ -14,6 +14,7 @@ class MiqSchedule < ApplicationRecord belongs_to :file_depot belongs_to :miq_search + belongs_to :resource, :polymorphic => true belongs_to :zone scope :in_zone, lambda { |zone_name| @@ -42,12 +43,6 @@ class MiqSchedule < ApplicationRecord default_value_for :enabled, true default_value_for(:zone_id) { MiqServer.my_server.zone_id } - def resource - # HACK: this should be a real relation, but for now it's using a reserve_attribute for backport reasons - return unless resource_id - towhat.safe_constantize.find_by(:id => resource_id) - end - def set_start_time_and_prod_default run_at # Internally this will correct :start_time to UTC self.prod_default = "system" if SYSTEM_SCHEDULE_CLASSES.include?(towhat.to_s) diff --git a/app/models/service_template.rb b/app/models/service_template.rb index 56ddcbf45aa4..59ef13ede183 100644 --- a/app/models/service_template.rb +++ b/app/models/service_template.rb @@ -55,6 +55,7 @@ class ServiceTemplate < ApplicationRecord belongs_to :service_template_catalog has_many :dialogs, -> { distinct }, :through => :resource_actions + has_many :miq_schedules, :as => :resource, :dependent => :destroy has_many :miq_requests, :as => :source, :dependent => :nullify has_many :active_requests, -> { where(:request_state => MiqRequest::ACTIVE_STATES) }, :as => :source, :class_name => "MiqRequest" @@ -406,11 +407,6 @@ def queue_order(user_id, options, request_options) ) end - def miq_schedules - schedule_ids = Reserve.where(:resource_type => "MiqSchedule").collect { |r| r.resource_id if r.reserved == {:resource_id => id} }.compact - MiqSchedule.where(:towhat => "ServiceTemplate", :id => schedule_ids) - end - def order(user_or_id, options = nil, request_options = nil, schedule_time = nil) user = user_or_id.kind_of?(User) ? user_or_id : User.find(user_or_id) workflow = provision_workflow(user, options, request_options) diff --git a/spec/models/miq_schedule_spec.rb b/spec/models/miq_schedule_spec.rb index a0eec07d289a..181c58bc9d80 100644 --- a/spec/models/miq_schedule_spec.rb +++ b/spec/models/miq_schedule_spec.rb @@ -729,7 +729,7 @@ end it "and does not respond to the method" do - schedule = FactoryGirl.create(:miq_schedule, :towhat => resource.class.name, :resource_id => resource.id, :sched_action => {:method => "test_method"}) + schedule = FactoryGirl.create(:miq_schedule, :resource => resource, :sched_action => {:method => "test_method"}) expect($log).to receive(:warn) do |message| expect(message).to include("no such action: [test_method], aborting schedule") @@ -739,7 +739,7 @@ end it "and responds to the method" do - schedule = FactoryGirl.create(:miq_schedule, :towhat => resource.class.name, :resource_id => resource.id, :sched_action => {:method => "test_method"}) + schedule = FactoryGirl.create(:miq_schedule, :resource => resource, :sched_action => {:method => "test_method"}) expect(resource).to receive("test_method").once @@ -747,7 +747,7 @@ end it "and responds to the method with arguments" do - schedule = FactoryGirl.create(:miq_schedule, :towhat => resource.class.name, :resource_id => resource.id, :sched_action => {:method => "test_method", :args => ["abc", 123, :a => 1]}) + schedule = FactoryGirl.create(:miq_schedule, :resource => resource, :sched_action => {:method => "test_method", :args => ["abc", 123, :a => 1]}) expect(resource).to receive("test_method").once.with("abc", 123, :a => 1) diff --git a/spec/models/service_template_spec.rb b/spec/models/service_template_spec.rb index 79ac76a84c9d..72de3ee4baea 100644 --- a/spec/models/service_template_spec.rb +++ b/spec/models/service_template_spec.rb @@ -839,8 +839,7 @@ expect(result[:schedule]).to have_attributes( :name => "Order ServiceTemplate #{service_template.id} at #{time}", :sched_action => {:args => [user.id, {}, {}], :method => "queue_order"}, - :towhat => "ServiceTemplate", - :resource_id => service_template.id + :resource => service_template ) end From a4b3a7207adc8995d3565bc68e45b4b5199538f3 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Thu, 14 Jun 2018 17:03:54 -0400 Subject: [PATCH 02/11] Update callers of MiqSchedule#towhat to #resource_type --- app/models/miq_schedule.rb | 26 ++++++++++++------------- app/models/miq_widget.rb | 12 ++++++------ app/models/service_template.rb | 3 +-- db/fixtures/miq_schedules.yml | 4 ++-- spec/factories/miq_schedule.rb | 6 +++--- spec/models/miq_schedule_filter_spec.rb | 24 +++++++++++------------ spec/models/miq_schedule_spec.rb | 4 ++-- 7 files changed, 39 insertions(+), 40 deletions(-) diff --git a/app/models/miq_schedule.rb b/app/models/miq_schedule.rb index fd7c2cace3a4..3c3cc36f9442 100644 --- a/app/models/miq_schedule.rb +++ b/app/models/miq_schedule.rb @@ -2,8 +2,8 @@ class MiqSchedule < ApplicationRecord include DeprecationMixin deprecate_attribute :towhat, :resource_type - validates :name, :uniqueness => {:scope => [:userid, :towhat]} - validates :name, :description, :towhat, :run_at, :presence => true + validates :name, :uniqueness => {:scope => [:userid, :resource_type]} + validates :name, :description, :resource_type, :run_at, :presence => true validate :validate_run_at, :validate_file_depot before_save :set_start_time_and_prod_default @@ -25,11 +25,11 @@ class MiqSchedule < ApplicationRecord where("updated_at > ?", time) } - scope :filter_matches_with, ->(exp) { where(:filter => exp) } - scope :with_prod_default_not_in, ->(prod) { where.not(:prod_default => prod).or(where(:prod_default => nil)) } - scope :without_adhoc, -> { where(:adhoc => nil) } - scope :with_towhat, ->(towhat) { where(:towhat => towhat) } - scope :with_userid, ->(userid) { where(:userid => userid) } + scope :filter_matches_with, ->(exp) { where(:filter => exp) } + scope :with_prod_default_not_in, ->(prod) { where.not(:prod_default => prod).or(where(:prod_default => nil)) } + scope :without_adhoc, -> { where(:adhoc => nil) } + scope :with_towhat, ->(resource_type) { where(:resource_type => resource_type) } + scope :with_userid, ->(userid) { where(:userid => userid) } serialize :sched_action serialize :filter @@ -45,7 +45,7 @@ class MiqSchedule < ApplicationRecord def set_start_time_and_prod_default run_at # Internally this will correct :start_time to UTC - self.prod_default = "system" if SYSTEM_SCHEDULE_CLASSES.include?(towhat.to_s) + self.prod_default = "system" if SYSTEM_SCHEDULE_CLASSES.include?(resource_type.to_s) end def run_at @@ -73,7 +73,7 @@ def self.queue_scheduled_work(id, _rufus_job_id, at, _params) end method = sched.sched_action[:method] rescue nil - _log.info("Queueing start of schedule id: [#{id}] [#{sched.name}] [#{sched.towhat}] [#{method}]") + _log.info("Queueing start of schedule id: [#{id}] [#{sched.name}] [#{sched.resource_type}] [#{method}]") action = "action_" + method @@ -86,7 +86,7 @@ def self.queue_scheduled_work(id, _rufus_job_id, at, _params) :msg_timeout => 1200 ) - _log.info("Queueing start of schedule id: [#{id}] [#{sched.name}] [#{sched.towhat}] [#{method}]...complete") + _log.info("Queueing start of schedule id: [#{id}] [#{sched.name}] [#{sched.resource_type}] [#{method}]...complete") msg elsif sched.resource.respond_to?(method) sched.resource.send(method, *sched.sched_action[:args]) @@ -122,12 +122,12 @@ def target_ids # Let RBAC evaluate the filter's MiqExpression, and return the first value (the target ids) my_filter = get_filter return [] if my_filter.nil? - Rbac.filtered(towhat, :filter => my_filter).pluck(:id) + Rbac.filtered(resource_type, :filter => my_filter).pluck(:id) end def get_targets # TODO: Add support to invoke_actions, get_targets, and get_filter to call class methods in addition to the normal instance methods - return [Object.const_get(towhat)] if sched_action.kind_of?(Hash) && ALLOWED_CLASS_METHOD_ACTIONS.include?(sched_action[:method]) + return [Object.const_get(resource_type)] if sched_action.kind_of?(Hash) && ALLOWED_CLASS_METHOD_ACTIONS.include?(sched_action[:method]) my_filter = get_filter if my_filter.nil? @@ -135,7 +135,7 @@ def get_targets return [] end - Rbac.filtered(towhat, :filter => my_filter) + Rbac.filtered(resource_type, :filter => my_filter) end def get_filter diff --git a/app/models/miq_widget.rb b/app/models/miq_widget.rb index c6bb9b40a2ad..4d799fa0bd42 100644 --- a/app/models/miq_widget.rb +++ b/app/models/miq_widget.rb @@ -521,12 +521,12 @@ def sync_schedule(schedule_info) end sched = MiqSchedule.create!( - :name => description, - :description => description, - :sched_action => {:method => "generate_widget"}, - :filter => MiqExpression.new("=" => {"field" => "MiqWidget-id", "value" => id}), - :towhat => self.class.name, - :run_at => { + :name => description, + :description => description, + :sched_action => {:method => "generate_widget"}, + :filter => MiqExpression.new("=" => {"field" => "MiqWidget-id", "value" => id}), + :resource_type => self.class.name, + :run_at => { :interval => {:value => value, :unit => unit}, :tz => server_tz, :start_time => sched_time diff --git a/app/models/service_template.rb b/app/models/service_template.rb index 59ef13ede183..ba8f03bf9396 100644 --- a/app/models/service_template.rb +++ b/app/models/service_template.rb @@ -421,8 +421,7 @@ def order(user_or_id, options = nil, request_options = nil, schedule_time = nil) :name => "Order #{self.class.name} #{id} at #{time}", :description => "Order #{self.class.name} #{id} at #{time}", :sched_action => {:args => [user.id, options, request_options], :method => "queue_order"}, - :resource_id => id, - :towhat => "ServiceTemplate", + :resource => self, :run_at => { :interval => {:unit => "once"}, :start_time => time, diff --git a/db/fixtures/miq_schedules.yml b/db/fixtures/miq_schedules.yml index e14410ff5be8..74a8b2bc46cc 100644 --- a/db/fixtures/miq_schedules.yml +++ b/db/fixtures/miq_schedules.yml @@ -19,7 +19,7 @@ :value: 1 :sched_action: :method: vm_scan - :towhat: Vm + :resource_type: Vm - :attributes: :name: "Sample: Hourly VM Analysis" :userid: system @@ -40,4 +40,4 @@ :value: 1 :sched_action: :method: vm_scan - :towhat: Vm + :resource_type: Vm diff --git a/spec/factories/miq_schedule.rb b/spec/factories/miq_schedule.rb index 9134c7216d5b..829f45c219da 100644 --- a/spec/factories/miq_schedule.rb +++ b/spec/factories/miq_schedule.rb @@ -2,7 +2,7 @@ factory :miq_schedule_validation, :class => :MiqSchedule do sequence(:name) { |n| "schedule_#{seq_padded_for_sorting(n)}" } description "test" - towhat "MiqReport" + resource_type "MiqReport" run_at {} sched_action {} end @@ -12,7 +12,7 @@ sched_action = {:method => "test"} sequence(:name) { |n| "schedule_#{seq_padded_for_sorting(n)}" } description "test" - towhat "MiqReport" + resource_type "MiqReport" run_at run_at sched_action sched_action end @@ -23,7 +23,7 @@ filter = {:uri_parts => {:instance => 'test', :message => 'create'}, :ui => { :ui_attrs => [], :ui_object => {} }, :parameters => {'request' => 'test_request', 'key1' => 'value1'}} sequence(:name) { |n| "automate_schedule_#{seq_padded_for_sorting(n)}" } description "test_automation" - towhat "AutomationRequest" + resource_type "AutomationRequest" run_at run_at sched_action sched_action filter filter diff --git a/spec/models/miq_schedule_filter_spec.rb b/spec/models/miq_schedule_filter_spec.rb index a84435d0506c..28fae24dc8c6 100644 --- a/spec/models/miq_schedule_filter_spec.rb +++ b/spec/models/miq_schedule_filter_spec.rb @@ -10,15 +10,15 @@ @vm4 = FactoryGirl.create(:vm_vmware, :name => "Special Test VM") @vm_single_schedule = FactoryGirl.create(:miq_schedule, - :towhat => "Vm", - :sched_action => {:method => "vm_scan"}, - :filter => MiqExpression.new("=" => {"field" => "Vm-name", "value" => "Special Test VM"}) + :resource_type => "Vm", + :sched_action => {:method => "vm_scan"}, + :filter => MiqExpression.new("=" => {"field" => "Vm-name", "value" => "Special Test VM"}) ) @vm_all_schedule = FactoryGirl.create(:miq_schedule, - :towhat => "Vm", - :sched_action => {:method => "vm_scan"}, - :filter => MiqExpression.new("IS NOT NULL" => {"field" => "Vm-name"}) + :resource_type => "Vm", + :sched_action => {:method => "vm_scan"}, + :filter => MiqExpression.new("IS NOT NULL" => {"field" => "Vm-name"}) ) # Schedule froma saved search @@ -27,15 +27,15 @@ :filter => MiqExpression.new("=" => {"field" => "Vm-name", "value" => "Test VM 2"}) ) @vm_search_schedule = FactoryGirl.create(:miq_schedule, - :towhat => "Vm", + :resource_type => "Vm", :sched_action => {:method => "vm_scan"}, :miq_search_id => @search.id ) # DB Baskup Schedule @db_backup = FactoryGirl.create(:miq_schedule, - :towhat => "DatabaseBackup", - :sched_action => {:method => "db_backup"} + :resource_type => "DatabaseBackup", + :sched_action => {:method => "db_backup"} ) end @@ -44,9 +44,9 @@ MiqReport.seed_report("Vendor and Guest OS") @report = MiqReport.first @report_schedule = FactoryGirl.create(:miq_schedule, - :towhat => "MiqReport", - :sched_action => {:method => "run_report"}, - :filter => MiqExpression.new("=" => {"field" => "MiqReport-id", "value" => @report.id}) + :resource_type => "MiqReport", + :sched_action => {:method => "run_report"}, + :filter => MiqExpression.new("=" => {"field" => "MiqReport-id", "value" => @report.id}) ) end diff --git a/spec/models/miq_schedule_spec.rb b/spec/models/miq_schedule_spec.rb index 181c58bc9d80..3d6facb0a482 100644 --- a/spec/models/miq_schedule_spec.rb +++ b/spec/models/miq_schedule_spec.rb @@ -514,7 +514,7 @@ context "valid action_automation_request" do let(:admin) { FactoryGirl.create(:user_miq_request_approver) } let(:automate_sched) do - MiqSchedule.create(:name => "test_method", :towhat => "AutomationRequest", + MiqSchedule.create(:name => "test_method", :resource_type => "AutomationRequest", :userid => admin.userid, :enabled => true, :run_at => {:interval => {:value => "1", :unit => "daily"}, :start_time => 2.hours.from_now.utc.to_i}, @@ -541,7 +541,7 @@ before do @valid_schedules = [] @valid_run_ats.each do |run_at| - @valid_schedules << FactoryGirl.create(:miq_schedule_validation, :run_at => run_at, :file_depot => file_depot, :sched_action => {:method => "db_backup"}, :towhat => "DatabaseBackup") + @valid_schedules << FactoryGirl.create(:miq_schedule_validation, :run_at => run_at, :file_depot => file_depot, :sched_action => {:method => "db_backup"}, :resource_type => "DatabaseBackup") end @schedule = @valid_schedules.first end From 1ff0da7c3fdf92a82e33a04f303af8305101ce16 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Mon, 23 Jul 2018 09:44:24 -0400 Subject: [PATCH 03/11] Not sure how this ever worked... --- spec/models/miq_schedule_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/models/miq_schedule_spec.rb b/spec/models/miq_schedule_spec.rb index 3d6facb0a482..55f9f3fd0a89 100644 --- a/spec/models/miq_schedule_spec.rb +++ b/spec/models/miq_schedule_spec.rb @@ -739,17 +739,17 @@ end it "and responds to the method" do - schedule = FactoryGirl.create(:miq_schedule, :resource => resource, :sched_action => {:method => "test_method"}) + schedule = FactoryGirl.create(:miq_schedule, :resource => resource, :sched_action => {:method => "name"}) - expect(resource).to receive("test_method").once + expect_any_instance_of(Host).to receive("name").once MiqSchedule.queue_scheduled_work(schedule.id, nil, "abc", nil) end it "and responds to the method with arguments" do - schedule = FactoryGirl.create(:miq_schedule, :resource => resource, :sched_action => {:method => "test_method", :args => ["abc", 123, :a => 1]}) + schedule = FactoryGirl.create(:miq_schedule, :resource => resource, :sched_action => {:method => "name", :args => ["abc", 123, :a => 1]}) - expect(resource).to receive("test_method").once.with("abc", 123, :a => 1) + expect_any_instance_of(Host).to receive("name").once.with("abc", 123, :a => 1) MiqSchedule.queue_scheduled_work(schedule.id, nil, "abc", nil) end From 485da7eb46066df9e2eb6c39ff2883a226e98808 Mon Sep 17 00:00:00 2001 From: lpichler Date: Mon, 23 Jul 2018 20:56:20 +0200 Subject: [PATCH 04/11] Move VIRTUAL_COL_USES translation to col_index method in ChargeableField --- app/models/chargeable_field.rb | 1 + app/models/chargeback/consumption_with_rollups.rb | 1 - spec/factories/chargeable_field.rb | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/chargeable_field.rb b/app/models/chargeable_field.rb index 7518274b3051..fbdbedcbef84 100644 --- a/app/models/chargeable_field.rb +++ b/app/models/chargeable_field.rb @@ -98,6 +98,7 @@ def self.cols_on_metric_rollup def self.col_index(column) @rate_cols ||= {} + column = VIRTUAL_COL_USES[column] || column @rate_cols[column] ||= cols_on_metric_rollup.index(column.to_s) end diff --git a/app/models/chargeback/consumption_with_rollups.rb b/app/models/chargeback/consumption_with_rollups.rb index 8f59763e8fb0..78ca0532ea30 100644 --- a/app/models/chargeback/consumption_with_rollups.rb +++ b/app/models/chargeback/consumption_with_rollups.rb @@ -71,7 +71,6 @@ def tag_list_with_prefix end def sum(metric, sub_metric = nil) - metric = ChargeableField::VIRTUAL_COL_USES[metric] || metric values(metric, sub_metric).sum end diff --git a/spec/factories/chargeable_field.rb b/spec/factories/chargeable_field.rb index cc9ea37cacca..7f74a1db465e 100644 --- a/spec/factories/chargeable_field.rb +++ b/spec/factories/chargeable_field.rb @@ -46,7 +46,7 @@ factory :chargeable_field_cpu_cores_used, :parent => :chargeable_field do description 'Used CPU in Cores' - metric 'cpu_usage_rate_average' + metric 'v_derived_cpu_total_cores_used' group 'cpu_cores' source 'used' end From 1a97e432cb3f7a1eae53ff0f2be427b27c39d407 Mon Sep 17 00:00:00 2001 From: Brant Evans Date: Sat, 21 Jul 2018 19:49:55 -0700 Subject: [PATCH 05/11] Add support for exporting and importing provision dialogs --- lib/task_helpers/exports/provision_dialogs.rb | 22 + lib/task_helpers/imports/provision_dialogs.rb | 20 + lib/tasks/evm_export_import.rake | 17 + .../exports/provision_dialogs_spec.rb | 118 +++ ...-test2_miq_provision_dialogs_template.yaml | 770 ++++++++++++++++++ ...w-test_miq_provision_dialogs_template.yaml | 769 +++++++++++++++++ ...iq_provision_dialogs_template_modified.yml | 769 +++++++++++++++++ .../imports/provision_dialogs_spec.rb | 78 ++ 8 files changed, 2563 insertions(+) create mode 100644 lib/task_helpers/exports/provision_dialogs.rb create mode 100644 lib/task_helpers/imports/provision_dialogs.rb create mode 100644 spec/lib/task_helpers/exports/provision_dialogs_spec.rb create mode 100644 spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test2_miq_provision_dialogs_template.yaml create mode 100644 spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test_miq_provision_dialogs_template.yaml create mode 100644 spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test_miq_provision_dialogs_template_modified.yml create mode 100644 spec/lib/task_helpers/imports/provision_dialogs_spec.rb diff --git a/lib/task_helpers/exports/provision_dialogs.rb b/lib/task_helpers/exports/provision_dialogs.rb new file mode 100644 index 000000000000..73750ca41c93 --- /dev/null +++ b/lib/task_helpers/exports/provision_dialogs.rb @@ -0,0 +1,22 @@ +module TaskHelpers + class Exports + class ProvisionDialogs + def export(options = {}) + export_dir = options[:directory] + + dialogs = options[:all] ? MiqDialog.order(:id).all : MiqDialog.order(:id).where(:default => [false, nil]) + + dialogs = dialogs.collect do |dialog| + Exports.exclude_attributes(dialog.to_model_hash, %i(file_mtime created_at updated_at id class)) + end + + dialogs.each do |dialog| + $log.info("Exporting Provision Dialog: #{dialog[:name]} (#{dialog[:description]})") + + fname = Exports.safe_filename("#{dialog[:dialog_type]}-#{dialog[:name]}", options[:keep_spaces]) + File.write("#{export_dir}/#{fname}.yaml", dialog.to_yaml) + end + end + end + end +end diff --git a/lib/task_helpers/imports/provision_dialogs.rb b/lib/task_helpers/imports/provision_dialogs.rb new file mode 100644 index 000000000000..a42a42cfb250 --- /dev/null +++ b/lib/task_helpers/imports/provision_dialogs.rb @@ -0,0 +1,20 @@ +module TaskHelpers + class Imports + class ProvisionDialogs + def import(options = {}) + return unless options[:source] + + glob = File.file?(options[:source]) ? options[:source] : "#{options[:source]}/*.yaml" + Dir.glob(glob) do |fname| + $log.info("Importing Provision Dialog from: #{fname}") + + dialog = YAML.load_file(fname) + + miq_dialog = MiqDialog.find_by(:name => dialog[:name], :dialog_type => dialog[:dialog_type]) + + miq_dialog.nil? ? MiqDialog.create(dialog) : miq_dialog.update(dialog) + end + end + end + end +end diff --git a/lib/tasks/evm_export_import.rake b/lib/tasks/evm_export_import.rake index eef077f0ca16..902614eeecae 100644 --- a/lib/tasks/evm_export_import.rake +++ b/lib/tasks/evm_export_import.rake @@ -4,6 +4,7 @@ # * Roles # * Tags # * Service Dialogs +# * Provision Dialogs namespace :evm do namespace :export do @@ -76,6 +77,14 @@ namespace :evm do exit # exit so that parameters to the first rake task are not run as rake tasks end + + desc 'Exports all provision dialogs to individual YAML files' + task :provision_dialogs => :environment do + options = TaskHelpers::Exports.parse_options + TaskHelpers::Exports::ProvisionDialogs.new.export(options) + + exit # exit so that parameters to the first rake task are not run as rake tasks + end end namespace :import do @@ -140,5 +149,13 @@ namespace :evm do exit # exit so that parameters to the first rake task are not run as rake tasks end + + desc 'Imports all provision dialogs from individual YAML files' + task :provision_dialogs => :environment do + options = TaskHelpers::Imports.parse_options + TaskHelpers::Imports::ProvisionDialogs.new.import(options) + + exit # exit so that parameters to the first rake task are not run as rake tasks + end end end diff --git a/spec/lib/task_helpers/exports/provision_dialogs_spec.rb b/spec/lib/task_helpers/exports/provision_dialogs_spec.rb new file mode 100644 index 000000000000..39fb4f75dc9b --- /dev/null +++ b/spec/lib/task_helpers/exports/provision_dialogs_spec.rb @@ -0,0 +1,118 @@ +describe TaskHelpers::Exports::ProvisionDialogs do + let(:dialog_name1) { "default_dialog" } + let(:dialog_name2) { "custom_dialog" } + let(:dialog_desc1) { "Default Provisioning Dialog" } + let(:dialog_desc2) { "Custom Provisioning Dialog" } + let(:dialog_type1) { "MiqProvisionWorkflow" } + let(:dialog_type2) { "MiqProvisionWorkflow" } + let(:dialog_type3) { "VmMigrateWorkflow" } + + let(:content) do + { + :dialogs => { + :hardware => { + :description => "Hardware", + :fields => { + :disk_format => { + :description => "Disk Format", + :required => false, + :display => :edit, + :default => "unchanged", + :data_type => :string, + :values => { + :thick => "Thick", + :thin => "Thin" + } + }, + :cpu_limit => { + :description => "CPU (MHz)", + :required => false, + :notes => "(-1 = Unlimited)", + :display => :edit, + :data_type => :integer, + :notes_display => :show + } + } + } + } + } + end + + let(:content2) do + { + :dialogs => { + :buttons => %i(submit cancel) + } + } + end + + let(:export_dir) do + Dir.mktmpdir('miq_exp_dir') + end + + before do + FactoryGirl.create(:miq_dialog, + :dialog_type => dialog_type1, + :name => dialog_name1, + :description => dialog_desc1, + :content => content, + :default => true) + + FactoryGirl.create(:miq_dialog, + :dialog_type => dialog_type2, + :name => dialog_name2, + :description => dialog_desc2, + :content => content, + :default => false) + end + + after do + FileUtils.remove_entry export_dir + end + + describe "when --all is not specified" do + let(:dialog_filename1) { "#{export_dir}/#{dialog_type1}-custom_dialog.yaml" } + let(:dialog_filename2) { "#{export_dir}/#{dialog_type3}-custom_dialog.yaml" } + + it 'exports user provision dialogs to a given directory' do + TaskHelpers::Exports::ProvisionDialogs.new.export(:directory => export_dir) + expect(Dir[File.join(export_dir, '**', '*')].count { |file| File.file?(file) }).to eq(1) + dialog = YAML.load_file(dialog_filename1) + expect(dialog[:content]).to eq(content) + expect(dialog[:description]).to eq(dialog_desc2) + end + + it 'exports dialogs with the same name to different files' do + FactoryGirl.create(:miq_dialog, + :dialog_type => dialog_type3, + :name => dialog_name2, + :description => dialog_desc2, + :content => content2, + :default => false) + TaskHelpers::Exports::ProvisionDialogs.new.export(:directory => export_dir) + expect(Dir[File.join(export_dir, '**', '*')].count { |file| File.file?(file) }).to eq(2) + dialog = YAML.load_file(dialog_filename1) + expect(dialog[:content]).to eq(content) + expect(dialog[:description]).to eq(dialog_desc2) + dialog2 = YAML.load_file(dialog_filename2) + expect(dialog2[:content]).to eq(content2) + expect(dialog2[:description]).to eq(dialog_desc2) + end + end + + describe "when --all is specified" do + let(:dialog_filename1) { "#{export_dir}/#{dialog_type1}-default_dialog.yaml" } + let(:dialog_filename2) { "#{export_dir}/#{dialog_type1}-custom_dialog.yaml" } + + it 'exports all provision dialogs to a given directory' do + TaskHelpers::Exports::ProvisionDialogs.new.export(:directory => export_dir, :all => true) + expect(Dir[File.join(export_dir, '**', '*')].count { |file| File.file?(file) }).to eq(2) + dialog1 = YAML.load_file(dialog_filename1) + dialog2 = YAML.load_file(dialog_filename2) + expect(dialog1[:content]).to eq(content) + expect(dialog1[:description]).to eq(dialog_desc1) + expect(dialog2[:content]).to eq(content) + expect(dialog2[:description]).to eq(dialog_desc2) + end + end +end diff --git a/spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test2_miq_provision_dialogs_template.yaml b/spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test2_miq_provision_dialogs_template.yaml new file mode 100644 index 000000000000..3dcecd9395a5 --- /dev/null +++ b/spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test2_miq_provision_dialogs_template.yaml @@ -0,0 +1,770 @@ +--- +:name: test2_miq_provision_dialogs_template +:description: Test2 Sample VM Provisioning Dialog (Template) +:dialog_type: MiqProvisionWorkflow +:content: + :buttons: + - :submit + - :cancel + :dialogs: + :requester: + :description: Request + :fields: + :owner_phone: + :description: Phone + :required: false + :display: :hide + :data_type: :string + :owner_country: + :description: Country/Region + :required: false + :display: :hide + :data_type: :string + :owner_phone_mobile: + :description: Mobile + :required: false + :display: :hide + :data_type: :string + :owner_title: + :description: Title + :required: false + :display: :hide + :data_type: :string + :owner_first_name: + :description: First Name + :required: false + :display: :edit + :data_type: :string + :owner_manager: + :description: Name + :required: false + :display: :edit + :data_type: :string + :owner_address: + :description: Address + :required: false + :display: :hide + :data_type: :string + :owner_company: + :description: Company + :required: false + :display: :hide + :data_type: :string + :owner_last_name: + :description: Last Name + :required: false + :display: :edit + :data_type: :string + :owner_manager_mail: + :description: E-Mail + :required: false + :display: :hide + :data_type: :string + :owner_city: + :description: City + :required: false + :display: :hide + :data_type: :string + :owner_department: + :description: Department + :required: false + :display: :hide + :data_type: :string + :owner_load_ldap: + :pressed: + :method: :retrieve_ldap + :description: Look Up LDAP Email + :required: false + :display: :show + :data_type: :button + :owner_manager_phone: + :description: Phone + :required: false + :display: :hide + :data_type: :string + :owner_state: + :description: State + :required: false + :display: :hide + :data_type: :string + :owner_office: + :description: Office + :required: false + :display: :hide + :data_type: :string + :owner_zip: + :description: Zip code + :required: false + :display: :hide + :data_type: :string + :owner_email: + :description: E-Mail + :required_method: :validate_regex + :required_regex: !ruby/regexp /\A[\w!#$\%&'*+\/=?`\{|\}~^-]+(?:\.[\w!#$\%&'*+\/=?`\{|\}~^-]+)*@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\Z/i + :required: true + :display: :edit + :data_type: :string + :request_notes: + :description: Notes + :required: false + :display: :edit + :data_type: :string + :display: :show + :field_order: + :purpose: + :description: Purpose + :fields: + :vm_tags: + :required_method: :validate_tags + :description: Tags + :required: false + :options: + :include: [] + :order: [] + :single_select: [] + :exclude: [] + :display: :edit + :required_tags: + - environment + :data_type: :integer + :display: :show + :field_order: + :customize: + :description: Customize + :fields: + :dns_servers: + :description: DNS Server list + :required: false + :display: :edit + :data_type: :string + :sysprep_organization: + :description: Organization + :required_method: :validate_sysprep_field + :required: true + :display: :edit + :data_type: :string + :sysprep_password: + :description: New Administrator Password + :required: false + :display: :edit + :data_type: :string + :sysprep_custom_spec: + :values_from: + :method: :allowed_customization_specs + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :string + :sysprep_server_license_mode: + :values: + perServer: Per server + perSeat: Per seat + :description: Identification + :required: false + :display: :edit + :default: perServer + :data_type: :string + :ldap_ous: + :values_from: + :method: :allowed_ous_tree + :auto_select_single: false + :description: LDAP Group + :required: false + :display: :edit + :data_type: :string + :sysprep_timezone: + :values_from: + :method: :get_timezones + :description: Timezone + :required_method: :validate_sysprep_field + :required: true + :display: :edit + :data_type: :string + :dns_suffixes: + :description: DNS Suffix List + :required: false + :display: :edit + :data_type: :string + :sysprep_product_id: + :description: ProductID + :required_method: :validate_sysprep_field + :required: false + :display: :edit + :data_type: :string + :sysprep_identification: + :values: + domain: Domain + workgroup: Workgroup + :description: Identification + :required: false + :display: :edit + :default: domain + :data_type: :string + :sysprep_per_server_max_connections: + :description: Maximum Connections + :required: false + :display: :edit + :default: '5' + :data_type: :string + :sysprep_computer_name: + :description: Computer Name + :required: false + :display: :edit + :data_type: :string + :sysprep_workgroup_name: + :description: Workgroup Name + :required: false + :display: :edit + :default: WORKGROUP + :data_type: :string + :sysprep_spec_override: + :values: + false: 0 + true: 1 + :description: Override Specification Values + :required: false + :display: :edit + :default: false + :data_type: :boolean + :addr_mode: + :values: + static: Static + dhcp: DHCP + :description: Address Mode + :required: false + :display: :edit + :default: dhcp + :data_type: :string + :linux_host_name: + :description: Computer Name + :required: false + :display: :edit + :data_type: :string + :sysprep_domain_admin: + :description: Domain Admin + :required: false + :display: :edit + :data_type: :string + :sysprep_change_sid: + :values: + false: 0 + true: 1 + :description: Change SID + :required: false + :display: :edit + :default: true + :data_type: :boolean + :sysprep_domain_name: + :values_from: + :options: + :active_proxy: + :platform: + :method: :allowed_domains + :auto_select_single: false + :description: Domain Name + :required: false + :display: :edit + :data_type: :string + :sysprep_upload_file: + :description: Upload + :required: false + :display: :edit + :data_type: :string + :gateway: + :description: Gateway + :required: false + :display: :edit + :data_type: :string + :ip_addr: + :description: IP Address + :required: false + :notes: "(Enter starting IP address)" + :display: :edit + :data_type: :string + :notes_display: :hide + :linux_domain_name: + :description: Domain Name + :required: false + :display: :edit + :data_type: :string + :sysprep_domain_password: + :description: Domain Password + :required: false + :display: :edit + :data_type: :string + :sysprep_auto_logon: + :values: + false: 0 + true: 1 + :description: Auto Logon + :required: false + :display: :edit + :default: true + :data_type: :boolean + :sysprep_enabled: + :values_from: + :method: :allowed_customization + :description: Customize + :required: false + :display: :edit + :default: disabled + :data_type: :string + :sysprep_delete_accounts: + :display_override: :hide + :values: + false: 0 + true: 1 + :description: Delete Accounts + :required: false + :display: :hide + :default: false + :data_type: :boolean + :sysprep_upload_text: + :description: Sysprep Text + :required_method: :validate_sysprep_upload + :required: true + :display: :edit + :data_type: :string + :wins_servers: + :description: WINS Server list + :required: false + :display: :edit + :data_type: :string + :subnet_mask: + :description: Subnet Mask + :required: false + :display: :edit + :data_type: :string + :sysprep_full_name: + :description: Full Name + :required_method: :validate_sysprep_field + :required: true + :display: :edit + :data_type: :string + :sysprep_auto_logon_count: + :values: + 1: '1' + 2: '2' + 3: '3' + :description: Auto Logon Count + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :customization_template_id: + :values_from: + :method: :allowed_customization_templates + :auto_select_single: false + :description: Script Name + :required: false + :display: :edit + :data_type: :integer + :root_password: + :description: Root Password + :required: false + :display: :edit + :data_type: :string + :hostname: + :description: Host Name + :required: false + :display: :edit + :data_type: :string + :customization_template_script: + :description: Script Text + :required: false + :display: :edit + :data_type: :string + :display: :show + :environment: + :description: Environment + :fields: + :placement_cluster_name: + :values_from: + :method: :allowed_clusters + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :cluster_filter: + :values_from: + :options: + :category: :EmsCluster + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :host_filter: + :values_from: + :options: + :category: :Host + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :ds_filter: + :values_from: + :options: + :category: :Storage + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :placement_storage_profile: + :values_from: + :method: :allowed_storage_profiles + :auto_select_single: false + :description: Storage Profile + :required: false + :display: :edit + :data_type: :integer + :placement_host_name: + :values_from: + :method: :allowed_hosts + :auto_select_single: false + :description: Name + :validation_method: :validate_placement_host_name + :required: false + :display: :edit + :data_type: :integer + :required_description: Host Name + :placement_ds_name: + :values_from: + :method: :allowed_storages + :auto_select_single: false + :description: Name + :required_method: :validate_placement + :required: true + :display: :edit + :data_type: :integer + :required_description: Datastore Name + :rp_filter: + :values_from: + :options: + :category: :ResourcePool + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :placement_auto: + :values: + false: 0 + true: 1 + :description: Choose Automatically + :required: false + :display: :edit + :default: false + :data_type: :boolean + :placement_folder_name: + :values_from: + :method: :allowed_folders + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :placement_rp_name: + :values_from: + :method: :allowed_respools + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :placement_dc_name: + :values_from: + :method: :allowed_datacenters + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :display: :show + :service: + :description: Catalog + :fields: + :number_of_vms: + :values_from: + :options: + :max: 50 + :method: :allowed_number_of_vms + :description: Count + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :vm_description: + :description: VM Description + :required: false + :display: :edit + :data_type: :string + :min_length: + :max_length: 100 + :vm_prefix: + :description: VM Name Prefix/Suffix + :required_method: :validate_vm_name + :required: false + :display: :hide + :data_type: :string + :src_vm_id: + :values_from: + :options: + :tag_filters: [] + :method: :allowed_templates + :description: Name + :required: true + :notes: + :display: :edit + :data_type: :integer + :notes_display: :show + :vm_name: + :description: VM Name + :required_method: :validate_vm_name + :required: true + :notes: + :display: :edit + :data_type: :string + :notes_display: :show + :min_length: + :max_length: + :pxe_image_id: + :values_from: + :method: :allowed_images + :auto_select_single: false + :description: Image + :required: true + :required_method: :validate_pxe_image_id + :display: :edit + :data_type: :string + :pxe_server_id: + :values_from: + :method: :allowed_pxe_servers + :auto_select_single: false + :description: Server + :required: true + :required_method: :validate_pxe_server_id + :display: :edit + :data_type: :integer + :host_name: + :description: Host Name + :required: false + :display: :hide + :data_type: :string + :provision_type: + :values_from: + :method: :allowed_provision_types + :description: Provision Type + :required: true + :display: :edit + :default: vmware + :data_type: :string + :linked_clone: + :values: + false: 0 + true: 1 + :description: Linked Clone + :required: false + :display: :edit + :default: false + :data_type: :boolean + :notes: VM requires a snapshot + :notes_display: :show + :snapshot: + :values_from: + :method: :allowed_snapshots + :description: Snapshot + :required: false + :display: :edit + :data_type: :string + :auto_select_single: false + :vm_filter: + :values_from: + :options: + :category: :Vm + :method: :allowed_filters + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :display: :show + :schedule: + :description: Schedule + :fields: + :schedule_type: + :values: + schedule: Schedule + immediately: Immediately on Approval + :description: When to Provision + :required: false + :display: :edit + :default: immediately + :data_type: :string + :vm_auto_start: + :values: + false: 0 + true: 1 + :description: Power on virtual machines after creation + :required: false + :display: :edit + :default: true + :data_type: :boolean + :schedule_time: + :values_from: + :options: + :offset: 1.day + :method: :default_schedule_time + :description: Provision on + :required: false + :display: :edit + :data_type: :time + :retirement: + :values: + 0: Indefinite + 1.month: 1 Month + 3.months: 3 Months + 6.months: 6 Months + :description: Time until Retirement + :required: false + :display: :edit + :default: 0 + :data_type: :integer + :retirement_warn: + :values_from: + :options: + :values: + 1.week: 1 Week + 2.weeks: 2 Weeks + 30.days: 30 Days + :include_equals: false + :field: :retirement + :method: :values_less_then + :description: Retirement Warning + :required: true + :display: :edit + :default: 1.week + :data_type: :integer + :display: :show + :network: + :description: Network + :fields: + :vlan: + :values_from: + :options: + :dvs: true + :vlans: true + :method: :allowed_vlans + :description: Virtual Network + :required: true + :display: :edit + :data_type: :string + :mac_address: + :description: MAC Address + :required: false + :display: :hide + :data_type: :string + :display: :show + :hardware: + :description: Hardware + :fields: + :disk_format: + :values: + thick: Thick + thin: Thin + unchanged: Default + :description: Disk Format + :required: false + :display: :edit + :default: unchanged + :data_type: :string + :cpu_limit: + :description: CPU (MHz) + :required: false + :notes: "(-1 = Unlimited)" + :display: :edit + :data_type: :integer + :notes_display: :show + :memory_limit: + :description: Memory (MB) + :required: false + :notes: "(-1 = Unlimited)" + :display: :edit + :data_type: :integer + :notes_display: :show + :number_of_sockets: + :values: + 1: '1' + 2: '2' + 4: '4' + 8: '8' + :description: Number of Sockets + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :cores_per_socket: + :values: + 1: '1' + 2: '2' + 4: '4' + 8: '8' + :description: Cores per Socket + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :cpu_reserve: + :description: CPU (MHz) + :required: false + :display: :edit + :data_type: :integer + :vm_memory: + :values: + '1024': '1024' + '2048': '2048' + '4096': '4096' + '8192': '8192' + '12288': '12288' + '16384': '16384' + '32768': '32768' + :description: Memory (MB) + :required: false + :display: :edit + :default: '1024' + :data_type: :string + :memory_reserve: + :description: Memory (MB) + :required: false + :display: :edit + :data_type: :integer + :validation_method: :validate_memory_reservation + :network_adapters: + :values: + 1: '1' + 2: '2' + 3: '3' + 4: '4' + :description: Network Adapters + :required: false + :display: :hide + :default: 1 + :data_type: :integer + :display: :show + :dialog_order: + - :requester + - :purpose + - :service + - :environment + - :hardware + - :network + - :customize + - :schedule +:default: false diff --git a/spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test_miq_provision_dialogs_template.yaml b/spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test_miq_provision_dialogs_template.yaml new file mode 100644 index 000000000000..d097a7c00682 --- /dev/null +++ b/spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test_miq_provision_dialogs_template.yaml @@ -0,0 +1,769 @@ +--- +:name: test_miq_provision_dialogs_template +:description: Test Sample VM Provisioning Dialog (Template) +:dialog_type: MiqProvisionWorkflow +:content: + :buttons: + - :submit + - :cancel + :dialogs: + :requester: + :description: Request + :fields: + :owner_phone: + :description: Phone + :required: false + :display: :hide + :data_type: :string + :owner_country: + :description: Country/Region + :required: false + :display: :hide + :data_type: :string + :owner_phone_mobile: + :description: Mobile + :required: false + :display: :hide + :data_type: :string + :owner_title: + :description: Title + :required: false + :display: :hide + :data_type: :string + :owner_first_name: + :description: First Name + :required: false + :display: :edit + :data_type: :string + :owner_manager: + :description: Name + :required: false + :display: :edit + :data_type: :string + :owner_address: + :description: Address + :required: false + :display: :hide + :data_type: :string + :owner_company: + :description: Company + :required: false + :display: :hide + :data_type: :string + :owner_last_name: + :description: Last Name + :required: false + :display: :edit + :data_type: :string + :owner_manager_mail: + :description: E-Mail + :required: false + :display: :hide + :data_type: :string + :owner_city: + :description: City + :required: false + :display: :hide + :data_type: :string + :owner_department: + :description: Department + :required: false + :display: :hide + :data_type: :string + :owner_load_ldap: + :pressed: + :method: :retrieve_ldap + :description: Look Up LDAP Email + :required: false + :display: :show + :data_type: :button + :owner_manager_phone: + :description: Phone + :required: false + :display: :hide + :data_type: :string + :owner_state: + :description: State + :required: false + :display: :hide + :data_type: :string + :owner_office: + :description: Office + :required: false + :display: :hide + :data_type: :string + :owner_zip: + :description: Zip code + :required: false + :display: :hide + :data_type: :string + :owner_email: + :description: E-Mail + :required_method: :validate_regex + :required_regex: !ruby/regexp /\A[\w!#$\%&'*+\/=?`\{|\}~^-]+(?:\.[\w!#$\%&'*+\/=?`\{|\}~^-]+)*@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\Z/i + :required: true + :display: :edit + :data_type: :string + :request_notes: + :description: Notes + :required: false + :display: :edit + :data_type: :string + :display: :show + :field_order: + :purpose: + :description: Purpose + :fields: + :vm_tags: + :required_method: :validate_tags + :description: Tags + :required: false + :options: + :include: [] + :order: [] + :single_select: [] + :exclude: [] + :display: :edit + :required_tags: [] + :data_type: :integer + :display: :show + :field_order: + :customize: + :description: Customize + :fields: + :dns_servers: + :description: DNS Server list + :required: false + :display: :edit + :data_type: :string + :sysprep_organization: + :description: Organization + :required_method: :validate_sysprep_field + :required: true + :display: :edit + :data_type: :string + :sysprep_password: + :description: New Administrator Password + :required: false + :display: :edit + :data_type: :string + :sysprep_custom_spec: + :values_from: + :method: :allowed_customization_specs + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :string + :sysprep_server_license_mode: + :values: + perServer: Per server + perSeat: Per seat + :description: Identification + :required: false + :display: :edit + :default: perServer + :data_type: :string + :ldap_ous: + :values_from: + :method: :allowed_ous_tree + :auto_select_single: false + :description: LDAP Group + :required: false + :display: :edit + :data_type: :string + :sysprep_timezone: + :values_from: + :method: :get_timezones + :description: Timezone + :required_method: :validate_sysprep_field + :required: true + :display: :edit + :data_type: :string + :dns_suffixes: + :description: DNS Suffix List + :required: false + :display: :edit + :data_type: :string + :sysprep_product_id: + :description: ProductID + :required_method: :validate_sysprep_field + :required: false + :display: :edit + :data_type: :string + :sysprep_identification: + :values: + domain: Domain + workgroup: Workgroup + :description: Identification + :required: false + :display: :edit + :default: domain + :data_type: :string + :sysprep_per_server_max_connections: + :description: Maximum Connections + :required: false + :display: :edit + :default: '5' + :data_type: :string + :sysprep_computer_name: + :description: Computer Name + :required: false + :display: :edit + :data_type: :string + :sysprep_workgroup_name: + :description: Workgroup Name + :required: false + :display: :edit + :default: WORKGROUP + :data_type: :string + :sysprep_spec_override: + :values: + false: 0 + true: 1 + :description: Override Specification Values + :required: false + :display: :edit + :default: false + :data_type: :boolean + :addr_mode: + :values: + static: Static + dhcp: DHCP + :description: Address Mode + :required: false + :display: :edit + :default: dhcp + :data_type: :string + :linux_host_name: + :description: Computer Name + :required: false + :display: :edit + :data_type: :string + :sysprep_domain_admin: + :description: Domain Admin + :required: false + :display: :edit + :data_type: :string + :sysprep_change_sid: + :values: + false: 0 + true: 1 + :description: Change SID + :required: false + :display: :edit + :default: true + :data_type: :boolean + :sysprep_domain_name: + :values_from: + :options: + :active_proxy: + :platform: + :method: :allowed_domains + :auto_select_single: false + :description: Domain Name + :required: false + :display: :edit + :data_type: :string + :sysprep_upload_file: + :description: Upload + :required: false + :display: :edit + :data_type: :string + :gateway: + :description: Gateway + :required: false + :display: :edit + :data_type: :string + :ip_addr: + :description: IP Address + :required: false + :notes: "(Enter starting IP address)" + :display: :edit + :data_type: :string + :notes_display: :hide + :linux_domain_name: + :description: Domain Name + :required: false + :display: :edit + :data_type: :string + :sysprep_domain_password: + :description: Domain Password + :required: false + :display: :edit + :data_type: :string + :sysprep_auto_logon: + :values: + false: 0 + true: 1 + :description: Auto Logon + :required: false + :display: :edit + :default: true + :data_type: :boolean + :sysprep_enabled: + :values_from: + :method: :allowed_customization + :description: Customize + :required: false + :display: :edit + :default: disabled + :data_type: :string + :sysprep_delete_accounts: + :display_override: :hide + :values: + false: 0 + true: 1 + :description: Delete Accounts + :required: false + :display: :hide + :default: false + :data_type: :boolean + :sysprep_upload_text: + :description: Sysprep Text + :required_method: :validate_sysprep_upload + :required: true + :display: :edit + :data_type: :string + :wins_servers: + :description: WINS Server list + :required: false + :display: :edit + :data_type: :string + :subnet_mask: + :description: Subnet Mask + :required: false + :display: :edit + :data_type: :string + :sysprep_full_name: + :description: Full Name + :required_method: :validate_sysprep_field + :required: true + :display: :edit + :data_type: :string + :sysprep_auto_logon_count: + :values: + 1: '1' + 2: '2' + 3: '3' + :description: Auto Logon Count + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :customization_template_id: + :values_from: + :method: :allowed_customization_templates + :auto_select_single: false + :description: Script Name + :required: false + :display: :edit + :data_type: :integer + :root_password: + :description: Root Password + :required: false + :display: :edit + :data_type: :string + :hostname: + :description: Host Name + :required: false + :display: :edit + :data_type: :string + :customization_template_script: + :description: Script Text + :required: false + :display: :edit + :data_type: :string + :display: :show + :environment: + :description: Environment + :fields: + :placement_cluster_name: + :values_from: + :method: :allowed_clusters + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :cluster_filter: + :values_from: + :options: + :category: :EmsCluster + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :host_filter: + :values_from: + :options: + :category: :Host + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :ds_filter: + :values_from: + :options: + :category: :Storage + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :placement_storage_profile: + :values_from: + :method: :allowed_storage_profiles + :auto_select_single: false + :description: Storage Profile + :required: false + :display: :edit + :data_type: :integer + :placement_host_name: + :values_from: + :method: :allowed_hosts + :auto_select_single: false + :description: Name + :validation_method: :validate_placement_host_name + :required: false + :display: :edit + :data_type: :integer + :required_description: Host Name + :placement_ds_name: + :values_from: + :method: :allowed_storages + :auto_select_single: false + :description: Name + :required_method: :validate_placement + :required: true + :display: :edit + :data_type: :integer + :required_description: Datastore Name + :rp_filter: + :values_from: + :options: + :category: :ResourcePool + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :placement_auto: + :values: + false: 0 + true: 1 + :description: Choose Automatically + :required: false + :display: :edit + :default: false + :data_type: :boolean + :placement_folder_name: + :values_from: + :method: :allowed_folders + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :placement_rp_name: + :values_from: + :method: :allowed_respools + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :placement_dc_name: + :values_from: + :method: :allowed_datacenters + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :display: :show + :service: + :description: Catalog + :fields: + :number_of_vms: + :values_from: + :options: + :max: 50 + :method: :allowed_number_of_vms + :description: Count + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :vm_description: + :description: VM Description + :required: false + :display: :edit + :data_type: :string + :min_length: + :max_length: 100 + :vm_prefix: + :description: VM Name Prefix/Suffix + :required_method: :validate_vm_name + :required: false + :display: :hide + :data_type: :string + :src_vm_id: + :values_from: + :options: + :tag_filters: [] + :method: :allowed_templates + :description: Name + :required: true + :notes: + :display: :edit + :data_type: :integer + :notes_display: :show + :vm_name: + :description: VM Name + :required_method: :validate_vm_name + :required: true + :notes: + :display: :edit + :data_type: :string + :notes_display: :show + :min_length: + :max_length: + :pxe_image_id: + :values_from: + :method: :allowed_images + :auto_select_single: false + :description: Image + :required: true + :required_method: :validate_pxe_image_id + :display: :edit + :data_type: :string + :pxe_server_id: + :values_from: + :method: :allowed_pxe_servers + :auto_select_single: false + :description: Server + :required: true + :required_method: :validate_pxe_server_id + :display: :edit + :data_type: :integer + :host_name: + :description: Host Name + :required: false + :display: :hide + :data_type: :string + :provision_type: + :values_from: + :method: :allowed_provision_types + :description: Provision Type + :required: true + :display: :edit + :default: vmware + :data_type: :string + :linked_clone: + :values: + false: 0 + true: 1 + :description: Linked Clone + :required: false + :display: :edit + :default: false + :data_type: :boolean + :notes: VM requires a snapshot + :notes_display: :show + :snapshot: + :values_from: + :method: :allowed_snapshots + :description: Snapshot + :required: false + :display: :edit + :data_type: :string + :auto_select_single: false + :vm_filter: + :values_from: + :options: + :category: :Vm + :method: :allowed_filters + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :display: :show + :schedule: + :description: Schedule + :fields: + :schedule_type: + :values: + schedule: Schedule + immediately: Immediately on Approval + :description: When to Provision + :required: false + :display: :edit + :default: immediately + :data_type: :string + :vm_auto_start: + :values: + false: 0 + true: 1 + :description: Power on virtual machines after creation + :required: false + :display: :edit + :default: true + :data_type: :boolean + :schedule_time: + :values_from: + :options: + :offset: 1.day + :method: :default_schedule_time + :description: Provision on + :required: false + :display: :edit + :data_type: :time + :retirement: + :values: + 0: Indefinite + 1.month: 1 Month + 3.months: 3 Months + 6.months: 6 Months + :description: Time until Retirement + :required: false + :display: :edit + :default: 0 + :data_type: :integer + :retirement_warn: + :values_from: + :options: + :values: + 1.week: 1 Week + 2.weeks: 2 Weeks + 30.days: 30 Days + :include_equals: false + :field: :retirement + :method: :values_less_then + :description: Retirement Warning + :required: true + :display: :edit + :default: 1.week + :data_type: :integer + :display: :show + :network: + :description: Network + :fields: + :vlan: + :values_from: + :options: + :dvs: true + :vlans: true + :method: :allowed_vlans + :description: Virtual Network + :required: true + :display: :edit + :data_type: :string + :mac_address: + :description: MAC Address + :required: false + :display: :hide + :data_type: :string + :display: :show + :hardware: + :description: Hardware + :fields: + :disk_format: + :values: + thick: Thick + thin: Thin + unchanged: Default + :description: Disk Format + :required: false + :display: :edit + :default: unchanged + :data_type: :string + :cpu_limit: + :description: CPU (MHz) + :required: false + :notes: "(-1 = Unlimited)" + :display: :edit + :data_type: :integer + :notes_display: :show + :memory_limit: + :description: Memory (MB) + :required: false + :notes: "(-1 = Unlimited)" + :display: :edit + :data_type: :integer + :notes_display: :show + :number_of_sockets: + :values: + 1: '1' + 2: '2' + 4: '4' + 8: '8' + :description: Number of Sockets + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :cores_per_socket: + :values: + 1: '1' + 2: '2' + 4: '4' + 8: '8' + :description: Cores per Socket + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :cpu_reserve: + :description: CPU (MHz) + :required: false + :display: :edit + :data_type: :integer + :vm_memory: + :values: + '1024': '1024' + '2048': '2048' + '4096': '4096' + '8192': '8192' + '12288': '12288' + '16384': '16384' + '32768': '32768' + :description: Memory (MB) + :required: false + :display: :edit + :default: '1024' + :data_type: :string + :memory_reserve: + :description: Memory (MB) + :required: false + :display: :edit + :data_type: :integer + :validation_method: :validate_memory_reservation + :network_adapters: + :values: + 1: '1' + 2: '2' + 3: '3' + 4: '4' + :description: Network Adapters + :required: false + :display: :hide + :default: 1 + :data_type: :integer + :display: :show + :dialog_order: + - :requester + - :purpose + - :service + - :environment + - :hardware + - :network + - :customize + - :schedule +:default: false diff --git a/spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test_miq_provision_dialogs_template_modified.yml b/spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test_miq_provision_dialogs_template_modified.yml new file mode 100644 index 000000000000..e1f952d818f6 --- /dev/null +++ b/spec/lib/task_helpers/imports/data/provision_dialogs/MiqProvisionWorkflow-test_miq_provision_dialogs_template_modified.yml @@ -0,0 +1,769 @@ +--- +:name: test_miq_provision_dialogs_template +:description: Test Sample VM Provisioning Dialog (Template) +:dialog_type: MiqProvisionWorkflow +:content: + :buttons: + - :submit + - :cancel + :dialogs: + :requester: + :description: Request + :fields: + :owner_phone: + :description: Phone + :required: false + :display: :hide + :data_type: :string + :owner_country: + :description: Country/Region + :required: false + :display: :hide + :data_type: :string + :owner_phone_mobile: + :description: Mobile + :required: false + :display: :hide + :data_type: :string + :owner_title: + :description: Title + :required: false + :display: :hide + :data_type: :string + :owner_first_name: + :description: First Name + :required: false + :display: :edit + :data_type: :string + :owner_manager: + :description: Name + :required: false + :display: :edit + :data_type: :string + :owner_address: + :description: Address + :required: false + :display: :hide + :data_type: :string + :owner_company: + :description: Company + :required: false + :display: :hide + :data_type: :string + :owner_last_name: + :description: Last Name + :required: false + :display: :edit + :data_type: :string + :owner_manager_mail: + :description: E-Mail + :required: false + :display: :hide + :data_type: :string + :owner_city: + :description: City + :required: false + :display: :hide + :data_type: :string + :owner_department: + :description: Department + :required: false + :display: :hide + :data_type: :string + :owner_load_ldap: + :pressed: + :method: :retrieve_ldap + :description: Look Up LDAP Email + :required: false + :display: :show + :data_type: :button + :owner_manager_phone: + :description: Phone + :required: false + :display: :hide + :data_type: :string + :owner_state: + :description: State + :required: false + :display: :hide + :data_type: :string + :owner_office: + :description: Office + :required: false + :display: :hide + :data_type: :string + :owner_zip: + :description: Zip code + :required: false + :display: :hide + :data_type: :string + :owner_email: + :description: E-Mail + :required_method: :validate_regex + :required_regex: !ruby/regexp /\A[\w!#$\%&'*+\/=?`\{|\}~^-]+(?:\.[\w!#$\%&'*+\/=?`\{|\}~^-]+)*@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\Z/i + :required: true + :display: :edit + :data_type: :string + :request_notes: + :description: Notes + :required: false + :display: :edit + :data_type: :string + :display: :show + :field_order: + :purpose: + :description: Purpose + :fields: + :vm_tags: + :required_method: :validate_tags + :description: Tags + :required: false + :options: + :include: [] + :order: [] + :single_select: [] + :exclude: [] + :display: :edit + :required_tags: [] + :data_type: :integer + :display: :show + :field_order: + :customize: + :description: Customize + :fields: + :dns_servers: + :description: DNS Server list + :required: false + :display: :edit + :data_type: :string + :sysprep_organization: + :description: Organization + :required_method: :validate_sysprep_field + :required: true + :display: :edit + :data_type: :string + :sysprep_password: + :description: New Administrator Password + :required: false + :display: :edit + :data_type: :string + :sysprep_custom_spec: + :values_from: + :method: :allowed_customization_specs + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :string + :sysprep_server_license_mode: + :values: + perServer: Per server + perSeat: Per seat + :description: Identification + :required: false + :display: :edit + :default: perServer + :data_type: :string + :ldap_ous: + :values_from: + :method: :allowed_ous_tree + :auto_select_single: false + :description: LDAP Group + :required: false + :display: :edit + :data_type: :string + :sysprep_timezone: + :values_from: + :method: :get_timezones + :description: Timezone + :required_method: :validate_sysprep_field + :required: true + :display: :edit + :data_type: :string + :dns_suffixes: + :description: DNS Suffix List + :required: false + :display: :edit + :data_type: :string + :sysprep_product_id: + :description: ProductID + :required_method: :validate_sysprep_field + :required: false + :display: :edit + :data_type: :string + :sysprep_identification: + :values: + domain: Domain + workgroup: Workgroup + :description: Identification + :required: false + :display: :edit + :default: domain + :data_type: :string + :sysprep_per_server_max_connections: + :description: Maximum Connections + :required: false + :display: :edit + :default: '5' + :data_type: :string + :sysprep_computer_name: + :description: Computer Name + :required: false + :display: :edit + :data_type: :string + :sysprep_workgroup_name: + :description: Workgroup Name + :required: false + :display: :edit + :default: WORKGROUP + :data_type: :string + :sysprep_spec_override: + :values: + false: 0 + true: 1 + :description: Override Specification Values + :required: false + :display: :edit + :default: false + :data_type: :boolean + :addr_mode: + :values: + static: Static + dhcp: DHCP + :description: Address Mode + :required: false + :display: :edit + :default: dhcp + :data_type: :string + :linux_host_name: + :description: Computer Name + :required: false + :display: :edit + :data_type: :string + :sysprep_domain_admin: + :description: Domain Admin + :required: false + :display: :edit + :data_type: :string + :sysprep_change_sid: + :values: + false: 0 + true: 1 + :description: Change SID + :required: false + :display: :edit + :default: true + :data_type: :boolean + :sysprep_domain_name: + :values_from: + :options: + :active_proxy: + :platform: + :method: :allowed_domains + :auto_select_single: false + :description: Domain Name + :required: false + :display: :edit + :data_type: :string + :sysprep_upload_file: + :description: Upload + :required: false + :display: :edit + :data_type: :string + :gateway: + :description: Gateway + :required: false + :display: :edit + :data_type: :string + :ip_addr: + :description: IP Address + :required: false + :notes: "(Enter starting IP address)" + :display: :edit + :data_type: :string + :notes_display: :hide + :linux_domain_name: + :description: Domain Name + :required: false + :display: :edit + :data_type: :string + :sysprep_domain_password: + :description: Domain Password + :required: false + :display: :edit + :data_type: :string + :sysprep_auto_logon: + :values: + false: 0 + true: 1 + :description: Auto Logon + :required: false + :display: :edit + :default: true + :data_type: :boolean + :sysprep_enabled: + :values_from: + :method: :allowed_customization + :description: Customize + :required: false + :display: :edit + :default: disabled + :data_type: :string + :sysprep_delete_accounts: + :display_override: :hide + :values: + false: 0 + true: 1 + :description: Delete Accounts + :required: false + :display: :hide + :default: false + :data_type: :boolean + :sysprep_upload_text: + :description: Sysprep Text + :required_method: :validate_sysprep_upload + :required: true + :display: :edit + :data_type: :string + :wins_servers: + :description: WINS Server list + :required: false + :display: :edit + :data_type: :string + :subnet_mask: + :description: Subnet Mask + :required: false + :display: :edit + :data_type: :string + :sysprep_full_name: + :description: Full Name + :required_method: :validate_sysprep_field + :required: true + :display: :edit + :data_type: :string + :sysprep_auto_logon_count: + :values: + 1: '1' + 2: '2' + 3: '3' + :description: Auto Logon Count + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :customization_template_id: + :values_from: + :method: :allowed_customization_templates + :auto_select_single: false + :description: Script Name + :required: false + :display: :edit + :data_type: :integer + :root_password: + :description: Root Password + :required: false + :display: :edit + :data_type: :string + :hostname: + :description: Host Name + :required: false + :display: :edit + :data_type: :string + :customization_template_script: + :description: Script Text + :required: false + :display: :edit + :data_type: :string + :display: :show + :environment: + :description: Environment + :fields: + :placement_cluster_name: + :values_from: + :method: :allowed_clusters + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :cluster_filter: + :values_from: + :options: + :category: :EmsCluster + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :host_filter: + :values_from: + :options: + :category: :Host + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :ds_filter: + :values_from: + :options: + :category: :Storage + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :placement_storage_profile: + :values_from: + :method: :allowed_storage_profiles + :auto_select_single: false + :description: Storage Profile + :required: false + :display: :edit + :data_type: :integer + :placement_host_name: + :values_from: + :method: :allowed_hosts + :auto_select_single: false + :description: Name + :validation_method: :validate_placement_host_name + :required: false + :display: :edit + :data_type: :integer + :required_description: Host Name + :placement_ds_name: + :values_from: + :method: :allowed_storages + :auto_select_single: false + :description: Name + :required_method: :validate_placement + :required: true + :display: :edit + :data_type: :integer + :required_description: Datastore Name + :rp_filter: + :values_from: + :options: + :category: :ResourcePool + :method: :allowed_filters + :auto_select_single: false + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :placement_auto: + :values: + false: 0 + true: 1 + :description: Choose Automatically + :required: false + :display: :edit + :default: false + :data_type: :boolean + :placement_folder_name: + :values_from: + :method: :allowed_folders + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :placement_rp_name: + :values_from: + :method: :allowed_respools + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :placement_dc_name: + :values_from: + :method: :allowed_datacenters + :auto_select_single: false + :description: Name + :required: false + :display: :edit + :data_type: :integer + :display: :show + :service: + :description: Catalog + :fields: + :number_of_vms: + :values_from: + :options: + :max: 50 + :method: :allowed_number_of_vms + :description: Count + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :vm_description: + :description: VM Description + :required: false + :display: :edit + :data_type: :string + :min_length: + :max_length: 100 + :vm_prefix: + :description: VM Name Prefix/Suffix + :required_method: :validate_vm_name + :required: false + :display: :hide + :data_type: :string + :src_vm_id: + :values_from: + :options: + :tag_filters: [] + :method: :allowed_templates + :description: Name + :required: true + :notes: + :display: :edit + :data_type: :integer + :notes_display: :show + :vm_name: + :description: VM Name + :required_method: :validate_vm_name + :required: true + :notes: + :display: :edit + :data_type: :string + :notes_display: :show + :min_length: + :max_length: + :pxe_image_id: + :values_from: + :method: :allowed_images + :auto_select_single: false + :description: Image + :required: true + :required_method: :validate_pxe_image_id + :display: :edit + :data_type: :string + :pxe_server_id: + :values_from: + :method: :allowed_pxe_servers + :auto_select_single: false + :description: Server + :required: true + :required_method: :validate_pxe_server_id + :display: :edit + :data_type: :integer + :host_name: + :description: Host Name + :required: false + :display: :hide + :data_type: :string + :provision_type: + :values_from: + :method: :allowed_provision_types + :description: Provision Type + :required: true + :display: :edit + :default: vmware + :data_type: :string + :linked_clone: + :values: + false: 0 + true: 1 + :description: Linked Clone + :required: false + :display: :edit + :default: false + :data_type: :boolean + :notes: VM requires a snapshot + :notes_display: :show + :snapshot: + :values_from: + :method: :allowed_snapshots + :description: Snapshot + :required: false + :display: :edit + :data_type: :string + :auto_select_single: false + :vm_filter: + :values_from: + :options: + :category: :Vm + :method: :allowed_filters + :description: Filter + :required: false + :display: :edit + :data_type: :integer + :display: :show + :schedule: + :description: Schedule + :fields: + :schedule_type: + :values: + schedule: Schedule + immediately: Immediately on Approval + :description: When to Provision + :required: false + :display: :edit + :default: immediately + :data_type: :string + :vm_auto_start: + :values: + false: 0 + true: 1 + :description: Power on virtual machines after creation + :required: false + :display: :edit + :default: true + :data_type: :boolean + :schedule_time: + :values_from: + :options: + :offset: 1.day + :method: :default_schedule_time + :description: Provision on + :required: false + :display: :edit + :data_type: :time + :retirement: + :values: + 0: Indefinite + 1.month: 1 Month + 3.months: 3 Months + 6.months: 6 Months + :description: Time until Retirement + :required: false + :display: :edit + :default: 0 + :data_type: :integer + :retirement_warn: + :values_from: + :options: + :values: + 1.week: 1 Week + 2.weeks: 2 Weeks + 30.days: 30 Days + :include_equals: false + :field: :retirement + :method: :values_less_then + :description: Retirement Warning + :required: true + :display: :edit + :default: 1.week + :data_type: :integer + :display: :show + :network: + :description: Network + :fields: + :vlan: + :values_from: + :options: + :dvs: true + :vlans: true + :method: :allowed_vlans + :description: Virtual Network + :required: true + :display: :edit + :data_type: :string + :mac_address: + :description: MAC Address + :required: false + :display: :hide + :data_type: :string + :display: :show + :hardware: + :description: Hardware + :fields: + :disk_format: + :values: + thick: Thick + thin: Thin + unchanged: Default + :description: Disk Format + :required: false + :display: :edit + :default: unchanged + :data_type: :string + :cpu_limit: + :description: CPU (MHz) + :required: false + :notes: "(-1 = Unlimited)" + :display: :edit + :data_type: :integer + :notes_display: :show + :memory_limit: + :description: Memory (MB) + :required: false + :notes: "(-1 = Unlimited)" + :display: :edit + :data_type: :integer + :notes_display: :show + :number_of_sockets: + :values: + 1: '1' + 2: '2' + 4: '4' + 8: '8' + 16: '16' + :description: Number of Sockets + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :cores_per_socket: + :values: + 1: '1' + 2: '2' + 4: '4' + 8: '8' + :description: Cores per Socket + :required: false + :display: :edit + :default: 1 + :data_type: :integer + :cpu_reserve: + :description: CPU (MHz) + :required: false + :display: :edit + :data_type: :integer + :vm_memory: + :values: + '2048': '2048' + '4096': '4096' + '8192': '8192' + '12288': '12288' + '16384': '16384' + '32768': '32768' + :description: Memory (MB) + :required: false + :display: :edit + :default: '1024' + :data_type: :string + :memory_reserve: + :description: Memory (MB) + :required: false + :display: :edit + :data_type: :integer + :validation_method: :validate_memory_reservation + :network_adapters: + :values: + 1: '1' + 2: '2' + 3: '3' + 4: '4' + :description: Network Adapters + :required: false + :display: :hide + :default: 1 + :data_type: :integer + :display: :show + :dialog_order: + - :requester + - :purpose + - :service + - :environment + - :hardware + - :network + - :customize + - :schedule +:default: false diff --git a/spec/lib/task_helpers/imports/provision_dialogs_spec.rb b/spec/lib/task_helpers/imports/provision_dialogs_spec.rb new file mode 100644 index 000000000000..92fe0d8841a5 --- /dev/null +++ b/spec/lib/task_helpers/imports/provision_dialogs_spec.rb @@ -0,0 +1,78 @@ +describe TaskHelpers::Imports::ProvisionDialogs do + let(:data_dir) { File.join(File.expand_path(__dir__), 'data', 'provision_dialogs') } + let(:dialog_file) { 'MiqProvisionWorkflow-test_miq_provision_dialogs_template.yaml' } + let(:mod_dialog_file) { 'MiqProvisionWorkflow-test_miq_provision_dialogs_template_modified.yml' } + let(:dialog_one_name) { 'test_miq_provision_dialogs_template' } + let(:dialog_two_name) { 'test2_miq_provision_dialogs_template' } + let(:dialog_one_desc) { 'Test Sample VM Provisioning Dialog (Template)' } + let(:dialog_two_desc) { 'Test2 Sample VM Provisioning Dialog (Template)' } + + describe "#import" do + let(:options) { { :source => source } } + + describe "when the source is a directory" do + let(:source) { data_dir } + + it 'imports all .yaml files in a specified directory' do + expect do + TaskHelpers::Imports::ProvisionDialogs.new.import(options) + end.to_not output.to_stderr + assert_test_provision_dialog_one_present + assert_test_provision_dialog_two_present + end + end + + describe "when the source is a file" do + let(:source) { "#{data_dir}/#{dialog_file}" } + + it 'imports a specified file' do + expect do + TaskHelpers::Imports::ProvisionDialogs.new.import(options) + end.to_not output.to_stderr + assert_test_provision_dialog_one_present + assert_test_provision_dialog_two_not_present + end + end + + describe "when the source file modifies an existing file" do + let(:source) { "#{data_dir}/#{mod_dialog_file}" } + + before do + TaskHelpers::Imports::ProvisionDialogs.new.import(:source => "#{data_dir}/#{dialog_file}") + end + + it 'modifies an existing provisioning dialog' do + expect do + TaskHelpers::Imports::ProvisionDialogs.new.import(options) + end.to_not output.to_stderr + assert_test_provision_dialog_one_modified + end + end + end + + def assert_test_provision_dialog_one_present + d = MiqDialog.find_by(:name => dialog_one_name) + expect(d.description).to eq(dialog_one_desc) + expect(d.valid?).to be true + end + + def assert_test_provision_dialog_two_present + d = MiqDialog.find_by(:name => dialog_two_name) + expect(d.description).to eq(dialog_two_desc) + expect(d.valid?).to be true + expect(d.content[:dialogs][:purpose][:fields][:vm_tags][:required_tags]).to contain_exactly("environment") + end + + def assert_test_provision_dialog_two_not_present + d = MiqDialog.find_by(:name => dialog_two_name) + expect(d).to be nil + end + + def assert_test_provision_dialog_one_modified + d = MiqDialog.find_by(:name => dialog_one_name) + expect(d.content[:dialogs][:hardware][:fields][:number_of_sockets][:values].keys).to contain_exactly(1, 2, 4, 8, 16) + expect(d.content[:dialogs][:hardware][:fields][:number_of_sockets][:values].values).to contain_exactly("1", "2", "4", "8", "16") + expect(d.content[:dialogs][:hardware][:fields][:vm_memory][:values].keys).to contain_exactly("2048", "4096", "8192", "12288", "16384", "32768") + expect(d.content[:dialogs][:hardware][:fields][:vm_memory][:values].values).to contain_exactly("2048", "4096", "8192", "12288", "16384", "32768") + end +end From 4bc36096627f685dad073a90f12fce8f63f4f62b Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Mon, 30 Jul 2018 15:42:54 +0200 Subject: [PATCH 06/11] Use standard method for filesystem cleanup Use standard method for filesystem cleanup, it fetches and memoizes the data, before it deletes the files holding the data. --- lib/ansible/runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/runner.rb b/lib/ansible/runner.rb index 43674395197a..ffb593b8541d 100644 --- a/lib/ansible/runner.rb +++ b/lib/ansible/runner.rb @@ -145,11 +145,11 @@ def run_via_cli(env_vars, extra_vars, playbook_path: nil, role_name: nil, roles_ :roles_path => roles_path, :role_skip_facts => role_skip_facts)) - response(base_dir, ansible_runner_method, result) + res = response(base_dir, ansible_runner_method, result) ensure # Clean up the tmp dir for the sync method, for async we will clean it up after the job is finished and we've # read the output, that will be written into this directory. - FileUtils.remove_entry(base_dir) unless async?(ansible_runner_method) + res.cleanup_filesystem! unless async?(ansible_runner_method) end end From 7aa8fcee03ac45dca0b6cf43ebf59c02400bb0aa Mon Sep 17 00:00:00 2001 From: Brant Evans Date: Mon, 30 Jul 2018 12:28:22 -0700 Subject: [PATCH 07/11] De-dup order statement and use collect! --- lib/task_helpers/exports/provision_dialogs.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/task_helpers/exports/provision_dialogs.rb b/lib/task_helpers/exports/provision_dialogs.rb index 73750ca41c93..6667ab30d5f2 100644 --- a/lib/task_helpers/exports/provision_dialogs.rb +++ b/lib/task_helpers/exports/provision_dialogs.rb @@ -4,9 +4,9 @@ class ProvisionDialogs def export(options = {}) export_dir = options[:directory] - dialogs = options[:all] ? MiqDialog.order(:id).all : MiqDialog.order(:id).where(:default => [false, nil]) + dialogs = options[:all] ? MiqDialog.all : MiqDialog.where(:default => [false, nil]) - dialogs = dialogs.collect do |dialog| + dialogs.order(:id).to_a.collect! do |dialog| Exports.exclude_attributes(dialog.to_model_hash, %i(file_mtime created_at updated_at id class)) end From 7357e42e2e838f293f17d3887d549e0d6b1987d9 Mon Sep 17 00:00:00 2001 From: Brant Evans Date: Mon, 30 Jul 2018 16:11:13 -0700 Subject: [PATCH 08/11] Make spec test clearer --- .../exports/provision_dialogs_spec.rb | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/spec/lib/task_helpers/exports/provision_dialogs_spec.rb b/spec/lib/task_helpers/exports/provision_dialogs_spec.rb index 39fb4f75dc9b..d27559e20315 100644 --- a/spec/lib/task_helpers/exports/provision_dialogs_spec.rb +++ b/spec/lib/task_helpers/exports/provision_dialogs_spec.rb @@ -81,23 +81,6 @@ expect(dialog[:content]).to eq(content) expect(dialog[:description]).to eq(dialog_desc2) end - - it 'exports dialogs with the same name to different files' do - FactoryGirl.create(:miq_dialog, - :dialog_type => dialog_type3, - :name => dialog_name2, - :description => dialog_desc2, - :content => content2, - :default => false) - TaskHelpers::Exports::ProvisionDialogs.new.export(:directory => export_dir) - expect(Dir[File.join(export_dir, '**', '*')].count { |file| File.file?(file) }).to eq(2) - dialog = YAML.load_file(dialog_filename1) - expect(dialog[:content]).to eq(content) - expect(dialog[:description]).to eq(dialog_desc2) - dialog2 = YAML.load_file(dialog_filename2) - expect(dialog2[:content]).to eq(content2) - expect(dialog2[:description]).to eq(dialog_desc2) - end end describe "when --all is specified" do @@ -115,4 +98,29 @@ expect(dialog2[:description]).to eq(dialog_desc2) end end + + describe "when multiple dialogs of different types have the same name" do + let(:dialog_filename1) { "#{export_dir}/#{dialog_type1}-custom_dialog.yaml" } + let(:dialog_filename2) { "#{export_dir}/#{dialog_type3}-custom_dialog.yaml" } + + before do + FactoryGirl.create(:miq_dialog, + :dialog_type => dialog_type3, + :name => dialog_name2, + :description => dialog_desc2, + :content => content2, + :default => false) + end + + it 'exports the dialogs to different files' do + TaskHelpers::Exports::ProvisionDialogs.new.export(:directory => export_dir) + expect(Dir[File.join(export_dir, '**', '*')].count { |file| File.file?(file) }).to eq(2) + dialog = YAML.load_file(dialog_filename1) + expect(dialog[:content]).to eq(content) + expect(dialog[:description]).to eq(dialog_desc2) + dialog2 = YAML.load_file(dialog_filename2) + expect(dialog2[:content]).to eq(content2) + expect(dialog2[:description]).to eq(dialog_desc2) + end + end end From 7de8cf2aed5acdd5686db21af35520509b47b8d7 Mon Sep 17 00:00:00 2001 From: Hilda Stastna Date: Tue, 31 Jul 2018 17:40:55 +0200 Subject: [PATCH 09/11] Fix Remove Selected Items from Inventory button for Images, Instances Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1601955 Fix the button by adding support for destroy to VmOrTemplate model. --- app/models/mixins/supports_feature_mixin.rb | 1 + app/models/vm_or_template.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/models/mixins/supports_feature_mixin.rb b/app/models/mixins/supports_feature_mixin.rb index 5202c49b2820..540cad1d8868 100644 --- a/app/models/mixins/supports_feature_mixin.rb +++ b/app/models/mixins/supports_feature_mixin.rb @@ -79,6 +79,7 @@ module SupportsFeatureMixin :external_logging => 'Launch External Logging UI', :swift_service => 'Swift storage service', :delete => 'Deletion', + :destroy => 'Destroy', :delete_aggregate => 'Host Aggregate Deletion', :delete_floating_ip => 'Floating IP Deletion', :delete_security_group => 'Security Group Deletion', diff --git a/app/models/vm_or_template.rb b/app/models/vm_or_template.rb index d73d9fa783bc..28f35ac7f531 100644 --- a/app/models/vm_or_template.rb +++ b/app/models/vm_or_template.rb @@ -1725,6 +1725,7 @@ def self.includes_template?(ids) end supports_not :snapshots + supports :destroy # Stop showing Reconfigure VM task unless the subclass allows def reconfigurable? From 0c82f4918c26a319ac571bbb884fc776c79d3d20 Mon Sep 17 00:00:00 2001 From: Alexander Zagaynov Date: Fri, 13 Jul 2018 16:49:59 +0200 Subject: [PATCH 10/11] put S3 refresh in a separate worker --- lib/workers/miq_worker_types.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/workers/miq_worker_types.rb b/lib/workers/miq_worker_types.rb index 0fda3b304caf..62ae7f9c6984 100644 --- a/lib/workers/miq_worker_types.rb +++ b/lib/workers/miq_worker_types.rb @@ -6,6 +6,7 @@ "ManageIQ::Providers::Amazon::CloudManager::EventCatcher" => %i(manageiq_default), "ManageIQ::Providers::Amazon::CloudManager::MetricsCollectorWorker" => %i(manageiq_default), "ManageIQ::Providers::Amazon::CloudManager::RefreshWorker" => %i(manageiq_default), + "ManageIQ::Providers::Amazon::StorageManager::S3::RefreshWorker" => %i(manageiq_default), "ManageIQ::Providers::AnsibleTower::AutomationManager::EventCatcher" => %i(manageiq_default), "ManageIQ::Providers::AnsibleTower::AutomationManager::RefreshWorker" => %i(manageiq_default), "ManageIQ::Providers::Azure::CloudManager::EventCatcher" => %i(manageiq_default), From 264e4c0bd6f2c3367f8c78dfc5df793f666a2c24 Mon Sep 17 00:00:00 2001 From: James Wong Date: Tue, 31 Jul 2018 18:29:25 -0400 Subject: [PATCH 11/11] Graph refresh of configuration_scripts and configuration_workflows in one InventoryCollection --- .../providers/embedded_ansible/automation_manager.rb | 2 -- .../inventory_collection/builder/automation_manager.rb | 5 ----- spec/factories/ext_management_system.rb | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/models/manageiq/providers/embedded_ansible/automation_manager.rb b/app/models/manageiq/providers/embedded_ansible/automation_manager.rb index 29a14c008f67..1df1245bf13f 100644 --- a/app/models/manageiq/providers/embedded_ansible/automation_manager.rb +++ b/app/models/manageiq/providers/embedded_ansible/automation_manager.rb @@ -26,8 +26,6 @@ class ManageIQ::Providers::EmbeddedAnsible::AutomationManager < ManageIQ::Provid require_nested :Refresher require_nested :RefreshWorker - has_many :configuration_workflows, :dependent => :destroy, :foreign_key => "manager_id", :inverse_of => :manager - def self.ems_type @ems_type ||= "embedded_ansible_automation".freeze end diff --git a/app/models/manager_refresh/inventory_collection/builder/automation_manager.rb b/app/models/manager_refresh/inventory_collection/builder/automation_manager.rb index 90091061aa85..2de9a401530f 100644 --- a/app/models/manager_refresh/inventory_collection/builder/automation_manager.rb +++ b/app/models/manager_refresh/inventory_collection/builder/automation_manager.rb @@ -19,11 +19,6 @@ def configuration_script_sources add_common_default_values end - def configuration_workflows - default_manager_ref - add_common_default_values - end - def configured_systems default_manager_ref add_common_default_values diff --git a/spec/factories/ext_management_system.rb b/spec/factories/ext_management_system.rb index 6d8e8e7b9388..d021da928ef5 100644 --- a/spec/factories/ext_management_system.rb +++ b/spec/factories/ext_management_system.rb @@ -347,7 +347,7 @@ trait(:configuration_workflow) do after(:create) do |x| type = (x.type.split("::")[0..2] + %w(AutomationManager ConfigurationWorkflow)).join("::") - x.configuration_workflows << FactoryGirl.create(:configuration_workflow, :type => type) + x.configuration_scripts << FactoryGirl.create(:configuration_workflow, :type => type) end end