Skip to content

Commit

Permalink
Introduce virtualization manager
Browse files Browse the repository at this point in the history
In order to support kubevirt as a secondary manager of the
openshift/kubevirt provider, a new mixin is added to represent that
capability.
  • Loading branch information
masayag committed Dec 27, 2017
1 parent ed4af9d commit 4e3c9bc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
9 changes: 9 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 HasVirtualizationManagerMixin
include SupportsFeatureMixin

has_many :container_nodes, -> { active }, :foreign_key => :ems_id
Expand Down Expand Up @@ -46,9 +47,17 @@ 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 :virtualization_manager,
:foreign_key => :parent_ems_id,
:class_name => "ManageIQ::Providers::Kubevirt::InfraManager",
:autosave => true,
:dependent => :destroy

virtual_column :port_show, :type => :string

before_create :ensure_virtualization_manager
before_update :ensure_virtualization_manager_properties

supports :external_logging do
unless respond_to?(:external_logging_route_name)
unsupported_reason_add(:external_logging, _('This provider type does not support external_logging'))
Expand Down
21 changes: 21 additions & 0 deletions app/models/mixins/has_virtualization_manager_mixin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module HasVirtualizationManagerMixin
extend ActiveSupport::Concern

private

def ensure_virtualization_manager
# virtualization_manager should be defined by child classes.
if try(:virtualization_manager_needed?)
build_virtualization_manager(:parent_manager => self)
virtualization_manager.name = "#{name} Virtualization Manager"
end
ensure_virtualization_manager_properties
end

def ensure_virtualization_manager_properties
if virtualization_manager
virtualization_manager.zone_id = zone_id
virtualization_manager.provider_region = provider_region
end
end
end

0 comments on commit 4e3c9bc

Please sign in to comment.