-
Notifications
You must be signed in to change notification settings - Fork 897
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
Keep archived out of VimPerformanceState #22585
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,19 +197,9 @@ def capture_total(field) | |
def capture_assoc_ids | ||
result = {} | ||
ASSOCIATIONS.each do |assoc| | ||
method = if assoc == :vms | ||
if resource.kind_of?(EmsCluster) | ||
:all_vms_and_templates | ||
elsif resource.kind_of?(Service) | ||
:vms | ||
else | ||
:vms_and_templates | ||
end | ||
else | ||
assoc | ||
end | ||
next unless resource.respond_to?(method) | ||
assoc_recs = resource.send(method) | ||
assoc_recs = fetch_assoc_records(resource, assoc) | ||
next if assoc_recs == false | ||
|
||
has_state = assoc_recs[0] && assoc_recs[0].respond_to?(:state) | ||
|
||
r = result[assoc] = {:on => [], :off => []} | ||
|
@@ -231,6 +221,25 @@ def capture_assoc_ids | |
self.assoc_ids = result.presence | ||
end | ||
|
||
def fetch_assoc_records(resource, assoc) | ||
method = if assoc == :vms | ||
if resource.kind_of?(EmsCluster) | ||
:all_vms_and_templates | ||
elsif resource.kind_of?(Service) | ||
:vms | ||
else | ||
:vms_and_templates | ||
end | ||
else | ||
assoc | ||
end | ||
return false unless resource.respond_to?(method) | ||
|
||
records = resource.send(method) | ||
records = records.not_archived_before(timestamp) if records.try(:klass).respond_to?(:not_archived_before) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only actual changed line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If the association is a virtual attribute, like it is for |
||
records | ||
end | ||
|
||
def capture_parent_cluster | ||
if resource.kind_of?(Host) || resource.kind_of?(VmOrTemplate) | ||
self.parent_ems_cluster_id = resource.parent_cluster.try(:id) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a minor change to return something so the parent knows we need to
next
(codeclimate this code to be its own method)