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



28
29
30
31
# File 'lib/hammer_cli_foreman/hostgroup.rb', line 28

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



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hammer_cli_foreman/hostgroup.rb', line 8

def self.included(base)
  base.option "--puppet-class-ids", "PUPPETCLASS_IDS", _("List of puppetclass ids"),
    :format => HammerCLI::Options::Normalizers::List.new,
    :attribute_name => :option_puppetclass_ids
  base.option "--puppet-classes", "PUPPET_CLASS_NAMES", "",
    :format => HammerCLI::Options::Normalizers::List.new,
    :attribute_name => :option_puppetclass_names
  base.option "--puppet-ca-proxy", "PUPPET_CA_PROXY_NAME", _("Name of puppet CA proxy")
  base.option "--puppet-proxy", "PUPPET_PROXY_NAME",  _("Name of puppet proxy")
  base.option "--parent", "PARENT_NAME",  _("Name of parent hostgroup")
  base.option ["--root-password", "--root-pass"], "ROOT_PASSWORD",  _("Root password"),
              deprecated: { '--root-pass' => _("Use --root-password instead") }
  base.option ["--ask-root-password", "--ask-root-pass"], "ASK_ROOT_PW", "",
              format: HammerCLI::Options::Normalizers::Bool.new,
              deprecated: { '--ask-root-pass' => _("Use --ask-root-password instead") }
  base.option "--subnet6", "SUBNET6_NAME", _("Subnet IPv6 name")

  base.build_options without: %i[root_pass]
end

Instance Method Details

#request_paramsObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/hammer_cli_foreman/hostgroup.rb', line 33

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

  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