Feature #5464
closedDelete unamanged compute resource host without deleting the virtual machine.
Description
I create a lot of vmware vm's in foreman that generally end up getting turned off after creation to prep for ova export. Id like to be able to provision them in forman and the delete the host in foreman; without actually deleting the vmware vm.
I found the following article:
https://groups.google.com/forum/#!topic/foreman-users/BES0qnmw9XE
which mentions editing compute.rb. I made edits to actually check if the entry in the database is managed or not before destroying, but it appears the host.destroy function actually deletes the db record before calling delCompute. Im not good enough with rails to follow the destroy chain to figure out where an edit needs to be placed to implement this. Ideally it would be a configurable option.
Thanks.
Updated by Trey Ormsbee over 10 years ago
I meant to post this as a feature request, not a bug report. Sorry.
Updated by Dominic Cleal over 10 years ago
- Status changed from New to Feedback
Foreman 1.5 has a "disassociate" button on hosts which will unlink it from the VM, allowing you to then delete the host without destroying the VM. Although it's not part of the destroy workflow, maybe it solves this for you?
Updated by Dominic Cleal over 10 years ago
- Related to Feature #3909: compute resources prevent or disassciate host from VM prevent vm deletion added
Updated by Trey Ormsbee over 10 years ago
Dominic Cleal wrote:
Foreman 1.5 has a "disassociate" button on hosts which will unlink it from the VM, allowing you to then delete the host without destroying the VM. Although it's not part of the destroy workflow, maybe it solves this for you?
That should work perfectly. Thank you!
Updated by Dominic Cleal over 10 years ago
- Status changed from Feedback to Duplicate
Great, give it a try once 1.5.0-RC2's available as we fixed a bug.
Updated by Trey Ormsbee over 10 years ago
I tried upgrading on a test box, and am having trouble getting it working (lots o DB errors).... but looking at the controller code it will do exactly what I need. Ill keep an eye out and try when rc3 hits and give it a try...
def disassociate
if @host.uuid.nil? && @host.compute_resource_id.nil?
process_error :error_msg => _("Host %s is not associated with a VM") % @host.name, :redirect => :back
else
@host.uuid = nil
@host.compute_resource_id = nil
@host.save!(:validate => false) # don't want to trigger callbacks
msg = _("%s has been disassociated from VM") % (@host.name)
process_success :success_msg => msg, :success_redirect => :back
end
end
Updated by Dominic Cleal over 10 years ago
I'd suggest posting to the -users list or popping on IRC if you're having upgrade problems, I'm not aware of any major DB errors so perhaps we can help you solve them.
Updated by Trey Ormsbee over 10 years ago
I got it working, I installed from rpm's first, then just pulled from git. I think I had other issues such as gem versioning. The functionality I am looking for is attained 100% with the disassociate host function. Thank you!