Advertisement
fmartinelli

SaltStack Legato Installation

May 8th, 2014
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.38 KB | None | 0 0
  1. #!pyobjects
  2.  
  3. """
  4. http://ait.web.psi.ch/services/central_backup/nsr_install_lnx.html
  5. """
  6.  
  7. LEGATO_LOCAL_CONF="/root/nsradmin76_x.txt"
  8.  
  9. with Pkg.installed("Legato RPMs", pkgs=[ "lgtoclnt", "lgtoman"   ]):
  10.   Service.running("networker", enable=True )
  11.  
  12.   import os
  13.   if not os.path.isfile( LEGATO_LOCAL_CONF + '.salt.done' ):
  14.     # We never configured Legato before, we have to configure it
  15.  
  16.     assert os.path.isfile("/usr/sbin/nsradmin")
  17.  
  18.     import socket
  19.  
  20.     FQDN , aliaslist, lan_ip = socket.gethostbyname_ex(socket.gethostname())
  21.  
  22.     if "." not in FQDN:
  23.       from dns import reversename, resolver
  24.       rev_name     = reversename.from_address(  lan_ip[0]     )
  25.       reversed_dns = str(resolver.query(rev_name,"PTR")[0])
  26.       FQDN         = reversed_dns[:-1] # t3ui.psi.ch
  27.  
  28.  
  29.     LEGATO_LOCAL_CONF_CONTENT = """. type: NSRLA
  30.  update administrator:"isroot,host=""" + FQDN + """","isroot,host=localhost","user=root,host=localhost","user=administrator,host=bs1","user=admin7,host=bs1","user=admin2,host=bs1"
  31.  . type: NSR System Port Ranges
  32.  update administrator:"isroot,host=""" + FQDN + """","isroot,host=localhost","user=root,host=localhost","user=administrator,host=bs1","user=admin7,host=bs1","user=admin2,host=bs1"
  33.  """
  34.  
  35.     with os.fdopen( os.open(  LEGATO_LOCAL_CONF, os.O_WRONLY | os.O_CREAT, 0600), 'w') as LEGATO_LOCAL_CONF_FILE :
  36.       LEGATO_LOCAL_CONF_FILE.write( LEGATO_LOCAL_CONF_CONTENT )
  37.      
  38.       Cmd.run("service networker stop" , shell='/bin/bash')
  39.       Cmd.run("service networker start", shell='/bin/bash')
  40.       with open( "/nsr/res/servers" , 'w' ) as file:
  41.         file.write("bs1.psi.ch\n")
  42.         Cmd.run("service networker  stop" , shell='/bin/bash')
  43.         Cmd.run("service networker  start", shell='/bin/bash')
  44.  
  45.         Cmd.run("/usr/sbin/nsradmin -i " + LEGATO_LOCAL_CONF + "  -p nsrexec ", shell='/bin/bash' )
  46.         Cmd.run("""
  47. /usr/sbin/nsradmin -p nsrexec  << EOF
  48. . type:NSR System Port Ranges
  49. update service ports:7937-7940
  50. yes
  51. update connection ports:10000-11000
  52. yes
  53. EOF""", shell='/bin/bash' )
  54.         Cmd.run("service networker   stop" , shell='/bin/bash')
  55.         Cmd.run("service networker   start", shell='/bin/bash')
  56.  
  57.         # a timestamp inside /root/nsradmin76_x.txt.salt.done
  58.         import time
  59.         open(  LEGATO_LOCAL_CONF + '.salt.done', 'w' ).write( time.strftime("%d-%m-%Y - %H:%M:%S") + "\n"   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement