Module: HammerCLIForeman::HostgroupUpdateCreateCommons

Included in:
HammerCLIForeman::Hostgroup::CreateCommand, HammerCLIForeman::Hostgroup::UpdateCommand
Defined in:
lib/hammer_cli_foreman/hostgroup.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ask_passwordObject



15
16
17
18
# File 'lib/hammer_cli_foreman/hostgroup.rb', line 15

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) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/hammer_cli_foreman/hostgroup.rb', line 5

def self.included(base)
  base.option "--parent", "PARENT_NAME",  _("Name of parent hostgroup")
  base.option ["--root-password"], "ROOT_PASSWORD",  _("Root password")
  base.option ["--ask-root-password", "--ask-root-pass"], "ASK_ROOT_PW", "",
              format: HammerCLI::Options::Normalizers::Bool.new
  base.option "--subnet6", "SUBNET6_NAME", _("Subnet IPv6 name")

  base.build_options without: %i[root_pass]
end

Instance Method Details

#request_paramsObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/hammer_cli_foreman/hostgroup.rb', line 20

def request_params
  params = super
  params['hostgroup']["parent_id"] ||= resolver.hostgroup_id('option_name' => option_parent) if option_parent

  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