ViaQ / watches-cli

:watch: CLI tool to pull statistics from Elasticsearch
Apache License 2.0
1 stars 1 forks source link

Validate URL parameter value #30

Open lukas-vlcek opened 7 years ago

lukas-vlcek commented 7 years ago

Add validation of --url parameter value.

For example, when using --url=http://10.40.2.198.9200 (notice use of . instead : before port #) the exception does not help much in troubleshooting:

ERROR:root:
Traceback (most recent call last):
  File "/home/lvlcek/projects/ViaQ/watches-cli/watches/cli.py", line 134, in execute
    command.run()
  File "/home/lvlcek/projects/ViaQ/watches-cli/watches/commands/base.py", line 29, in run
    data = self.getData()
  File "/home/lvlcek/projects/ViaQ/watches-cli/watches/commands/cluster_health.py", line 17, in getData
    return self.es.cluster.health(**args)
  File "/usr/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 71, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/usr/lib/python2.7/site-packages/elasticsearch/client/cluster.py", line 33, in health
    'health', index), params=params)
  File "/usr/lib/python2.7/site-packages/elasticsearch/transport.py", line 327, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/usr/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 120, in perform_request
    raise ConnectionError('N/A', str(e), e)
ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f3359416cd0>: Failed to establish a new connection: [Errno -5] No address associated with hostname) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f3359416cd0>: Failed to establish a new connection: [Errno -5] No address associated with hostname)