Giter VIP home page Giter VIP logo

Comments (16)

LindsayHill avatar LindsayHill commented on September 24, 2024 1

That config looks good. I think the problem is in the code here:

40             if autodiscover:
 41                 self.account = Account(
 42                     primary_smtp_address=config['primary_smtp_address'],
 43                     credentials=self._credentials,
 44                     autodiscover=autodiscover,
 45                     access_type=DELEGATE)
 46             else:
 47                 config = Configuration(
 48                     server=server,
 49                     credentials=self._credentials)
 50                 self.account = Account(
 51                     primary_smtp_address=config['primary_smtp_address'],
 52                     config=config,
 53                     autodiscover=False,
 54                     access_type=DELEGATE)

The problem starts at line 41. It is re-defining config, which was originally an st2 config object. It redefines it as a Configuration object from exchangelib. Then on line 51 it tries to retrieve an item from the original config object, but that no longer exists.

If you have auto discovery enabled, it never goes down this code path, which is probably why other people have not hit this issue (since most people have autodiscover in their Exchange environments).

You could probably do something like this:

--- a/actions/base/action.py
+++ b/actions/base/action.py
@@ -44,12 +44,12 @@ class BaseExchangeAction(Action):
                     autodiscover=autodiscover,
                     access_type=DELEGATE)
             else:
-                config = Configuration(
+                ms_config = Configuration(
                     server=server,
                     credentials=self._credentials)
                 self.account = Account(
                     primary_smtp_address=config['primary_smtp_address'],
-                    config=config,
+                    config=ms_config,
                     autodiscover=False,
                     access_type=DELEGATE)
             self._store_cache_configuration()

Can you try making that change locally and see if that helps?

from stackstorm-msexchange.

LindsayHill avatar LindsayHill commented on September 24, 2024 1

Also, please open a separate issue about that get_folder_by_name() deprecation warning. That is something else, related to https://github.com/ecederstrand/exchangelib/blob/master/CHANGELOG.rst#1102

from stackstorm-msexchange.

irom77 avatar irom77 commented on September 24, 2024 1

Bingo ! That one below worked ...

st2 run msexchange.search_items folder=Inbox

Much appreciated

from stackstorm-msexchange.

LindsayHill avatar LindsayHill commented on September 24, 2024

Double-checking: have you loaded that configuration with sudo st2ctl reload --register-configs?

from stackstorm-msexchange.

irom77 avatar irom77 commented on September 24, 2024

I did, also when I do 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.

from stackstorm-msexchange.

LindsayHill avatar LindsayHill commented on September 24, 2024

So after reloading the config, actions are still failing with that same TypeError?

Can you try connecting to mongoDB (mongo -u stackstorm -p <password> st2), and running a query like this:

db.config_d_b.find({"pack":"msexchange"})

Mask out any sensitive results

from stackstorm-msexchange.

irom77 avatar irom77 commented on September 24, 2024

Correct , same Typeerror after reload --register-configs, what's the default password to mongo ?

from stackstorm-msexchange.

LindsayHill avatar LindsayHill commented on September 24, 2024

There is no default password. They are randomly generated if you use the install script. Check your st2.conf to see what your system is using

from stackstorm-msexchange.

irom77 avatar irom77 commented on September 24, 2024

oh, here it is

> db.config_d_b.find({"pack":"msexchange"})
{ "_id" : ObjectId("5a8dcbd950140028874da756"), "pack" : "msexchange", "values" : { "primary_smtp_address" : "[email protected]", "username" : "[email protected]", "password" : "password", "server" : "mailserver.common.com", "timezone" : "America/New_York" } }

from stackstorm-msexchange.

irom77 avatar irom77 commented on September 24, 2024

Now , after that change I am getting UserWarning: The get_folder_by_name() method is deprecated and then Error: No subfolders found with name None\n"

from stackstorm-msexchange.

LindsayHill avatar LindsayHill commented on September 24, 2024

That get_folder_by_name() error is just a deprecation warning at this stage, and can be ignored.

The more important issue is Error: No subfolders found with name None

What is the full command (with parameters) that you're running?

from stackstorm-msexchange.

irom77 avatar irom77 commented on September 24, 2024

I tried all below:

st2 run msexchange.search_items 
st2 run msexchange.search_items folder=inbox
st2 run msexchange.search_items folder=netpro-reply
st2 run msexchange.search_items [email protected]

always same Error: No subfolders found

from stackstorm-msexchange.

LindsayHill avatar LindsayHill commented on September 24, 2024

I'm not convinced that the code should work if folder is not specified, but I would have expected something like st2 run msexchange.search_items folder=inbox to work. What if you use proper case for Inbox?

I would not expect st2 run msexchange.search_items [email protected] to work

from stackstorm-msexchange.

LindsayHill avatar LindsayHill commented on September 24, 2024

Thanks for confirmation. Maybe worth doing a PR to update the README, and possibly to update that action to make folder a required parameter?

from stackstorm-msexchange.

irom77 avatar irom77 commented on September 24, 2024

I tried PR, 'Create pull request' button is not active. Troubleshooting sensor, it is not working despite msexchange.search_items being fine

from stackstorm-msexchange.

LindsayHill avatar LindsayHill commented on September 24, 2024

from stackstorm-msexchange.

Related Issues (8)

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.