diff --git a/bin/appliance_console b/bin/appliance_console index 4507178a..3d5685fc 100755 --- a/bin/appliance_console +++ b/bin/appliance_console @@ -119,7 +119,7 @@ module ApplianceConsole summary_entry("MAC Address", mac), summary_entry("Timezone", timezone), summary_entry("Local Database Server", PostgresAdmin.local_server_status), - summary_entry("#{I18n.t("product.name")} Server", evm_running ? "running" : "not running"), + summary_entry("#{I18n.t("product.name")} Server", evm_running ? "running" : "not running - #{ManageIQ::ApplianceConsole::EvmServer.not_runnable_reason}"), summary_entry("#{I18n.t("product.name")} Database", dbhost || "not configured"), summary_entry("Database/Region", database ? "#{database} / #{region.to_i}" : "not configured"), summary_entry("Messaging", messaging ? "configured" : "not configured"), diff --git a/lib/manageiq/appliance_console/evm_server.rb b/lib/manageiq/appliance_console/evm_server.rb index 04dba20f..8c7d3ac7 100644 --- a/lib/manageiq/appliance_console/evm_server.rb +++ b/lib/manageiq/appliance_console/evm_server.rb @@ -1,21 +1,26 @@ module ManageIQ module ApplianceConsole class EvmServer + class NotRunnableError < RuntimeError; end + class << self def running? service.running? end def start!(enable: false) + raise NotRunnableError, not_runnable_reason unless runnable? + service.start(enable) end def start(enable: false) start!(:enable => enable) - rescue AwesomeSpawn::CommandResultError => e + rescue AwesomeSpawn::CommandResultError, NotRunnableError => e say e.result.output say e.result.error say "" + false end def stop @@ -34,6 +39,21 @@ def disable service.disable end + def runnable? + DatabaseConfiguration.database_yml_configured? && MessageConfiguration.configured? + end + + def not_runnable_reason + reason = + if DatabaseConfiguration.database_yml_configured? + _("A Database connection has not been configured.") + elsif MessageConfiguration.configured? + _("Messaging has not been configured.") + end + + _("Cannot start %{product_name}: %{reason}") % {:product_name => I18n.t("product.name"), :reason => reason} + end + private def service