Commit Graph

26 Commits

Author SHA1 Message Date
Doug Szumski efc6e28edc Fix periodic notifications for webhooks
- Removes the hard-coded magic number of 60 seconds allowing users to
  choose the period that they require.
- Standardise on strings for DictOpt dict keys. When loaded from a config
  file, the DictOpt keys are parsed as strings, which was conflicting with
  the default integer dict keys. This caused the periodic engine to silently
  fail to load when configured via a config file.
- Remove unused variable

Story: 2006783
Task: 37313
Change-Id: Ibd61c45fc1ade37022150d34a5b00c56fdf69814
2019-12-11 11:13:17 +00:00
Jui Chandwaskar d396753a83 Update pep8 checks
* Set max line length to 100
* Clean up code for pep8 checks

Change-Id: Ie00dc204f522fb2112f02f4151ec8a15d5523459
Signed-off-by: Jui Chandwaskar <jchandwaskar@op5.com>
2018-04-11 14:16:27 +02:00
Tomasz Trębski e1a9b9a96a Integrate with oslo.conf and oslo.log
Change upgrades the monasca-notification to leverage
the capabilities of both oslo.log and oslo.conf:

- configuration of logging separated from application settings
- ability to enforce data types for application settings
- ability to use oslo.config-generator capabilities
- automatic configuration parsing done by oslo.cfg

That change will bring it closer to the rest of monasca
components where such transition has happened already.
However, in the rest of monasca, oslo.cfg was partially
or fully implemented whereas monasca-notification has
been relying on YAML based configuration file.

Therefore backward compatybility for such format will
be kept for now.

Story: 2000959
Task: 4093
Task: 4092

Change-Id: Ia75c3b60d0fada854178f21ca5ccb9e6a880f37f
2017-10-20 09:32:11 +02:00
Craig Bryant 5a119df577 Revert Ibd2f64f464af1f501d45c43c0f438f5c74027f6c
Georgia-Anna Farmaki found the import of logging.config to be
required. I see the same thing while testing. I should have
tested instead of just inspecting this code when I approved
Ibd2f64f464af1f501d45c43c0f438f5c74027f6c.

Change-Id: If73576882cf29588d6a4b395b04b3168ff2b84ea
2017-09-05 08:37:47 -06:00
Jenkins 67bcb4318f Merge "Removed redundant import" 2017-08-30 07:29:29 +00:00
Artur Basiak 1ee321bb05 Make code compatible with Python3.5
Add adjustments:
   - read configuration file in binary mode
   - remove extra encoding
   - check if string is binary class and convert it to
     standard string

Change-Id: I5f73b6b0e8b5592539e07fe66debf917540ce24c
Story: 2001124
Task: 4816
2017-08-10 07:12:26 +02:00
Artur Basiak 68fac3b664 Use absolute paths for imports
Absolute paths are required for importing modules.
Python3 cannot find modules if absolute paths are not used.

Change-Id: Id060f269bfb1d17ccad844451678359e664386fa
2017-07-18 11:11:53 +00:00
Johannes Grassler 387096c4d9 Do not log stack traces when out of disk
This commit silences monasca-notifications in situations where
it cannot write to its log file due to ENOSPC by preventing
the logging module from raising exceptions (recommended best
practice for production use).

The old behaviour can be restored by setting the
logging/raise_exceptions setting in the configuration file to
True (defaults to False).

Change-Id: Idbe5bdf56fb280412c34f04de8f2e2f301a7a432
Story: 2001089
Task: 4749
2017-06-28 11:40:36 +02:00
Craig Bryant ef9db22744 Turn on bandit check as part of pep8
Add bandit job as part of pep8 in tox.ini

Had to mark two instances of try except pass as OK so that bandit
will pass

Change-Id: If3b78e9dcbfc65c232a6ba35665430a6463841e6
2017-02-07 12:13:12 -07:00
Nam Nguyen Hoai 6f75509f9c Replace yaml.load() with yaml.safe_load()
Avoid dangerous file parsing and object serialization libraries.
yaml.load is the obvious function to use but it is dangerous[1]
Because yaml.load return Python object may be dangerous if you
receive a YAML document from an untrusted source such as the Internet.
The function yaml.safe_load limits this ability to simple Python
objects like integers or lists.

In addition, Bandit flags yaml.load() as security risk so replace
all occurrences with yaml.safe_load(). Thus I replace yaml.load()
with yaml.safe_load()

[1] https://security.openstack.org/guidelines/dg_avoid-dangerous-input-parsing-libraries.html

Change-Id: I3f1a756e80b617ba1bcf824ef4dee9a27eb6887a
Closes-Bug: #1634265
2017-01-18 09:31:10 +07:00
zhangyanxian 85f9420a7e Fix typo in main.py
TrivialFix

Change-Id: I13b57badc51eb0afc09c81aceeeb1fceb6f6326c
2016-12-16 02:44:37 +00:00
Anh Tran 4ef1c8145f Removed redundant import
Change-Id: Ibd2f64f464af1f501d45c43c0f438f5c74027f6c
2016-09-29 16:28:13 +07:00
Michael James Hoppal 79189ca811 Adding support for periodic notifications
New periodic notification engine that will take a notification send it, and then
place it back onto the periodic notification topic. Once the alarm associated
with the notification has transitioned to a state that is different from the
original state the notification is removed from the queue.

Change-Id: Ie3103a0ec30abcd8dfc53869b1c3135953aabf3a
2016-05-09 08:18:11 -06:00
Hangbo Zhao 19fbca0ba0 Fix the spelling mistake
Here is an obvious misspelling : "proccess_type", which should be "process_type"
This may confuse others.

So I changed all the "proccess_type" to "process_type"

Change-Id: If9844b4141c030a41ce2ab8f9983b760bcd6a9ae
2016-03-08 10:08:47 +00:00
Michael James Hoppal e5ad1f4f49 When receiving a SIGTERM exit with a zero
Change-Id: I05056eeaf9a99433df07c844adc994803286e071
2016-02-05 16:17:15 -07:00
Michael James Hoppal 8f05261e6a Add in HP Copyrights
Change-Id: I54d8bb19e6cd44557cf4757bb1283c8b9821ba35
2016-01-27 12:56:23 -07:00
Tim Kuhlman 89d495e2d9 Exit with the signal number
Change-Id: Ied5201eb2196073fa21ee34058077730278267e9
2015-03-03 14:30:37 -07:00
Joe Keen 9f0e65028f Added retry engine to notification system
Change-Id: Iea1a05c1b7336b9e3e8aeb972e0f9ba1b7f74d69
2015-02-09 11:40:02 -07:00
Joe Keen 3eb169fac3 Notification engine refactored from many processes to one
Squished the notification down to one process in preparation for making
multiple engine instances able to talk to the same topic.

Added HA capabilities to the KafkaConsumer object.

Change-Id: Id4799d690c7caf10ae7ba89c2d4e0aeb76c54375
2015-01-30 11:59:57 -07:00
Joe Keen ebc1ed72d6 Refactored notification engine types
Added more test coverage for email notifications.

Moved notification methods from notification_processor to new types directory.

types/interface.py now automatically records statsd information for configured
types.

Configuration for a type is now optional.  Uncofigured types are not able to
send notifications.  Notifications that come across for unconfigured types
generate a warning.

Email notification type now explicity exits when unable to connect to an SMTP
server.

Change-Id: I213d815965761736eb3680b5e14206ba7bef7e90
2015-01-21 10:07:00 -07:00
Joe Keen 45a2411ebb Added pagerduty support to notification_processor
Refactored the tests to make pagerduty functionality more clear

Change-Id: Ie9616d8629112fc5f1f1576951a3cbe3b99218b0
2015-01-05 17:20:55 -07:00
Joe Keen f0b4f91960 Added timeout to webhook
Added a timeout keyword to requests.post that we use to send webhooks.  Updated
the tests to verify that the webhook will properly time out.

Change-Id: I27140a8c13afcd8f2e30ea1367f0bd9f4944ba36
2014-12-12 15:42:03 -07:00
Tim Kuhlman f85cc90f22 Added mysql ssl support
Change-Id: I274c58e3ebc05845bfb7992e4a2c5b68704f0e22
2014-12-03 16:12:43 -07:00
Tim Kuhlman 5510f79975 Change timeouts so shutdown is quicker
Change-Id: I9403ccfe7b730e58a4f515cbcd3b21832e4e8267
2014-11-18 12:36:25 -07:00
Tim Kuhlman 3d1deca139 Move from using zookeeper to track partition offsets to kafka
With kafka 0.8.1 it is now possible for non-java clients to track
offsets with kafka. Previously the code had built this using zookeeper.
This relies on kafka-python > 0.9.1

Change-Id: Ia42e713cc5d9ca61d8f8df2adc454f1e2579a229
2014-08-28 08:25:47 -06:00
Tim Kuhlman e6e54c6576 Rename to monasca, setup for tox, removed legacy bits
Removed manual tests which are no longer valid with a modern mini-mon
Removed debian creation bits all distribution is with pypi now
Minor pep8 fixes

Change-Id: I1f2fc4d0ad6375f4c39446f9627247945066e4ad
2014-07-16 15:59:00 -06:00