Bug 1005426 - Better CLI Parsing and Error reporting
Better CLI Parsing and Error reporting
Status: CLOSED CURRENTRELEASE
Product: JBoss Operations Network
Classification: JBoss
Component: CLI, Usability (Show other bugs)
JON 3.1.2
Unspecified Unspecified
medium Severity low
: ER05
: JON 3.3.0
Assigned To: Thomas Segismont
Armine Hovsepyan
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-06 17:58 EDT by Jim Tyrrell
Modified: 2015-09-02 20:01 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-12-11 09:02:24 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
rhq_cli.log (1.80 KB, text/plain)
2014-10-24 07:57 EDT, Armine Hovsepyan
no flags Details

  None (edit)
Description Jim Tyrrell 2013-09-06 17:58:23 EDT
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 17:27:27 EDT
Maybe we can make this a bit better for 3.3.0. Setting to ER04.
Comment 2 Thomas Segismont 2014-09-29 11:35:39 EDT
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 11:41:01 EDT
(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 08:27:12 EDT
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 16:24:12 EDT
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 07:57:54 EDT
Created attachment 950358 [details]
rhq_cli.log
Comment 7 Armine Hovsepyan 2014-10-24 07:58:27 EDT
verified in JON 3.3 ER05
rhq-cli.log attached

Note You need to log in before you can comment on or make changes to this bug.