Sha256: a62642ce320a54ea662ce7bd908bf1777c0dc830a27b7a35e81e75642c9b86f6
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true # Copyright 2021 Tristan Robert # This file is part of ForemanFogProxmox. # ForemanFogProxmox is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # ForemanFogProxmox is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. module HostExt module Proxmox module Associator extend ActiveSupport::Concern included do prepend Overrides end module Overrides def associate!(cr, vm) self.uuid = proxmox_vm_id(cr, vm) self.compute_resource_id = cr.id save!(:validate => false) # don't want to trigger callbacks end def proxmox_vm_id(compute_resource, vm) id = vm.identity id = vm.unique_cluster_identity(compute_resource) if compute_resource.class == ForemanFogProxmox::Proxmox id end end def for_vm_uuid(cr, vm) where(:compute_resource_id => cr.id, :uuid => Array.wrap(vm).compact.map(cr.id.to_s + '_' + vm&.identity).map(&:to_s)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreman_fog_proxmox-0.14.0 | app/models/concerns/host_ext/proxmox/associator.rb |
foreman_fog_proxmox-0.13.4 | app/models/concerns/host_ext/proxmox/associator.rb |