Class: HammerCLIForeman::ComputeAttribute

Inherits:
Command
  • Object
show all
Defined in:
lib/hammer_cli_foreman/compute_attribute.rb

Defined Under Namespace

Classes: AddInterface, AddVolume, Create, RemoveInterface, RemoveVolume, Update, UpdateInterface, UpdateVolume

Class Method Summary collapse

Methods inherited from Command

alias_name_for_resource, build_options, connection_name, create_option_builder, #customized_options, #dependency_resolver, dependency_resolver, #exception_handler_class, #get_identifier, #get_resource_id, #get_resource_ids, #request_params, resolver, #resolver, resource_alias_name_mapping, resource_config, resource_name_mapping, #searchables, searchables, #send_request, #transform_format

Class Method Details

.attribute_hash(attribute_list) ⇒ Object



20
21
22
# File 'lib/hammer_cli_foreman/compute_attribute.rb', line 20

def self.attribute_hash(attribute_list)
  attribute_list.size.times.map { |idx| idx.to_s }.zip(attribute_list).to_h
end

.get_params(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/hammer_cli_foreman/compute_attribute.rb', line 9

def self.get_params(options)
  params = {}
  params['compute_attribute'] = {}
  profile = HammerCLIForeman.record_to_common_format(
      HammerCLIForeman.foreman_resource(:compute_profiles).call(:show, 'id' => options['option_compute_profile_id'] )
  )
  params['compute_attribute'] = profile['compute_attributes'].select { |hash| hash['compute_resource_id'] == options['option_compute_resource_id']}[0] || {}
  params['compute_attribute'].delete('attributes') if params['compute_attribute']['attributes']
  params
end