Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #11236 - add root_pass option #189

Merged
merged 1 commit into from Aug 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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