Skip to content

Commit

Permalink
Merge pull request #18229 from borod108/rfe/add_ca_ansible
Browse files Browse the repository at this point in the history
Pass CA when upgrading cluster through Ansible
  • Loading branch information
agrare authored Nov 22, 2018
2 parents 3129ad7 + 2ce4d1f commit 0598dc1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 4 additions & 3 deletions app/models/ems_cluster/cluster_upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module EmsCluster::ClusterUpgrade

def upgrade_cluster(options = {})
role_options = {:role_name => "oVirt.cluster-upgrade"}
job = ManageIQ::Providers::AnsibleRoleWorkflow.create_job({}, extra_vars_for_upgrade(options), role_options)
job = ManageIQ::Providers::Redhat::AnsibleRoleWorkflow.create_job({}, extra_vars_for_upgrade(options), role_options)
job.signal(:start)
job.miq_task
end
Expand All @@ -32,7 +32,8 @@ def extra_vars_for_upgrade(options = {})
:engine_user => connect_options[:username],
:engine_password => connect_options[:password],
:cluster_name => name,
:hostname => "localhost"
}
:hostname => "localhost",
:ca_string => connect_options[:ca_certs]
}.compact
end
end
12 changes: 12 additions & 0 deletions spec/factories/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@
end
end

trait :skip_validate do
to_create { |instance| instance.save(:validate => false) }
end

factory :ems_redhat_with_authentication_with_ca,
:parent => :ems_redhat do
certificate_authority "cert108"
after(:create) do |x|
x.authentications << FactoryGirl.create(:authentication)
end
end

factory :ems_redhat_with_metrics_authentication,
:parent => :ems_redhat do
after(:create) do |x|
Expand Down
5 changes: 3 additions & 2 deletions spec/models/ems_cluster_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@

context "#upgrade_cluster" do
before do
@ems = FactoryGirl.create(:ems_redhat_with_authentication)
@ems = FactoryGirl.create(:ems_redhat_with_authentication_with_ca, :skip_validate)
@cluster = FactoryGirl.create(:ems_cluster, :ems_id => @ems.id)
my_server = double("my_server", :guid => "guid1")
allow(MiqServer).to receive(:my_server).and_return(my_server)
Expand All @@ -259,7 +259,8 @@
:engine_user => @ems.authentication_userid,
:engine_password => @ems.authentication_password,
:cluster_name => @cluster.name,
:hostname => "localhost"}
:hostname => "localhost",
:ca_string => @ems.default_endpoint.certificate_authority}
role_arg = {:role_name=>"oVirt.cluster-upgrade"}
expect(ManageIQ::Providers::AnsibleRoleWorkflow).to receive(:create_job).with(env_vars, extra_args, role_arg).and_call_original
@cluster.upgrade_cluster
Expand Down

0 comments on commit 0598dc1

Please sign in to comment.