Git Product home page Git Product logo

python-argusclient's Issues

Deleting notifications fails with AttributeError: 'tuple' object has no attribute 'argus_id'

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/pkuznetsov/sfstore/moncfg/moncfg/__main__.py", line 87, in <module>
    main()
  File "/Users/pkuznetsov/sfstore/moncfg/moncfg/__main__.py", line 65, in main
    services[service].push(config)
  File "/Users/pkuznetsov/sfstore/moncfg/moncfg/argus/arguscfg.py", line 124, in push
    self._delete_notification(argus_alert, argus_notification)
  File "/Users/pkuznetsov/sfstore/moncfg/moncfg/argus/arguscfg.py", line 205, in _delete_notification
    self._call_argus(alert.notifications.delete, notification.argus_id)
  File "/Users/pkuznetsov/sfstore/moncfg/moncfg/argus/arguscfg.py", line 260, in _call_argus
    return argus(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/argusclient-0.2dev_r0-py2.7.egg/argusclient/client.py", line 550, in delete
AttributeError: 'tuple' object has no attribute 'argus_id'

Alerts with multiple notifications and triggers is not handled correctly

Currently, most of the code is written such that it works only with a single notification or trigger. When there are multiple notifications or triggers, the interface is buggy as alert.notifications and alert.trigger code gets set to a service object instead of a list and so the client code can't even access them.

argus.alerts.update returns incomplete object

    @mock.patch('requests.Session.put', return_value=MockResponse(json.dumps(alert_D), 200))
    def testUpdateAlert(self, mockPut):
        res = self.argus.alerts.update(testId, Alert.from_dict(alert_D))
        self.assertTrue(isinstance(self.argus.alerts.get(testId), Alert))
        self.assertEquals(self.argus.alerts.get(testId).to_dict(), alert_D)
        self.assertIn((os.path.join(endpoint, "alerts", str(testId)),), tuple(mockPut.call_args))

        // The following fails:
        for method in ['get', 'add', 'update', 'delete']:
            self.assertTrue(hasattr(res.triggers, method), msg='no alert.triggers.{}()'.format(method))
            self.assertTrue(hasattr(res.notifications, method), msg='no alert.notifications.{}()'.format(method))

HTTP not found on Alert Obj

I faced this in the alert object but I suspect it occurs across all objects.

Issue: Per documentation, the check to see if alert exists only works if the alert exists.
If it doesn't, it throws httplib.NOT_FOUND(404) exception from here. Traceback below.

All actions including Alert creation/modification should be idempotent. So DELETE and PUT is the way to go. We just need a better mechanism for handling the error.
May be instead of raise, just catch the exception and gently let the calling function know? Thoughts?

Exception:

Traceback (most recent call last):
  File "alert.py", line 32, in <module>
    alertobj = argus.alerts.get_user_alert(user, alert_name, shared=False)
  File "client.py", line 473, in get_user_alert
    alerts = self.argus._request("get", "alerts/meta", params=dict(alertname=alertName, ownername=ownerName, shared=shared))
  File "client.py", line 555, in with_retry
    return f(*args, **kwargs)
  File "client.py", line 588, in with_auth_token
    return f(*args, **kwargs)
  File "client.py", line 708, in _request
    return self._request_no_auth(method, path, params, dataObj, encCls, decCls)
  File "client.py", line 730, in _request_no_auth
    res = check_success(resp, decCls)
  File "client.py", line 744, in check_success
    raise ArgusException("Object not found at endpoint: %s message: %s" % (resp.request.url, resp.text))
argusclient.client.ArgusException: Object not found at endpoint: 
https://<argus_url>/argusws/alerts/meta?shared=False&ownername=<owner_name>&alertname=<alert_name> 
message: {"status":404,"message":"Not Found"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.