-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
5 deletions.
There are no files selected for viewing
35 changes: 30 additions & 5 deletions
35
.../ManageIQ/Cloud/VM/Retirement/StateMachines/Methods.class/__methods__/delete_from_vmdb.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
# | ||
# Description: This method removes the VM from the VMDB database | ||
# | ||
module ManageIQ | ||
module Automate | ||
module Cloud | ||
module VM | ||
module Retirement | ||
module StateMachines | ||
module Methods | ||
class DeleteFromVmdb | ||
def initialize(handle = $evm) | ||
@handle = handle | ||
end | ||
|
||
vm = $evm.root['vm'] | ||
def main | ||
vm = @handle.root['vm'] | ||
|
||
if vm && $evm.get_state_var('vm_removed_from_provider') | ||
$evm.log('info', "Removing VM <#{vm.name}> from VMDB") | ||
vm.remove_from_vmdb | ||
$evm.root['vm'] = nil | ||
if vm && @handle.get_state_var('vm_removed_from_provider') | ||
@handle.log('info', "Removing VM <#{vm.name}> from VMDB") | ||
vm.remove_from_vmdb | ||
@handle.root['vm'] = nil | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
if $PROGRAM_NAME == __FILE__ | ||
ManageIQ::Automate::Cloud::VM::Retirement::StateMachines::Methods::DeleteFromVmdb.new.main | ||
end |