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



22
23
24
25
# 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) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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

Instance Method Details

#request_paramsObject



27
28
29
30
31
32
33
34
35
36
# 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