Changeset 1202
- Timestamp:
- 12/13/06 16:25:01 (6 years ago)
- File:
-
- 1 edited
-
ccsd/trunk/crcnetd/_utils/ccsd_cfengine.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ccsd/trunk/crcnetd/_utils/ccsd_cfengine.py
r1199 r1202 48 48 from crcnetd._utils.ccsd_server import registerResource, exportViaXMLRPC, \ 49 49 initThread, registerRecurring, suggestThreadpoolSize 50 from crcnetd._utils.ccsd_service import getServiceInstance, ccs_service_error 50 51 51 52 DEFAULT_MAX_THREADS = 10 … … 293 294 stats["planned"] = {} 294 295 stats["generated"] = {} 296 stats["skipped"] = {} 295 297 stats["initiated"] = time.time() 296 298 stats["setupprogress"] = 10 … … 314 316 stats["planned"]["hosts"] = hosts 315 317 stats["generated"]["hosts"] = {} 316 318 stats["skipped"]["hosts"] = {} 319 317 320 # Work out how many host templates we're going to be generating 318 321 total = 0 … … 331 334 stats["planned"]["total"] += len(stats["planned"]["network"]) 332 335 stats["generated"]["network"] = {} 333 336 stats["skipped"]["network"] = {} 337 334 338 # Aquire the lock to deal with statistics 335 339 statsKey = token = createPassword(8) … … 499 503 try: 500 504 generated = _templateStats[statsKey]["generated"]["network"] 505 skipped = _templateStats[statsKey]["skipped"]["network"] 501 506 for template in network: 502 if not template in generated.keys(): 503 continue 504 # Check for errors 505 if generated[template]["error"] != "": 506 hasTemplateError = True 507 if template in generated.keys(): 508 # Check for errors 509 if generated[template]["error"] != "": 510 hasTemplateError = True 511 else: 512 if template not in skipped.keys(): 513 continue 507 514 # Remove from the list 508 515 network.remove(template) … … 666 673 template = _networkTemplates[template_id] 667 674 t = eval("template.%s()" % template.templateName) 675 # Is it enabled? 676 if not t.enabledOnNetwork(networkData["session_id"]): 677 _statsLock.acquire() 678 try: 679 skipped = _templateStats[statsKey]["skipped"]["network"] 680 skipped[template_id] = True 681 finally: 682 _statsLock.release() 683 _threadLimit.release() 684 return 668 685 # Set up the variables we want to substitute in 669 686 t._searchList = [networkData] … … 789 806 return host.hasServiceEnabledByName(serviceName) 790 807 808 def enabledOnNetwork(self, session_id): 809 """Returns true if the template is able to be processed 810 811 By default this method looks to see if the template has defined a 812 serviceName parameter. If it has then the function checks to see if 813 that service is enabled. If it is not the function returns False. 814 815 This function may be overriden by other classes/templates if you want 816 to implement more logic than the default implementation provides. 817 """ 818 serviceName = getattr(self, "serviceName", None) 819 if serviceName is None: 820 return True 821 822 try: 823 service = getServiceInstance(session_id, serviceName) 824 except ccs_service_error: 825 # Named service not known 826 return False 827 return service.getState() 828 791 829 def getTemplateVariables(self): 792 830 """Returns a dictionary of variables that can be used by the template … … 913 951 session.begin("Moved SSH keys due to host rename from %s => %s" % 914 952 (old_name, host["host_name"])) 915 print "started revision"916 953 commit = 1 917 954 … … 940 977 # Commit changeset if necessary 941 978 if commit==1: 942 print "committing revision"943 979 session.commit() 944 980 … … 1259 1295 # PHP sends in an associative array we want the values only 1260 1296 hosts = hosts.values() 1261 print hosts1262 1297 1263 1298 # Loop through the specified hosts and mark them as pending
Note: See TracChangeset
for help on using the changeset viewer.
