Skip to content

Commit

Permalink
Upgrade Ovirt Cluster through Ansible
Browse files Browse the repository at this point in the history
Add method to upgrade cluster using ovirt-ansible-cluster-upgrade role.
  • Loading branch information
Boris Odnopozov committed Nov 3, 2018
1 parent db724df commit 81a6b20
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ def use_graph_refresh?
use_ovirt_sdk? && supported_api_versions.include?('4')
end

def connect(options = {})
raise "no credentials defined" if missing_credentials?(options[:auth_type])
version = options[:version] || highest_allowed_api_version
unless options[:skip_supported_api_validation] || supports_the_api_version?(version)
raise "version #{version} of the api is not supported by the provider"
end

# Prepare the options to call the method that creates the actual connection:
connect_options = {
def apply_connection_options_defaults(options)
{
:id => id,
:scheme => options[:scheme] || 'https',
:server => options[:ip] || address,
Expand All @@ -48,7 +41,17 @@ def connect(options = {})
:verify_ssl => default_endpoint.verify_ssl,
:ca_certs => default_endpoint.certificate_authority
}
end

def connect(options = {})
raise "no credentials defined" if missing_credentials?(options[:auth_type])
version = options[:version] || highest_allowed_api_version
unless options[:skip_supported_api_validation] || supports_the_api_version?(version)
raise "version #{version} of the api is not supported by the provider"
end

# Prepare the options to call the method that creates the actual connection:
connect_options = apply_connection_options_defaults(options)
# Starting with version 4 of oVirt authentication doesn't work when using directly the IP address, it requires
# the fully qualified host name, so if we received an IP address we try to convert it into the corresponding
# host name:
Expand Down
29 changes: 29 additions & 0 deletions app/models/manageiq/providers/redhat/infra_manager/ems_cluster.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class ManageIQ::Providers::Redhat::InfraManager::EmsCluster < ManageIQ::Providers::InfraManager::EmsCluster
def upgrade(options = {})
role_options = {:role_name => "oVirt.cluster-upgrade"}
job = ManageIQ::Providers::AnsibleRoleWorkflow.create_job({}, extra_vars_for_upgrade(options), role_options)
job.signal(:start)
job.miq_task
end

private

def extra_vars_for_upgrade(options = {})
connect_options = ext_management_system.apply_connection_options_defaults(options)

url = URI::Generic.build(
:scheme => connect_options[:scheme],
:host => connect_options[:server],
:port => connect_options[:port],
:path => connect_options[:path]
).to_s

{
:engine_url => url,
:engine_user => connect_options[:username],
:engine_password => connect_options[:password],
:cluster_name => name,
:hostname => "localhost"
}
end
end

0 comments on commit 81a6b20

Please sign in to comment.