示例#1
0
def process_2b(otsa, contract, inc):
    """Process transactions with '2B' status."""
    zld_remedy_url = 'https://itsmweb.corp.tepenet/arsys/forms/itsm.corp.tepenet/TP%3ASKR%3AUserPage/ORANGE_ZLD/'
    _ = otsa
    resolution, work_info = '', ''
    if to_cancel(inc):
        return resolution, work_info
    if 'ponowione' in inc['summary']:
        resolution = 'Umowa ' + contract[
            'trans_num'] + ' przekazana do realizacji.'
    elif contract['process_error'] != -31000:
        work_info_ = get_work_info(inc)
        if not is_work_info_empty(work_info_):
            return '', ''

        if contract['trans_type'][0] == 'T':
            ml_con = ml_prod_connection()
            ml_order = get_order_data(ml_con, contract['msisdn'])
            if ml_order and ml_order['status'] != 'DELV':
                resolution = 'Zamówienie przetwarzane w ML. ' \
                             'Proszę swoje zgłoszenie przekierować na panel zarządzania łańcuchem dostaw: {}'. \
                    format(zld_remedy_url)
            ml_con.close()
        else:
            work_info += 'Umowa {} (ncs_trans_num: {}, om_order_id: {}) w trakcie realizacji. ' \
                         'Prośba o weryfikację w OM.' \
                .format(contract['trans_num'], contract['ncs_trans_num'], contract['om_order_id'])
            reassign_incident(inc, 'OM')
            resolution = ''
    return resolution, work_info
示例#2
0
def handle_ncs_errors(otsa, contract, inc):
    """Handle NCS errors - another artificially separated function just to try and solve the process_3c mess."""
    update_status = True
    if contract['ncs_error_desc'] is not None and 'CSC.185' in contract[
            'ncs_error_desc']:
        fix_csc185(otsa, contract['cart_code'])
        resolution = ''
    elif contract['ncs_error_desc'] is not None and 'CSC.178' in contract[
            'ncs_error_desc']:
        fix_csc178(otsa, contract['cart_code'])
        resolution = ''
    elif contract['ncs_error_desc'] is not None and 'CSC.59' in contract[
            'ncs_error_desc']:  # CSC.598, CSC.597
        if not contract['cart_code']:
            fix_csc598(otsa, contract['trans_code'])
        else:
            cart = search_cart(otsa, contract['cart_code'])
            fix_csc598_cart(otsa, cart)
        resolution = ''
    elif contract['ncs_error_desc'] is not None and 'EDL.33' in contract[
            'ncs_error_desc']:
        update_transaction(otsa, contract['trans_code'], '3A')
        update_contract(otsa, contract['trans_code'], '3A')
        update_status = False
        resolution = 'Umowa ' + str(contract['trans_num']) + ' zrealizowana.'
    elif contract[
            'ncs_error_desc'] is not None and 'ACCOUNT ALREADY CREATED' in contract[
                'ncs_error_desc']:
        bscs = bscs_connection()
        customer_id = get_customer_id(bscs, contract['custcode'])
        bscs.close()
        fix_aac(otsa, contract['trans_code'], customer_id)
        resolution = ''
    elif contract['ncs_error_desc'] is not None and (
            'na zleceniu nie odpowiada' in contract['ncs_error_desc']
            or 'nie jest dostepny' in contract['ncs_error_desc']):
        work_info = get_work_info(inc)
        if not is_work_info_empty(work_info):
            return ''
        add_work_info(
            inc, 'VC_OPTIPOS',
            'Prośba o weryfikację, MSISDN {}.'.format(contract['msisdn']))
        reassign_incident(inc, 'OV')
        resolution = ''
    elif contract['ncs_error_desc'] is not None and 'Voucher' in contract[
            'ncs_error_desc']:
        work_info = get_work_info(inc)
        if not is_work_info_empty(work_info):
            return ''
        add_work_info(
            inc, 'VC_OPTIPOS',
            'Prośba o zmianę statusu vouchera, MSISDN {}.'.format(
                contract['msisdn']))
        reassign_incident(inc, 'OV')
        resolution = ''
    else:
        resolution = ''
    return update_status, resolution
def optipos_tp_errors():
    pesel_or_nip_regex = re.compile(r'\d{10,11}')
    incidents = get_all_incidents('VC3_BSS_OPTIPOS_FIX')
    for inc in incidents:
        if not has_exactly_one_entry(get_work_info(inc)):
            continue

        lines = inc['notes']
        pesel_or_nip_string = ''
        for i, line in enumerate(lines):
            if 'Proszę podać numer PESEL lub NIP klienta:' in line:
                pesel_or_nip_regex_search_result = pesel_or_nip_regex.findall(
                    lines[i + 1])
                if not pesel_or_nip_regex_search_result:
                    continue
                pesel_or_nip_string = pesel_or_nip_regex_search_result[
                    0].strip()
        if not pesel_or_nip_string:
            continue

        get_session_data_cmd = """ 
            ssh hooter "find /nas/logs/optineo -maxdepth 1 -name 'optineo_*.log*' -mtime -7 | 
            xargs grep {} | cut -d' ' -f1,2,4 | sed 's/:/\ /' | sort -k2 | tail -1" """.format(
            pesel_or_nip_string)
        get_logs_cmd = 'ssh hooter "fgrep {} {} | grep xml | tail -2"'

        ssh_client = paramiko.SSHClient()
        ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh_client.connect(config.OPTPOS_LOGS['server'],
                           username=config.OPTPOS_LOGS['user'],
                           password=config.OPTPOS_LOGS['password'],
                           allow_agent=False)
        _, ssh_stdout, _ = ssh_client.exec_command(
            get_session_data_cmd.format(pesel_or_nip_string))
        session_data = ssh_stdout.readlines()
        if not session_data:
            continue

        session_data = session_data[0].strip().split(' ')
        file, session = session_data[0], session_data[3]
        _, ssh_stdout, _ = ssh_client.exec_command(
            get_logs_cmd.format(session, file))
        logs = ssh_stdout.readlines()

        input_, output = logs[0], logs[1]
        if 'INVALID' in output or 'PSCRM' in output:
            wi_notes = 'Prośba o weryfikację:\r\n\r\n{}\r\n{}\r\n'.format(
                input_, output)
            add_work_info(inc, 'VC_OPTIPOS', wi_notes)
            reassign_incident(inc, 'VC3_BSS_OV_TP')
def pbi184471():
    wi_notes = 'Błędna sekcja documents, brak określenia pola TYPE dla jednego z dokumentów. PBI000000184471'
    incidents = []
    incidents += get_incidents('VC3_BSS_OM_TP', '(001) CRM Fix')
    incidents += get_incidents('VC3_BSS_OM_TP', '(039) Obieg zleceń CRM-KSP')
    provik = provik_connection()
    for inc in incidents:
        work_info = get_work_info(inc)
        tel_order_number = get_tel_order_number(inc)
        if (is_work_info_empty(work_info) or has_exactly_one_entry(work_info))\
                and has_pbi184471_error(provik, tel_order_number):
            add_work_info(inc, 'OM_TP', wi_notes)
            reassign_incident(inc, 'APLIKACJE_DEVOPS_HYBRIS')
    provik.close()
def process_sims(sims, otsa, inc):
    """This function changes SIM card statuses, if allowed and necessary.
    If the status is 'd', 'l', or 'E', then we change it to 'r' and close the ticket.
    If it's 'a' or 'B' or there is an open transaction with this card, we don't change the status.
    All other cases (less than 1%) must be handled manually."""
    all_resolved = True
    resolution = ''

    nra = nra_connection()
    for sim in sims:
        partial_resolution = ''
        result = check_sim(otsa, sim)
        result = [r for r in result if r['status'] not in ('3D', '3G', '9')]
        if not result:
            wi_notes = ''
            sim_status = get_sim_status(nra, sim)
            if not sim_status:
                partial_resolution = 'Brak karty SIM {0} w nRA. Proszę podać poprawny numer.'.format(sim)
                resolution = partial_resolution + '\r\n'
                continue
            if sim_status['status_nra'] == sim_status['status_bscs']:
                if sim_status['status_nra'] in ('r', 'd', 'l', 'E') \
                        and sim_status['status_nra'] == sim_status['status_bscs']:
                    set_sim_status_nra(nra, sim, 'r')
                    set_sim_status_bscs(nra, sim, 'r')
                    set_imsi_status_bscs(nra, sim_status['imsi'], 'r')
                    partial_resolution = 'Karta SIM {0} uwolniona.'.format(sim)
                elif sim_status['status_nra'] in ('a', 'B'):
                    partial_resolution = 'Karta SIM {0} aktywna. Brak możliwości odblokowania.'.format(sim)
                else:
                    all_resolved = False
                    wi_notes += 'Karta SIM {} w statusie {}.\nW Optiposie brak powiązań.'.format(sim, sim_status)
            if wi_notes:
                add_work_info(inc, 'VC_OPTIPOS', wi_notes)
                reassign_incident(inc, 'NRA')
        else:
            partial_resolution = 'Karta SIM {0} powiązana z nieanulowaną umową {1}. ' \
                                 'Brak możliwości odblokowania. ' \
                                 'Proszę o kontakt z dealer support lub z działem reklamacji.' \
                .format(sim, result[0]['trans_num'])
        if partial_resolution != '':
            resolution = resolution + '\r\n' + partial_resolution
    nra.close()

    return all_resolved, resolution
示例#6
0
def send_error_to_ov(inc, contract):
    """Look for an error in applier logs an if there is one, send it to OV for further analysis."""
    grep_files = '/nas/logs/optpos/NodeManagerLogs/applier_*.log'
    grep_command = 'grep {} {} | grep INVOKE | tail -2 | grep -v ">0</errorCode>" | grep -v createInteraction'
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(config.OPTPOS_LOGS['server'],
                allow_agent=False,
                username=config.OPTPOS_LOGS['user'],
                password=config.OPTPOS_LOGS['password'])
    _, ssh_stdout, _ = ssh.exec_command(
        grep_command.format(contract['trans_code'], grep_files))
    logs = ssh_stdout.readlines()
    if len(logs) == 2:
        work_info = get_work_info(inc)
        if not is_work_info_empty(work_info):
            return ''
        work_info = 'Prośba o weryfikację: \r\n' + logs[0] + '\r\n' + logs[1]
        add_work_info(inc, 'VC_OPTIPOS', work_info)
        reassign_incident(inc, 'OV')
    return ''
def cancel_om_orders():
    incidents = get_all_incidents('VC3_BSS_OM_TP')
    provik = provik_connection()
    for inc in incidents:
        work_info = get_work_info(inc)
        tel_order_number = get_tel_order_number(inc)
        order_info = get_order_info(tel_order_number)
        order_data = get_order_data(order_info)

        ord_id = None
        if 'OM zamowienie (ORD_ID)' in order_data:
            ord_id = order_data['OM zamowienie (ORD_ID)']

        if not ord_id or is_ctx_session(ord_id):
            continue

        for entry in work_info:
            notes = '\r\n'.join(entry['notes']).lower()
            summary = entry['summary'].lower()
            if 'crm' in summary and \
                    ('anulowanie z bazy' in notes or 'do anulowania z bazy' in notes) \
                    and not has_gpreprov(provik, ord_id):

                if is_geqret_processing(provik, ord_id):
                    pgo_ids = get_pgo_id(provik, ord_id, 'GEQRET')
                    for pgo_id in pgo_ids:
                        set_business_error(pgo_id)
                        bpm_id = get_bpm_id(provik, pgo_id)
                        delete_process_timeout(provik, bpm_id)

                pgo_id_gbill = get_pgo_id(provik, ord_id, 'GBILL')
                set_business_error(pgo_id_gbill)
                pgo_id_gprov = get_pgo_id(provik, ord_id, 'GPROV')
                set_business_error(pgo_id_gprov)
                cancel_order(provik, ord_id)
                add_work_info(inc, 'OM_TP', 'Zamówienie anulowane.')
                reassign_incident(inc, 'VC3_BSS_CRM_FIX')
    provik.close()
def handle_brm_errors():
    incidents = get_all_incidents('VC3_BSS_OM_TP')
    provik = provik_connection()

    for inc in incidents:
        if to_cancel(inc):
            continue

        work_info = get_work_info(inc)
        tel_order_number = get_tel_order_number(inc)
        order_info = get_order_info(tel_order_number)
        order_data = get_order_data(order_info)
        if 'OM zamowienie (ORD_ID)' in order_data:
            ord_id = order_data['OM zamowienie (ORD_ID)']

        if 'BRM3' in inc['summary']:
            if is_gbill_out_for_order(provik, ord_id):
                update_summary(inc, 'CRM')
                add_work_info(inc, 'OM_TP', 'Poprawione.')
                reassign_incident(inc, 'VC3_BSS_CRM_FIX')

        elif 'BRM2' in inc['summary']:
            if is_gbill_out_for_order(provik, ord_id):
                resolution = 'Zamówienie {} przekazane do realizacji.'.format(tel_order_number)
                close_incident(inc, resolution)

        elif 'BRM' in inc['summary'] or 'PK' in inc['summary']:
            promotion_regex = re.compile(r'pro[0-9]{14}')
            promotion_ids = []
            return_flag = get_return_flag(work_info)

            for entry in work_info[::-1]:
                notes = '\r\n'.join(entry['notes']).lower()
                summary = entry['summary'].lower()
                promotion_ids += promotion_regex.findall(notes)

                if 'crm' in summary and \
                        ('bez kary' in notes or 'bez naliczania kary' in notes or 'bez naliczenia kary' in notes):
                    if ord_id:
                        fine_flag_value_replace(ord_id, inc)
                        resubmit_successful = resubmit_goal(tel_order_number)
                        if resubmit_successful:
                            update_summary(inc, 'BRM3') if return_flag else update_summary(inc, 'BRM2')

                elif 'crm' in summary and ('promo' in notes or 'pro000' in notes) and \
                        ('bez' in notes or 'usunięcie' in notes or 'do usunięcia' in notes):
                    promotion_ids_from_crm = promotion_regex.findall(notes)
                    promotion_id = None
                    # promotion_ids = list(set(promotion_ids))
                    # if len(promotion_ids) == 1:
                    #     promotion_id = promotion_ids[0].upper()
                    if len(promotion_ids_from_crm) == 1:
                        promotion_id = promotion_ids_from_crm[0].upper()
                    if promotion_id:
                        update_cf_service(ord_id, promotion_id, inc)
                        resubmit_successful = resubmit_goal(tel_order_number)
                        if resubmit_successful:
                            update_summary(inc, 'BRM3') if return_flag else update_summary(inc, 'BRM2')

                elif 'crm' in summary and \
                        ('bez ins000' in notes or 'usunięcie ins000' in notes or 'do usunięcia ins000' in notes):
                    ins_regex = re.compile(r'ins[0-9]{14}')
                    ins_ids = ins_regex.findall(notes)
                    ins_id = None
                    if len(ins_ids) == 1:
                        ins_id = ins_ids[0].upper()
                    if ins_id:
                        delete_cf_service(ord_id, ins_id, inc)
                        resubmit_successful = resubmit_goal(tel_order_number)
                        if resubmit_successful:
                            update_summary(inc, 'BRM3') if return_flag else update_summary(inc, 'BRM2')

        elif tel_order_number and (is_work_info_empty(work_info) or has_exactly_one_entry(work_info)):
            if to_cancel(inc):
                continue
            process_errors = get_process_errors(order_info)
            if has_brm_process_error(process_errors) or has_brm_error(work_info):
                logs = get_logs_for_order(tel_order_number)
                logs_string = '\r\n'.join(logs)
                if len(logs) == 2:
                    update_summary(inc, 'BRM')
                    add_work_info(inc, 'OM_TP', logs_string)
                    reassign_incident(inc, 'APLIKACJE_OBRM_DOSTAWCA')
                    sleep(30)
                elif len(logs) == 1 and not is_gbill_out_for_order(provik, ord_id):
                    resubmit_successful = resubmit_goal(tel_order_number)
                    if resubmit_successful:
                        print('{} Zamówienie {} ponowione w OM TP'.format(inc['inc'], tel_order_number),
                              file=sys.stderr)
                else:
                    process_errors = get_process_errors(get_order_info(tel_order_number))
                    error_id = ''
                    if process_errors and process_errors[0]:
                        error_id = process_errors[0][0]
                    print('{} {} {} {}'.format(inc['inc'], error_id, tel_order_number, logs_string), file=sys.stderr)

    provik.close()