How do you import standard Python modules?You've got the right idea here. It is expected that 'import os' should "just work". There are no special hoops you should have to jump through to import standard Python stuff like this. I just confirmed that I could include 'import os' in my 'plugin_runner.py' file successfully.
(As an aside... plugin code will run with fairly tight security constraints. Many of the 'os' functions will need higher levels of permissions than plugin code is allowed. Depending on what you're trying to do with the 'os' module, you might get security-related errors. But simply importing the module is expected to work just fine.)
Since you're asking about 'os' and 'glob' modules specifically, I also want to point out that Python plugin code runs on the Delphix Engine. So, for most plugins, any OS-related and filename-related code will actually be in Bash or Powershell code, which runs on remote hosts/environments.
How can you debug Python problems when you get an error during discovery?Unfortunately, you are hitting a known bug here. In the special case, of discovery, we are accidentally not showing the Python error message. Had the error happened as part of another operation (such as dSource syncing), you would see the Python error in the UI. We hope to fix this bug soon.
In the meantime, to workaround this problem, you can see the Python error by looking in the engine's debug logs:
- In the Engine UI, go to "Help" then "Support Logs", and follow the prompts to download a support bundle.
- Untar the downloaded support bundle to a scratch directory.
- Open up the 'logs/mgmt_log/debug.log' file in a text editor. Search for the most recent occurrence of "generic.plugin.problem.detected".
- Immediately afterward, you should see a Python stack trace and the error as reported by the Python interpreter.
For example, you might see something like this:
com.delphix.server.core.messages.PythonExceptions$PythonGenericPluginProblemDetected: exception.python.python.generic.plugin.problem.detected {Repository Discovery|Traceback (most recent cal
l last):
File "__pyclasspath__/dlpx/virtualization/platform/_plugin.py", line 226, in _internal_repository
File "/Users/tomwalsh/code/toolkits/exploit/src/plugin_runner.py", line 69, in repository_discovery
File "/Users/tomwalsh/code/toolkits/exploit/src/plugin_runner.py", line 69, in repository_discovery
NameError: global name 'bad_name' is not defined
}
This tells me that, at line 69 of my 'plugin_runner.py' file, I've tried to use a variable named 'bad_name', but no such thing exists. Your problem might be completely different, of course, but hopefully the error report will point you to the problem.