rax-maas / rackspace-monitoring-cli

Command line utility for Rackspace Cloud Monitoring (MaaS).
49 stars 18 forks source link

Exit 1 when CLI encounters stack trace #78

Closed mattt416 closed 9 years ago

mattt416 commented 9 years ago

The raxmon-* CLI tools do not set exit code when you hit an exception. This commit does a sys.exist(1) when an exception is encountered.

mattt416 commented 9 years ago
root@jenk-heat-313-node1:~# raxmon-checks-create --entity-id en4dkU0joh --label lb_api_check_cinder --type remote.http --details url=http://<redacted>:8776 --monitoring-zones "mzdfw,mziad,mzord,mzlon,mzhkg" --target-alias public0_v4 --period 60 --timeout 30; echo $?
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/raxmon_cli/common.py", line 130, in run_action
    callback(instance, options, args, done)
  File "/usr/local/bin/raxmon-checks-create", line 53, in callback
    why=options.why)
  File "/usr/local/lib/python2.7/dist-packages/rackspace_monitoring/drivers/rackspace.py", line 743, in create_check
    data=data, coerce=self.get_check, headers=headers)
  File "/usr/local/lib/python2.7/dist-packages/rackspace_monitoring/drivers/rackspace.py", line 301, in _create
    headers=headers)
  File "/usr/local/lib/python2.7/dist-packages/rackspace_monitoring/drivers/rackspace.py", line 152, in request
    raw=raw
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 577, in request
    return super(OpenStackBaseConnection, self).request(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/base.py", line 683, in request
    response = responseCls(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/libcloud/common/base.py", line 116, in __init__
    raise Exception(self.parse_error())
  File "/usr/local/lib/python2.7/dist-packages/rackspace_monitoring/drivers/rackspace.py", line 107, in parse_error
    raise error
RackspaceMonitoringValidationError: <ValidationError type=badRequest, message="Validation error", details=en4dkU0joh: no such alias public0_v4>
0
root@jenk-heat-313-node1:~#
robert-chiniquy commented 9 years ago

Nice find.