Bug 1552671 - [RFE][XS-2] Add possibility to unregister a VM in RHV provider
Summary: [RFE][XS-2] Add possibility to unregister a VM in RHV provider
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Providers
Version: 5.8.0
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: GA
: 5.9.2
Assignee: Moti Asayag
QA Contact: Ilanit Stein
URL:
Whiteboard:
Depends On: 1536628
Blocks: 1554897
TreeView+ depends on / blocked
 
Reported: 2018-03-07 14:10 UTC by Satoe Imaishi
Modified: 2022-07-09 09:29 UTC (History)
14 users (show)

Fixed In Version: 5.9.2.0
Doc Type: Enhancement
Doc Text:
Clone Of: 1536628
Environment:
Last Closed: 2018-05-07 20:43:22 UTC
Category: ---
Cloudforms Team: RHEVM
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
automate_simulation.png (43.18 KB, image/png)
2018-04-16 14:16 UTC, Ilanit Stein
no flags Details
add_method_for_unregister.png (132.43 KB, image/png)
2018-04-16 14:16 UTC, Ilanit Stein
no flags Details
unregister_vm_copy_instance.png (113.26 KB, image/png)
2018-04-16 14:17 UTC, Ilanit Stein
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:1328 0 None None None 2018-05-07 20:43:56 UTC

Comment 2 CFME Bot 2018-03-07 14:12:50 UTC
New commit detected on ManageIQ/manageiq-providers-ovirt/gaprindashvili:

https://github.com/ManageIQ/manageiq-providers-ovirt/commit/1c5ef885593efe52a2c4b3239a25fd165f547a32
commit 1c5ef885593efe52a2c4b3239a25fd165f547a32
Author:     Piotr Kliczewski <piotr.kliczewski>
AuthorDate: Mon Mar  5 10:34:23 2018 -0500
Commit:     Piotr Kliczewski <piotr.kliczewski>
CommitDate: Mon Mar  5 10:34:23 2018 -0500

    Merge pull request #223 from masayag/unregistervm

    Support Unregister VM
    (cherry picked from commit f0dfe4f9d59e850177d4fb837e37ea10707aa62b)

    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1552671

 app/models/manageiq/providers/redhat/infra_manager/ovirt_services/strategies/v4.rb | 4 +
 app/models/manageiq/providers/redhat/infra_manager/vm/operations.rb | 4 +
 spec/models/manageiq/providers/redhat/infra_manager/vm_spec.rb | 20 +
 3 files changed, 28 insertions(+)

Comment 3 Ilanit Stein 2018-04-16 14:03:52 UTC
Verified on CFME-5.9.2.1/RHV-4.2.2-5:

1) In Automate->Explorer added a new domain and a namespace.
(As a reference, this link can be used to create the domain/namespace:
https://pemcg.gitbooks.io/introduction-to-cloudforms-automation/content/chapter1/methods.html 
See the "hello world" method creation flow.

Copy instance Redhat-> Infrastructure->VMware->VimApi->"VMware_HotAdd_Disk"
to the created namespace path.
(See 'unregister_vm_copy_instance.png' attached).

2) Edit the Instance name into "Unregister_vm", and the method name into "unregister_vm".
(See 'add_method_for_unregister.png' attached)
Set the method type as inline, and add this content:

#
# Description: This method is used to unregister a vm
#
# Inputs: vm_name
#

# Get vm object
vm_name = $evm.root['vm_name']
$evm.log("info", "-------->>>> Trying to unregister VM: <#{vm_name}>")

$evm.root['vm'] = $evm.vmdb('vm').find_by_name(vm_name)
vm = $evm.root['vm']
raise "Missing $evm.root['vm'] object" unless vm

vm.unregister

3) Then run Automate->Simulation, with vm_name of VM that we want to unregister.
This VM should have a disk that is not of an existing template, and should be in state down for the unregister succeed.
(See automate_simulation.png)

Once the simulation operation is complete, the VM should be removed, and it's disks should remain (not removed).

In case of there is a problem, check CFME automation/evm.log

Comment 4 Ilanit Stein 2018-04-16 14:16:08 UTC
Created attachment 1422569 [details]
automate_simulation.png

Comment 5 Ilanit Stein 2018-04-16 14:16:49 UTC
Created attachment 1422570 [details]
add_method_for_unregister.png

Comment 6 Ilanit Stein 2018-04-16 14:17:38 UTC
Created attachment 1422572 [details]
unregister_vm_copy_instance.png

Comment 9 errata-xmlrpc 2018-05-07 20:43:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHSA-2018:1328


Note You need to log in before you can comment on or make changes to this bug.