module HammerCLIForeman::HostgroupUpdateCreateCommons

Public Class Methods

ask_password() click to toggle source
# File lib/hammer_cli_foreman/hostgroup.rb, line 22
def self.ask_password
  prompt = _("Enter the root password for the host group:") + " "
  HammerCLI.interactive_output.ask(prompt) { |q| q.echo = false }
end
included(base) click to toggle source
# File lib/hammer_cli_foreman/hostgroup.rb, line 5
def self.included(base)
  base.option '--root-password', 'ROOT_PASSWORD', _('Root password')
  base.option '--ask-root-password', 'ASK_ROOT_PW', '',
              format: HammerCLI::Options::Normalizers::Bool.new

  base.build_options without: %i[root_pass]

  base.option_family associate: 'subnet6' do
    child '--subnet6', 'SUBNET6_NAME', _('Subnet IPv6 name')
  end

  base.option_family associate: 'parent' do
    child '--parent', 'PARENT_NAME', _('Name of parent hostgroup')
    child '--parent-title', 'PARENT_TITLE', _('Title of parent hostgroup')
  end
end

Public Instance Methods

request_params() click to toggle source
Calls superclass method
# File lib/hammer_cli_foreman/hostgroup.rb, line 27
def request_params
  params = super
  params['hostgroup']['parent_id'] ||= resolver.hostgroup_id('option_name' => option_parent) if option_parent
  params['hostgroup']['parent_id'] ||= resolver.hostgroup_id('option_title' => option_parent_title) if option_parent_title
  params['hostgroup']['root_pass'] = option_root_password if option_root_password
  params['hostgroup']['root_pass'] = HammerCLIForeman::HostgroupUpdateCreateCommons::ask_password if option_ask_root_password

  params['hostgroup']['subnet6_id'] = resolver.subnet_id('option_name' => option_subnet6) if option_subnet6
  params
end

Private Instance Methods

proxy_id(name) click to toggle source
# File lib/hammer_cli_foreman/hostgroup.rb, line 40
def proxy_id(name)
  resolver.smart_proxy_id('option_name' => name) if name
end