Changeset 994
- Timestamp:
- Apr 9, 2012, 10:02:11 AM (13 years ago)
- Location:
- dassmodus/trunk/dassmodus/nosferatu/nosferatu
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
dassmodus/trunk/dassmodus/nosferatu/nosferatu/config_classes.py
r953 r994 57 57 'fullbackuppool', 58 58 'differentialbackuppool', 59 'nextpool', 59 60 'job', 60 61 'basejob', 61 62 'device', 63 62 64 ]) 63 65 … … 97 99 'file', 98 100 'run', 101 'plugin', 99 102 ]) 100 103 -
dassmodus/trunk/dassmodus/nosferatu/nosferatu/tools/generate_web2py_db_model.py
r991 r994 34 34 from nosferatu.config_classes import * 35 35 from resource import Resource 36 from nosferatu import prettynames, auto_configrules 36 from nosferatu import prettynames, auto_configrules, auto_types 37 37 38 38 #single_res=['dir_res'] … … 52 52 53 53 54 def item2field(confshort, item): 54 def item2field(confshort, item, resname): 55 # file, run and plugin item names can appear multiple times 56 if item.name in MULTIPLE_ALLOWED_ITEMS_SET: 57 print "# item %s can appear multiple times" %(item.name) 58 refname = item.name 59 fieldtype = 'reference %s_conf__%s' % ('dird', item.name) 60 defaultvalue = 0 61 return """ Field('%s','%s', default=%s), """ %(item.name, fieldtype , defaultvalue) 62 63 64 65 66 67 68 69 70 if resname == 'inc_options_items': 71 if item.name in auto_types.FS_option_kw: 72 fieldtype = 'string' 73 defaultvalue = '"' + FS_option_kw[item.name][0] + '"' #"incremental" 74 return """ Field('%s','%s', default=%s, 75 requires=IS_IN_SET(%s)), """ %(item.name, 76 fieldtype , defaultvalue, 77 repr(auto_types.FS_option_kw[item.name])) 78 79 55 80 if item.name == 'where' : # where cannot be a column name in sqlite 56 81 item.name = 'where_' … … 65 90 defaultvalue = 0 66 91 return """ Field('%s','%s', default=%s), """ %(item.name, fieldtype , defaultvalue) 92 93 elif item.name in set(['include', 'exclude']): 94 refname = item.name 95 fieldtype = 'reference %s_conf__%s_link' % ('dird','inc_newinc_items') 96 defaultvalue = 0 97 return """ Field('%s','%s', default=%s), """ %(item.name, fieldtype , defaultvalue) 98 99 elif item.name == 'options': 100 refname = item.name 101 fieldtype = 'reference %s_conf__%s_link' % ('dird','inc_options') 102 defaultvalue = 0 103 return """ Field('%s','%s', default=%s), """ %(item.name, fieldtype , defaultvalue) 104 105 elif item.name == 'runscript': 106 refname = item.name 107 fieldtype = 'reference %s_conf__%s_link' % ('dird','runscript') 108 defaultvalue = 0 109 return """ Field('%s','%s', default=%s), """ %(item.name, fieldtype , defaultvalue) 110 111 112 elif item.name == 'level': 113 refname = item.name 114 fieldtype = 'string' 115 defaultvalue = '"' + auto_types.joblevels[2] + '"' #"incremental" 116 return """ Field('%s','%s', default=%s, 117 requires=IS_IN_SET(%s)), """ %(item.name, 118 fieldtype , defaultvalue, 119 repr(auto_types.joblevels)) 120 elif item.name == 'type': 121 refname = item.name 122 fieldtype = 'string' 123 defaultvalue = '"' + auto_types.jobtypes[5] + '"' # "backup" 124 return """ Field('%s','%s', default=%s, 125 requires=IS_IN_SET(%s)), """ %(item.name, 126 fieldtype , defaultvalue, 127 repr(auto_types.jobtypes)) 128 129 elif item.name == 'replace': 130 refname = item.name 131 fieldtype = 'string' 132 defaultvalue = '"' + auto_types.ReplaceOptions[0] + '"' # "always" 133 return """ Field('%s','%s', default=%s, 134 requires=IS_IN_SET(%s)), """ %(item.name, 135 fieldtype , defaultvalue, 136 repr(auto_types.ReplaceOptions)) 67 137 else: 68 138 fieldtype = 'string' 69 139 defaultvalue = item.defaultvalue 140 if defaultvalue == None: 141 defaultvalue = '' 70 142 if item.type == "store_bool": 71 143 fieldtype = "boolean" … … 77 149 78 150 79 151 # subressourcen: 152 # unterhalb von fileset include und exclude 153 # unterhalb von include und exclude options 154 # unterhalb von job runscript 155 156 157 158 #inc_newinc_items 159 #inc_options_items 160 #dird_runscript_items 161 print "# subressources" 162 163 164 confshort = 'dird' 165 res_name = 'options' 166 print """db.define_table('%s_conf__%s', """ % (confshort,res_name) 167 for item in auto_configrules.inc_options_items: 168 item.required=False 169 item.printall=True 170 print item2field(confshort,item, res_name) 171 print """ format='options-%(id)s') 172 """ 173 #print """db.define_table('%s_conf__%s_link', 174 # Field('%s','reference %s_conf__%s'), 175 # format = '%%(id)s') 176 # """ % (confshort,res_name, res_name, confshort,res_name) 177 178 179 180 for res_name in ('include', 'exclude'): 181 confshort = 'dird' 182 #res_name = 'include' 183 print """db.define_table('%s_conf__%s', """ % (confshort,res_name) 184 for item in auto_configrules.inc_newinc_items: 185 item.required=False 186 item.printall=True 187 print item2field(confshort,item, res_name) 188 print """ format='include-%(id)s') 189 """ 190 # print """db.define_table('%s_conf__%s_link', 191 # Field('%s','reference %s_conf__%s'), 192 # format = '%%(id)s') 193 # """ % (confshort,res_name, res_name, confshort,res_name) 194 195 196 # 197 198 confshort = 'dird' 199 res_name = 'dird_runscript_items' 200 print """db.define_table('%s_conf__%s', """ % (confshort,res_name) 201 for item in auto_configrules.dird_runscript_items: 202 item.required=False 203 item.printall=True 204 print item2field(confshort,item, res_name) 205 print """ format='runscript-%(id)s') 206 """ 207 #print """db.define_table('%s_conf__%s_link', 208 # Field('%s','reference %s_conf__%s'), 209 # format = '%%(id)s') 210 # """ % (confshort,res_name, res_name, confshort,res_name) 211 212 213 # TODO: folgende linktabellen herstellen 214 # TODO: include_to_options 215 # TODO: fileset_to_include 216 # TODO: fileset_to_exclude 217 # TODO: job_to_runscript_items 218 219 220 # Anlegen der eigentlichen Speicherplätze für die Ressourcen 80 221 81 222 dir_res_list = list() … … 89 230 print 90 231 #print res_name 91 print """db.define_table('%s_conf__%s', """ % (confshort, res_name)232 print """db.define_table('%s_conf__%s', """ % (confshort, res_name) 92 233 for item in res_items: 93 234 item.required=False 94 235 item.printall=True 95 print item2field(confshort,item )236 print item2field(confshort,item, res_name) 96 237 print """ format='%(name)s')""" 97 238 … … 110 251 item.required=False 111 252 item.printall=True 112 print item2field(confshort,item )253 print item2field(confshort,item, res_name) 113 254 print """ format='%(name)s')""" 114 255 … … 127 268 item.required=False 128 269 item.printall=True 129 print item2field(confshort,item )270 print item2field(confshort,item, res_name) 130 271 print """ format='%(name)s')""" 131 272 … … 143 284 item.required=False 144 285 item.printall=True 145 print item2field(confshort,item )286 print item2field(confshort,item, res_name) 146 287 print """ format='%(name)s')""" 147 288 … … 150 291 151 292 152 for res in dir_res_list: 153 print """db.define_table('dird_conf__%s_link', 154 Field('%s','reference dird_conf__%s'), 293 for confshort in ['dird','stored','filed','cons']: 294 295 296 print "\n#the table representing the %s configuration file" % (confshort) 297 298 print """db.define_table('%s_conf', 299 Field('name','string'), 300 format='%%(name)s') """ % (confshort) 301 302 print "\n#link tables between %s configs and %s config ressources" % (confshort, confshort) 303 304 for res in dir_res_list: 305 print """db.define_table('%s_conf_to_%s', 306 Field('%s_conf','reference %s_conf'), 307 Field('%s','reference %s_conf__%s'), 308 format = '%%(id)s') 309 """ % (confshort,res,confshort,confshort,res,confshort,res) 310 311 312 313 314 315 316 print "# items that can appear multiple times" 317 confshort = 'dird' 318 for name in MULTIPLE_ALLOWED_ITEMS_SET: 319 320 # create the table itself 321 print """db.define_table('%s_conf__%s', 322 Field('%s','string', default=''), 323 format = '%%(%s)s') 324 """ % (confshort, name, name, name ) 325 326 # create the linking tables 327 # plugin and file belong to dird_fileset_includes, 328 # runscript belong to job ressource 329 if name == 'run': 330 parent_res = 'schedule' 331 else: 332 parent_res = 'include' 333 334 print """db.define_table('%s_conf__%s_to_%s_conf__%s', 335 Field('%s_conf__%s','reference %s_conf__%s'), 336 Field('%s_conf__%s','reference %s_conf__%s'), 155 337 format = '%%(id)s') 156 """ % (res,res,res) 157 print """db.define_table('dird_conf', 158 Field('name','string'),""" 159 160 for res in dir_res_list: 161 print " Field('dird_conf__%s', 'reference dird_conf__%s_link')," % (res,res ) 162 print """ format='%(name)s') 163 """ 164 165 166 167 for res in stor_res_list: 168 print """db.define_table('stord_conf__%s_link', 169 Field('%s','reference stord_conf__%s'), 170 format = '%%(id)s') 171 """ % (res,res,res) 172 print """db.define_table('stord_conf', 173 Field('name','string'),""" 174 175 for res in stor_res_list: 176 print " Field('stord_conf__%s', 'reference stord_conf__%s_link')," % (res,res ) 177 print """ format='%(name)s') 178 """ 179 180 181 182 for res in filed_res_list: 183 print """db.define_table('filed_conf__%s_link', 184 Field('%s','reference filed_conf__%s'), 185 format = '%%(id)s') 186 """ % (res,res,res) 187 print """db.define_table('filed_conf', 188 Field('name','string'),""" 189 190 for res in filed_res_list: 191 print " Field('filed_conf__%s', 'reference filed_conf__%s_link')," % (res,res ) 192 print """ format='%(name)s') 193 """ 194 195 196 197 198 for res in cons_res_list: 199 print """db.define_table('cons_conf__%s_link', 200 Field('%s','reference cons_conf__%s'), 201 format = '%%(id)s') 202 """ % (res,res,res) 203 print """db.define_table('cons_conf', 204 Field('name','string'),""" 205 206 for res in cons_res_list: 207 print " Field('cons_conf__%s', 'reference cons_conf__%s_link')," % (res,res ) 208 print """ format='%(name)s') 209 """ 338 """ % (confshort,name,confshort,parent_res, 339 confshort,name,confshort,name, 340 confshort,parent_res,confshort,parent_res) 341 342 343 344 345 346 347 348 349 # print """db.define_table('dird_conf_to_%s', 350 # Field('dird_conf','reference dird_conf'), 351 # Field('%s','reference dird_conf__%s'), 352 # format = '%%(id)s') 353 # """ % (res,res,res) 354 355 356 #for res in dir_res_list: 357 # print " Field('dird_conf__%s', 'reference dirs_to_%ss')," % (res,res ) 358 #print """ format='%(name)s') 359 #""" 360 361 362 363 #for res in stor_res_list: 364 # print """db.define_table('stord_conf__%s_link', 365 # Field('%s','reference stord_conf__%s'), 366 # format = '%%(id)s') 367 # """ % (res,res,res) 368 #print """db.define_table('stord_conf', 369 # Field('name','string'),""" 370 # 371 #for res in stor_res_list: 372 # print " Field('stord_conf__%s', 'reference stord_conf__%s_link')," % (res,res ) 373 #print """ format='%(name)s') 374 #""" 375 # 376 # 377 # 378 #for res in filed_res_list: 379 # print """db.define_table('filed_conf__%s_link', 380 # Field('%s','reference filed_conf__%s'), 381 # format = '%%(id)s') 382 # """ % (res,res,res) 383 #print """db.define_table('filed_conf', 384 # Field('name','string'),""" 385 # 386 #for res in filed_res_list: 387 # print " Field('filed_conf__%s', 'reference filed_conf__%s_link')," % (res,res ) 388 #print """ format='%(name)s') 389 #""" 390 # 391 # 392 # 393 #for res in cons_res_list: 394 # print """db.define_table('cons_conf__%s_link', 395 # Field('%s','reference cons_conf__%s'), 396 # format = '%%(id)s') 397 # """ % (res,res,res) 398 #print """db.define_table('cons_conf', 399 # Field('name','string'),""" 400 # 401 #for res in cons_res_list: 402 # print " Field('cons_conf__%s', 'reference cons_conf__%s_link')," % (res,res ) 403 #print """ format='%(name)s') 404 #""" 405 # 406 407 408 409 410 210 411 211 412 … … 247 448 248 449 249 450 # Tabellenarchitektur: 451 452 453 # Zur Speicherung der verschiedenen Ressourcentypen benötigen 454 # wir jeweils eine Tabelle für jeden Ressourcentyp 455 456 457 458 459 # jede Konfigurationsdatei hat wird durch eine Tabelle dargestellt: 460 #db.dirdconf 461 #db.consconf 462 #db.stordconf 463 #db.filedconf 464 465 # da jeder dieser Konfigurationsdateien ressourcen 466 # enthalten kann, auch unterschiedlichen Typs, 467 # enthält jede Konfigdateitabelle einen Verweis auf eine 468 # Tabelle des jeweiligen ressourcentyps. 469 # Diese Tabelle verweist dann auf die eigentlichen Ressourcen: 470 471 472 473 474 475 476 477 478 479 480 481 482 483
Note:
See TracChangeset
for help on using the changeset viewer.