Skip to content

Commit

Permalink
Move is_podified?/is_systemd? into MiqServer
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Aug 18, 2023
1 parent 32794f9 commit 18da47c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
24 changes: 19 additions & 5 deletions app/models/miq_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,20 @@ def set_database_application_name
ArApplicationName.name = database_application_name
end

def self.podified?
return @podified unless @podified.nil?

@podified = MiqEnvironment::Command.is_podified?
end
delegate :podified?, :to => :class

def self.systemd?
return @systemd unless @systemd.nil?

@systemd = MiqEnvironment::Command.supports_systemd?
end
delegate :systemd?, :to => :class

def is_local?
guid == MiqServer.my_guid
end
Expand All @@ -353,7 +367,7 @@ def is_recently_active?
end

def is_deleteable?
return true if MiqEnvironment::Command.is_podified?
return true if podified?

if self.is_local?
message = N_("Cannot delete currently used %{log_message}") % {:log_message => format_short_log_msg}
Expand Down Expand Up @@ -405,7 +419,7 @@ def logon_status_details
end

def ui_address(contact_with = :hostname)
if MiqEnvironment::Command.is_podified?
if podified?
ENV.fetch("APPLICATION_DOMAIN")
else
address = hostname if contact_with == :hostname
Expand All @@ -424,7 +438,7 @@ def ui_url(contact_with = :hostname)
end

def ws_address
if MiqEnvironment::Command.is_podified?
if podified?
ENV.fetch("APPLICATION_DOMAIN")
else
address = hostname if ::Settings.webservices.contactwith == 'hostname'
Expand Down Expand Up @@ -555,7 +569,7 @@ def self.display_name(number = 1)
end

def self.zone_is_modifiable?
return false if MiqEnvironment::Command.is_podified?
return false if podified?

Zone.visible.in_my_region.count > 1
end
Expand Down Expand Up @@ -584,7 +598,7 @@ def self.audit_managed_resources
private

def zone_unchanged_in_pods
return unless MiqEnvironment::Command.is_podified?
return unless podified?

errors.add(:zone, N_('cannot be changed when running in containers')) if zone_id_changed?
end
Expand Down
12 changes: 2 additions & 10 deletions app/models/miq_server/worker_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class MiqServer::WorkerManagement
attr_reader :my_server

def self.build(my_server)
klass = if podified?
klass = if my_server.podified?
Kubernetes
elsif systemd?
elsif my_server.systemd?
Systemd
else
Process
Expand All @@ -23,14 +23,6 @@ def self.build(my_server)
klass.new(my_server)
end

def self.podified?
MiqEnvironment::Command.is_podified?
end

def self.systemd?
MiqEnvironment::Command.supports_systemd?
end

def initialize(my_server)
@my_server = my_server
@workers_lock = Sync.new
Expand Down

0 comments on commit 18da47c

Please sign in to comment.