From 11370175f8178ac4fa58bba72cb243d217ee7444 Mon Sep 17 00:00:00 2001 From: Tina Fitzgerald Date: Wed, 31 Jan 2018 16:37:54 -0500 Subject: [PATCH] Use new cloud_tenant helper method for tenant_name in connection_options. --- .../manageiq/providers/openstack/cloud_manager/provision.rb | 1 + .../providers/openstack/cloud_manager/provision/cloning.rb | 4 ++-- .../openstack/cloud_manager/provision/options_helper.rb | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 app/models/manageiq/providers/openstack/cloud_manager/provision/options_helper.rb diff --git a/app/models/manageiq/providers/openstack/cloud_manager/provision.rb b/app/models/manageiq/providers/openstack/cloud_manager/provision.rb index cdb7b92bd..54837e572 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/provision.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/provision.rb @@ -2,4 +2,5 @@ class ManageIQ::Providers::Openstack::CloudManager::Provision < ::MiqProvisionCl include_concern 'Cloning' include_concern 'Configuration' include_concern 'VolumeAttachment' + include_concern 'OptionsHelper' end diff --git a/app/models/manageiq/providers/openstack/cloud_manager/provision/cloning.rb b/app/models/manageiq/providers/openstack/cloud_manager/provision/cloning.rb index a5b8b4411..205add79c 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/provision/cloning.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/provision/cloning.rb @@ -9,7 +9,7 @@ def find_destination_in_vmdb(ems_ref) end def do_clone_task_check(clone_task_ref) - connection_options = {:tenant_name => options[:cloud_tenant][1]} if options[:cloud_tenant].kind_of?(Array) + connection_options = {:tenant_name => cloud_tenant.name} source.with_provider_connection(connection_options) do |openstack| instance = if connection_options openstack.servers.get(clone_task_ref) @@ -55,7 +55,7 @@ def log_clone_options(clone_options) end def start_clone(clone_options) - connection_options = {:tenant_name => options[:cloud_tenant][1]} if options[:cloud_tenant].kind_of?(Array) + connection_options = {:tenant_name => cloud_tenant.name} if source.kind_of?(ManageIQ::Providers::Openstack::CloudManager::VolumeTemplate) # remove the image_ref parameter from the options since it actually refers # to a volume, and then overwrite the default root volume with the volume diff --git a/app/models/manageiq/providers/openstack/cloud_manager/provision/options_helper.rb b/app/models/manageiq/providers/openstack/cloud_manager/provision/options_helper.rb new file mode 100644 index 000000000..03479acfb --- /dev/null +++ b/app/models/manageiq/providers/openstack/cloud_manager/provision/options_helper.rb @@ -0,0 +1,5 @@ +module ManageIQ::Providers::Openstack::CloudManager::Provision::OptionsHelper + def cloud_tenant + @cloud_tenant ||= CloudTenant.find_by(:id => get_option(:cloud_tenant)) + end +end