def prepare_global_plan(filename): REQS = load_eos_from_xls_new(filename) prepocess_super_plan(REQS) try: if access(GLOBAL_PLAN_WORK_DIR, R_OK): print "Directory exists" try: # make_tarfile(BOC_WORK_DIR + "global_plan.tar", GLOBAL_PLAN_WORK_DIR) make_zipfile(BOC_WORK_DIR + "global_plan.zip", GLOBAL_PLAN_WORK_DIR) # tarfile = BOC_WORK_DIR + "global_plan.tar" tarfile = BOC_WORK_DIR + "global_plan.zip" except: tarfile = None logger.error("Error while creating tarball for GLOBAL_PLAN_WORK_DIR") except: logger.error("Access denied for GLOBAL_PLAN_WORK_DIR") return tarfile
def prepare_resource_plan(eos_items, workdir=BOC_WORK_DIR, compress=True): sudir_included = False try: project_id = str(eos_items["project_id"]) except: project_id = eos_items["project_id"] project_name = eos_items["project_name"] eos_items.pop("project_id", None) eos_items.pop("project_name", None) if project_id == u"0": filename = "tp_" + str(int(time())) else: filename = "tp_" + project_id techporject = ProjectPlan(project_id, path.join(workdir, filename + ".xml")) techporject.add_extednded_attrs() techporject.add_calendar() project_tasks = { "prom": [], "test-nt": [], "test-dev": [], "test-sst1": [], "test-sst2": [], "test-ift": [], "test-obuch": [], "test-psi": [], "test-hf": [], "test-other": [], } for key in eos_items.keys(): req_line_tasks = [] # print eos_items[key] if "x86" in eos_items[key]["platform_type"]: if (eos_items[key]["platform_type"] == "x86") or (eos_items[key]["itemtype1"] == u"mqdmz"): if (eos_items[key]["itemtype1"] == u"mqdmz") or (eos_items[key]["ostype"] == u"windows"): if eos_items[key]["cluster_type"] == u"vcs": if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["windows_cluster"]) else: req_line_tasks.append(tasks_id_values["windows_cluster_test"]) else: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["windows_standalone"]) else: req_line_tasks.append(tasks_id_values["windows_standalone_test"]) if int(eos_items[key]["san_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["san_upgrade_standalone"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_standalone_test"]) if int(eos_items[key]["nas_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["nas_upgrade"]) else: req_line_tasks.append(tasks_id_values["nas_upgrade_test"]) elif eos_items[key]["ostype"] == u"linux": if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["linux"]) else: req_line_tasks.append(tasks_id_values["linux_test"]) if int(eos_items[key]["san_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": if eos_items[key]["cluster_type"] == u"vcs": req_line_tasks.append(tasks_id_values["san_upgrade_cluster"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_standalone"]) else: if eos_items[key]["cluster_type"] == u"vcs": req_line_tasks.append(tasks_id_values["san_upgrade_cluster_test"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_standalone_test"]) if int(eos_items[key]["nas_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["nas_upgrade"]) else: req_line_tasks.append(tasks_id_values["nas_upgrade_test"]) elif eos_items[key]["platform_type"] == "x86_vm": if eos_items[key]["ostype"] == u"windows": if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["x86_vm"]) req_line_tasks.append(tasks_id_values["windows_standalone"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["x86_vm_test"]) req_line_tasks.append(tasks_id_values["windows_standalone_test"]) if int(eos_items[key]["san_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["san_upgrade_standalone"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_standalone_test"]) if int(eos_items[key]["nas_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["nas_upgrade"]) else: req_line_tasks.append(tasks_id_values["nas_upgrade_test"]) elif eos_items[key]["ostype"] == u"linux": if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["x86_vm"]) req_line_tasks.append(tasks_id_values["linux"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["x86_vm_test"]) req_line_tasks.append(tasks_id_values["linux_test"]) if int(eos_items[key]["san_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["san_upgrade_standalone"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_standalone_test"]) if int(eos_items[key]["nas_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["nas_upgrade"]) else: req_line_tasks.append(tasks_id_values["nas_upgrade_test"]) elif eos_items[key]["platform_type"] == "power": if eos_items[key]["itemtype2"] == u"upgrade": if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["aix_upgrade"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["aix_upgrade_test"]) if int(eos_items[key]["san_count"]) > 0: if eos_items[key]["cluster_type"] == u"vcs": if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["san_upgrade_cluster"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_cluster_test"]) else: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["san_upgrade_standalone"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_standalone_test"]) if int(eos_items[key]["nas_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["nas_upgrade"]) else: req_line_tasks.append(tasks_id_values["nas_upgrade_test"]) elif eos_items[key]["cluster_type"] == u"vcs": if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["aix_cluster"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["aix_cluster_test"]) else: if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["aix_standalone"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["aix_standalone_test"]) elif u"_series" in eos_items[key]["platform_type"]: if eos_items[key]["itemtype2"] == u"upgrade": if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["solaris_upgrade"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["solaris_upgrade_test"]) if int(eos_items[key]["san_count"]) > 0: if eos_items[key]["cluster_type"] == u"vcs": if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["san_upgrade_cluster"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_cluster_test"]) else: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["san_upgrade_standalone"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_standalone_test"]) if int(eos_items[key]["nas_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["nas_upgrade"]) else: req_line_tasks.append(tasks_id_values["nas_upgrade_test"]) elif eos_items[key]["cluster_type"] == u"vcs": if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["solaris_cluster"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["solaris_cluster_test"]) else: if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["solaris_standalone"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["solaris_standalone_test"]) elif eos_items[key]["platform_type"] == "itanium": if eos_items[key]["itemtype2"] == u"upgrade": if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["hpux_upgrade"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["hpux_upgrade_test"]) if int(eos_items[key]["san_count"]) > 0: if eos_items[key]["cluster_type"] == u"vcs": if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["san_upgrade_cluster"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_cluster_test"]) else: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["san_upgrade_standalone"]) else: req_line_tasks.append(tasks_id_values["san_upgrade_standalone_test"]) if int(eos_items[key]["nas_count"]) > 0: if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["nas_upgrade"]) else: req_line_tasks.append(tasks_id_values["nas_upgrade_test"]) elif eos_items[key]["cluster_type"] == u"vcs": if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["hpux_cluster"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["hpux_cluster_test"]) else: if (eos_items[key]["itemstatus"] == u"prom") and (int(eos_items[key]["cpu_count"]) > 0): req_line_tasks.append(tasks_id_values["hpux_standalone"]) elif int(eos_items[key]["cpu_count"]) > 0: req_line_tasks.append(tasks_id_values["hpux_standalone_test"]) else: if eos_items[key]["itemtype1"] == u"dp": if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["datapower"]) else: req_line_tasks.append(tasks_id_values["datapower_test"]) elif eos_items[key]["itemtype1"] == u"lb": if eos_items[key]["itemstatus"] == u"prom": req_line_tasks.append(tasks_id_values["loadbalancer"]) else: req_line_tasks.append(tasks_id_values["loadbalancer_test"]) if (eos_items[key]["db_type"] <> "---") and (eos_items[key]["itemtype2"] <> u"upgrade"): if eos_items[key]["db_type"] == "mssql": req_line_tasks.append(tasks_id_values["mssql"]) elif eos_items[key]["db_type"] == "db2": if eos_items[key]["cluster_type"] == u"vcs": req_line_tasks.append(tasks_id_values["db2_cluster"]) else: req_line_tasks.append(tasks_id_values["db2_standalone"]) elif "oracle" in eos_items[key]["db_type"]: if eos_items[key]["cluster_type"] == u"vcs": req_line_tasks.append(tasks_id_values["oracle_cluster"]) else: req_line_tasks.append(tasks_id_values["oracle_standalone"]) if (eos_items[key]["app_type"] <> "---") and (eos_items[key]["itemtype2"] <> u"upgrade"): if eos_items[key]["app_type"] == "was": if eos_items[key]["cluster_type"] == u"app": req_line_tasks.append(tasks_id_values["was_cluster"]) else: req_line_tasks.append(tasks_id_values["was_standalone"]) if eos_items[key]["app_type"] == "mb": if eos_items[key]["cluster_type"] == u"app": req_line_tasks.append(tasks_id_values["wmb_cluster"]) else: req_line_tasks.append(tasks_id_values["wmb_standalone"]) if eos_items[key]["app_type"] == "wls": if eos_items[key]["cluster_type"] == u"app": req_line_tasks.append(tasks_id_values["wls_cluster"]) else: req_line_tasks.append(tasks_id_values["wls_standalone"]) if eos_items[key]["app_type"] == "mq": if eos_items[key]["cluster_type"] == u"app": req_line_tasks.append(tasks_id_values["mq_cluster"]) else: req_line_tasks.append(tasks_id_values["mq_standalone"]) if eos_items[key]["app_type"] == "sybase_as": if eos_items[key]["cluster_type"] == u"app": req_line_tasks.append(tasks_id_values["sybase_cluster"]) else: req_line_tasks.append(tasks_id_values["sybase_standalone"]) if eos_items[key]["app_type"] == "iis": req_line_tasks.append(tasks_id_values["iis"]) if eos_items[key]["app_type"] == "prpc": req_line_tasks.append(tasks_id_values["was_standalone"]) req_line_tasks.append(tasks_id_values["prpc"]) if eos_items[key]["app_type"] == "ad": req_line_tasks.append(tasks_id_values["ad"]) if eos_items[key]["app_type"] == "dns": req_line_tasks.append(tasks_id_values["dns"]) if eos_items[key]["app_type"] == "sudir": req_line_tasks.append(tasks_id_values["sudir"]) if eos_items[key]["itemtype1"] == "term": req_line_tasks.append(tasks_id_values["citrix"]) # print req_line_tasks # print eos_items[key] for i in range(int(eos_items[key]["item_count"])): task_details = unicode(ru_vals[eos_items[key]["itemtype1"]]) project_tasks[eos_items[key]["itemstatus"]].append({"task_details": task_details, "tasks": req_line_tasks}) # block_id = None # for task in req_line_tasks: # task_details = unicode(ru_vals[eos_items[key]['itemtype1']]) + u' CPU/RAM/SAN : ' + \ # str(eos_items[key]['cpu_count']) + u"/" + str(eos_items[key]['ram_count']) + u"/" + \ # str(eos_items[key]['san_count']) # block_id = techporject.add_task(taskid=task, linked_with_block=block_id, # task_additional_name = task_details) # print project_tasks if project_tasks["prom"]: project_tasks["prom"].append({"task_details": u"Интеграционное решение", "tasks": [tasks_id_values["sudir"]]}) sudir_included = True else: for key in project_tasks.keys(): if project_tasks[key] and (not sudir_included): project_tasks[key].append( {"task_details": u"Интеграционное решение", "tasks": [tasks_id_values["sudir"]]} ) sudir_included = True try: if access(workdir + project_id, R_OK): print "Directory exists" rmtree(workdir + project_id) mkdir(workdir + project_id) PROJECT_DIR = workdir + project_id except: PROJECT_DIR = workdir print PROJECT_DIR for key in project_tasks: if project_tasks[key]: # print "key = " + key techporject = ProjectPlan( project_id, path.join(PROJECT_DIR, filename + "_" + ru_vals_4project[key] + ".xml") ) techporject.add_extednded_attrs() techporject.add_calendar() techporject.add_summary_task(name=project_id + "_" + ru_vals_4project[key]) for req_line_tasks in project_tasks[key]: block_id = None for task in req_line_tasks["tasks"]: # print task # task_details = unicode(ru_vals[eos_items[key]['itemtype1']]) + u' CPU/RAM/SAN : ' + \ # str(eos_items[key]['cpu_count']) + u"/" + str(eos_items[key]['ram_count']) + u"/" + \ # str(eos_items[key]['san_count']) block_id = techporject.add_task( taskid=task, linked_with_block=block_id, task_additional_name=req_line_tasks["task_details"] ) techporject.export_project_xml() if compress: try: make_zipfile(workdir + filename + ".zip", PROJECT_DIR) except: filename = None logger.error("Error compressing %s directory" % PROJECT_DIR) else: filename = None return filename