Module: HammerCLIForeman::ComputeResources

Defined in:
lib/hammer_cli_foreman/compute_resource/ec2.rb,
lib/hammer_cli_foreman/compute_resource/base.rb,
lib/hammer_cli_foreman/compute_resource/ovirt.rb,
lib/hammer_cli_foreman/compute_resource/utils.rb,
lib/hammer_cli_foreman/compute_resource/vmware.rb,
lib/hammer_cli_foreman/compute_resource/libvirt.rb,
lib/hammer_cli_foreman/compute_resource/openstack.rb

Defined Under Namespace

Classes: Base, EC2, Libvirt, OpenStack, Ovirt, VMware

Class Method Summary collapse

Class Method Details

.get_host_compute_resource_id(host_id) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/hammer_cli_foreman/compute_resource/utils.rb', line 27

def self.get_host_compute_resource_id(host_id)
  HammerCLIForeman.record_to_common_format(
    HammerCLIForeman.foreman_resource(:hosts).call(
      :show, 'id' => host_id
    )['compute_resource_id']
  )
end

.get_hostgroup_compute_resource_id(hostgroup_id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hammer_cli_foreman/compute_resource/utils.rb', line 11

def self.get_hostgroup_compute_resource_id(hostgroup_id)
  hostgroup = HammerCLIForeman.record_to_common_format(
      HammerCLIForeman.foreman_resource(:hostgroups).call(:show, 'id' => hostgroup_id)
  )
  compute_resource_id = hostgroup['compute_resource_id']
  if !hostgroup['compute_resource_name'].to_s.strip.empty? && compute_resource_id.nil?
    compute_resource= HammerCLIForeman.record_to_common_format(
      HammerCLIForeman.foreman_resource(:compute_resources).call(
          :index, :search => "name = \"#{hostgroup['compute_resource_name']}\""
      )
    )
    compute_resource_id = compute_resource['results'][0]['id'] if compute_resource['results'][0]
  end
  compute_resource_id
end

.get_image_uuid(compute_resource_id, image_id) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/hammer_cli_foreman/compute_resource/utils.rb', line 3

def self.get_image_uuid(compute_resource_id, image_id)
  HammerCLIForeman.record_to_common_format(
    HammerCLIForeman.foreman_resource(:images).call(
      :show, 'compute_resource_id' => compute_resource_id, 'id' => image_id
    )['uuid']
  )
end

.resource_provider(compute_resource_id) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/hammer_cli_foreman/compute_resource/utils.rb', line 35

def self.resource_provider(compute_resource_id)
  HammerCLIForeman.record_to_common_format(
    HammerCLIForeman.foreman_resource(:compute_resources).call(
      :show, 'id' => compute_resource_id
    )
  )['provider'].downcase
end