Class: HammerCLIForeman::OperatingSystem::DeleteOsDefaultTemplate

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

Instance Method Summary collapse

Methods inherited from Command

build_options, connection_name, create_option_builder, #customized_options, #dependency_resolver, dependency_resolver, #get_identifier, #get_resource_id, #request_params, #resolver, resolver, resource_config, resource_name_mapping, searchables, #searchables, #send_request

Instance Method Details

#base_action_paramsObject



229
230
231
# File 'lib/hammer_cli_foreman/operating_system.rb', line 229

def base_action_params
  {"operatingsystem_id" => option_id}
end

#executeObject



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/hammer_cli_foreman/operating_system.rb', line 212

def execute
  templates = HammerCLIForeman.collection_to_common_format(resource.call(:index, base_action_params))
  tpl = templates.find { |p| p["template_kind_name"] == option_type }

  if tpl.nil?
    raise RuntimeError.new(_("Default template of type %s not found") % option_type)
  end

  params = {
    "id" => tpl["id"]
  }.merge base_action_params

  HammerCLIForeman.record_to_common_format(resource.call(:destroy, params))
  print_message success_message if success_message
  HammerCLI::EX_OK
end