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

Introduce virtualization manager #16721

Merged
merged 1 commit into from
Jan 17, 2018
Merged
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: 16 additions & 0 deletions app/models/manageiq/providers/container_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ContainerManager < BaseManager

include AvailabilityMixin
include HasMonitoringManagerMixin
include HasInfraManagerMixin
include SupportsFeatureMixin

has_many :container_nodes, -> { active }, :foreign_key => :ems_id
Expand Down Expand Up @@ -46,6 +47,11 @@ class ContainerManager < BaseManager
has_many :all_container_images, :foreign_key => :ems_id, :dependent => :destroy, :class_name => "ContainerImage"
has_many :all_container_nodes, :foreign_key => :ems_id, :dependent => :destroy, :class_name => "ContainerNode"

has_one :infra_manager,
:foreign_key => :parent_ems_id,
:class_name => "ManageIQ::Providers::Kubevirt::InfraManager",
:autosave => true,
:dependent => :destroy

virtual_column :port_show, :type => :string

Expand Down Expand Up @@ -92,5 +98,15 @@ def validate_authentication_status
def port_show
port.to_s
end

def endpoint_created(role)
monitoring_endpoint_created(role) if respond_to?(:monitoring_endpoint_created)
virtualization_endpoint_created(role) if respond_to?(:virtualization_endpoint_created)
end

def endpoint_destroyed(role)
monitoring_endpoint_destroyed(role) if respond_to?(:monitoring_endpoint_destroyed)
virtualization_endpoint_destroyed(role) if respond_to?(:virtualization_endpoint_destroyed)
end
end
end
29 changes: 29 additions & 0 deletions app/models/mixins/has_infra_manager_mixin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module HasInfraManagerMixin
extend ActiveSupport::Concern

def virtualization_endpoint_created(role)
if role == "kubevirt" && infra_manager.nil?
infra_manager = ensure_infra_manager
infra_manager.save
end
end

def virtualization_endpoint_destroyed(role)
if role == "kubevirt" && infra_manager.present?
infra_manager.destroy_queue
end
end

private

def ensure_infra_manager
if infra_manager.nil?
build_infra_manager(:parent_manager => self,
:name => "#{name} Virtualization Manager",
:zone_id => zone_id,
:provider_region => provider_region)
end

infra_manager
end
end
4 changes: 2 additions & 2 deletions app/models/mixins/has_monitoring_manager_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module HasMonitoringManagerMixin
extend ActiveSupport::Concern

def endpoint_created(role)
def monitoring_endpoint_created(role)
if role == "prometheus_alerts" && monitoring_manager.nil?
monitoring_manager = ensure_monitoring_manager
monitoring_manager.save
end
end

def endpoint_destroyed(role)
def monitoring_endpoint_destroyed(role)
if role == "prometheus_alerts" && monitoring_manager.present?
# TODO: if someone deletes the alerts endpoint and then quickly readds it they can end up without a manager.
monitoring_manager.destroy_queue
Expand Down