From 963116ba8d0c0a04e109481e18106c9e20238d89 Mon Sep 17 00:00:00 2001 From: Greg McCullough Date: Tue, 29 May 2018 11:16:31 -0400 Subject: [PATCH] Remove references to host provisioning --- .../miq_ae_engine/miq_ae_builtin_method.rb | 6 -- .../engine/miq_ae_engine/miq_ae_object.rb | 2 - .../miq_ae_service_miq_host_provision.rb | 16 ----- ...q_ae_service_miq_host_provision_request.rb | 9 --- spec/miq_ae_engine_spec.rb | 10 +-- ...service_miq_host_provision_request_spec.rb | 70 ------------------- .../miq_ae_service_miq_host_provision_spec.rb | 67 ------------------ 7 files changed, 5 insertions(+), 175 deletions(-) delete mode 100644 lib/miq_automation_engine/service_models/miq_ae_service_miq_host_provision.rb delete mode 100644 lib/miq_automation_engine/service_models/miq_ae_service_miq_host_provision_request.rb delete mode 100644 spec/service_models/miq_ae_service_miq_host_provision_request_spec.rb delete mode 100644 spec/service_models/miq_ae_service_miq_host_provision_spec.rb diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb index 459885945..6c38c06e1 100644 --- a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb +++ b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb @@ -6,7 +6,6 @@ class MiqAeBuiltinMethod orchestration_stack miq_request miq_provision - miq_host_provision vm_migrate_task vm_retire_task service_retire_task @@ -68,7 +67,6 @@ def self.miq_parse_automation_request(obj, _inputs) when 'vm_retire' then %w(VM Lifecycle Retirement) when 'vm_migrate' then %w(VM Lifecycle Migrate) when 'service_retire' then %w(Service Lifecycle Retirement) - when 'host_provision' then %w(Host Lifecycle Provisioning) when 'configured_system_provision' obj.workspace.root['ae_provider_category'] = 'infrastructure' %w(Configured_System Lifecycle Provisioning) @@ -181,8 +179,6 @@ def self.detect_category(obj_name, prov_obj) case obj_name when "orchestration_stack" CLOUD - when "miq_host_provision" - INFRASTRUCTURE when "miq_request", "miq_provision", "vm_migrate_task", "vm_retire_task" vm_detect_category(prov_obj.source) if prov_obj when "service_retire_task" @@ -221,8 +217,6 @@ def self.detect_vendor(src_obj, attr) case attr when "orchestration_stack" src_obj.ext_management_system.try(:provider_name) - when "miq_host_provision" - "vmware" when "miq_request", "miq_provision", "vm_migrate_task" src_obj.source.try(:provider_name) when "vm" diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb index f66f4cf20..6e5a243b0 100644 --- a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb +++ b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb @@ -31,8 +31,6 @@ class MiqAeObject # Default conversion for Service Models SM_LOOKUP = Hash.new { |_, k| k.classify }.merge( 'ems' => 'ExtManagementSystem', - 'host_provision' => 'MiqHostProvision', - 'host_provision_request' => 'MiqHostProvisionRequest', 'policy' => 'MiqPolicy', 'provision' => 'MiqProvision', 'provision_request' => 'MiqProvisionRequest', diff --git a/lib/miq_automation_engine/service_models/miq_ae_service_miq_host_provision.rb b/lib/miq_automation_engine/service_models/miq_ae_service_miq_host_provision.rb deleted file mode 100644 index 65b4832fc..000000000 --- a/lib/miq_automation_engine/service_models/miq_ae_service_miq_host_provision.rb +++ /dev/null @@ -1,16 +0,0 @@ -module MiqAeMethodService - class MiqAeServiceMiqHostProvision < MiqAeServiceMiqRequestTask - expose :miq_host_provision_request, :association => true - expose :host, :association => true - - def statemachine_task_status - ar_method do - if ['finished', 'provisioned'].include?(@object.state) - @object.host_rediscovered? ? 'ok' : 'error' - else - 'retry' - end - end - end - end -end diff --git a/lib/miq_automation_engine/service_models/miq_ae_service_miq_host_provision_request.rb b/lib/miq_automation_engine/service_models/miq_ae_service_miq_host_provision_request.rb deleted file mode 100644 index fbcb0f55b..000000000 --- a/lib/miq_automation_engine/service_models/miq_ae_service_miq_host_provision_request.rb +++ /dev/null @@ -1,9 +0,0 @@ -module MiqAeMethodService - class MiqAeServiceMiqHostProvisionRequest < MiqAeServiceMiqRequest - expose :miq_host_provisions, :association => true - - def ci_type - 'host' - end - end -end diff --git a/spec/miq_ae_engine_spec.rb b/spec/miq_ae_engine_spec.rb index 051e1673d..257ab3ade 100644 --- a/spec/miq_ae_engine_spec.rb +++ b/spec/miq_ae_engine_spec.rb @@ -314,9 +314,9 @@ def call_automate(obj_type, obj_id) expect(MiqAeEngine.create_automation_attribute_key(host)).to eq("Host::host") end - it "with a MiqRequest" do - host = FactoryGirl.create(:miq_host_provision_request) - expect(MiqAeEngine.create_automation_attribute_key(host)).to eq("MiqHostProvisionRequest::miq_host_provision_request") + it "with a MiqRequest" do + prov_request = FactoryGirl.create(:miq_provision_request) + expect(MiqAeEngine.create_automation_attribute_key(prov_request)).to eq("MiqProvisionRequest::miq_provision_request") end it "with an EmsCluster" do @@ -345,8 +345,8 @@ def call_automate(obj_type, obj_id) end it "with an MiqRequest" do - host = FactoryGirl.create(:miq_host_provision_request) - expect(MiqAeEngine.create_automation_attribute_class_name(host)).to eq("MiqHostProvisionRequest") + host = FactoryGirl.create(:miq_provision_request) + expect(MiqAeEngine.create_automation_attribute_class_name(host)).to eq("MiqProvisionRequest") end end diff --git a/spec/service_models/miq_ae_service_miq_host_provision_request_spec.rb b/spec/service_models/miq_ae_service_miq_host_provision_request_spec.rb deleted file mode 100644 index d74aaed19..000000000 --- a/spec/service_models/miq_ae_service_miq_host_provision_request_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -module MiqAeServiceMiqHostProvisionRequestSpec - include MiqAeEngine - describe MiqAeMethodService::MiqAeServiceMiqHostProvisionRequest do - def assert_ae_host_provision_matches_ar_host_provision(ae_object, ar_object) - expect(ae_object).to be_kind_of(MiqAeMethodService::MiqAeServiceMiqHostProvision) - [:id, :provision_type, :state, :options].each { |method| expect(ae_object.send(method)).to eq(ar_object.send(method)) } - end - - before(:each) do - Spec::Support::MiqAutomateHelper.create_service_model_method('SPEC_DOMAIN', 'EVM', 'AUTOMATE', 'test1', 'test') - @ae_method = ::MiqAeMethod.first - @ae_result_key = 'foo' - - @user = FactoryGirl.create(:user_with_group) - @miq_host_provision_request = FactoryGirl.create(:miq_host_provision_request, :provision_type => 'host_pxe_install', :state => 'pending', :status => 'Ok', :requester => @user) - end - - def invoke_ae - MiqAeEngine.instantiate("/EVM/AUTOMATE/test1?MiqHostProvisionRequest::miq_host_provision_request=#{@miq_host_provision_request.id}", @user) - end - - it "#miq_request" do - @miq_host_provision_request.save! - - method = "$evm.root['#{@ae_result_key}'] = $evm.root['miq_host_provision_request'].miq_request" - @ae_method.update_attributes(:data => method) - ae_object = invoke_ae.root(@ae_result_key) - expect(ae_object).to be_kind_of(MiqAeMethodService::MiqAeServiceMiqRequest) - expect(ae_object.id).to eq(@miq_host_provision_request.id) - end - - it "#miq_host_provisions" do - method = "$evm.root['#{@ae_result_key}'] = $evm.root['miq_host_provision_request'].miq_host_provisions" - @ae_method.update_attributes(:data => method) - ae_object = invoke_ae.root(@ae_result_key) - expect(ae_object).to eq([]) - - miq_host_provision1 = FactoryGirl.create(:miq_host_provision, :provision_type => 'host_pxe_install', :state => 'pending', :status => 'Ok') - miq_host_provision2 = FactoryGirl.create(:miq_host_provision, :provision_type => 'host_pxe_install', :state => 'pending', :status => 'Ok') - - @miq_host_provision_request.miq_host_provisions = [miq_host_provision1] - @miq_host_provision_request.save! - ae_object = invoke_ae.root(@ae_result_key) - expect(ae_object).to be_kind_of(Array) - expect(ae_object.length).to eq(1) - assert_ae_host_provision_matches_ar_host_provision(ae_object.first, miq_host_provision1) - - @miq_host_provision_request.miq_host_provisions = [miq_host_provision1, miq_host_provision2] - @miq_host_provision_request.save! - ae_object = invoke_ae.root(@ae_result_key) - expect(ae_object).to be_kind_of(Array) - expect(ae_object.length).to eq(2) - ae_object.each do |miq_ae_host_provision| - expect([miq_host_provision1.id, miq_host_provision2.id]).to include(miq_ae_host_provision.id) - ar_object = - case miq_ae_host_provision.id - when miq_host_provision1.id then miq_host_provision1 - when miq_host_provision2.id then miq_host_provision2 - end - assert_ae_host_provision_matches_ar_host_provision(miq_ae_host_provision, ar_object) - end - end - - it "#ci_type" do - method = "$evm.root['#{@ae_result_key}'] = $evm.root['miq_host_provision_request'].ci_type" - @ae_method.update_attributes(:data => method) - expect(invoke_ae.root(@ae_result_key)).to eq('host') - end - end -end diff --git a/spec/service_models/miq_ae_service_miq_host_provision_spec.rb b/spec/service_models/miq_ae_service_miq_host_provision_spec.rb deleted file mode 100644 index 28cc82b81..000000000 --- a/spec/service_models/miq_ae_service_miq_host_provision_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -module MiqAeServiceMiqHostProvisionSpec - describe MiqAeMethodService::MiqAeServiceMiqHostProvision do - before(:each) do - @user = FactoryGirl.create(:user_with_group) - Spec::Support::MiqAutomateHelper.create_service_model_method('SPEC_DOMAIN', 'EVM', 'AUTOMATE', 'test1', 'test') - @ae_method = ::MiqAeMethod.first - @ae_result_key = 'foo' - - @miq_host_provision = FactoryGirl.create(:miq_host_provision, :provision_type => 'host_pxe_install', :state => 'pending', :status => 'Ok') - end - - def invoke_ae - MiqAeEngine.instantiate("/EVM/AUTOMATE/test1?MiqHostProvision::miq_host_provision=#{@miq_host_provision.id}", @user) - end - - it "#miq_host_provision_request" do - miq_host_provision_request = FactoryGirl.create(:miq_host_provision_request, :provision_type => 'host_pxe_install', :state => 'pending', :status => 'Ok', :requester => @user) - @miq_host_provision.miq_host_provision_request = miq_host_provision_request - @miq_host_provision.save! - - method = "$evm.root['#{@ae_result_key}'] = $evm.root['miq_host_provision'].miq_host_provision_request" - @ae_method.update_attributes!(:data => method) - ae_object = invoke_ae.root(@ae_result_key) - expect(ae_object).to be_kind_of(MiqAeMethodService::MiqAeServiceMiqHostProvisionRequest) - [:id, :provision_type, :state, :userid].each { |method| expect(ae_object.send(method)).to eq(miq_host_provision_request.send(method)) } - end - - it "#host" do - host = FactoryGirl.create(:host) - @miq_host_provision.host = host - @miq_host_provision.save! - method = "$evm.root['#{@ae_result_key}'] = $evm.root['miq_host_provision'].host" - @ae_method.update_attributes!(:data => method) - ae_object = invoke_ae.root(@ae_result_key) - expect(ae_object).to be_kind_of(MiqAeMethodService::MiqAeServiceHost) - [:id].each { |method| expect(ae_object.send(method)).to eq(host.send(method)) } - end - - context "#status" do - before(:each) do - method = "$evm.root['#{@ae_result_key}'] = $evm.root['miq_host_provision'].status" - @ae_method.update_attributes!(:data => method, :display_name => 'RSpec') - end - - it "#status should return 'retry' unless state is finished or provisioned" do - @miq_host_provision.update_attributes(:state => 'queued') - expect(invoke_ae.root(@ae_result_key)).to eq('retry') - end - - it "#status should return 'ok' when state is finished or provisioned and host has been rediscovered" do - allow_any_instance_of(MiqHostProvision).to receive(:host_rediscovered?).and_return(true) - ['finished', 'provisioned'].each do |state| - @miq_host_provision.update_attributes(:state => state) - expect(invoke_ae.root(@ae_result_key)).to eq('ok') - end - end - - it "#status should return 'error' when state is finished or provisioned and host has not been rediscovered" do - allow_any_instance_of(MiqHostProvision).to receive(:host_rediscovered?).and_return(false) - ['finished', 'provisioned'].each do |state| - @miq_host_provision.update_attributes(:state => state) - expect(invoke_ae.root(@ae_result_key)).to eq('error') - end - end - end - end -end