Skip to content

Commit

Permalink
Don't start evmserverd until db and messaging configured
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Oct 13, 2022
1 parent f867380 commit 0fab933
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/appliance_console
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
22 changes: 21 additions & 1 deletion lib/manageiq/appliance_console/evm_server.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0fab933

Please sign in to comment.