Bug 1005426

Summary: Better CLI Parsing and Error reporting
Product: [JBoss] JBoss Operations Network Reporter: Jim Tyrrell <jtyrrell>
Component: CLI, UsabilityAssignee: Thomas Segismont <tsegismo>
Status: CLOSED CURRENTRELEASE QA Contact: Armine Hovsepyan <ahovsepy>
Severity: low Docs Contact:
Priority: medium    
Version: JON 3.1.2CC: ahovsepy, hrupp, jkremser, jshaughn, mfoley, myarboro, tsegismo
Target Milestone: ER05   
Target Release: JON 3.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-11 14:02:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
rhq_cli.log none

Description Jim Tyrrell 2013-09-06 21:58:23 UTC
Description of problem:
A few things around connecting via the CLI could be improved

Version-Release number of selected component (if applicable):
RHQ Enterprise Remote CLI 4.4.0.JON312GA 

Expected results:
1.) When running the command line I should get help with more then just
./rhq-cli.sh --help
rhq-cli.sh [-h] [-u user] [-p pass] [-P] [-s host] [-t port] [-v] [-f file]|[-c command]
RHQ Enterprise Remote CLI 4.4.0.JON312GA


/? and -help and -h could all return the same to match.

2.)  Jim-Tyrrells-MacBook-Pro-2:bin jimtyrrell$ ./rhq-cli.sh -u rhqadmin -p rhqadmin 192.168.1.25
RHQ Enterprise Remote CLI 4.4.0.JON312GA
Login failed: Can not connect http client invoker. Connection refused.
Usage: login username password [host port [transport]]


When running this command with a bad command line parameter passed in I should get a output above of:
rhq-cli.sh [-h] [-u user] [-p pass] [-P] [-s host] [-t port] [-v] [-f file]|[-c command]
Instead of the command line usage once I started the tool

3.)  ./rhq-cli.sh -u rhqadmin -p rhqadmin -s 192.168.1.25
RHQ Enterprise Remote CLI 4.4.0.JON312GA
Remote server version is: 3.1.2.GA (323587d:38819b7)
Login successful

Good job on this working and assuming the 7080 port.

However, ./rhq-cli.shRHQ Enterprise Remote CLI 4.4.0.JON312GA
unconnected$ login rhqadmin rhqadmin 192.168.1.25
Login failed: Can not connect http client invoker. Connection refused.
Usage: login username password [host port [transport]]
This doesn't respect the usual port.

4.)  Also if I pass in a bad port or IP address a better message should occur to m let me now it is not working.  For example running this command:
./rhq-cli.sh -u rhqadmin -p rhqadminRHQ Enterprise Remote CLI 4.4.0.JON312GA
Login failed: Can not connect http client invoker. Connection refused.
Usage: login username password [host port [transport]]

I have no idea which IP address is trying to be connected or if it was the problem or the port.

Comment 1 Jay Shaughnessy 2014-09-03 21:27:27 UTC
Maybe we can make this a bit better for 3.3.0. Setting to ER04.

Comment 2 Thomas Segismont 2014-09-29 15:35:39 UTC
Fixed in master

commit 5fec5167ff76c9081203b538db9098ad47765fe2
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Mon Sep 29 17:34:23 2014 +0200
    
    * Unified behavior for CLI script args and "login" command args
    * Fixed "login" command:
    ** support host definition without port definition
    ** output defaults for host and port
    ** command syntax message
    ** show meaningful error messages:
    *** for port number format
    *** for unsupported transport
    *** for exceptions (use exception cause message instead of meaningless JBoss Remoting exception message)
    
    Also, some code cleanup

Comment 3 Thomas Segismont 2014-09-29 15:41:01 UTC
(In reply to Jim Tyrrell from comment #0)
> Description of problem:
> A few things around connecting via the CLI could be improved
> 
> Version-Release number of selected component (if applicable):
> RHQ Enterprise Remote CLI 4.4.0.JON312GA 
> 
> Expected results:
> 1.) When running the command line I should get help with more then just
> ./rhq-cli.sh --help
> rhq-cli.sh [-h] [-u user] [-p pass] [-P] [-s host] [-t port] [-v] [-f
> file]|[-c command]
> RHQ Enterprise Remote CLI 4.4.0.JON312GA
> 
> 
> /? and -help and -h could all return the same to match.

Could not find a way to do that with Gnu Getopt for Java. Getopt accepts arguments in the short and long form ("-h", "--help"). It's not perfect but already good IMO.

> 
> 2.)  Jim-Tyrrells-MacBook-Pro-2:bin jimtyrrell$ ./rhq-cli.sh -u rhqadmin -p
> rhqadmin 192.168.1.25
> RHQ Enterprise Remote CLI 4.4.0.JON312GA
> Login failed: Can not connect http client invoker. Connection refused.
> Usage: login username password [host port [transport]]
> 
> 
> When running this command with a bad command line parameter passed in I
> should get a output above of:
> rhq-cli.sh [-h] [-u user] [-p pass] [-P] [-s host] [-t port] [-v] [-f
> file]|[-c command]
> Instead of the command line usage once I started the tool
> 

This is considered valid because 192.168.1.25 may be a parameter.

With commit 5fec5167ff76c9081203b538db9098ad47765fe2 you'll see a message telling you that the CLI will log in with the default host (localhost). 

> 3.)  ./rhq-cli.sh -u rhqadmin -p rhqadmin -s 192.168.1.25
> RHQ Enterprise Remote CLI 4.4.0.JON312GA
> Remote server version is: 3.1.2.GA (323587d:38819b7)
> Login successful
> 
> Good job on this working and assuming the 7080 port.
> 
> However, ./rhq-cli.shRHQ Enterprise Remote CLI 4.4.0.JON312GA
> unconnected$ login rhqadmin rhqadmin 192.168.1.25
> Login failed: Can not connect http client invoker. Connection refused.
> Usage: login username password [host port [transport]]
> This doesn't respect the usual port.
> 
> 4.)  Also if I pass in a bad port or IP address a better message should
> occur to m let me now it is not working.  For example running this command:
> ./rhq-cli.sh -u rhqadmin -p rhqadminRHQ Enterprise Remote CLI 4.4.0.JON312GA
> Login failed: Can not connect http client invoker. Connection refused.
> Usage: login username password [host port [transport]]
> 
> I have no idea which IP address is trying to be connected or if it was the
> problem or the port.

Fixed

Comment 4 Jirka Kremser 2014-10-03 12:27:12 UTC
branch:  release/jon3.3.x
link:    https://github.com/rhq-project/rhq/commit/83bb4ab21
time:    2014-10-03 14:26:27 +0200
commit:  83bb4ab218c49505188bed263b3c6423eae65eea
author:  Thomas Segismont - tsegismo@redhat.com
message: Bug 1005426 - Better CLI Parsing and Error reporting

         * Unified behavior for CLI script args and "login" command args
         * Fixed "login" command:
         ** support host definition without port definition
         ** output defaults for host and port
         ** command syntax message
         ** show meaningful error messages:
         *** for port number format
         *** for unsupported transport
         *** for exceptions (use exception cause message instead of
         meaningless JBoss Remoting exception message)

         Also, some code cleanup

         (cherry picked from commit
         5fec5167ff76c9081203b538db9098ad47765fe2) Signed-off-by: Jirka
         Kremser <jkremser@redhat.com>

         Conflicts:
         modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/commands/LoginCommand.java

Comment 5 Simeon Pinder 2014-10-21 20:24:12 UTC
Moving to ON_QA as available to test with the latest brew build:
https://brewweb.devel.redhat.com//buildinfo?buildID=394734

Comment 6 Armine Hovsepyan 2014-10-24 11:57:54 UTC
Created attachment 950358 [details]
rhq_cli.log

Comment 7 Armine Hovsepyan 2014-10-24 11:58:27 UTC
verified in JON 3.3 ER05
rhq-cli.log attached