Changeset 813 for vanHelsing/trunk/src/bcfg.py
- Timestamp:
- Jan 13, 2010, 12:39:46 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vanHelsing/trunk/src/bcfg.py
r812 r813 8 8 import resource 9 9 import directive 10 import random 10 11 11 12 RESOURCE_TYPES = ('dird', 'console', 'filed', 'stored') … … 65 66 #curRes.add_comment(inlinecomment) 66 67 67 if len(line)>0 and line[0]=='@': 68 includepath=line[1:].strip() 69 print "include " +includepath 70 self.parse(self.resources,open(includepath,"r"),0) 68 include=line.strip() 69 if include.startswith("@"): 70 includepath=include[1:].strip() 71 print "include " +includepath 72 self.parse(curRes,open(includepath,"r"),level) 71 73 72 74 if rxp_closebrace.match(line): … … 124 126 125 127 class FiledConfig(Config): 126 pass 128 def __init__(self, filename=""): 129 Config.__init__(self, 'fd', filename) 127 130 131 def setDefaults(self,directorName,directorPassword,myName): 132 director=resource.Director(1,"Director") 133 director.add("Name",directorName) 134 director.add("Password",'"'+directorPassword+'"') 135 self.getRoot().add_item(director) 136 137 fileDaemon=resource.FileDaemon(1,"FileDaemon") 138 fileDaemon.add("Name",myName) 139 #fileDaemon.add("FDport","9102") 140 fileDaemon.add("WorkingDirectory","/var/lib/bacula") 141 fileDaemon.add("Pid Directory","/var/run") 142 fileDaemon.add("Maximum Concurrent Jobs","20") 143 self.getRoot().add_item(fileDaemon) 144 145 messages=resource.Messages(1,"Messages") 146 messages.add("Name","Standard") 147 messages.add("director",directorName+" = all, !skipped, !restored") 148 self.getRoot().add_item(messages) 149 128 150 class StoredConfig(Config): 129 151 pass … … 135 157 #newclient.add("FDPort",fdport) 136 158 newclient.add("Catalog",catalog) 137 newclient.add("Password", password)159 newclient.add("Password",'"'+password+'"') 138 160 return newclient 139 161 162 def genpasswd(len=32): 163 charset="01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!/%()=?@" 164 password="" 165 for a in xrange(0,len): 166 password += random.choice(charset) 167 return password 168 140 169 if __name__ == "__main__": 141 142 dirdcfg = DirdConfig("test.conf") 170 171 if len(sys.argv) < 2: 172 filename="test.conf" 173 else: 174 filename=sys.argv[1] 175 176 dirdcfg = DirdConfig(filename) 143 177 dirdcfg.read() 144 178 … … 152 186 root.add_item(job) 153 187 154 newclient=createClient("testclient-fd","testclient","MyCatalog","testpassword") 188 pwd=genpasswd() 189 newclient=createClient("test-fd","testclient","MyCatalog",pwd) 155 190 root.add_item(newclient) 156 191 157 192 dirdcfg.write("test.conf.out") 193 194 fdcfg=FiledConfig("test-fd.conf") 195 fdcfg.setDefaults("bacula-dird",pwd,"test-fd") 196 fdcfg.write() 197 158 198 sys.exit(0)
Note:
See TracChangeset
for help on using the changeset viewer.