def offer_availability():
    """Add an offer to the list of available ones in case of a contract renewal."""
    incidents = []
    incidents += get_incidents('VC3_BSS_RSW', '(357) RSW / nBUK',
                               '(357B) PROBLEMY Z OFERTĄ I TERMINALAMI',
                               'Orange Mobile, B2C, B2B, Love')
    incidents += get_incidents('VC3_BSS_RSW', '(129) OPTIPOS Mobile',
                               '(129C) OFERTA UTRZYMANIOWA', 'otsa utrzymanie')

    rsw = rsw_connection()
    for inc in incidents:
        availability_inc, msisdns, offer_name = extract_data_from_rsw_inc(inc)
        if msisdns and len(msisdns) != 1:
            continue
        elif msisdns:
            msisdn = msisdns[0]
        if msisdns and availability_inc:
            offer_id = get_offer_id_by_name(rsw, offer_name)
            if offer_id:
                make_offer_available(rsw, msisdn, offer_id)
            else:
                make_offer_available(rsw, msisdn)
            resolution = 'Numer {} uprawniony.'.format(msisdn)
            close_incident(inc, resolution)
            print('{} {}: {}'.format(
                str(datetime.now()).split('.')[0], inc['inc'],
                resolution.strip()))
    rsw.close()
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 release_resources():
    """Use to change SIM status to 'r' so the card can be used again in sales.
    Logic implemented in helper_functions.py"""
    incidents = get_incidents('VC3_BSS_OPTIPOS_MOBILE', '(129) OPTIPOS Mobile',
                              '(129M) UWOLNIENIE ZASOBOW', 'otsa sprzedaż')

    otsa = otsa_connection()
    sim_regex = re.compile(r'[0-9]{19,20}')
    for inc in incidents:
        sims = []
        for line in inc['notes']:
            sims.extend(sim_regex.findall(line))

        all_resolved, resolution = process_sims(sims, otsa, inc)

        if is_empty(inc):
            resolution = 'Puste zgłoszenie, prawdopodobnie duplikat.'

        if all_resolved and resolution != '':
            resolution = '\r\n'.join(list(set(
                resolution.split('\r\n')))).strip()
            close_incident(inc, resolution)
            print('{} {}: {}'.format(
                str(datetime.now()).split('.')[0], inc['inc'], resolution))
    otsa.close()
def unlock_accounts():
    """Reset the password and unlock the account, if the login can be found in the ticket."""
    incidents = []
    incidents += get_incidents('VC3_BSS_OPTIPOS_MOBILE',
                               '(129) OPTIPOS Mobile',
                               '(129O) OTSA/OPTIPOS - odblokowanie konta',
                               'ota login odblokowanie')
    incidents += get_incidents('VC3_BSS_OPTIPOS_MOBILE',
                               '(129) OPTIPOS Mobile',
                               '(129RF) DEALER SUPPORT - AKTYWACJA KONTA',
                               'otsa login dealersupport DS.')

    incidents += get_incidents('VC3_BSS_OPTIPOS_MOBILE',
                               '(129) OPTIPOS Mobile',
                               '(129I) PROBLEM Z LOGOWANIEM', 'login OTSA')

    sd_tiers = [
        '(129RI) OKI i SOHO - AKTYWACJA KONTA',
        '(129RA) KKB,ADT - AKTYWACJA KONTA',
        '(129RK) ZŁD Aktywacja/Modyfikacja konta',
        '(129RH) OKB i TAM - AKTYWACJA KONTA'
    ]
    for tier2 in sd_tiers:
        incidents += get_incidents('VC3_BSS_OPTIPOS_MOBILE',
                                   '(129) OPTIPOS Mobile', tier2, 'otsa login')

    otsa = otsa_connection()

    for inc in incidents:
        login = find_login(inc)
        if login:
            rows_updated = unlock_account(otsa, login)
            if rows_updated == 1:
                resolution = 'Konto o loginie {} jest aktywne. Nowe hasło to: centertel.'.format(
                    login)
                close_incident(inc, resolution)
                print('{} {}: {}'.format(
                    str(datetime.now()).split('.')[0], inc['inc'],
                    resolution.strip()))

    otsa.close()
def process_transactions():
    """Process transactions on prod otsa database.
    Do so using rules that no one understands anymore (defined in otsa_processing.py)."""
    incidents = get_incidents('VC3_BSS_OPTIPOS_MOBILE', '(129) OPTIPOS Mobile',
                              '(129B) AKTYWACJA KLIENTA', 'login OTSA')
    incidents += get_incidents('VC3_BSS_OPTIPOS_MOBILE',
                               '(129) OPTIPOS Mobile',
                               '(129D) MIGRACJA KLIENTA', 'otsa sprzedaż')
    incidents += get_incidents('VC3_BSS_OPTIPOS_MOBILE',
                               '(129) OPTIPOS Mobile', '(129E) SPRZEDAZ USLUG',
                               'otsa sprzedaż')

    msisdn_regex = re.compile(r'\d{3}[ -]?\d{3}[ -]?\d{3}')
    trans_num_regex = re.compile('[A-Z0-9]{5,}?/?[0-9]{4}/[0-9]+')
    for inc in incidents:
        resolution = ''
        lines = inc['notes']
        all_resolved = True
        for i, line in enumerate(lines):
            if 'Proszę podać numer MSISDN' in line or 'Numer telefonu klienta Orange / MSISDN' in line:
                msisdns = msisdn_regex.findall(lines[i + 1])
                msisdns += msisdn_regex.findall(lines[i + 2])
                msisdns = [
                    msisdn.translate(''.maketrans({
                        '-': '',
                        ' ': ''
                    })) for msisdn in msisdns
                ]
                trans_nums = trans_num_regex.findall(lines[i + 1])
                resolution, all_resolved = process_msisdns(
                    msisdns, trans_nums, inc)
        if is_empty(inc):
            resolution = 'Puste zgłoszenie, prawdopodobnie duplikat.'
        if resolution != '' and all_resolved:
            resolution = '\r\n'.join(list(set(
                resolution.split('\r\n')))).strip()
            close_incident(inc, resolution)
            print('{} {}: {}'.format(
                str(datetime.now()).split('.')[0], inc['inc'],
                resolution.strip()))
def tester_accounts():
    incidents = get_incidents('VC3_BSS_OPTIPOS_MOBILE', '(129) OPTIPOS Mobile',
                              '(129S) TESTER - POWIĄZANIE IFS',
                              'otsa sprzedaż')
    optipot3 = optipos_sti_connection()
    for inc in incidents:
        login = None
        lines = inc['notes']
        for i, line in enumerate(lines):
            if 'Podaj login testera' in line:
                login = lines[i + 1].strip()
        if login:
            row_count = link_login_with_ifs(optipot3, login)
            if row_count == 1:
                resolution = 'Powiązano konto {} z IFS.'.format(login)
                close_incident(inc, resolution)
                print('{} {}: {}'.format(
                    str(datetime.now()).split('.')[0], inc['inc'],
                    resolution.strip()))
    optipot3.close()
Example #7
0
def process_ml_wzmuks(tier2, ml_connection, env_name):
    """Process access requests for ML system. Depending on what's in the request it can:
    create a new account, delete an old one, or change permissions for an existing account."""
    incidents = get_incidents(
        'VC3_BSS_ML', '(185) E-WZMUK-konto w SI Nowe/Modyfikacja/Likwidacja',
        tier2, '40h')
    try:
        ml_con = ml_connection()
    except cx_Oracle.DatabaseError:
        return

    for inc in incidents:
        work_info = get_work_info(inc)
        filename, contents = work_info[0]['attachment']

        xls_file = open(filename, 'wb')
        xls_file.write(contents)
        xls_file.close()
        users = get_users_data_from_xls(filename)
        os.remove(filename)

        resolution = ''
        for user in users:
            if user['typ_wniosku'] == 'Modyfikacja uprawnień':
                resolution += ml_modify_access(ml_con, user, env_name, inc)
            elif user['typ_wniosku'] == 'Nowe konto':
                resolution += ml_add_access(ml_con, user, env_name, inc)
            elif user['typ_wniosku'] == 'Likwidacja konta':
                resolution += ml_remove_access(ml_con, user, env_name, inc)

        if resolution:
            close_incident(inc, resolution.strip())
            print('{} {}: {}'.format(
                str(datetime.now()).split('.')[0], inc['inc'],
                resolution.strip()))

    ml_con.close()
def om_tp_wzmuk():
    incidents = get_incidents(
        'VC3_BSS_OM_TP',
        '(185) E-WZMUK-konto w SI Nowe/Modyfikacja/Likwidacja',
        'O30 OMTP',
        '40h'
    )
    for inc in incidents:
        work_info = get_work_info(inc)
        filename, contents = work_info[0]['attachment']

        xls_file = open(filename, 'wb')
        xls_file.write(contents)
        xls_file.close()
        users = get_users_data_from_xls(filename)
        os.remove(filename)

        for user in users:
            if not user['login_ad']:
                continue

            if user['typ_wniosku'] == 'Nowe konto':
                if user['profil'] == 'konsola zamówień OM (odczyt)':
                    password = new_ro_user(user['login_ad'])
                    close_incident(inc, f'Konto założone, hasło to: {password}')
                else:
                    pass
            elif user['typ_wniosku'] == 'Modyfikacja uprawnień':
                if user['profil'] == 'konsola zamówień OM (odczyt)':
                    password = new_ro_user(user['login_ad'])
                    close_incident(inc, f'Zrealizowano, nowe hasło to: {password}')
                else:
                    pass
            elif user['typ_wniosku'] == 'Likwidacja konta':
                disable_user(user['login_ad'])
                close_incident(inc, 'Konto wyłączone.')