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

Add aggregate_memory to container project #18159

Merged
Merged
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
17 changes: 17 additions & 0 deletions app/models/container_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ContainerProject < ApplicationRecord
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
has_many :computer_systems, :through => :container_nodes

# Needed for metrics
has_many :metrics, :as => :resource
Expand All @@ -43,6 +44,7 @@ class ContainerProject < ApplicationRecord

include EventMixin
include Metric::CiMixin
include AggregationMixin::Methods

PERF_ROLLUP_CHILDREN = :all_container_groups

Expand All @@ -69,6 +71,21 @@ def perf_rollup_parents(interval_name = nil)
[]
end

# required by aggregate_hardware
alias all_computer_system_ids computer_system_ids

def aggregate_memory(targets = nil)
aggregate_hardware(:computer_systems, :memory_mb, targets)
end

def aggregate_cpu_speed(targets = nil)
aggregate_hardware(:computer_systems, :cpu_speed, targets)
end

def aggregate_cpu_total_cores(targets = nil)
aggregate_hardware(:computer_systems, :cpu_total_cores, targets)
end

def disconnect_inv
return if archived?
_log.info("Disconnecting Container Project [#{name}] id [#{id}] from EMS [#{ext_management_system.name}] id [#{ext_management_system.id}]")
Expand Down