Skip to content

Commit

Permalink
Merge pull request #16903 from zeari/container_project_created_event
Browse files Browse the repository at this point in the history
Add a 'Container Project Discovered' event
  • Loading branch information
agrare authored Feb 6, 2018
2 parents 8be29c6 + d7deca9 commit d2672cc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
15 changes: 15 additions & 0 deletions app/models/container_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class ContainerProject < ApplicationRecord
include SupportsFeatureMixin
include CustomAttributeMixin
include ArchivedMixin
include MiqPolicyMixin
include TenantIdentityMixin
include CustomActionsMixin
include_concern 'Purging'
belongs_to :ext_management_system, :foreign_key => "ems_id"
Expand All @@ -20,6 +22,7 @@ class ContainerProject < ApplicationRecord
has_many :container_templates
has_many :archived_container_groups, :foreign_key => "old_container_project_id", :class_name => "ContainerGroup"
has_many :persistent_volume_claims
has_many :miq_alert_statuses, :as => :resource, :dependent => :destroy

# Needed for metrics
has_many :metrics, :as => :resource
Expand All @@ -35,6 +38,8 @@ class ContainerProject < ApplicationRecord
virtual_total :containers_count, :containers
virtual_total :images_count, :container_images

after_create :raise_creation_event

include EventMixin
include Metric::CiMixin

Expand Down Expand Up @@ -67,4 +72,14 @@ def disconnect_inv
self.deleted_on = Time.now.utc
save
end

def self.raise_creation_events(container_project_ids)
where(:id => container_project_ids).find_each do |record|
MiqEvent.raise_evm_event(record, 'containerproject_created', {})
end
end

def raise_creation_event
MiqEvent.raise_evm_event(self, 'containerproject_created', {})
end
end
1 change: 1 addition & 0 deletions app/models/miq_alert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MiqAlert < ApplicationRecord
ExtManagementSystem
MiqServer
ContainerNode
ContainerProject
)

def self.base_tables
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MiqEvent < EventStream
SUPPORTED_POLICY_AND_ALERT_CLASSES = [Host, VmOrTemplate, Storage,
EmsCluster, ResourcePool, MiqServer,
ExtManagementSystem,
ContainerReplicator, ContainerGroup,
ContainerReplicator, ContainerGroup, ContainerProject,
ContainerNode, ContainerImage, PhysicalServer].freeze

def self.raise_evm_event(target, raw_event, inputs = {}, options = {})
Expand Down
2 changes: 2 additions & 0 deletions db/fixtures/miq_event_definitions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ containerreplicator_compliance_check,Replicator Compliance Check,Default,complia
containerreplicator_compliance_passed,Replicator Compliance Passed,Default,compliance
containerreplicator_compliance_failed,Replicator Compliance Failed,Default,compliance

containerproject_created,Container Project Discovered,Default,container_operations

#
# Physical Server Operations
#
Expand Down

0 comments on commit d2672cc

Please sign in to comment.