Bug 1162263

Summary: ambari_config.sh does not accept args in different order
Product: [Red Hat Storage] Red Hat Gluster Storage Reporter: Martin Kudlej <mkudlej>
Component: rhs-hadoop-installAssignee: Jeff Vance <jvance>
Status: CLOSED WONTFIX QA Contact: BigData QE <bigdata-qe-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rhgs-3.0CC: bchilds, eboyd, matt, nlevinki
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-10 17:41:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Martin Kudlej 2014-11-10 16:55:06 UTC
Description of problem:
I've read script help message:
configs.sh [-u userId] [-p password] [-port port] ...
and I see there just tiny bug where configs.sh should be changed to real name of script. I recommend to use $0 param.

And I've tried to do permutations of first 3 params because from that help message I expect that I can do that.
Just this permutation passed:
-u admin -p admin -port 8080
USERID=admin
PASSWORD=admin
PORT=:8080
########## Performing 'GET' on (Site:core-site, Tag:version1415365175001)

Others return help message:
-u admin -port 8080 -p admin
-p admin -u admin -port 8080
-p admin -port 8080 -u admin
-port 8080 -p admin -u admin
-port 8080 -u admin -p admin


I recommend to use getopt utility to parse arguments.


Version-Release number of selected component (if applicable):
rhs-hadoop-install-2_29-1

How reproducible:
100%

Actual results:
Script cannot handle permutations of arguments.

Expected results:
All supported scripts will handle permutations of args where it is possible according help message.

Additional info:
perm.sh:
#!/bin/bash

for i in `cat x.txt`; do
  par="";
  for c in `echo $i | sed -e 's/\(.\)/\1\n/g'`; do
    if [ $c == 'a' ]; then
      par="$par -u admin"
    fi
    if [ $c == 'b' ]; then
      par="$par -p admin"
    fi
    if [ $c == 'c' ]; then
      par="$par -port 8080"
    fi
  done;
  echo $par;
  ./ambari_config.sh $par get _hostname_ TestCluster core-site;
done

x.txt:
file with permutations

perm.awk for creating permutations:
function permute(s, st,     i, j, n, tmp) {
    n = split(s, item,//)
    if (st > n) {  print s; return }
    for (i=st; i<=n; i++) {
        if (i != st) {
         tmp = item[st]; item[st] = item[i]; item[i] = tmp
         nextstr = item[1]
         for (j=2; j<=n; j++) nextstr = nextstr delim item[j]
        }else {
          nextstr = s
        }
       permute(nextstr, st+1)
       n = split(s, item, //)
   }
}
{ permute($0,1) }

Comment 1 Martin Kudlej 2014-11-10 16:57:08 UTC
There is another subbug when user miss one argument:
"./ambari_config.sh -p admin -p 8080 get" ... (-u admin is missed)

Comment 4 Martin Kudlej 2014-11-11 09:18:51 UTC
I haven't known that this script is deprecated. I think in this case wontfix is OK and I've filed BZ for removing deprecated scripts from package. I think errata problems cannot be solved like this. Please see bug 1162527