Module: ProxmoxVmUuidHelper

Included in:
ForemanFogProxmox::ProxmoxVmQueries
Defined in:
app/helpers/proxmox_vm_uuid_helper.rb

Overview

You should have received a copy of the GNU General Public License along with ForemanFogProxmox. If not, see <www.gnu.org/licenses/>.

Constant Summary collapse

UUID_REGEXP =
/(?<cluster_id>\d+)_(?<vmid>\d+)/.freeze

Instance Method Summary collapse

Instance Method Details

#extract(uuid, name) ⇒ Object



22
23
24
25
# File 'app/helpers/proxmox_vm_uuid_helper.rb', line 22

def extract(uuid, name)
  captures_h = uuid ? UUID_REGEXP.match(uuid.to_s) : { cluster_id: '', vmid: '' }
  captures_h ? captures_h[name] : ''
end

#extract_vmid(uuid) ⇒ Object



31
32
33
# File 'app/helpers/proxmox_vm_uuid_helper.rb', line 31

def extract_vmid(uuid)
  extract(uuid, :vmid)
end

#match_uuid?(uuid) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/helpers/proxmox_vm_uuid_helper.rb', line 27

def match_uuid?(uuid)
  extract(uuid, :cluster_id) != ''
end