27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb', line 27
def associate
if Host.for_vm_uuid(@compute_resource, @vm).any?
process_error(:error_msg => _("VM already associated with a host"),
:redirect => compute_resource_vm_path(:compute_resource_id => params[:compute_resource_id],
:id => proxmox_vm_id(@compute_resource, @vm)))
return
end
host = @compute_resource.associated_host(@vm) if @compute_resource.respond_to?(:associated_host)
if host.present?
host.associate!(@compute_resource, @vm)
process_success(:success_msg => _("VM associated to host %s") % host.name,
:success_redirect => host_path(host))
else
process_error(:error_msg => _("No host found to associate this VM with"),
:redirect => compute_resource_vm_path(:compute_resource_id => params[:compute_resource_id],
:id => proxmox_vm_id(@compute_resource, @vm)))
end
end
|