#!/usr/bin/env python
#---------------------------------#
# Author: V.garonne               #
# Mail: garonne@lal.in2p3.fr      #
# Description: script to a ssh    #
# proxy to connect severals hosts #
# i.d. a grid-like proxy          #
#---------------------------------#

import os, string
import getpass

# my own stuffs
from   p3 import encrypt
  
#--------------------# MAIN #-------------------------#
if __name__ == '__main__':  
#lx64slc4
    pool = {
    'OSF1-alpha':            {'machine':'asc.lal.in2p3.fr'},
    'Linux-i686':            {'machine':'lxplus.cern.ch'},
    #'Linux-x86_64':          {'machine':'h4.lal.in2p3.fr'},
    'SunOS-sun4u':           {'machine':'ccasn.in2p3.fr'},
    'AIX-002064874C00':      {'machine': 'ccars01.in2p3.fr' },
    'Darwin-PowerMacintosh': {'machine':'wl-72137.lal.in2p3.fr'}, #mac-90109.lal.in2p3.fr
    'CYGWIN_NT-5.1-i686'   : {'machine':'134.158.72.234'},
    'VisualC'              : {'machine':'134.158.72.234'},              
    'Linux-x86_64':          {'machine':'lxcert-amd64.cern.ch'},
    'Linux-ia64'  :          {'machine':'lxcert-ia64.cern.ch'}
    }
    #134.158.72.234
    #134.158.72.234
    preambule = 'cmt_create_proxy > '   
    print preambule + "Do the configuration acces of the remote machines"
    for platform in pool:  
       print preambule + 'Enter the parameters for machine ' + pool[platform]['machine'] 
       user      = raw_input (preambule + ' user: ')
       password = getpass.getpass(preambule + user+'@'+ pool[platform]['machine'] + "'s password: ")
       pool[platform]['user'] = user
       pool[platform]['pwd']  = password
       
    f = open('.cmtproxy', 'w+')
    f.write (encrypt(str(pool)))
    f.close()   
#----------------------- End Of File --------------------------#
