We're in the process of upgrading from MarkLogic 6 to 8 and have run into some problems calling library modules. We have xquery library modules that are called both from custom REST extensions and from non-REST xquery.
MarkLogic's documentation says that REST endpoints can use libraries installed either with their new /ext endpoint or libraries installed the old way (placed somewhere else in the modules database). However, when the library module is using, for example, the functx package that comes with MarkLogic, I can't get the cross-over to work.
Say I have two identical library modules, one installed via /ext and one not:
xquery version "1.0-ml";
module namespace test = "test/lib";
import module namespace functx = "http://www.functx.com" at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
declare function test:stuff() {
<foo/>
};
The first is installed using this command, in case it matters:
curl --anyauth --user user:pwd -X PUT -i -d #".\\module\\testlib-ext.xqy" -H "Content-type: application/xquery" "http://host:8020/v1/ext/test/testlib-ext.xqy?perm:rest-reader=execute"
I have rest endpoints that use each module (the only difference is the namespace and import):
xquery version "1.0-ml";
module namespace te = "http://marklogic.com/rest-api/resource/test-ext-to-ext";
import module namespace test = "test/lib" at "/ext/test/testlib-ext.xqy";
declare function te:get($context as map:map, $params as map:map) as document-node()* {
document { test:stuff() }
};
The one using the library installed using /ext works. The one using the module that's simply placed in the modules database installs without errors but gives me an error when called by a non-admin user (it works when called by admin):
RESTAPI-INVALIDREQ: (err:FOER0000) Invalid request: reason: Extension test-ext-to-lib does not exist.
I'd just install them all using /ext, but then xquery that uses xdmp:invoke breaks. It's a different error, but it seems to be the same underlying issue. Invoking a module using the library placed in the modules database works. Invoking a module using the library installed via /ext fails with this error:
XDMP-MODNOTFOUND: (err:XQST0059) xdmp:invoke("/test/test-module-to-ext.xqy", (), ()) -- Module C:\Program Files\MarkLogic\Modules\MarkLogic\functx\functx-1.0-nodoc-2007-01.xqy not found
If I add the admin role to the calling user, all of them work. They also work even without the admin role if I take the functx import out.
It looks like a permission problem, but I can't find a role or permission that will fix it. The user has a role with every checkbox except admin itself checked. Checking that last checkbox is the only thing I've found that makes this work, and that's obviously not a viable solution.
We don't really care how the libraries are installed, but we don't want to duplicate code. How can we make these imports work with both REST and non-REST xquery?
For the permissions to work, the main module and each library in the dependency chain must be executable by at least one role assigned to the user (where assignment includes inheritance and amping).
The REST API sets the rest-extension-user role on modules that it installs under /ext.
So, a user who has the rest-extension-user role should be able to invoke a module installed by the REST API under /ext.
More generally, any module (regardless of how it is installed) that is executable by the rest-extension-user role should be able to have dependencies on libraries installed by the REST API under /ext (assuming, of course, that all paths are correct).
Related
Trying to clean up some testing for IaC using Inspec, But hardcoding security_group_ids is a no go for obvious reasons.
Im trying to use the ruby sdk instead to pull down the id based of a name (ie like you do with Terraform data resources).
But we work from aws named profiles and while Inspec can connect to named profiles when i run the test ie :
inspec exec . -t aws://prod_account
Is it possible from Inspec to link the call to aws named profiles to ruby code within a control?
since inspec is written in ruby, you can embed any ruby code within your spec files. for instance, you can have a ruby code with an array and for each array have a spec code.
thus, you can implement a logic for collecting the security group ids and then iterate over them.
is it possible to to use Datahander Scripts (TCEmain) in a Extbase Command Controller via cli_dispatch.phpsh? I tried but i got no result - no error message and no entry in the tables.
Perhaps there is no backend available in cli scripts ...
Thanks!
You find the documentation for using DataHandler in CLI scripts here.
CLI scripts use the backend user _cli_ (should be created automatically). You can take a look at the source of \TYPO3\CMS\Backend\Console\CliRequestHandler::boot if you're interested in how it works.
You can check the public instance variable $dataHandler->errorLog for any errors, DataHandler won't output anything else.
Mind that cli_dispatch.phpsh & Co. are deprecated, you can already use Symfony Commands in TYPO3 CMS 8.
I am new to MarkLogic and I cannot find a way to do module invoke instead of adhoc query for using dls:document-insert-and-manage.
I have a content source connected to my host and port.
Session session = contentSource.newSession();
Request request = session.newModuleInvoke("marklogic.com/xdmp/dls/MarkLogic/dls.xqy)
Does not seem to work.
The dls module is a library module. It provides a set of functions that you can call. You need to import it into a main module (or require it into a JavaScript module) and then call the function you want.
I have created Azure Batch pool with Linux Machine and specified Application Package for the Pool.
My command line is
command='python $AZ_BATCH_APP_PACKAGE_scriptv1_1/tasks/XXX/get_XXXXX_data.py',
python3: can't open file '$AZ_BATCH_APP_PACKAGE_scriptv1_1/tasks/XXX/get_XXXXX_data.py':
[Errno 2] No such file or directory
when i connect to node and look at working directory non of the Application Package files are present there.
How do i make sure that files from Application Package are available in working directory or I can invoke/execute files under Application Package from command line ?
Make sure that your async operation have proper await in place before you start using the package in your code.
Also please share your design \ pseudo-code scenario and how you are approaching it as a design?
Further to add:
Seems like this one is pool level package.
The error seems like that the application env variable is either incorrectly used or there is some other user level issue. Please checkout linmk below and specially the section where use of env variable is mentioned.
This seems like user level issue because In case of downloading the package resource, if there will be an error it will be visible to you via exception handler or at the tool level is you are using batch explorer \ Batch-labs or code level exception handling.
https://learn.microsoft.com/en-us/azure/batch/batch-application-packages
Reason \ Rationale:
If the pool level or the task application has error, an error-list will come back if there was an error in the application package then it will be returned as the UserError or and AppPackageError which will be visible in the exception handle of the code.
Key you can always RDP into your node and checkout the package availability: information here: https://learn.microsoft.com/en-us/azure/batch/batch-api-basics#connecting-to-compute-nodes
I once created a small sample to help peeps around so this resource might help you to checkeout the use here.
Hope rest helps.
On Linux, the application package with version string is formatted as:
AZ_BATCH_APP_PACKAGE_{0}_{1}
On Windows it is formatted as:
AZ_BATCH_APP_PACKAGE_APPLICATIONID#version
Where 0 is the application name and 1 is the version.
$AZ_BATCH_APP_PACKAGE_scriptv1_1 will take you to the root folder where the application was unzipped.
Does this "exact" path exist in that location?
tasks/XXX/get_XXXXX_data.py
You can see more information here:
https://learn.microsoft.com/en-us/azure/batch/batch-application-packages
Edit: Just saw this question: "or can I invoke/execute files under Application Package from command line"
Yes you can invoke and execute files from the application package directory with the environment variable above.
If you type env on the node you will see the environment variables that have been set.
I have installed the postgresql module from Puppetforge.
How can I query Postgresql resources using ralsh ?
None of the following works:
# ralsh postgresql::db
# ralsh puppetlabs/postgresql::db
# ralsh puppetlabs-postgresql::db
I was hoping to use this to get a list of databases (including attributes such as character sets) and user names/passwords from the current system in a form that I can paste into a puppet manifest to recreate that setup on a different machine.
In principle, any puppet client gets the current state of your system from another program called Facter. You should create a custom Fact (a module of Facter), and then included into your puppet client. Afterwards, I think you could call this custom Fact from ralsh.
More information about creating a custom Fact can be found in here.
In creating your own Fact, you should execute your SQL query and then save the result into particular variable.