Permalink
Browse files

Moved from github - version 1.5.8

git-svn-id: https://opencadc.googlecode.com/svn/trunk/projects/cadcVOFS@1641 728ff76a-78ac-11de-a72b-d90af8dea425
  • Loading branch information...
adrian.damian@nrc.ca
adrian.damian@nrc.ca committed Sep 11, 2012
1 parent b2e7db1 commit 4ef461fd0da9c117e0bcadfd01fd42388cc11a6e
View
14 FAQ.txt
@@ -0,0 +1,14 @@
+
+1)
+
+Q: I just got a message like:
+
+mount_osxfusefs: failed to mount /private/tmp/vospace@/dev/osxfuse0:
+Connection refused
+
+What does this mean?
+
+A: Likely you authentication certificat has expired. Use the
+'getCert' command to pull a new cert and try again. If the message
+doesn't go away, please contact CADC for help fixxing your
+authentication issue.
View
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: vos
+Version: 1.1.1
+Summary: CADC VOSpace Filesystem
+Home-page: http://www.cadc.hia.nrc.gc.ca/vosui/#jkavelaars/
+Author: JJ Kavelaars
+Author-email: jj.kavelaars@nrc.gc.ca
+License: GPL
+Description: a FUSE layer for interaction with the IVOA VOSpace standard.
+Platform: python2.6+
View
77 README
@@ -0,0 +1,77 @@
+
++++++++++++++++++++++++++ DOCUMENTATION ++++++++++++++++++++++++++
+
+cadcVOFS is a set of python modules and scripts for access VOSpace.
+
+The default installation of cadcVOFS is tuned for accessing the
+VOSpace provided by the Canadian Astronomy Data Centre
+http://www.cadc.hia.nrc.gc.ca/vospace.
+
+VOSpace is a Distrbuted Cloud storage service for use in Astronomy.
+
+There are three ways to use cadcVOFS:
+
+ 1) access VOSpace from the command-line
+
+ 2) make VOSpace appear as mounted filesystem
+
+ 3) use the vos module inside a Python script
+
+All of these methods require the user to have a pre-existing VOSpace
+account with the CADC.
+
+Authentication to the CADC VOSpace service is performed using security
+certificates which are managed by the CADC Group Management Service
+(GMS). The certificates can be retrieved from the CADC using the
+'getCert' script and users CADC account and password information.
+
+ADDITIONAL DOCUMENTATION AVAILABLE AT:
+
+ <http://canfar.phys.uvic.ca/wiki/index.php/VOSpace_filesystem>
+
++++++++++++++++++++++++ REQUIREMENTS +++++++++++++++++++++++++++++++
+
+ A CADC VOSpace account
+ fuse OR OS-FUSE (see additional documentation)
+ python2.6 or newer
+
++++++++++++++++++++++++++ INSTALLATION +++++++++++++++++++++++++++
+
+python setup.py install
+
++++++++++++++++++++++++++ USAGE ++++++++++++++++++++++++++++++++++
+
+1) Get a CADC account <http://www.cadc.hia.nrc.gc.ca/>
+
+2) Retrieve a SSL certificate from the CADC servers.
+
+> getCert
+
+ retrieves a certificate from the CADC servers, these certifcates are
+ valid for 2 days (be default) but can be valid for upto 30 days (see
+ the getCert help). The cerificate is stored in ${HOME}/.ssl by
+ default.
+
+3a) For filesystem usage:
+
+> mountvofs
+
+ mounts the CADC VOSpace root Container Node at /tmp/vospace and
+ initiates a 5GB cache in the users home directory (${HOME}/vos_)
+
+ **** Since the VOSpace does not have a mapping of your unix users
+ IDs all files appear to be owned by the user who issued the
+ 'mountvofs' command. Only that user can see the mount point.
+
+3b) Commandline usage:
+
+> vls -l vos:
+
+ Lists the contents of the CADC root VOSpace Container Node.
+
+> vcp vos:jkavelaars/test.txt ./
+
+ copys the files 'test.txt' from the the vospace container jkavelaars
+ to your local directory.
+
+See --help for the commands: vmkdir, vrm, vrmdir, vsync
View
104 getCert
@@ -0,0 +1,104 @@
+#!python
+def getCert(certHost='www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca',certfile=None,
+ certQuery="/cred/proxyCert?daysValid=",daysValid=2):
+ """Access the cadc certificate server"""
+
+ import os
+
+ if certfile is None:
+ certfile=os.path.join(os.getenv("HOME","/tmp"),".ssl/cadcproxy.pem")
+
+ dirname=os.path.dirname(certfile)
+ try:
+ os.makedirs(dirname)
+ except OSError as e:
+ if os.path.isdir(dirname):
+ pass
+ elif e.errno==20 or e.errno==17:
+ import sys
+ sys.stderr.write(e.strerror+": %s \n" %(dirname))
+ sys.stderr.write("Expected %s to be a directory.\n" % ( dirname))
+ sys.exit(e.errno)
+ else:
+ raise e
+
+ import urllib2
+
+ ## Example taken from voidspace.org.uk
+ # create a password manager
+ password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
+
+ (username,passwd)=getUserPassword(host=certHost)
+
+ # Add the username and password.
+ # If we knew the realm, we could use it instead of ``None``.
+ top_level_url = "http://"+certHost
+ password_mgr.add_password(None, top_level_url, username, passwd)
+
+ handler = urllib2.HTTPBasicAuthHandler(password_mgr)
+
+ # create "opener" (OpenerDirector instance)
+ opener = urllib2.build_opener(handler)
+
+ # Install the opener.
+ urllib2.install_opener(opener)
+
+ # Now all calls to urllib2.urlopen use our opener.
+ url="http://"+certHost+certQuery+str(daysValid)
+ r= urllib2.urlopen(url)
+ w= file(certfile,'w')
+ while True:
+ buf=r.read()
+ if not buf:
+ break
+ w.write(buf)
+ w.close()
+ r.close()
+ return
+
+def getUserPassword(host='www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca'):
+ import netrc,getpass,os,sys
+ """"Getting the username/password for host from .netrc filie """
+ if os.access(os.path.join(os.environ.get('HOME','/'),".netrc"),os.R_OK):
+ auth=netrc.netrc().authenticators(host)
+ else:
+ auth=False
+ if not auth:
+ sys.stdout.write("CADC Username: ")
+ username=sys.stdin.readline().strip('\n')
+ password=getpass.getpass().strip('\n')
+ else:
+ username=auth[0]
+ password=auth[2]
+ return (username,password)
+
+def signal_handler(signal, frame):
+ sys.stderr.write("\n")
+ sys.exit(-1)
+
+import optparse,os
+
+import signal
+signal.signal(signal.SIGINT, signal_handler)
+
+
+parser = optparse.OptionParser(description='Get CADC proxy certificate')
+parser.add_option('--daysValid', type=int, default=10,
+ help='Number of days the cetificate should be valid (default: 10)')
+parser.add_option('--dest', default=os.path.join(os.getenv('HOME','/tmp'),".ssl/cadcproxy.pem"),
+ help="Location to store the proxy certifacte")
+(opt,args) = parser.parse_args()
+
+import urllib2,sys
+
+if __name__=='__main__':
+ retry=True
+ while retry:
+ try:
+ getCert(daysValid=opt.daysValid,certfile=opt.dest)
+ retry=False
+ except urllib2.HTTPError as e:
+ sys.stderr.write(str(e)+"\n")
+ if "basic auth failed" not in str(e):
+ sys.exit(1)
+ sys.exit(0)
Oops, something went wrong.

0 comments on commit 4ef461f

Please sign in to comment.