-
Notifications
You must be signed in to change notification settings - Fork 898
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
Schedule a daily count of managed VMs and print result to audit log. #19830
Conversation
Schedule the collection of VMs managed and print to the audit log.
app/models/miq_server.rb
Outdated
total_vms += vms | ||
total_hosts += hosts | ||
end | ||
$audit_log.info("Under Management: VMs: [#{total_vms}], Hosts: [#{total_hosts}]") |
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.
For parsing purposes, let's change the log message to be a JSON output. Something like
totals = {"vms" => total_vms, "hosts" => total_hosts}
$audit_log.info("Under Management: #{totals.to_json}")
This way, your parser can just parse simple JSON, and if we ever need to add stuff in the future we can and it won't break your parser.
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.
OK, I've changed it. Output is:
[----] I, [2020-02-14T11:06:26.844294 #84536:3fde43432e3c] INFO -- : Q-task_id([audit_managed_resources]) Under Management: {"vms":0,"hosts":0}
Overall LGTM... Just a few comments above. |
@@ -16,6 +16,10 @@ def miq_server_worker_log_status | |||
queue_work(:class_name => "MiqWorker", :method_name => "log_status_all", :task_id => "log_status", :server_guid => MiqServer.my_guid, :priority => MiqQueue::HIGH_PRIORITY) | |||
end | |||
|
|||
def miq_audit_vm_total |
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.
why the miq
prefix on this method name? Is that a standard in this file? /cc @Fryguy
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.
I would suggest a simpler name, such as audit_managed_resources
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.
I was using the same convention (although missed the _server) as the rest of the file "miq_server_worker_log_status" and "miq_server_status_update" which are the two methods above. My guess is that it is a way to discern where the job is coming from. So the method should be "miq_server_audit_managed_resources"
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.
If you look through the file, you will see many methods without miq_server
. miq_server
refers to the MiqServer object (which is associated with the appliance). I advise we use the name audit_managed_resources
here.
miq_server.rb - Changed method name and log entry is JSON encoded. jobs.rb - Method name is now miq_server_audit_managed_resources. settings.yaml - Setting name is now :audit_managed_resources runner.rb - Update for method name changes
config/settings.yml
Outdated
@@ -1211,6 +1211,7 @@ | |||
:vim_performance_states_purge_interval: 1.day | |||
:vm_retired_interval: 10.minutes | |||
:yum_update_check: 12.hours | |||
:audit_managed_resources: 1.days |
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 list is intended to be alphabetized, so if you can move this line into the proper place - that would be great
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.
I moved my setting to the top of the list. Although the list isn't sorted properly. Should I move the other settings?
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.
let's change the other out of order ones in a separate PR
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.
I didn't find a way other then restarting evmserverd
for this value (when changed) to pick up. Is this expected?
Checked commits jaredm-ibm/manageiq@589add9~...5f6ea19 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.20.0, and yamllint |
Thank you @jaredm-ibm for your first PR to ManageIQ! |
Schedule a daily count of managed VMs and print result to audit log. (cherry picked from commit c223c1c) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1805915
Ivanchuk backport details:
|
To implement license management, we need to get a daily count of managed VMs. This work adds a scheduled task controlled. The frequency is controlled by :audit_vm_total key. A new method was added to miq_server which performs the count and logging.
The more specific license management is not part of this PR. We decided to add this feature here to avoid requiring credentials in the client script.
https://bugzilla.redhat.com/show_bug.cgi?id=1805252