Closed pdonorio closed 8 years ago
To use the environment set in plumbum (just like passing the env
to Popen
):
https://plumbum.readthedocs.org/en/latest/local_machine.html#guide-local-machine
With plumbum the env varibles can be set in 2 ways:
ls = local["ls"].with_env(TEST="env_vale")
local.env["TEST"] = "env_vale"
I have tried to use the icommands without setting a "~/.irods/irods_environment.json" file and setting environment variables but I wasn't able to make it work. Also, I haven't find anything about this in the user documentation. @akrause2014 how did you manage to do that in your client.py? I also tried it but it doesn't seem to work without an irods_environment.json. Thanks!
All parameters in irods_environment.json must be translated into upper-case environment variables to provide when running the client. In my example client the environment would be the following:
local.env['IRODS_USER_NAME'] = 'newuser'
local.env['IRODS_HOST'] = 'rodserver'
local.env['IRODS_PORT'] = '1247'
local.env['IRODS_AUTHENTICATION_SCHEME'] = 'gsi'
local.env['IRODS_DEFAULT_RESOURCE'] = "demoResc"
local.env['IRODS_ZONE'] = 'tempZone'
etc.
And the location of the X509 proxy (if it's not created on the fly or located in the standard path):
local.env['X509_USER_PROXY'] = '/path/to/proxy'
Then you don't need an irods_environment.json file. (Note that my example client wasn't using the correct variable names - I'll need to fix that! - but the ones above work and I've just tested it.)
Thanks @akrause2014 !
So with plumbum we can manage the environment in two ways. Here is the script that I used:
# -*- coding: utf-8 -*-
import os
from plumbum import local
irods_env = os.environ.copy()
irods_env['IRODS_USER_NAME'] = 'guest'
irods_env['IRODS_HOST'] = 'rodserver'
irods_env['IRODS_PORT'] = '1247'
irods_env['IRODS_AUTHENTICATION_SCHEME'] = 'gsi'
irods_env['IRODS_ZONE'] = 'tempZone'
irods_env['IRODS_HOME'] = '/tempZone/home/guest'
ils = local['ils'].with_env(**irods_env)
print(ils())
#----------------
local.env['IRODS_USER_NAME'] = 'guest'
local.env['IRODS_HOST'] = 'rodserver'
local.env['IRODS_PORT'] = '1247'
local.env['IRODS_AUTHENTICATION_SCHEME'] = 'gsi'
local.env['IRODS_ZONE'] = 'tempZone'
local.env['IRODS_HOME'] = '/tempZone/home/guest'
ils = local['ils']
print(ils())
ils = local['ils'].with_env(**irods_env)
I prefer this version. Will do this week :smiley:
To automatize the creation of users in our tests, i shall make a script that takes the username
as parameter and creates the certificates, register into irods, save it in a docker shared folder.
Since the basic error is:
| The host key could not be found in:
| 1) env. var. X509_USER_KEY
| 2) /etc/grid-security/hostkey.pem
| 3) $GLOBUS_LOCATION/etc/hostkey.pem
| 4) $HOME/.globus/hostkey.pem
i'd go with X509_USER_KEY
env var to specify the certificate on irods client side before launching the command.
Closing this with commit b5b46eebd810ae333e95dd34d6663f49debab17e
See this piece of code to check how i pass the certificates to the flask server before any icommand.
Become a different iRODS user via certificate on each HTTP request.