Class/Module Index [+]

Quicksearch

HammerCLIForeman::OperatingSystem::SetOsDefaultTemplate

Public Instance Methods

base_action_params() click to toggle source
# File lib/hammer_cli_foreman/operating_system.rb, line 114
def base_action_params
  {"operatingsystem_id" => option_id}
end
create_default_template(tpl_kind_name) click to toggle source
# File lib/hammer_cli_foreman/operating_system.rb, line 135
def create_default_template(tpl_kind_name)
  params = {
    "os_default_template" => {
      "config_template_id" => option_config_template_id,
      "template_kind_name" => tpl_kind_name
    }
  }.merge base_action_params

  HammerCLIForeman.record_to_common_format(resource.call(:create, params))
end
execute() click to toggle source
# File lib/hammer_cli_foreman/operating_system.rb, line 146
def execute
  tpl_kind_name = option_type_name
  tpl = template_exist? tpl_kind_name
  if tpl
    update_default_template tpl
    print_message(success_message, tpl) if success_message
  else
    tpl = create_default_template tpl_kind_name
    print_message(success_message, tpl) if success_message
  end
  HammerCLI::EX_OK
end
option_type_name() click to toggle source
# File lib/hammer_cli_foreman/operating_system.rb, line 108
def option_type_name
  tpl = HammerCLIForeman.collection_to_common_format(
    HammerCLIForeman.foreman_resource!(:config_templates).call(:show, {"id" => option_config_template_id}))
  tpl[0]["template_kind_name"]
end
template_exist?(tpl_kind_name) click to toggle source
# File lib/hammer_cli_foreman/operating_system.rb, line 118
def template_exist?(tpl_kind_name)
  templates = HammerCLIForeman.collection_to_common_format(resource.call(:index, base_action_params))
  templates.find { |p| p["template_kind_name"] == tpl_kind_name}
end
update_default_template(tpl) click to toggle source
# File lib/hammer_cli_foreman/operating_system.rb, line 123
def update_default_template(tpl)
  params = {
    "id" => tpl["id"],
    "os_default_template" => {
      "config_template_id" => option_config_template_id,
      "template_kind_id" => tpl["template_kind_id"]
    }
  }.merge base_action_params

  HammerCLIForeman.record_to_common_format(resource.call(:update, params))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.