Giter VIP home page Giter VIP logo

stackstorm-msexchange's Introduction

Build Status

Microsoft Exchange Integration Pack

This pack provides Microsoft Exchange integration to perform simple searches on an Exchange user.

Exchange Server 2010, 2013 and 2016 as well as Office 365 hosted Exchange accounts.

Actions

  • do_attachment_directory_maintenance - Performance maintenance on server directory in which email file attachments are saved.
  • get_calendar_items - Get a list of calendar items within a date range
  • get_folder - Get information about a folder (mail, contact, meta)
  • list_folders - List all folders or subfolders within a folder
  • save_attachments - Save file attachments on email messages to server directory.
  • search_items - Search for items by subject and/or date within a folder (default folder Inbox)
  • send_email - Send an email

Rules

  • attachment_directory_maintenance - Runs maintenance (storage usage) via do_attachment_directory_maintenance action on server directory in which file attachments are saved when triggered by associated sensor.

Sensors

  • attachment_directory_maintenance_sensor - Runs maintenance periodically (default daily).
  • item_sensor - Monitors the configured folder (Inbox by default) for new items and sends a exchange_new_item trigger when one is received

Configuration

Configuration should contain the primary SMTP address (for knowing what user to send email as), the username and password. Also, for searches using date ranges, the time zone will be normalized to the one specified.

---
primary_smtp_address: "[email protected]"
username: "[email protected]"
password: "B0bsPassword!"
timezone: "Europe/London"

Where autodiscovery is not available, the EWS host (typically the webmail host address) can be used.

---
primary_smtp_address: "[email protected]"
username: "[email protected]"
password: "B0bsPassword!"
server: ourcompany-webmail.company.com
timezone: "Europe/London"

The sensor folder for the new item sensor can also be configured

---
primary_smtp_address: "[email protected]"
username: "[email protected]"
password: "B0bsPassword!"
timezone: "Europe/London"
sensor_folder: "My folder to monitor"

Email Attachment Configuration

  • attachment_directory: Fully-qualified server path name used to store attachments. Must be readable and writeable by Stackstorm. Defaults to "/opt/stackstorm/packs/msexchange/attachments".
  • attachment_folder_maximum_size: Maximum storage space in MB (default is 50MB) alloted to attachment_directory. Pack maintenance process (see below) manages this.
  • attachment_days_to_keep: Maximum number of days to keep saved attachments (default is 7 days). Also, managed by pack maintenance process.

stackstorm-msexchange's People

Contributors

amanda11 avatar blag avatar cognifloyd avatar enykeev avatar jamesdreid avatar kami avatar lindsayhill avatar minsis avatar nmaludy avatar tonybaloney avatar zwiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stackstorm-msexchange's Issues

The get_folder_by_name() method is deprecated

When I do sensor troubleshooting

$ sudo /opt/stackstorm/st2/bin/st2sensorcontainer --config-file=/etc/st2/st2.conf --sensor-ref=msexchange.ItemSensor

I can see the error below

2018-02-21 15:40:29,548 ERROR [-] /opt/stackstorm/virtualenvs/msexchange/lib/python2.7/site-packages/exchangelib/folders.py:151: UserWarning: The get_folder_by_name() method is deprecated. Use "[f for f in self.walk() if f.name == name]" or "some_folder / 'Sub Folder'" instead, to find folders by name.

sensor 'Found 0 items in Messages'

Despite action st2 run msexchange.search_items folder=Inbox finding new item in Inbox, sensor msexchange.ItemSensor is not finding it. See below , I added time and folder to log:

2018-02-24 12:48:58,107 INFO [-] Found 0 items in Messages (Inbox) at 2018-02-24 12:48:58.031213-05:00
2018-02-24 12:49:03,245 INFO [-] Found 0 items in Messages (Inbox) at 2018-02-24 12:49:03.156893-05:00
2018-02-24 12:49:08,395 INFO [-] Found 0 items in Messages (Inbox) at 2018-02-24 12:49:08.297001-05:00

Not sure if it is important but I can see one error

$ sudo /opt/stackstorm/st2/bin/st2sensorcontainer --config-file=/etc/st2/st2.conf --sensor-ref=msexchange.ItemSensor
2018-02-24 15:08:22,306 DEBUG [-] Using config files: /etc/st2/st2.conf
...
2018-02-24 15:08:23,835 ERROR [-] Exception in thread Thread-17:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 325, in _handle_workers
    while thread._state == RUN or (pool._cache and thread._state != TERMINATE):
AttributeError: '_MainThread' object has no attribute '_state'

2018-02-24 15:08:23,836 ERROR [-]
2018-02-24 15:09:50,719 INFO [-] Running sensor in passive mode
2018-02-24 15:09:50,729 AUDIT [-] Access granted to "sensor_service" with the token set to expire at "2018-02-25T20:09:50.726292Z". (username='sensor_service',token_expiration='2018-02-25T20:09:50.726292Z')
2018-02-24 15:09:50,730 WARNING [-] "auth.api_url" configuration option is not configured

'Configuration' object has no attribute '__getitem__'

When running $ st2 run msexchange.search_items I am getting error below:

..
id: 5a8dce1c5014005a99230f52
status: failed
parameters: None
result:
  exit_code: 1
  result: None
  stderr: "Traceback (most recent call last):\n  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py\", line 275, in <module>\n    obj.run()\n  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py\", line 162, in run\n    action = self._get_action_instance()\n  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py\", line 240, in _get_action_instance\n    action_service=action_service)\n  File \"/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/runners/utils.py\", line 98, in get_action_class_instance\n    action_instance = action_cls(**kwargs)\n  File \"/opt/stackstorm/packs/msexchange/actions/base/action.py\", line 51, in __init__\n    primary_smtp_address=config['primary_smtp_address'],\nTypeError: 'Configuration' object has no attribute '__getitem__'\n"
  stdout: ''

Complaining about primary_smtp_address which is I think fine

$ cat /opt/stackstorm/configs/msexchange.yaml
---
primary_smtp_address: "[email protected]"
username: "[email protected]"
password: "password"
timezone: "America/New_York"
server: mailserver.common.com

exchangelib needs to be updated

exchangelib is grossly out of date. This pack will only install 1.10.0 as the latest version which is from 2017
https://github.com/ecederstrand/exchangelib/releases/tag/v1.10.0

The latest version is now 4.6.0
https://github.com/ecederstrand/exchangelib/releases/tag/v4.6.0

As a preliminary check get_folder_by_name has been deprecated and removed as of 1.11.0
https://github.com/ecederstrand/exchangelib/blob/0f346094e136ce9764c1486a144db0dcee80e414/CHANGELOG.md#1110

Sensor not detecting new items in Inbox

The issue is similar to #8 but I'm seeing the same issue with the polling sensor generating the INFO [-] Found 0 items, yet I can run st2 run msexchange.search_items folder=Inbox and have it finding new items in the Inbox, the sensor msexchange.ItemSensor is not finding/triggering on any new items.

2018-07-31 12:40:54,026 DEBUG [-] Using config files: /etc/st2/st2.conf
2018-07-31 12:40:54,026 DEBUG [-] Using logging config: /etc/st2/logging.sensorcontainer.conf
2018-07-31 12:40:54,030 INFO [-] Connecting to database "st2" @ "127.0.0.1:27017" as user `"stackstorm".
2018-07-31 12:40:54,035 INFO [-] Successfully connected to database "st2" @ "127.0.0.1:27017" as user "stackstorm".
2018-07-31 12:40:54,276 INFO [-] Running in single sensor mode, using a single sensor partitioner...
2018-07-31 12:40:54,280 INFO [-] Setting up container to run 1 sensors.
2018-07-31 12:40:54,281 INFO [-]        Sensors list - [u'msexchange.ItemSensor'].
2018-07-31 12:40:54,281 INFO [-] (PID:7460) SensorContainer started.
2018-07-31 12:40:54,283 INFO [-] Running sensor msexchange.ItemSensor
2018-07-31 12:40:54,289 AUDIT [-] Access granted to "sensors_container" with the token set to expire at "2018-08-01T17:40:54.286474Z". (username='sensors_container',token_expiration='2018-08-01T17:40:54.286474Z')
2018-07-31 12:40:54,289 WARNING [-] "auth.api_url" configuration option is not configured
2018-07-31 12:40:54,344 INFO [-] Connected to amqp://guest:**@127.0.0.1:5672//
2018-07-31 12:40:54,370 INFO [-] Sensor msexchange.ItemSensor started
2018-07-31 12:40:55,766 INFO [-] Found config for sensor "ItemSensor"
2018-07-31 12:40:55,794 INFO [-] Watcher started
2018-07-31 12:40:55,795 INFO [-] Running sensor initialization code
2018-07-31 12:40:55,818 INFO [-] Connected to amqp://guest:**@127.0.0.1:5672//
2018-07-31 12:40:56,310 INFO [-] Running sensor in passive mode
2018-07-31 12:40:56,312 WARNING [-] "auth.api_url" configuration option is not configured
2018-07-31 12:40:56,319 AUDIT [-] Access granted to "sensor_service" with the token set to expire at "2018-08-01T17:40:56.316871Z". (username='sensor_service',token_expiration='2018-08-01T17:40:56.316871Z')
2018-07-31 12:40:56,449 INFO [-] Found 0 items
2018-07-31 12:41:01,622 INFO [-] Found 0 items

I also validated by using st2 trigger-instance list and found that there was no trigger generated.

The ST2 version is st2 2.8.1, on Python 2.7.12

Support for OAuth over username/password

Lots of companies, including ours, wont allow a basic username/password login for an Office365 account. Instead there's a usecase here for using client_id and client_secret for authenticating. If using exhangelib it should be able to be used using OAuth method: https://ecederstrand.github.io/exchangelib/#oauth-authentication.

I haven't tired doing this with exhangelib, but in the past I've used https://pypi.org/project/Office365-REST-Python-Client/ library which is easy to use when needing to use client credentials instead of username/password.

If I ever get some time in the next 10 years I'll try to contribute something.

Move or add sensor_folder to sensor parameters

sensor_folder should be configured at the sensor parameter level so you can monitor specific folders for specific a trigger.

Maybe it be left in the config file as a default but then allow the override in the sensor's parameters.

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.