Bug 1450351

Summary: [RFE] Allow specifying a shutdown reason on the .shutdown() call
Product: [oVirt] ovirt-engine Reporter: nicolas
Component: RestAPIAssignee: Liran Rotenberg <lrotenbe>
Status: CLOSED CURRENTRELEASE QA Contact: Guilherme Santos <gdeolive>
Severity: low Docs Contact:
Priority: unspecified    
Version: 4.1.1CC: bugs, juan.hernandez, lleistne, lrotenbe, rbarry, sgoodman
Target Milestone: ovirt-4.4.0Keywords: FutureFeature, Reopened
Target Release: ---Flags: rbarry: ovirt-4.4?
rule-engine: planning_ack?
pm-rhel: devel_ack+
lleistne: testing_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
With this update, you can set the reason for shutting down or powering off a virtual machine when using a REST API request to execute the shutdown or power-off.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-20 20:01:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description nicolas 2017-05-12 10:13:23 UTC
Description of problem:

It would be nice if Python-SDK allowed specifying the shutdown reason using the .shutdown() call of Connection.system_service().vms_service().vm_service()

Currently this is not implemented.

Comment 1 Juan Hernández 2017-05-12 10:23:57 UTC
In order to have this in the Python SDK (and in all the other SDKs) we need to add it to the specification of the API, and then implement it in the API itself, so I am moving to the API component. Once it is implemented in the API the SDKs will automatically reflect it.

Comment 2 Juan Hernández 2017-05-12 10:29:14 UTC
This should be added also to the 'stop' operation.

We already have a 'stop_reason' attribute in the VM type, so I think this could be implemented copying the reason provided by the user into that attribute, both for the 'shutodwn' and 'stop' operations.

I'd suggest to define it as follows:

  POST /ovirt-engine/api/vms/123/shutdown?reason=My%20reason

In the Python SDK it will then be used like this:

  vm_service = ...
  vm_service.shutdown(
    reason='My reason'
  )

Same for 'stop'.

Comment 3 Ryan Barry 2019-01-03 12:49:55 UTC
This will not be addressed in a reasonable timeframe. Please re-open if it's still important.

Comment 4 nicolas 2019-01-03 15:53:00 UTC
Even if not implemented in a short timefrime, it's still important to us... It allows to automatize tasks from the Python-SDK API and let the users know why the VMs were shut down.

Comment 5 Ryan Barry 2019-09-13 13:29:16 UTC
*** Bug 1751734 has been marked as a duplicate of this bug. ***

Comment 6 Ryan Barry 2019-09-13 13:30:16 UTC
Let's also fix the other half (shutdown/stop reason propagation from the admin portal) in this bug

Comment 8 Guilherme Santos 2020-03-23 20:30:26 UTC
Verified on:
ovirt-engine-4.4.0-0.25.master.el8ev.noarch

Steps:
1. # curl -X POST -H "Content-type: application/xml" -u admin@internal:<password> --insecure https://<engine-fqdn>/ovirt-engine/api/v4/vms/<vm-id>/stop -d'<action><reason>why not</reason></action>'
2. On engine: # grep "why not" /var/log/ovirt-engine/engine.log
3. Checked the Events Tab in the engine GUI

Results:
Vm successfully stopped with reason message "why not" showing in the logs and in the events tab

Comment 9 Sandro Bonazzola 2020-05-20 20:01:48 UTC
This bugzilla is included in oVirt 4.4.0 release, published on May 20th 2020.

Since the problem described in this bug report should be
resolved in oVirt 4.4.0 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.