def calc_req(request): req_line = loads(request.POST['json']) return HttpResponse(dumps(calculate_req_line(req_line)))
def load_eos_from_xls_new(xls_file): EOS_VALS = {} if eos_xls_check(xls_file): try: xls_workbook = open_workbook(xls_file) xls_worksheet = xls_workbook.sheet_by_name(u'Технические требования') except: return None EOS_VALS['prjnum'] = str(xls_worksheet.cell_value(xls_vals['prjrow'], xls_vals['prjcell'])).split(".")[0] num_rows = xls_worksheet.nrows - 1 curr_row = xls_vals['eos_start_row'] req_count = 0 while curr_row <= num_rows: req_line = {} xls_line = {} for key in xls_vals.keys(): if '_col' in key: try: xls_line[key] = unicode(xls_worksheet.cell_value(curr_row, xls_vals[key])) except: xls_line[key] = "" # print xls_line xls_value = xls_line['itemtype1_col'] # print xls_value if xls_value == u'Сервер БД' or xls_value == u'Сервер_БД': req_line['itemtype1']='db' elif xls_value == u'Сервер приложений' or xls_value == u'Сервер_приложений': req_line['itemtype1']='app' elif xls_value == u'TS' or xls_value == u'Терминальный_сервер': req_line['itemtype1']='term' elif xls_value == u'Сервер MQ (DMZ)' or xls_value == u'Сервер_MQ_Шлюз': req_line['itemtype1']='mqdmz' req_line['platform_type']='---' elif xls_value == u'Сервер_архивной_СУБД': req_line['itemtype1']='dbarch' elif xls_value == u'IBM_DataPower': req_line['platform_type'] = '---' req_line['ostype'] = '---' req_line['itemtype1'] = 'dp' req_line['utilization'] = '100' elif xls_value == u'Балансировщик': req_line['platform_type'] = '---' req_line['ostype'] = '---' req_line['itemtype1'] = 'lb' req_line['utilization'] = '100' else: req_line['itemtype1']='other' xls_value = xls_line['itemname_col'] req_line['itemname'] = xls_value req_line['servername']=xls_line['servername_col'] if (req_line['servername'] == '') or (u'Новый КТС' in req_line['servername']): req_line['itemtype2'] = 'new' else: req_line['itemtype2'] = 'upgrade' req_line['cpu_count']= xls_line['cpucount_col'].split(".")[0] if req_line['cpu_count'] == '': req_line['cpu_count'] = 0 req_line['ram_count']= xls_line['ramcount_col'].split(".")[0] if req_line['ram_count'] == '': req_line['ram_count'] = 0 req_line['hdd_count']= xls_line['hddcount_col'].split(".")[0] if req_line['hdd_count'] == '': req_line['hdd_count'] = 0 req_line['san_count']= xls_line['sancount_col'].split(".")[0] if req_line['san_count'] == '': req_line['san_count'] = 0 req_line['nas_count']= xls_line['nascount_col'].split(".")[0] if req_line['nas_count'] == '': req_line['nas_count'] = 0 req_line['item_count']= xls_line['itemcount_col'].split(".")[0] if req_line['item_count'] == '': req_line['item_count'] = 0 xls_value = xls_line['platform_type_col'] if xls_value == u'x86_vm' and req_line['itemtype1'] <> 'mqdmz': req_line['platform_type']='x86_vm' elif xls_value == u'x86' and req_line['itemtype1'] <> 'mqdmz': req_line['platform_type']='x86' elif xls_value == u'Power': req_line['platform_type']='power' elif (xls_value == u'SPARC T') or (xls_value == u'SPARC_T'): req_line['platform_type']='t_series' elif (xls_value == u'SPARC 64') or (xls_value == u'SPARC_M'): req_line['platform_type']='m_series' elif xls_value == u'Itanium': req_line['platform_type']='itanium' # elif xls_value == u'DataPower': # req_line['platform_type']='---' # req_line['ostype']='---' # req_line['itemtype1']='dp' # req_line['utilization']='100' # elif xls_value == u'Alteon': # req_line['platform_type']='---' # req_line['ostype']='---' # req_line['itemtype1']='lb' # req_line['utilization']='100' elif xls_value == u'Другое': req_line['platform_type']='---' else: req_line['platform_type']='---' xls_value = xls_line['ostype_col'] if u'aix' in xls_value.lower(): req_line['ostype']='aix' elif u'solaris' in xls_value.lower(): req_line['ostype']='solaris' elif (u'linux' in xls_value.lower()) or (u'rhel' in xls_value.lower()) or\ (u'sles' in xls_value.lower()): req_line['ostype']='linux' elif u'win' in xls_value.lower(): req_line['ostype']='windows' elif (u'hp' in xls_value.lower()) and (u'ux' in xls_value.lower()): req_line['ostype']='hpux' else: if not(req_line['platform_type'] == '---'): if req_line['platform_type'] == 'itanium': req_line['ostype']='hpux' elif req_line['platform_type'] == 'power': req_line['ostype']='aix' elif (req_line['platform_type'] == 't_series') or (req_line['platform_type'] == 'm_series'): req_line['ostype']='solaris' elif 'x86' in req_line['platform_type']: req_line['ostype']='linux' else: req_line['ostype']='---' req_line['swaddons']=xls_line['swaddons_col'] xls_value = xls_line['itemstatus_col'] if u'пром' in xls_value.lower(): req_line['itemstatus'] = 'prom' elif u'нт' in xls_value.lower(): req_line['itemstatus'] = 'test-nt' elif u'dev' in xls_value.lower(): req_line['itemstatus'] = 'test-dev' elif u'сст1' in xls_value.lower(): req_line['itemstatus'] = 'test-sst1' elif u'сст2' in xls_value.lower(): req_line['itemstatus'] = 'test-sst2' elif u'ифт' in xls_value.lower(): req_line['itemstatus'] = 'test-ift' elif u'обуч' in xls_value.lower(): req_line['itemstatus'] = 'test-obuch' elif u'пси' in xls_value.lower(): req_line['itemstatus'] = 'test-psi' elif u'hf' in xls_value.lower(): req_line['itemstatus'] = 'test-hf' else: req_line['itemstatus'] = 'test-other' xls_value = xls_line['lansegment_col'] if xls_value == u'ALPHA': req_line['lan_segment'] = 'alpha' elif xls_value == u'SIGMA': req_line['lan_segment'] = 'sigma' elif xls_value == u'TAU': req_line['lan_segment'] = 'tay' elif xls_value == u'DMZ': req_line['lan_segment'] = 'DMZ' else: req_line['lan_segment'] = 'other' xls_value = xls_line['swtype_col'].lower() if (u'oracle' in xls_value) and (not u'java' in xls_value): req_line['db_type']='oracle' req_line['app_type']='---' elif u'db2' in xls_value: req_line['db_type']='db2' req_line['app_type']='---' elif u'sql' in xls_value: req_line['db_type'] = 'mssql' req_line['app_type']='---' elif u'mq' in xls_value: req_line['db_type'] = '---' req_line['app_type']='mq' elif u'mb' in xls_value: req_line['db_type'] = '---' req_line['app_type']='mb' elif u'was' in xls_value: req_line['db_type'] = '---' req_line['app_type']='was' elif (u'ad' in xls_value) or (u'active' in xls_value) or (u'directory' in xls_value): req_line['db_type'] = '---' req_line['app_type']='ad' elif (u'iis' in xls_value): req_line['db_type'] = '---' req_line['app_type']='iis' elif (u'dns' in xls_value): req_line['db_type'] = '---' req_line['app_type']='dns' elif (u'судир' in xls_value): req_line['db_type'] = '---' req_line['app_type']='sudir' elif (u'wls' in xls_value) or (u'weblogic' in xls_value): req_line['db_type'] = '---' req_line['app_type']='wls' elif (u'sybase' in xls_value): req_line['db_type'] = '---' req_line['app_type']='sybase_as' elif (u'prpc' in xls_value): req_line['db_type'] = '---' req_line['app_type']='prpc' else: req_line['db_type'] = '---' req_line['app_type']='---' xls_value = xls_line['irestype_col'].lower() # print 'xls_value = ' + xls_value if (u'oracle' in xls_value) and (not u'as' in xls_value): req_line['db_type']='oracle' req_line['app_type']='---' elif u'db2' in xls_value: req_line['db_type']='db2' req_line['app_type']='---' elif u'ms sql' in xls_value: req_line['db_type'] = 'mssql' req_line['app_type']='---' elif u'mq series' in xls_value: req_line['db_type'] = '---' req_line['app_type']='mq' elif u'message broker' in xls_value: req_line['db_type'] = '---' req_line['app_type']='mb' elif (u'websphere' in xls_value) and (not u'message broker' in xls_value): req_line['db_type'] = '---' req_line['app_type']='was' elif (u'web-' in xls_value) or (u'iis' in xls_value): req_line['db_type'] = '---' req_line['app_type']='iis' elif (u'weblogic' in xls_value) or (u'wls' in xls_value): req_line['db_type'] = '---' req_line['app_type']='wls' elif (u'eas server' in xls_value) or (u'sybase' in xls_value): req_line['db_type'] = '---' req_line['app_type']='sybase_as' elif (u'prpc' in xls_value): req_line['db_type'] = '---' req_line['app_type']='prpc' else: req_line['db_type'] = '---' req_line['app_type']='---' # print 'db_type = ' + req_line['db_type'] # print 'app_type = ' + req_line['app_type'] # print "db_type - " + req_line['db_type'] # print "app_type - " + req_line['app_type'] xls_value = xls_line['clustype_col'] if (u'тр' in xls_value.lower()) or (u'лок' in xls_value.lower()): req_line['cluster_type'] = 'vcs' elif (u'на уровне приложения' in xls_value.lower()) : req_line['cluster_type'] = 'app' else: req_line['cluster_type'] = 'none' xls_value = xls_line['backuptype_col'] if xls_value == u'НЕТ': req_line['backup_type'] = 'no' else: req_line['backup_type'] = 'yes' req_line['utilization']='100' xls_value = xls_worksheet.cell_value(curr_row, xls_vals['project_id']) if xls_value: try: req_line['project_id'] = str(unicode(xls_value)).split('.')[0] except: req_line['project_id'] = xls_value curr_row += 1 if (req_line['item_count'] <> 0) and (req_line['item_count'] <> ""): req_line = calculate_req_line(req_line) req_count += 1 for key in req_line.keys(): EOS_VALS[key+'_'+str(req_count)] = req_line[key] EOS_VALS['req_count'] = req_count return EOS_VALS else: return None