DCache python interface

From SysadminWiki

There is several ways to interact with dCache.

  • You can connect interactively using the GUI [1] (http://www.dcache.org/downloads/gui/index.shtml).
    • Easy to use but not convenient for automatic, repetitive tasks
  • You can use the adminDoor to connect interactively [2] (http://www.dcache.org/manuals/Book/intouch-admin.shtml)
    • Can be used for very simple automatic tasks, but not feasable for slightly evoluted tasks
  • You can use jython to import the java libraries of dCache
    • This is a new feature. Convenient and reliable but a bit complicated.
  • You can use a python module
    • This is the method we commonly use at CCIN2P3. It allows you to make evoluted scripts with a good level of abstraction.

This python module defines the interaction with the adminDoor, the other is a collection of classes representing the dCache objects (movers, gridftp logins, pools ...) Check it out on the SVN repository (https://www.sysadmin.hep.ac.uk/svn/fabric-management/dcache/admintools/adminDoor.py) :


For instance, you can use it as follow :

>>> import adminDoor
>>> add = adminDoor.adminDoor()
>>> cmd=['cd PoolManager','psu ls pgroup']
>>> for l in add.exec_cmd(cmd) :
...   print l
...
(local) admin > cd PoolManager
(PoolManager) admin > psu ls pgroup
pgroup-disk-sc3
pgroup-cms-hpssdata
pgroup-atlas-temp
pgroup-atlas-mc12
pgroup-lhcb-sc3
pgroup-monitoring
pgroup-atlas-prodprivdisk
pgroup-cms-prod
pgroup-cms-import
pgroup-atlas-prodprivtape
pgroup-cms-analysis
pgroup-atlas-dq2
pgroup-hpss
pgroup-lhcb-dst
pgroup-atlas-testbeam
(PoolManager) admin > ..
(local) admin > logoff
dmg.util.CommandExitException: (0) Done
(local) admin >

>>> for l in list 
['(local) admin > cd PoolManager\n', '(PoolManager) admin > psu ls pgroup\n', 'pgroup-disk-sc3\n', 'pgroup-cms-hpssdata\n', 'pgroup-atlas-temp\n', 'pgroup-atlas-mc12\n', 'pgroup-lhcb-sc3\n', 'pgroup-monitoring\n',  'pgroup-atlas-prodprivdisk\n', 'pgroup-cms-prod\n', 'pgroup-cms-import\n', 'pgroup-atlas-prodprivtape\n', 'pgroup-cms-analysis\n', 'pgroup-atlas-dq2\n', 'pgroup-hpss\n', 'pgroup-lhcb-dst\n', 'pgroup-atlas-testbeam\n', '(PoolManager) admin > ..\n', '(local) admin > logoff\n', 'dmg.util.CommandExitException: (0) Done\n', '(local) admin > ']


In addition to this, you can describe some of the dCache objects as python classes. The descriptions are found here (https://www.sysadmin.hep.ac.uk/svn/fabric-management/dcache/admintools/dCacheObjs.py)

Then you just have to import dCacheObjects.py in your python script and that's it.

Some usage examples :