- Timestamp:
- Sep 21, 2012, 12:29:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
opsi/products/opsi-bacula-server-conf.py
r1094 r1095 5 5 import logging 6 6 import subprocess 7 import time 7 8 import json 8 9 from pprint import pprint … … 22 23 23 24 24 def write_client_conf( client, properties ):25 def write_client_conf( fd, client, properties ): 25 26 #Client { 26 27 #Name = ting-fd … … 34 35 #} 35 36 params = [ "FDPort", "Catalog", "FileRetention", "JobRetention", "AutoPrune" ] 36 print "Client {"37 print " Name =", properties['filedaemon_full_name']38 print " Address =", client['clientId']37 fd.write( "Client {\n" ) 38 fd.write( " Name = " + properties['filedaemon_full_name'] + "\n" ) 39 fd.write( " Address = " + client['clientId'] + "\n" ) 39 40 # ipAddress: method host_getObjects [] '{"id":client['clientId']}' 40 41 #print " # Address =", ipAddress 41 print " Password =", properties['filedaemon_full_password']42 fd.write( " Password = " + properties['filedaemon_full_password'] + "\n" ) 42 43 for i in params: 43 44 try: 44 print " " + i + " = " + properties[i.lower()]45 fd.write( " " + i + " = " + properties[i.lower()] + "\n" ) 45 46 except KeyError: 46 print " # " + i + " = "47 print "}"48 print47 fd.write( " # " + i + " = " + "\n" ) 48 fd.write( "}\n") 49 fd.write( "\n" ) 49 50 50 51 51 52 52 53 53 def write_job_conf( client, properties ):54 def write_job_conf( fd, client, properties ): 54 55 #Job { 55 56 #FileSet = "tingfileset" … … 60 61 #} 61 62 params = [ "Fileset", "JobDefs" ] 62 print "Job {"63 print " Name =", client['clientId'] + "-job"64 print " Client =", properties['filedaemon_full_name']63 fd.write( "Job {" + "\n" ) 64 fd.write( " Name = " + client['clientId'] + "-job" + "\n" ) 65 fd.write( " Client = " + properties['filedaemon_full_name'] + "\n" ) 65 66 for i in params: 66 print " ",67 fd.write( " " ) 67 68 try: 68 69 if not properties[i.lower()]: 69 print "#",70 print i + " = " + properties[i.lower()]70 fd.write( "# " ) 71 fd.write( i + " = " + properties[i.lower()] + "\n" ) 71 72 except KeyError: 72 print "# " + i + " = " 73 print "}" 74 print 75 76 73 fd.write( "# " + i + " = " + "\n" ) 74 fd.write( "}" + "\n" ) 75 fd.write( "\n" ) 77 76 78 77 # … … 96 95 97 96 #pprint( clientsWithBacula ) 97 98 if clientsWithBacula: 99 try: 100 file_opsi_clients = open('opsi-clients-generated.conf', 'w') 101 file_opsi_clients.write( "#\n" ) 102 file_opsi_clients.write( "# automatically generated at {}\n".format( time.asctime() ) ) 103 file_opsi_clients.write( "#\n\n" ) 98 104 105 file_opsi_jobs = open('opsi-jobs-generated.conf', 'w') 106 file_opsi_jobs.write( "#\n" ) 107 file_opsi_jobs.write( "# automatically generated at {}\n".format( time.asctime() ) ) 108 file_opsi_jobs.write( "#\n\n" ) 109 except e: 110 logger.exception( "failed to create files" ) 111 exit(1) 112 99 113 for client in clientsWithBacula: 100 114 clientId = client['clientId'] … … 109 123 else: 110 124 #pprint( clientBaculaProperties ) 111 write_client_conf( client, clientBaculaProperties )112 write_job_conf( client, clientBaculaProperties )125 write_client_conf( file_opsi_clients, client, clientBaculaProperties ) 126 write_job_conf( file_opsi_jobs, client, clientBaculaProperties ) 113 127 logger.info( "%s: OK" % clientId ) 114 128
Note:
See TracChangeset
for help on using the changeset viewer.