Sha256: 907603e7fcd3b2401f8a07a3d287d1c377f2c9a809b5cd77e8a2d1389720967b

Contents?: true

Size: 1.57 KB

Versions: 24

Compression:

Stored size: 1.57 KB

Contents

module HammerCLIForeman
  module ComputeResources
    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

    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

    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

    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
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
hammer_cli_foreman-3.5.1 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-3.6.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-3.5.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-3.4.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-3.3.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-3.2.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.5.2 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-3.1.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-3.0.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.5.1 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.5.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.3.2 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.4.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.3.1 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.3.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.1.3 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.2.0 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.1.2 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.1.1 lib/hammer_cli_foreman/compute_resource/utils.rb
hammer_cli_foreman-2.1.0 lib/hammer_cli_foreman/compute_resource/utils.rb