Пример #1
0
def _provider_del_link(web, conn_name_fmt, conn_name_type, conn_src, conn_dst):
    prv_name_src = conn_src['prv_name']
    kms_addr_range_src = Conf.expand_kms_addr(conn_src['kms_addr_spec'])
    prv_name_dst = conn_dst['prv_name']
    kms_addr_range_dst = Conf.expand_kms_addr(conn_dst['kms_addr_spec'])

    build_conname = _generate_conn_name_builder(conn_name_type, conn_name_fmt,
                                                prv_name_src, prv_name_dst)
    pinf('delete provider links ...')
    for ai, (kms_src, kms_dst) in enumerate(zip(kms_addr_range_src,
                                                kms_addr_range_dst),
                                            start=1):
        conn_name = build_conname(ai, kms_src, kms_dst)

        # minimize lookup time : WebDriverWait timeout is too long
        r = _conn_exist(web, conn_name)
        if r:
            web.click(r)
            web.click('btnDeletePrvdrCnctn')
            web.click('div.bootbox-confirm button.bootbox-accept', SW.CSS)
            web.click('div.bootbox-alert button.bootbox-accept', SW.CSS)
            print(f'  {ai}: delete provider link({conn_name})')
            web.wait_detach(r)
        else:
            perr('  {}: skip link({}) :: not exist', ai, conn_name)
Пример #2
0
def _provider_add_link(web, conn_name_fmt, conn_name_type, conn_src, conn_dst):
    ''' choose src '''
    ui_src = (
        'src',  # link end type
        'srcPopup',  # add-popup id
        'selSrc',  # btn_add id
        'srcSearchElmtNm',  # text_input id for provider name
        'srcSearchBtn',  # btn id for provider search
        'grid-src-prvdr',  # provider table id, td[title="<prv_name>"][aria-describedby$="_ELMT_NM"]
        'grid-src-prvdr-intf',  # kms table id, td[title="<kms_addr>"][aria-describedby$="_KMS_PROTOCOL_ID"]
    )
    prv_name_src = conn_src['prv_name']
    kms_addr_range_src = Conf.expand_kms_addr(conn_src['kms_addr_spec'])
    select_src = partial(_select_link_end,
                         prv_name=prv_name_src,
                         uiid=ui_src,
                         web=web)
    ''' choose dst '''
    ui_dst = (
        'dst',  # link end type
        'dstntPopup',  # add-popup id
        'selDstnt',  # btn_add id
        'dstSearchElmtNm',  # text_input id for provider name
        'dstSearchBtn',  # btn id for provider search
        'grid-dstnt-prvdr-table',  # provider table id, td[title="<prv_name>"][aria-describedby$="_ELMT_NM"]
        'grid-dstnt-prvdr-intf',  # kms table id, td[title="<kms_addr>"][aria-describedby$="_KMS_PROTOCOL_ID"]
    )
    prv_name_dst = conn_dst['prv_name']
    kms_addr_range_dst = Conf.expand_kms_addr(conn_dst['kms_addr_spec'])
    select_dst = partial(_select_link_end,
                         prv_name=prv_name_dst,
                         uiid=ui_dst,
                         web=web)

    build_conname = _generate_conn_name_builder(conn_name_type, conn_name_fmt,
                                                prv_name_src, prv_name_dst)
    pinf('add provider links ...')
    for ai, (kms_src, kms_dst) in enumerate(zip(kms_addr_range_src,
                                                kms_addr_range_dst),
                                            start=1):
        conn_name = build_conname(ai, kms_src, kms_dst)

        # minimize lookup time : WebDriverWait timeout is too long
        if _conn_exist(web, conn_name):
            perr('  {}: skip {} :: already exist', ai, conn_name)
            continue

        web.click('btnResetPrvdrCnctnForm')
        if select_src(ai, kms_src) and select_dst(ai, kms_dst):
            web.sendkeys(web.find('linkNm'), conn_name)
            print(
                f'  {ai} : add link[{conn_name}]::({prv_name_src}.{kms_src})-({prv_name_dst}.{kms_dst})'
            )
            web.click('btnPrvdrCnctnSave')
            web.click('div.bootbox-alert button.bootbox-accept', SW.CSS)
Пример #3
0
def _provider_add_addr(web, prv_name, prv_addr, kms_addr_spec, prv_agt):
    pnbox = web.find('elmtNm')
    pnbox.clear()
    web.sendkeys(pnbox, prv_name)
    stale = web.check_stale(_PRV_NAME_IN_LIST.format(prv_name),
                            SW.CSS)  # maybe target PRV is already listed
    web.click('searchBtn')  # Search for target PRV will obsolete old element
    if stale:
        web.wait_detach(
            stale
        )  # Make sure to pick a fresh element after the old one got detached

    try:
        web.clickp(_PRV_NAME_IN_LIST.format(prv_name), SW.CSS)

        addrs_exist = []
        _walkthrough_kms_addrs(
            web, lambda re, ka, pa: addrs_exist.append(
                (ka, pa)) is 'Return False')

        pinf('add provider addresses for Provider[{}]...', prv_addr)

        for i, kms_addr in enumerate(Conf.expand_kms_addr(kms_addr_spec),
                                     start=1):

            if (kms_addr, prv_addr) in addrs_exist:
                perr('  {}: {} exist/skipped', i, kms_addr)
                continue

            web.click('protIntfInsert')

            web.sendkeys(web.find('kmsProtocolId'), kms_addr)
            web.sendkeys(web.find('provProtocolId'), prv_addr)
            web.click('app')
            web.click(f'#app option[value="{prv_agt}"]', SW.CSS)

            web.click('protIntfSaveBtn')

            row_add = _walkthrough_kms_addrs(
                web, lambda re, ka, pa: ka == kms_addr and pa == prv_addr)
            web.click(row_add)

            prt('  {}: {}/{} added', i, kms_addr, prv_agt)
        else:
            # save to DB
            if 'row_add' in dir():
                web.click('btnPrvdrSave')  # save all
                prt('  committed')

                # accept modal dialogue
                web.click('div.modal-content button.bootbox-accept', SW.CSS)
            return

        perr('  aborted !')
    except TimeoutException:
        perr('provider: {} not found', prv_name)
    except StaleElementReferenceException as e:
        pause(2)
        raise e
Пример #4
0
def _provider_del_addr(web, prv_name, prv_addr, kms_addr_spec, prv_agt):
    pnbox = web.find('elmtNm')
    pnbox.clear()
    web.sendkeys(pnbox, prv_name)

    stale = web.check_stale(_PRV_NAME_IN_LIST.format(prv_name),
                            SW.CSS)  # maybe target PRV is already listed
    web.click('searchBtn')  # Search for target PRV will obsolete old element
    if stale:
        web.wait_detach(
            stale
        )  # Make sure to pick a fresh element after the old one got detached

    try:
        web.clickp(_PRV_NAME_IN_LIST.format(prv_name), SW.CSS)

        pinf('delete provider addresses for Provider[{}]...', prv_addr)

        kaddrs2del = list(Conf.expand_kms_addr(kms_addr_spec))

        bDeleteDirty = False

        def walkthrough_callback(re, ka, pa):
            nonlocal bDeleteDirty
            if pa == prv_addr and ka in kaddrs2del:
                chkbox = re.find_element_by_tag_name('input')
                web.click(chkbox)  # check row to delete
                prt('  {} : {} checked ', ka, pa)
                kaddrs2del.remove(ka)
                bDeleteDirty = True

            return False

        _walkthrough_kms_addrs(web, walkthrough_callback)

        if len(kaddrs2del) > 0:
            for ka in kaddrs2del:
                perr('  {} : {} not exist/skipped', ka, prv_addr)

        # commit
        if bDeleteDirty:
            web.click('protIntfDelete')

            web.click('protIntfDelOK')
            prt('  deleted')

            web.click('btnPrvdrSave')
            prt('  committed')

            # accept modal dialogue
            web.click('div.modal-content button.bootbox-accept', SW.CSS)
    except StaleElementReferenceException as e:
        pause(2)
        raise e