def remove_datacenter(*datacenter_obj):
    '''
    remove_datacenter function to remove the datacenter from the appliance
    '''
    logging._log_to_console_and_log_file("Removing datacenter")
    if isinstance(datacenter_obj, test_data.DataObj):
        datacenter_obj = [datacenter_obj]
    elif isinstance(datacenter_obj, tuple):
        datacenter_obj = list(datacenter_obj[0])

    for datacenter in datacenter_obj:
        logging._log_to_console_and_log_file(
            "Removing datacenter with name.... %s" % datacenter.name)
        select_datacenter(datacenter.name)
        ui_lib.wait_for_element_and_click(
            FusionDataCenterPage.ID_ACTION_MAIN_BTN)
        ui_lib.wait_for_element_and_click(
            FusionDataCenterPage.ID_MENU_ACTION_REMOVE)

        ui_lib.wait_for_element_and_click(
            FusionDataCenterPage.ID_BTN_YES_REMOVE_CONFIRMATION)
        ui_lib.refresh_browser(FusionDataCenterPage.ID_MAIN_MENU,
                               PerfConstants.DEFAULT_SYNC_TIME)
        if ui_lib.wait_for_element_remove(
                FusionDataCenterPage.ID_SELECT_DATACENTER %
                str(datacenter.name)):
            logging._log_to_console_and_log_file(
                "Datacenter with name %s Deleted" % datacenter.name)
        else:
            ui_lib.fail_test("Unable to Delete datacenter with name %s" %
                             datacenter.name)
    return True
Exemplo n.º 2
0
 def refresh_browser_on_firmware_page(cls, timeout=30, fail_if_false=False):
     logger.debug("refresh browser and wait add firmware bundle button show")
     if not ui_lib.refresh_browser(FusionFirmwareBundlePage.ID_LINKE_ADD_FW_BUNDLE, time=timeout):
         return FusionUIBase.fail_test_or_return_false(message="Browser refresh failed.", fail_if_false=fail_if_false)
     else:
         return True
Exemplo n.º 3
0
def display_alerts_on_activity_state(state):

    logger.info(
        "Filtering and displaying based on the Activity state i.e %s " % state)

    if not ui_lib.wait_for_element_visible(FusionActivityPage.ID_FILTER_STATES,
                                           PerfConstants.DEFAULT_SYNC_TIME):
        ui_lib.refresh_browser(FusionBasePage.ID_MENU_ONE_VIEW,
                               PerfConstants.DEFAULT_SYNC_TIME)
    ui_lib.wait_for_element_visible(FusionActivityPage.ID_FILTER_STATES,
                                    PerfConstants.DEFAULT_SYNC_TIME)
    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_STATES,
                                      PerfConstants.DEFAULT_SYNC_TIME)
    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_STATES_ALL,
                                      PerfConstants.DEFAULT_SYNC_TIME)
    ui_lib.wait_for_element_and_click(
        FusionActivityPage.ID_FILTER_BY_STATE % state,
        PerfConstants.DEFAULT_SYNC_TIME)
    ui_lib.refresh_browser(FusionUIBaseElements.ID_MAIN_MENU_CONTROL,
                           PerfConstants.BROWSER_REFRESH)
    ui_lib.wait_for_element_visible(
        FusionActivityPage.ID_ACTIVITY_FILTER_COUNT,
        PerfConstants.DEFAULT_SYNC_TIME)
    activity_count = int(
        ui_lib.get_text(FusionActivityPage.ID_ACTIVITY_FILTER_COUNT,
                        PerfConstants.DEFAULT_SYNC_TIME))
    logger.info("No of %s Alerts :%s" % (state, activity_count))
    for i in range(1, activity_count + 1):

        if i <= activity_count:

            ui_lib.wait_for_element_and_click(
                FusionActivityPage.ID_LABEL_PAGE_CLICK_ERROR % i,
                PerfConstants.DEFAULT_SYNC_TIME)

            if ui_lib.wait_for_element(
                    FusionActivityPage.ID_LABEL_PAGE_ERROR % (i),
                    PerfConstants.DEFAULT_SYNC_TIME):
                error_msg1 = ui_lib.get_text(
                    FusionActivityPage.ID_LABEL_PAGE_ERROR % (i),
                    PerfConstants.DEFAULT_SYNC_TIME)
            if ui_lib.wait_for_element(
                    FusionActivityPage.ID_LABEL_PAGE_ERROR_FULL % (i + 1),
                    PerfConstants.DEFAULT_SYNC_TIME):
                error_msg2 = ui_lib.get_text(
                    FusionActivityPage.ID_LABEL_PAGE_ERROR_FULL % (i + 1),
                    PerfConstants.DEFAULT_SYNC_TIME)
            ui_lib.wait_for_element_and_click(
                FusionActivityPage.ID_LABEL_EVENT_CLICK_ERROR % (i + 1),
                PerfConstants.DEFAULT_SYNC_TIME)
            event_msg = ui_lib.get_text(
                FusionActivityPage.ID_EVENT_MESSAGE % (i + 1),
                PerfConstants.DEFAULT_SYNC_TIME)
            logger.info("---------------------------------------\n")
            logger.info("%d. Alert: %s \n" % (i, error_msg1))
            logger.info("%s \n" % error_msg2)
            logger.info("%s \n" % event_msg)
            logger.info("---------------------------------------\n")
            ui_lib.wait_for_element_and_click(
                FusionActivityPage.ID_LABEL_EVENT_CLICK_ERROR % (i + 1),
                PerfConstants.DEFAULT_SYNC_TIME)
            ui_lib.wait_for_element_and_click(
                FusionActivityPage.ID_LABEL_PAGE_UNCLICK_ERROR % i,
                PerfConstants.DEFAULT_SYNC_TIME)

    return activity_count
Exemplo n.º 4
0
def verify_alertpage_information(activity_obj):
    """
    This function is displays the critical Alerts with user provided state(Active or locked or cleared...). Then Verifies Alert name, Owner and Resource in displayed alerts
    in Activity Page
    """
    if not ui_lib.wait_for_element(FusionActivityPage.ID_PAGE_LABEL):
        navigate()

    if isinstance(activity_obj, test_data.DataObj):
        activity_obj = [activity_obj]
    elif isinstance(activity_obj, tuple):
        activity_obj = list(activity_obj)

    err_val = 0

    ui_lib.wait_for_element_visible(FusionActivityPage.ID_ACTIVITY_TABLE,
                                    PerfConstants.DEFAULT_SYNC_TIME)
    logger.info("Activity Table is loaded with the activities.")
    if not ui_lib.wait_for_element_visible(
            FusionActivityPage.ID_FILTER_ALL_TYPES,
            PerfConstants.DEFAULT_SYNC_TIME):
        ui_lib.refresh_browser(FusionBasePage.ID_MENU_ONE_VIEW,
                               PerfConstants.DEFAULT_SYNC_TIME)
    ui_lib.wait_for_element_visible(FusionActivityPage.ID_FILTER_ALL_TYPES,
                                    PerfConstants.DEFAULT_SYNC_TIME)

    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_ALL_TYPES,
                                      PerfConstants.DEFAULT_SYNC_TIME)

    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_ON_TYPE,
                                      PerfConstants.DEFAULT_SYNC_TIME)
    # Clicking on Critical status
    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_ALL_STATUS,
                                      PerfConstants.DEFAULT_SYNC_TIME)
    ui_lib.wait_for_element_and_click(
        FusionActivityPage.ID_FILTER_ON_STATUSTYPE,
        PerfConstants.DEFAULT_SYNC_TIME)

    # Displays all critical alerts based on state
    activity_states = [
        'Active', 'Locked', 'Cleared', 'Pending', 'Running', 'Completed',
        'Interrupted', 'Error', 'Warning'
    ]
    list_entries = []
    for activity in activity_obj:

        for order in range(0, len(activity_states)):
            if (activity_states[order] == activity.state):
                if order not in list_entries:
                    state = activity.state

                    no_of_alrets = display_alerts_on_activity_state(state)
                    error = validate_displayed_alert_info_on_activity_state(
                        activity, no_of_alrets)
                    list_entries.append(order)
                else:
                    error = validate_displayed_alert_info_on_activity_state(
                        activity, no_of_alrets)

        if (error > 0):
            err_val += 1

    if (err_val > 0):
        message = "One or more Alert validations failed"
        raise AssertionError(message)
    else:
        return True
Exemplo n.º 5
0
def verify_alert_page_details(activityname, resource, owner):
    """
        This function is to verify activity page details.
        Example:
        verify_alert_page_details()
    """
    selenium2lib = ui_lib.get_s2l()
    if not selenium2lib._is_element_present(FusionActivityPage.ID_PAGE_LABEL):
        navigate()
    """  Validating activity fields like Name, Resource, Time, State and user      """
    item_min_val = 3
    item_max_val = 8
    statelist = [
        'Active', 'Locked', 'Cleared', 'Pending', 'Running', 'Completed',
        'Interrupted', 'Error', 'Warning'
    ]

    ui_lib.wait_for_element_visible(FusionActivityPage.ID_ACTIVITY_TABLE,
                                    PerfConstants.DEFAULT_SYNC_TIME)
    logger._log_to_console_and_log_file(
        "Activity Table is loaded with the activities.")
    if not ui_lib.wait_for_element_visible(
            FusionActivityPage.ID_FILTER_ALL_TYPES,
            PerfConstants.DEFAULT_SYNC_TIME):
        ui_lib.wait_for_element_and_click(FusionActivityPage.ID_RESET_FILTER)
    ui_lib.wait_for_element_visible(FusionActivityPage.ID_FILTER_ALL_TYPES,
                                    PerfConstants.DEFAULT_SYNC_TIME)

    selenium2lib.click_element(FusionActivityPage.ID_FILTER_ALL_TYPES)
    ui_lib.wait_for_element_visible(FusionActivityPage.ID_FILTER_TASKS,
                                    PerfConstants.DEFAULT_SYNC_TIME)
    selenium2lib.click_element(FusionActivityPage.ID_FILTER_TASKS)

    logger._log_to_console_and_log_file("Validating activity details")
    for intcount in range(item_min_val, item_max_val):
        if intcount == 3:
            ui_lib.wait_for_element_visible(
                FusionActivityPage.ID_ACTIVITY_DETAILS % intcount,
                PerfConstants.DEFAULT_SYNC_TIME)
            logger._log_to_console_and_log_file("Validating Activity name")
            if selenium2lib.get_text(FusionActivityPage.ID_ACTIVITY_DETAILS %
                                     intcount) == activityname:
                logger._log_to_console_and_log_file(
                    "Activity has proper name i.e : '%s'" % activityname)
        elif intcount == 4:
            ui_lib.wait_for_element_visible(
                FusionActivityPage.ID_ACTIVITY_DETAILS % intcount,
                PerfConstants.DEFAULT_SYNC_TIME)
            logger._log_to_console_and_log_file("Validating Activity resource")
            if selenium2lib.get_text(FusionActivityPage.ID_ACTIVITY_DETAILS %
                                     intcount) == resource:
                logger._log_to_console_and_log_file(
                    "Activity has proper resource i.e : '%s'" % resource)
        elif intcount == 5:
            ui_lib.wait_for_element_visible(
                FusionActivityPage.ID_ACTIVITY_DETAILS % intcount,
                PerfConstants.DEFAULT_SYNC_TIME)
            logger._log_to_console_and_log_file("Validating Activity Date")
            logger._log_to_console_and_log_file(
                selenium2lib.get_text(FusionActivityPage.ID_ACTIVITY_DETAILS %
                                      intcount))
        elif intcount == 6:
            ui_lib.wait_for_element_visible(
                FusionActivityPage.ID_ACTIVITY_DETAILS % intcount,
                PerfConstants.DEFAULT_SYNC_TIME)
            logger._log_to_console_and_log_file("Validating Activity State")
            activity_state = str(
                selenium2lib.get_text(FusionActivityPage.ID_ACTIVITY_DETAILS %
                                      intcount))
            state_count = 0
            for state_count in range(0, len(statelist)):
                if activity_state.find(statelist[state_count]) > -1:
                    logger._log_to_console_and_log_file(
                        "Activity state '%s' returned is expected one" %
                        statelist[state_count])
                    break
        elif intcount == 7:
            ui_lib.wait_for_element_visible(
                FusionActivityPage.ID_ACTIVITY_DETAILS % intcount,
                PerfConstants.DEFAULT_SYNC_TIME)
            logger._log_to_console_and_log_file(
                "Validating Activity assigned user")
            activity_user = str(
                selenium2lib.get_text(FusionActivityPage.ID_ACTIVITY_DETAILS %
                                      intcount))
            if activity_user.lower() == "unassigned" or activity_user.lower(
            ) == owner.lower():
                logger._log_to_console_and_log_file(
                    "Activity assigned user '%s' is as per expected" %
                    activity_user)
    """ Filtering activities by State and validating the listed activities      """
    logger._log_to_console_and_log_file("Filtering activities by State")
    activity_state = [
        'Active', 'Locked', 'Cleared', 'Pending', 'Running', 'Completed',
        'Interrupted', 'Error', 'Warning'
    ]
    state_order = 0
    for state_order in range(0, len(activity_state)):
        logger._log_to_console_and_log_file(
            "Filtering alerts by status: '%s'" % activity_state[state_order])
        if not ui_lib.wait_for_element_visible(
                FusionActivityPage.ID_FILTER_ALL_STATES,
                PerfConstants.DEFAULT_SYNC_TIME):
            ui_lib.wait_for_element_and_click(
                FusionActivityPage.ID_RESET_FILTER)
        ui_lib.wait_for_element_visible(
            FusionActivityPage.ID_FILTER_ALL_STATES,
            PerfConstants.DEFAULT_SYNC_TIME)
        ui_lib.wait_for_element_and_click(
            FusionActivityPage.ID_FILTER_ALL_STATES)
        ui_lib.wait_for_element_and_click(
            FusionActivityPage.ID_FILTER_BY_STATE %
            activity_state[state_order])

        ui_lib.refresh_browser(FusionUIBaseElements.ID_MAIN_MENU_CONTROL,
                               PerfConstants.BROWSER_REFRESH)
        ui_lib.wait_for_element_visible(
            FusionActivityPage.ID_ACTIVITY_FILTER_COUNT,
            PerfConstants.DEFAULT_SYNC_TIME)
        acitivity_count = selenium2lib.get_text(
            FusionActivityPage.ID_ACTIVITY_FILTER_COUNT)
        status_count = 0
        if int(acitivity_count) > 6:
            for status_count in range(0, 6):
                ui_lib.wait_for_element_visible(
                    FusionActivityPage.ID_ACTIVITY_STATE_DETAILS %
                    (status_count + 1), PerfConstants.DEFAULT_SYNC_TIME)
                state_ui = selenium2lib.get_text(
                    FusionActivityPage.ID_ACTIVITY_STATE_DETAILS %
                    (status_count + 1))
                if not ((state_ui.lower()).find(
                        activity_state[state_order].lower())) == 0:
                    logger._warn(
                        "Listed activities for status filter '%s' in not as per expected"
                        % activity_state[state_order])
                    break
            logger._log_to_console_and_log_file(
                "Activities are filtered as per status filter: '%s' " %
                activity_state[state_order])
        elif int(acitivity_count) > 0 and int(acitivity_count) < 6:
            for status_count in range(0, int(acitivity_count)):
                ui_lib.wait_for_element_visible(
                    FusionActivityPage.ID_ACTIVITY_STATE_DETAILS %
                    (status_count + 1), PerfConstants.DEFAULT_SYNC_TIME)
                state_ui = selenium2lib.get_text(
                    FusionActivityPage.ID_ACTIVITY_STATE_DETAILS %
                    (status_count + 1))
                if not (state_ui.lower()
                        == activity_state[state_order].lower()):
                    logger._warn(
                        "Listed activities for status filter '%s' in not as per expected"
                        % activity_state[state_order])
                    break
        else:
            logger._log_to_console_and_log_file(
                "No activity available for the status: '%s'" %
                activity_state[state_order])
Exemplo n.º 6
0
def verify_reports_page_alerts_data_against_activity_page():
    """
        Verifies the alerts data present in reports and activity page are same or not
        Example:
        |Fusion UI Verify Alerts Data Against Activity Page|
    """

    s2l = ui_lib.get_s2l()
    # Navigate to Reports page
    if not navigate():
        ui_lib.fail_test("Fail: failed to navigate reports page")

    report_page_alert_details = []
    fail_count = 0

    if not ui_lib.wait_for_element_visible(FusionReportsPage.ID_ELEMENT_ALERTS_TITLE):
        ui_lib.wait_for_element_and_click(FusionReportsPage.ID_ELEMENT_ACTIVE_ALERTS)

    ui_lib.wait_for_element_visible(FusionReportsPage.ID_TABLE_REPORT_RESOURCES)
    alerts_list = [ui_lib.get_text(el) for el in s2l._element_find(FusionReportsPage.ID_ACTIVE_ALERTS_LIST, False, False)]

    # capturing alert details from reports page
    for index in range(1, len(alerts_list)):
        report_page_alert_details.append(_report_page_alert_dateils(index))

    # Removing repeated alerts
    for j in report_page_alert_details:
        count = 0
        for i in report_page_alert_details:
            if j['name'] == i['name'] and j['resource'] == i['resource']:
                count = count + 1
                if count > 1:
                    report_page_alert_details.remove(i)

    # Navigating to Activity page
    if not ui_lib.wait_for_element_visible(FusionActivityPage.ID_PAGE_LABEL):
        activity.navigate()

    # Filtering active alerts
    logger._log_to_console_and_log_file("Activity Table starts loading with the Alert activities only")
    if ui_lib.wait_for_element_visible(FusionActivityPage.ID_RESET_FILTER):
        ui_lib.wait_for_element_and_click(FusionActivityPage.ID_RESET_FILTER)

    if not ui_lib.wait_for_element_visible(FusionActivityPage.ID_FILTER_ALL_TYPES, PerfConstants.DEFAULT_SYNC_TIME):
        ui_lib.refresh_browser(FusionUIBaseElements.ID_MENU_ONE_VIEW, PerfConstants.DEFAULT_SYNC_TIME)
    ui_lib.wait_for_element_visible(FusionActivityPage.ID_FILTER_ALL_TYPES, PerfConstants.DEFAULT_SYNC_TIME)
    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_ALL_TYPES)
    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_ALERTS, PerfConstants.DEFAULT_SYNC_TIME)

    logger._log_to_console_and_log_file("Filtering alerts by status: 'Active' and 'Locked'")
    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_ALL_STATES)
    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_BY_STATE % "Active")
    ui_lib.wait_for_element_and_click(FusionActivityPage.ID_FILTER_BY_STATE % "Locked")
    ui_lib.refresh_browser(FusionUIBaseElements.ID_MENU_ONE_VIEW, PerfConstants.DEFAULT_SYNC_TIME)

    for item in report_page_alert_details:
        severity = item["severity"].lower()
        name = item["name"].split('[')[0]
        resource = item["resource"]
        resource_type = item["resource_type"].replace('-', ' ')
        resolution = item["resolution"]

        alert = FusionActivityPage.ID_ELEMENT_ALERT % (severity, name, resource)
        if ui_lib.wait_for_element_visible(alert):
            ui_lib.wait_for_element_and_click(alert + "/td[1]/div")
            if not ui_lib.wait_for_element(FusionReportsPage.ID_ELEMENT_CORRECTIVEACTION):
                ui_lib.wait_for_element_and_click(FusionReportsPage.ID_ELEMENT_EVENT_DETAILS)
            alert_resolution = ui_lib.get_text(FusionReportsPage.ID_ELEMENT_RESOLUTION)
            alert_resource_type = ui_lib.get_text(alert + "/td[4]/span")
            ui_lib.wait_for_element_and_click(alert + "/td[1]/div")
            if alert_resource_type.title() != resource_type.title():
                logger._warn("Fail: Hardware type of alert '{0}' is mismatching".format(name))
                fail_count += 1
                continue
            if resolution != alert_resolution:
                logger._warn("Fail: Corrective action for alert '{0}' is mismatching".format(name))
                fail_count += 1
                continue
        else:
            logger._log_to_console_and_log_file("Failed to select alert: %s".format(alert))
            fail_count += 1

    if fail_count == 0:
        logger._log_to_console_and_log_file("SUCESS: Data present in reports page and activity page for alerts is same")
        return True
    else:
        ui_lib.fail_test("FAIL: '{0}' alerts data is mismatching from reports and activity page" .format(fail_count))
Exemplo n.º 7
0
def delete_all_server_hardware_types():
    """ Delete All Hardware Types
    """
    navigate()

    count = 0
    ret = True

    # get all server hardware types name
    sht_names = CommonOperationServerHardwareType.get_sht_list()
    logger.info("About to delete all server hardware types: %r" % sht_names)

    for n, name in enumerate(sht_names):
        logger.info("{2} No: {0} --- Total: {1} {2}".format((n + 1),
                                                            len(sht_names),
                                                            '-' * 14))
        logger.info("Removing a server hardware type with name %s" % name)
        if not select_server_hardware_type(name):
            continue

        DeleteServerHardwareType.select_actions_delete()
        if DeleteServerHardwareType.wait_delete_dialog_shown(
                fail_if_false=False) is False:
            if DeleteServerHardwareType.wait_delete_error_dialog_shown(
                    fail_if_false=False) is True:
                ui_lib.get_s2l().capture_page_screenshot()
                error_msg = DeleteServerHardwareType.get_delete_error_text()
                logger.warn(
                    "Got warn message '%s' when remove server hardware type with name %s"
                    % (error_msg, name))
                DeleteServerHardwareType.click_close()
                DeleteServerHardwareType.wait_delete_error_dialog_disappear()
            else:
                ui_lib.get_s2l().capture_page_screenshot()
                logger.warn(
                    "Failed to delete server hardware type with name %s" %
                    name)
            continue

        DeleteServerHardwareType.click_yes_delete_button()
        DeleteServerHardwareType.wait_delete_dialog_disappear()

        FusionUIBase.show_activity_sidebar()
        if FusionUIBase.wait_activity_action_ok(name,
                                                "Delete server hardware type",
                                                timeout=30,
                                                fail_if_false=False) is False:
            ret = False
        FusionUIBase.show_activity_sidebar()

        if VerifyServerHardwareType.verify_sht_not_exist(name,
                                                         fail_if_false=False):
            logger.info(
                "Remove server hardware type {0} successfully".format(name))
        elif DeleteServerHardwareType.wait_sht_show_not_found(
                name, fail_if_false=False):
            logger.info(
                "server hardware type status appear as 'not found', remove server hardware type {0} successfully."
                .format(name))
        else:
            msg = "The server hardware type does not disappear in 10s!"
            logger.warn(msg)
            continue

        count += 1
        ui_lib.refresh_browser(FusionUIBaseElements.ID_MENU_ONE_VIEW,
                               PerfConstants.DEFAULT_SYNC_TIME)

    if count == 0:
        msg = "no target server hardware type exists!"
        logger.warn(msg)
        return False

    if count != len(sht_names):
        logger.warn("Not able to delete all server hardware type!")
        return False

    return ret