Skip to content

Commit

Permalink
fixes #11236 - add root_pass option
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomizadok committed Aug 18, 2015
1 parent d3da582 commit 49cdd33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/hammer_cli_foreman/host.rb
Expand Up @@ -59,7 +59,7 @@ def self.included(base)
end

def self.ask_password
prompt = "Enter the root password for the host: "
prompt = _("Enter the root password for the host:")
ask(prompt) {|q| q.echo = false}
end

Expand Down
10 changes: 10 additions & 0 deletions lib/hammer_cli_foreman/hostgroup.rb
Expand Up @@ -14,6 +14,14 @@ def self.included(base)
base.option "--parent", "PARENT_NAME", _("Name of parent hostgroup")
base.option "--puppet-classes", "PUPPET_CLASS_NAMES", "",
:format => HammerCLI::Options::Normalizers::List.new
base.option "--root-pass", "ROOT_PASSWORD", _("Root password")
base.option "--ask-root-pass", "ASK_ROOT_PW", "",
:format => HammerCLI::Options::Normalizers::Bool.new
end

def self.ask_password
prompt = _("Enter the root password for the host group:")
ask(prompt) {|q| q.echo = false}
end

def request_params
Expand All @@ -22,6 +30,8 @@ def request_params
params['hostgroup']["puppet_proxy_id"] ||= proxy_id(option_puppet_proxy)
params['hostgroup']["puppet_ca_proxy_id"] ||= proxy_id(option_puppet_ca_proxy)
params['hostgroup']['puppetclass_ids'] = option_puppet_class_ids || puppet_class_ids(option_puppet_classes)
params['hostgroup']['root_pass'] = option_root_pass if option_root_pass
params['hostgroup']['root_pass'] = HammerCLIForeman::HostgroupUpdateCreateCommons::ask_password if option_ask_root_pass
params
end

Expand Down
4 changes: 2 additions & 2 deletions test/unit/hostgroup_test.rb
Expand Up @@ -64,7 +64,7 @@
context "parameters" do
it_should_accept "name, parent_id, environment_id, architecture_id, domain_id, puppet_proxy_id, operatingsystem_id and more",
["--name=hostgroup", "--parent-id=1", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1",
"--operatingsystem-id=1", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids=1,2']
"--operatingsystem-id=1", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids=1,2', '--root-pass=foreman']
# it_should_fail_with "name or id missing",
# ["--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1"]
# TODO: temporarily disabled, parameters are checked in the api
Expand All @@ -78,7 +78,7 @@
context "parameters" do
it_should_accept "name, parent_id, environment_id, architecture_id, domain_id, puppet_proxy_id, operatingsystem_id and more",
["--id=1 --name=hostgroup2 --title=default/hostgroup2", "--parent-id=1", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1",
"--operatingsystem-id=1", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids=1,2']
"--operatingsystem-id=1", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids=1,2', '--root-pass=foreman']
# it_should_fail_with "no params", []
# it_should_fail_with "id missing", ["--name=host2"]
# TODO: temporarily disabled, parameters are checked in the id resolver
Expand Down

0 comments on commit 49cdd33

Please sign in to comment.