Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Refactor UI ws address podified #22671

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions app/models/miq_region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,8 @@ def remote_ui_miq_server
MiqServer.in_region(region).recently_active.find_by(:has_active_userinterface => true)
end

def remote_ui_ipaddress
remote_ui_miq_server&.ui_ipaddress
end

def remote_ui_hostname
remote_ui_miq_server&.ui_hostname
def remote_ui_address
remote_ui_miq_server&.ui_address
end

def remote_ui_url(contact_with = :hostname)
Expand All @@ -208,14 +204,6 @@ def remote_ws_address
remote_ws_miq_server&.ws_address
end

def remote_ws_ipaddress
remote_ws_miq_server&.ws_ipaddress
end

def remote_ws_hostname
remote_ws_miq_server&.ws_hostname
end

def remote_ws_url
remote_ws_miq_server&.ws_url
end
Expand Down
62 changes: 23 additions & 39 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 @@ -404,27 +418,12 @@ def logon_status_details
result.merge(:message => message)
end

def ui_hostname
if MiqEnvironment::Command.is_podified?
ENV.fetch("APPLICATION_DOMAIN")
else
hostname || ipaddress
end
end

def ui_ipaddress
if MiqEnvironment::Command.is_podified?
nil
else
ipaddress
end
end

def ui_address(contact_with = :hostname)
if MiqEnvironment::Command.is_podified?
if podified?
ENV.fetch("APPLICATION_DOMAIN")
else
contact_with == :hostname ? ui_hostname : ui_ipaddress
address = hostname if contact_with == :hostname
address || ipaddress
end
end

Expand All @@ -438,27 +437,12 @@ def ui_url(contact_with = :hostname)
URI::HTTPS.build(:host => host).to_s
end

def ws_hostname
if MiqEnvironment::Command.is_podified?
ENV.fetch("APPLICATION_DOMAIN")
else
hostname || ipaddress
end
end

def ws_ipaddress
if MiqEnvironment::Command.is_podified?
nil
else
ipaddress
end
end

def ws_address
if MiqEnvironment::Command.is_podified?
if podified?
ENV.fetch("APPLICATION_DOMAIN")
else
::Settings.webservices.contactwith == 'hostname' ? ws_hostname : ws_ipaddress
address = hostname if ::Settings.webservices.contactwith == 'hostname'
address || ipaddress
end
end

Expand Down Expand Up @@ -585,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 @@ -614,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
Loading