Class: ForemanResourceQuota::ResourceOrigins::VMAttributesOrigin

Inherits:
ForemanResourceQuota::ResourceOrigin show all
Defined in:
app/services/foreman_resource_quota/resource_origins/vm_attributes_origin.rb

Constant Summary

Constants inherited from ForemanResourceQuota::ResourceOrigin

ForemanResourceQuota::ResourceOrigin::RESOURCE_FUNCTION_MAP

Instance Method Summary collapse

Methods inherited from ForemanResourceQuota::ResourceOrigin

#collect_resources!

Instance Method Details

#extract_cpu_cores(param) ⇒ Object



14
15
16
17
18
19
# File 'app/services/foreman_resource_quota/resource_origins/vm_attributes_origin.rb', line 14

def extract_cpu_cores(param)
  return nil unless param.key?(:cpus)
  param[:cpus]
rescue StandardError
  nil
end

#extract_disk_gb(param) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'app/services/foreman_resource_quota/resource_origins/vm_attributes_origin.rb', line 28

def extract_disk_gb(param)
  return nil unless param.key?(:volumes_attributes)
  extract_volumes(param).sum do |disk|
    # key can be capactiy or size_gb
    return nil unless disk.key?(:capacity) || disk.key?(:size_gb)
    (disk[:size_gb] || disk[:capacity]).to_i
  end
rescue StandardError
  nil
end

#extract_memory_mb(param) ⇒ Object



21
22
23
24
25
26
# File 'app/services/foreman_resource_quota/resource_origins/vm_attributes_origin.rb', line 21

def extract_memory_mb(param)
  return nil unless param.key?(:memory_mb)
  param[:memory_mb]
rescue StandardError
  nil
end

#host_attribute_eager_nameObject



6
7
8
# File 'app/services/foreman_resource_quota/resource_origins/vm_attributes_origin.rb', line 6

def host_attribute_eager_name
  :compute_resource
end

#host_attribute_nameObject



10
11
12
# File 'app/services/foreman_resource_quota/resource_origins/vm_attributes_origin.rb', line 10

def host_attribute_name
  :vm_compute_attributes
end