From 4155045082c9e2112e0b1fb9b9deab6f7b6be48a Mon Sep 17 00:00:00 2001 From: Daniel Berger Date: Thu, 31 May 2018 15:49:23 -0400 Subject: [PATCH] Sysprep is not supported by default, modify allowed_customization templates to check for support first. --- .../providers/cloud_manager/provision_workflow.rb | 11 +++++++++-- .../cloud_manager/provision_workflow_spec.rb | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/models/manageiq/providers/cloud_manager/provision_workflow.rb b/app/models/manageiq/providers/cloud_manager/provision_workflow.rb index e43b2e7adea..8c8a45e7036 100644 --- a/app/models/manageiq/providers/cloud_manager/provision_workflow.rb +++ b/app/models/manageiq/providers/cloud_manager/provision_workflow.rb @@ -60,12 +60,16 @@ def display_name_for_name_description(ci) ci.description.blank? ? ci.name : "#{ci.name}: #{ci.description}" end + # Override in provider subclass as needed. + # def supports_cloud_init? true end + # Override in provider subclass as needed. + # def supports_sysprep? - true + false end def set_or_default_hardware_field_values(_vm) @@ -81,7 +85,10 @@ def show_customize_fields(fields, _platform) end def allowed_customization_templates(options = {}) - allowed_cloud_init_customization_templates(options).concat(allowed_sysprep_customization_templates(options)) + allowed = [] + allowed.concat(allowed_cloud_init_customization_templates(options)) if supports_cloud_init? + allowed.concat(allowed_sysprep_customization_templates(options)) if supports_sysprep? + allowed end private diff --git a/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb b/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb index e2eb0b9da79..57fb7d70d6c 100644 --- a/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb +++ b/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb @@ -47,6 +47,7 @@ it "should retrieve sysprep templates when cloning" do options = {'key' => 'value' } allow(sysprep_workflow).to receive(:supports_native_clone?).and_return(true) + allow(sysprep_workflow).to receive(:supports_sysprep?).and_return(true) allow(sysprep_workflow).to receive(:load_ar_obj).and_return(template) allow(template).to receive(:platform).and_return('windows') @@ -229,7 +230,7 @@ context "#supports_sysprep?" do it "returns the expected boolean value" do - expect(workflow.supports_sysprep?).to eql(true) + expect(workflow.supports_sysprep?).to eql(false) end end end