Changeset 1028


Ignore:
Timestamp:
Jul 10, 2012, 6:57:18 PM (12 years ago)
Author:
joergs
Message:

create bacula-dir.conf complaiend output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • opsi/products/opsi-bacula-server-conf.py

    r1027 r1028  
    2020opsiCallClientBaculaProperties=[ "method", "getProductProperties_hash", "bacula" ]
    2121
     22
     23def write_client_conf( client, properties ):
     24    #Client {
     25    #Name = ting-fd
     26    #Address = ting.dass-it
     27    #FDPort = 9102
     28    #Catalog = MyCatalog
     29    #Password = "D5w2V5w6B8a9H5Z"
     30    #File Retention = 6 months
     31    #Job Retention = 6 months
     32    #AutoPrune = yes
     33    #}
     34    params = [ "FDPort", "Catalog", "FileRetention", "JobRetention", "AutoPrune" ]
     35    print "Client {"
     36    print "  Name     =", properties['filedaemon_full_name']
     37    print "  Address  =", client['clientId']
     38    # ipAddress: method host_getObjects [] '{"id":client['clientId']}'
     39    #print "  # Address =", ipAddress
     40    print "  Password =", properties['filedaemon_full_password']
     41    for i in params:
     42        try:
     43            print " " + i + " = " + properties[i.lower()]
     44        except KeyError:
     45            print "  # " + i + " = "
     46    print "}"
     47    print
     48   
     49   
     50
     51
     52def write_job_conf( client, properties ):
     53    #Job {
     54    #FileSet = "tingfileset"
     55    #Name = "ting"
     56    #Client = ting-fd
     57    #JobDefs = "LaptopJob"
     58    ## Write Bootstrap = "/var/lib/bacula/ting.bsr"
     59    #}
     60    params = [ "Fileset", "JobDefs" ]
     61    print "Job {"
     62    print "  Name    =", client['clientId'] + "-job"
     63    print "  Client  =", properties['filedaemon_full_name']
     64    for i in params:
     65        print " ",
     66        try:
     67            if not properties[i.lower()]:
     68                print "#",
     69            print i + " = " + properties[i.lower()]
     70        except KeyError:
     71            print "# " + i + " = "
     72    print "}"
     73    print
     74
     75   
     76
     77#
     78# main
     79#
     80
    2281try:
    2382    clientsWithBacula=json.loads( subprocess.check_output( opsiCallPrefix + opsiCallClientsWithBacula ) )
     
    2988       
    3089for client in clientsWithBacula:
    31     print client['clientId']
     90    clientId = client['clientId']
     91    print clientId
    3292   
    3393    try:
     
    3898       
    3999    pprint( clientBaculaProperties )
     100    write_client_conf( client, clientBaculaProperties )
     101    write_job_conf( client, clientBaculaProperties )
Note: See TracChangeset for help on using the changeset viewer.