コード例 #1
0
def _add_custom_range(addrange, table_locator):
    """
        _add_custom_range(addrange)
        function called when adding custom range while editing address and identifier on settings page
    """
    s2l = ui_lib.get_s2l()
    ui_lib.wait_for_element_and_input_text(FusionSettingsPage.ID_INPUT_ADD_CUSTOM_RANGE_FROM, addrange.rangefrom)
    ui_lib.wait_for_element_and_input_text(FusionSettingsPage.ID_INPUT_ADD_CUSTOM_RANGE_TO, addrange.to)
    ui_lib.wait_for_element_and_input_text(FusionSettingsPage.ID_INPUT_ADD_CUSTOM_RANGE_COUNT, addrange.count)

    # check for errors, if any !! click cancel and proceed for the next add custom WWN
    actual_xpath_count = len(s2l._element_find(FusionSettingsPage.ID_LABEL_ERROR_ADD_CUSTOM, False, False))
    if int(actual_xpath_count) != 0:
        logger._warn(" custom range add failed as there is error while filling info, Custom range from : '%s'" % addrange.rangefrom)
        ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_CANCEL_MAC_CUSTOM_ADD)
        return False
    else:
        # No Error, Clicking on add
        ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_ADD_CUSTOM_RANGE)
        if ui_lib.wait_for_element_visible(FusionSettingsPage.ID_LABEL_CUSTOM_ADD_OVERLAPPING_ERROR):
            ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_CANCEL_MAC_CUSTOM_ADD)
            logger._warn(" Cannot create overlapping pool. Please select a different range, CURRENT RANGE PASSED - '%s'" % addrange.rangefrom)
            return False
        else:
            # check for custom range in table after addition.
            from_element = s2l._table_element_finder.find_by_content(s2l._current_browser(), table_locator, addrange.rangefrom)
            to_element = s2l._table_element_finder.find_by_content(s2l._current_browser(), table_locator, addrange.to)

            if from_element is None or to_element is None:
                logger._warn(" Custom Range not reflecting in table, range starting from %s" % addrange.rangefrom)
                return False
            else:
                logger._log_to_console_and_log_file("Added CUSTOM RANGE starting from %s" % addrange.rangefrom)
                return True
コード例 #2
0
def convert_oa_powersubsystem_status_to_dictionary(status):
    """
        Convert the OA POWER SUBSYSTEM status into a dictionary

        Sample output from CLI that we are parsing:

        Power Subsystem:
            Status: OK
            Power Mode: Power Supply Redundant
            Redundancy State: Redundant
            Power Capacity: 6750 Watts DC
            Power Available: 4365 Watts DC
            Present Power: 1354 Watts AC


    """
    status_dic = {}
    try:
        # taking raw data from CLI output and creating a list by splitting by
        # newline
        status = status.split("\n")
        # remove all lines below Power Subsystem status
        del status[18:]
        # remove all lines above Power Subsystem status
        del status[0:12]
        for index, value in enumerate(status):
            ps_stat = value.split(':')
            status_dic[ps_stat[0].strip()] = ps_stat[1].strip()
        return status_dic
    except:
        logger._log_to_console_and_log_file(
            "Fail to convert the power subsystem status list to dictionary : %s"
            % status)
コード例 #3
0
def Massage_Expected_SanStorage(sanStorage, regex):
    # used to add a target regexp for validation Fusion Api Validate Response Follow as we don't specify targets but
    # the profile will actually have targets specified.

    new_targets = [{"name": "REGEX:%s" % regex}, {"name": "REGEX:%s" % regex}]

    logger._log_to_console_and_log_file("march through volumeAttachments")
    for volumeAttachment in sanStorage['volumeAttachments']:
        for storagePath in volumeAttachment['storagePaths']:
            storagePath['targets'] = new_targets

        # these items part of PUT but not returned in GET
        if 'volumeShareable' in volumeAttachment:
            del volumeAttachment['volumeShareable']
        if 'volumeName' in volumeAttachment:
            volumeAttachment[
                'volumeUri'] = 'SVOL:%s' % volumeAttachment['volumeName']
            del volumeAttachment['volumeName']
        if 'volumeProvisionType' in volumeAttachment:
            del volumeAttachment['volumeProvisionType']
        if 'volumeProvisionedCapacityBytes' in volumeAttachment:
            del volumeAttachment['volumeProvisionedCapacityBytes']
        if 'permanent' in volumeAttachment:
            del volumeAttachment['permanent']
        if 'volume' in volumeAttachment:
            del volumeAttachment['volume']

            # add status to check
            volumeAttachment['status'] = 'OK'

    return sanStorage
コード例 #4
0
def add_rack(rack_name):
    """
        Edit a system profile, adding a specific rack.
    """
    logger._log_to_console_and_log_file(
        "\n>>> Add rack \"%s\" to system profile." % rack_name)
    __open_edit_system_profile_page()
    # validating if rack is not already added to the system profile
    if ui_lib.wait_for_element_visible(systemprofilesPage.ID_LABEL_RACK_NAME %
                                       rack_name):
        ui_lib.wait_for_element_and_click(
            systemprofilesPage.ID_BUTTON_CANCEL_EDIT_SYSTEM_PROFILE)
        ui_lib.fail_test(
            "Rack \"%s\" cannot be added because it's already listed in rack's table"
            % rack_name)
    logger._log_to_console_and_log_file("\t-Clicking on \"Add rack\" button.")
    if not ui_lib.wait_for_element_and_click(
            systemprofilesPage.ID_BUTTON_ADD_RACK_FROM_EDIT_PAGE):
        ui_lib.wait_for_element_and_click(
            systemprofilesPage.ID_BUTTON_CANCEL_EDIT_SYSTEM_PROFILE)
        ui_lib.fail_test(
            "\"Add rack\" button is not available at Edit System Profile Page.",
            True)
    if not ui_lib.wait_for_element_and_click(
            systemprofilesPage.ID_ITEM_RACK_TO_BE_ADDED % rack_name):
        ui_lib.wait_for_element_and_click(
            systemprofilesPage.ID_BUTTON_CANCEL_EDIT_SYSTEM_PROFILE)
        ui_lib.fail_test("Rack named \"%s\" not found." % rack_name, True)
    ui_lib.wait_for_element_and_click(
        systemprofilesPage.ID_BUTTON_ADD_RACK_AND_CLOSE_PAGE)
    ui_lib.wait_for_element_and_click(
        systemprofilesPage.ID_BUTTON_EDIT_SYSTEM_PROFILE)
    ui_lib.wait_for_element_hidden(
        systemprofilesPage.ID_BUTTON_EDIT_SYSTEM_PROFILE,
        mantraSyncConstants.SYSTEM_PROFILE_TASK_TIMEOUT, True)
コード例 #5
0
def get_contents_from_UI():
    go_system_profiles_wait_for_contents_to_load()

    cData = ui_lib.get_text(systemprofilesPage.OVERVIEW_CONTENTS)
    logger._log_to_console_and_log_file(
        "Creating a Dictionary from the following Text from System profile UI: \n\"%s\""
        % cData)

    cData = cData.split()

    logger._log_to_console_and_log_file(
        "Contents from UI after split: \"%s\"\n" % cData)

    ss_count = get_text_from_contents_storage(cData)
    spt_count = get_text_from_server_profile_template(cData)

    rack_total = Rack()
    rack_total.clusters = get_text_from_contents_clusters(cData)
    rack_total.enclosures = get_text_from_contents_enclosures(cData)
    rack_total.interconnects = get_text_from_contents_interconnects(cData)
    rack_total.mngHosts = get_text_from_contents_management_hosts(cData)
    rack_total.racks = get_text_from_contents_racks(cData)
    ui_contents = Converged_System([rack_total], ss_count, spt_count)

    return ui_contents
コード例 #6
0
 def close_serial_connection(self):
     """Close serial port."""
     try:
         logger._log_to_console_and_log_file("Close Serial Port")
         self.ser.close()
     except Exception:
         raise AssertionError('Unable to close port')
コード例 #7
0
def checkSystemProfileStatus(system_profile_name, expected_status):
    """
        Check the status of a specific system profile at System Profiles Page
    """

    if not ui_lib.wait_for_element_visible(systemprofilesPage.ID_PAGE_LABEL):
        navigate()

    logger._log_to_console_and_log_file(
        "\n- Checking if system profile status is as expected...")
    SPStatus = systemprofilesPage.Status()
    if (SPStatus.is_valid(expected_status)):
        expected_status = expected_status.lower()
    else:
        ui_lib.fail_test(
            "\tStatus not recognized: %s. Valid status are %s" %
            (expected_status, systemprofilesPage.Status.status_list))

    # Verify if system profile exists
    actual_status = get_system_profile_status(system_profile_name)
    if actual_status == expected_status:
        logger._log_to_console_and_log_file(
            "\t- System profile is | %s |, as expected." % expected_status)
    else:
        ui_lib.fail_test(
            "\tSystem Profile at wrong status! Expected: %s | Actual: %s" %
            (expected_status, actual_status))
コード例 #8
0
def select_power_delivery_device(pddname):
    """ This function is to Select Power Delivery Device
    select_power_delivery_device

        Example:
       select_power_delivery_device(pddname)
    """
    selenium2lib = ui_lib.get_s2l()
    navigate()

    if selenium2lib._is_element_present(
            FusionPowerDeliveryDevicePage.ID_PAGE_LABEL):
        """ check for Power Delivery Device exists """
        if not (selenium2lib._is_element_present(
                FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE %
                pddname.strip())):
            logger._warn("Power Delivery Device '%s' is not present" % pddname)
            selenium2lib.capture_page_screenshot()
            return False
        else:
            """ Select if Power Delivery Device exists """
            ui_lib.wait_for_element_and_click(
                FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE %
                pddname.strip())
            ui_lib.wait_for_element(
                FusionPowerDeliveryDevicePage.ID_ELEMENT_PDD_NAME_BASE %
                pddname.strip() +
                "/ancestor::tr[contains(@class, hp-selected)]")
            #             logger._log_to_console_and_log_file("Selected the Power Delivery Device %s successfully" % pddname)
            return True
    else:
        logger._log_to_console_and_log_file(
            "Fail in navigating to Power Delivery Device Page")
        selenium2lib.capture_page_screenshot()
        return False
コード例 #9
0
def _retrieve_general_data(OAIP, bay_no, Formfactor_dict, hw_type,
                           *enclosure_obj):
    """Reads the data of enclosure from datafile and retrieves server information and returns in the form of lists."""
    ret_val = (True, [])
    if isinstance(enclosure_obj, test_data.DataObj):
        enclosure_obj = [enclosure_obj]
    elif isinstance(enclosure_obj, tuple):
        enclosure_obj = list(enclosure_obj[0][0])

    enclosure_data = ""
    for enclosure in enclosure_obj:
        if enclosure.oa1hostname == OAIP:
            enclosure_data = enclosure
            break
    if enclosure_data == "":
        logger._log_to_console_and_log_file(
            "Given encolsure "
            "%s"
            " information is not available in the data file please verify" %
            OAIP)
        ret_val = (False, [])
    else:
        try:
            formfactor = Formfactor_dict[hw_type]
            OA_info_obj = blade_info(OAIP, enclosure_data.oa1username,
                                     enclosure_data.oa1password)
            model = str(
                OA_info_obj.get_server_model_from_OA(bay_no)).strip(' ')
            ret_val = [True, [model, formfactor]]
        except Exception as e:
            ret_val = (False, [])
            logger._warn(
                "Given hardware type %s formfactor is not updated in the resource file. Exception is %s"
                % (hw_type, e))
    return ret_val
コード例 #10
0
def verify_sanmanagers_count_dashboard(*sanmanager_obj):
    logger._log_to_console_and_log_file(
        "Function call to Add dashboard panel and validate sanmanagers count from Dashboard"
    )
    s2l = ui_lib.get_s2l()
    """ Navigate to SAN Manager Page """
    if not s2l._is_element_present(FusionSANManagersPage.ID_PAGE_LABEL):
        if not navigate():
            return False

    san_managers_count = ui_lib.get_text(
        FusionSANManagersPage.ID_SAN_MANAGERS_COUNT, 2)
    """ Retrieve data from datasheet """
    if isinstance(sanmanager_obj, test_data.DataObj):
        sanmanager_obj = [sanmanager_obj]
    elif isinstance(sanmanager_obj, tuple):
        sanmanager_obj = list(sanmanager_obj)
    """ Navigate to Dashboard Page  *sanmanager_obj """
    fusion_ui.dashboard.navigate()
    fusion_ui.dashboard.create_dashboard(sanmanager_obj)
    #    fusion_ui.dashboard.verify_dashboard_exist(sanmanager_obj)
    fusion_ui.dashboard.navigate()
    san_managers_count_dashboard = ui_lib.get_text(
        FusionSANManagersPage.ID_DASHBOARD_SAN_MANAGERS_COUNT, 1)
    if (san_managers_count == san_managers_count_dashboard):
        logger._log_to_console_and_log_file(
            "successfully verified dashboard san managers count")
        return True
    else:
        message = "Dashboard san managers count failed to match with actual sanmanagers count"
        raise AssertionError(message)
コード例 #11
0
def filter_by_label_logical_switch_groups(*net_obj):

    s2l = ui_lib.get_s2l()
    if not ui_lib.wait_for_element(FusionLSGPage.ID_PAGE_LABEL):
        navigate()

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

    for net in net_obj:
        logger._log_to_console_and_log_file("Filtering LSG by label %s" %
                                            net.name)
        ui_lib.wait_for_element_and_click(FusionLSGPage.ID_FILTER_RESET)
        ui_lib.wait_for_element_and_click(FusionLSGPage.ID_FILTER_LABEL)
        ui_lib.wait_for_element_and_click(
            "//*[@id='cic-torswitchgroup-labels-filter']/ol/li[contains(.,'%s')]"
            % net.name)
        if ui_lib.wait_for_element(FusionLSGPage.ID_ELEMENT_LSG_NAME_BASE %
                                   net.lsgname):
            logger._log_to_console_and_log_file("LSG '%s' is present" %
                                                net.lsgname)
        else:
            return False
        ui_lib.wait_for_element_and_click(FusionLSGPage.ID_FILTER_RESET)
    return True
コード例 #12
0
def sanmanager_action_menu_set(action_option):
    xpath_action = FusionSANManagersPage.ID_MENU_ACTION_MAIN_BTN

    try:
        ui_lib.wait_for_element_visible(xpath_action, 5)
    except:
        pass

    ui_lib.wait_for_element_and_click(xpath_action)
    logger._log_to_console_and_log_file("Action= %s passed" % action_option)
    if (action_option == "Add"):
        ui_lib.wait_for_element_and_click(
            FusionSANManagersPage.ID_ACTIONS_ADD_SAN_MANAGER)
    elif (action_option == "Refresh"):
        ui_lib.wait_for_element_and_click(
            FusionSANManagersPage.ID_ACTIONS_REFRESH_SAN_MANAGER)
    elif (action_option == "Edit"):
        ui_lib.wait_for_element_and_click(
            FusionSANManagersPage.ID_ACTIONS_EDIT_SAN_MANAGER)
    else:
        logger._log_to_console_and_log_file(
            "Invalid action= %s passed for flatsan" % action_option)
        ui_lib.fail_test("unable to find the" + action_option + "action")

    return True
コード例 #13
0
def _Navigate_To_Licenses():
    """ _Navigate_To_Licenses

        Example:
        | _Navigate_To_Licenses()
    """

    """ Navigate to Settings Page """
    if not ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL):
        ui_lib.wait_for_element_and_click(FusionBasePage.ID_MAIN_MENU_CONTROL)
        ui_lib.wait_for_element(FusionBasePage.ID_MENU_LINK_USERS_AND_GROUPS, PerfConstants.DEFAULT_SYNC_TIME)
        ui_lib.wait_for_element_and_click(FusionBasePage.ID_MENU_LINK_SETTINGS)
        ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL)

    if ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL):
        logger._log_to_console_and_log_file("Navigated succesfully to Settings Page")
        ui_lib.wait_for_element(FusionSettingsPage.ID_LINK_OVERVIEW)
        ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_LINK_OVERVIEW)
        ui_lib.wait_for_element(FusionSettingsPage.ID_LINK_LICENSE)
        ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_LINK_LICENSE)

        if ui_lib.wait_for_element(FusionSettingsPage.ID_LINK_OVERVIEW_DROPDOWN % 'Licenses'):
            logger._log_to_console_and_log_file("Navigated succesfully to Licenses")
            return True
        else:
            ui_lib.fail_test("Fail to Navigate Licenses")
            return False
コード例 #14
0
def navigate_settings_base(currentpage, menulink):
    logger._log_to_console_and_log_file('Navigating to "{0}"'.format(currentpage))
    if not ui_lib.wait_for_element(currentpage):
        ui_lib.wait_for_element_and_click(FusionBasePage.ID_MAIN_MENU_CONTROL)
        ui_lib.wait_for_element(FusionBasePage.ID_MENU_LINK_USERS_AND_GROUPS, 10)
        ui_lib.wait_for_element_and_click(menulink)
        ui_lib.wait_for_element(currentpage)
コード例 #15
0
def _validate_critical_object_hyper_link(component):
    """
        validating dash board component's critical object hyper link
    """
    if not ui_lib.wait_for_element(FusionDashboardPage.ID_PAGE_LABEL):
        navigate()

    ui_lib.wait_for_element(
        FusionDashboardPage.ID_CRITICAL_OBJECTS_COUNT % component,
        PerfConstants.DEFAULT_SYNC_TIME)
    critical_obj_count = ui_lib.get_text(
        FusionDashboardPage.ID_CRITICAL_OBJECTS_COUNT % component)
    logger._log_to_console_and_log_file(
        "number of objects with critical status :{0}".format(
            critical_obj_count))
    ui_lib.wait_for_element(FusionDashboardPage.ID_CRITICAL_OBJECTS_COUNT %
                            component)
    ui_lib.wait_for_element_and_click(
        FusionDashboardPage.ID_CRITICAL_OBJECTS_COUNT % component)

    if int(critical_obj_count) == 0:
        logger._log_to_console_and_log_file(
            "'{0}' Component does not have any critical status".format(
                component))
        return True
    else:
        if not _validate_dashboard_component_hyper_link(
                component, critical_obj_count):
            return False
コード例 #16
0
def _validate_general_information(hw_type, data_list):
    # Validating general tab information
    return_val = True
    selenium2lib = ui_lib.get_s2l()
    model = str(
        selenium2lib._get_text(FusionServerHardwareTypePage.ID_MODEL_TEXT))
    formfactor = str(
        selenium2lib._get_text(
            FusionServerHardwareTypePage.ID_FORMFACTOR_TEXT))
    if ([model, formfactor] == data_list):
        logger._log_to_console_and_log_file(
            "Values retrieved for the hardware type %s from appliance is %s and values from devices is %s"
            % (hw_type, str([model, formfactor]), str(data_list)))
        logger._log_to_console_and_log_file(
            "Server Hardware type general information is matching properly for the type: %s"
            % hw_type)
    else:
        logger._warn(
            "Values retrieved for the hardware type %s from appliance is %s and values from devices is %s"
            % (hw_type, str([model, formfactor]), str(data_list)))
        logger._warn(
            "Server Hardware type general information is mismatching for the type: %s"
            % hw_type)
        return_val = False
    return return_val
コード例 #17
0
def _validate_error_object_hyper_link(component):
    """
        validating dash board component's error object hyper link
    """
    if not ui_lib.wait_for_element(FusionDashboardPage.ID_PAGE_LABEL):
        navigate()

    ui_lib.wait_for_element(
        FusionDashboardPage.ID_OK_COUNT_SUMMARY % component,
        PerfConstants.DEFAULT_SYNC_TIME)
    ok_obj_count = int(
        ui_lib.get_text(FusionDashboardPage.ID_OK_COUNT_SUMMARY % component))
    logger._log_to_console_and_log_file(
        "number of ok status are:{0}".format(ok_obj_count))
    ui_lib.wait_for_element(FusionDashboardPage.ID_OK_COUNT_SUMMARY %
                            component)
    ui_lib.wait_for_element_and_click(FusionDashboardPage.ID_OK_COUNT_SUMMARY %
                                      component)

    if int(ok_obj_count) == 0:
        logger._log_to_console_and_log_file(
            "'{0}' Component does not have any ok status".format(component))
        return True
    else:
        if not _validate_dashboard_component_hyper_link(
                component, ok_obj_count):
            return False
コード例 #18
0
def navigate_base(currentpage, menulink, itemcount):
    s2l = ui_lib.get_s2l()
    logger._log_to_console_and_log_file(
        'Navigating to "{0}"'.format(currentpage))
    if not s2l._is_element_present(currentpage):
        ui_lib.wait_for_element(i3SBasePage.ID_MAIN_MENU_CONTROL,
                                PerfConstants.DEFAULT_SYNC_TIME)
        ui_lib.wait_for_element_and_click(i3SBasePage.ID_MAIN_MENU_CONTROL,
                                          PerfConstants.DEFAULT_SYNC_TIME)
        ui_lib.wait_for_element(i3SBasePage.ID_MENU_LINK_DASHBOARD,
                                PerfConstants.DEFAULT_SYNC_TIME)
        ui_lib.wait_for_element_and_click(menulink,
                                          PerfConstants.DEFAULT_SYNC_TIME)
        s2l.wait_until_page_contains_element(currentpage,
                                             PerfConstants.DEFAULT_SYNC_TIME)
    # wait for the page to get loaded
    s2l.wait_until_page_contains_element(itemcount,
                                         PerfConstants.DEFAULT_SYNC_TIME)
    # added wait to remove int Base 10 conversion error while running with Selenium speed 0.0
    BuiltIn().sleep(1)
    for x in range(1, 5):
        try:
            el = int(s2l.get_text(itemcount))
        except ValueError:
            BuiltIn().sleep(1)
            pass
    while el >= 0:
        BuiltIn().sleep(0.1)
        tmp_el = int(s2l.get_text(itemcount))
        if el == tmp_el:
            break
コード例 #19
0
def _verify_activity_owner(actname, resource, timestamp, assignusername):
    """ This function is to verify the user name once the activity is assigned to any user.
    This function is written wrt E2E UC3.it will work only when we pass all the four parameters.
        Example:
        _verify_activity_owner('Update started for interconnect CC-2-LI', 'CC-2-LI', 'Today 10.45 am', 'NetAdmin')
    """
    selenium2lib = ui_lib.get_s2l()
    if not selenium2lib._is_element_present(FusionActivityPage.ID_PAGE_LABEL):
        selenium2lib.click_element(FusionUIBaseElements.ID_MAIN_MENU_CONTROL)
        ui_lib.wait_for_element_visible(
            FusionUIBaseElements.ID_MENU_LINK_ACTIVITY,
            PerfConstants.DEFAULT_SYNC_TIME)
        ui_lib.wait_for_element_and_click(
            FusionUIBaseElements.ID_MENU_LINK_ACTIVITY)
        ui_lib.wait_for_element_visible(FusionActivityPage.ID_PAGE_LABEL)

        actavailable = _is_element_present_activity_page_without_time(
            actname, resource)
        if actavailable:
            assignuser_name = selenium2lib.get_text(
                FusionActivityPage.ID_ASSIGNED_OWNER %
                (actname, resource, timestamp))
            if assignuser_name == assignusername:
                logger._log_to_console_and_log_file(
                    "Activity is available with assigned user name only")
            else:
                logger._warn(
                    "Activity is not available with assigned user name")
        else:
            logger._warn("Assigned activity is not visible to this user %s" %
                         assignusername)
コード例 #20
0
    def get_latest_build_url(self, pass_build=False):
        """
        Returns the latest build version parsed from the web-page
        :param pass_build: Boolean - True if latest qualified build is required
        :return: (String) URL of the latest version
        """
        versions = []

        for item in self.links:
            # Assumption version of build follows the below format
            # HPEOneView-SSH-4.00.00-0320050_signed-withsig_PASS112.zip
            if pass_build:
                if 'PASS' not in item:
                    continue

            version = re.findall("\d{6}", item)
            if version:
                versions.append(version[0])

        m = "INFO: Available builds in the web-page: {}".format(versions)
        log._log_to_console_and_log_file(m)
        versions.sort()

        latest_version = versions[-1] if len(versions) else None

        for i in self.links:
            if latest_version in i:
                return i

        return None
コード例 #21
0
def remove_rack(rack_name):
    """
        Edit a system profile, removing a specific rack.
    """

    __open_edit_system_profile_page()
    if not __is_racks_table_empty():
        logger._log_to_console_and_log_file("\tRack(s) Found")
        logger._log_to_console_and_log_file("\tRemoving rack \"%s\"" %
                                            rack_name)
        if not ui_lib.wait_for_element_visible(
                systemprofilesPage.ID_LABEL_RACK_NAME % rack_name):
            ui_lib.wait_for_element_and_click(
                systemprofilesPage.ID_BUTTON_CANCEL_EDIT_SYSTEM_PROFILE)
            ui_lib.fail_test(
                "\tRack not found. Verify the rack name informed.")

        else:
            ui_lib.wait_for_element_and_click(
                systemprofilesPage.ID_BUTTON_REMOVE_RACK % rack_name)
            ui_lib.wait_for_element_and_click(
                systemprofilesPage.ID_BUTTON_EDIT_SYSTEM_PROFILE)
            ui_lib.wait_for_element_hidden(
                systemprofilesPage.ID_BUTTON_EDIT_SYSTEM_PROFILE,
                mantraSyncConstants.SYSTEM_PROFILE_TASK_TIMEOUT, True)
    else:
        ui_lib.wait_for_element_and_click(
            systemprofilesPage.ID_BUTTON_CANCEL_EDIT_SYSTEM_PROFILE)
        ui_lib.fail_test("\tNo Rack(s) Found. The Rack Table is empty.")
コード例 #22
0
def add_user_input_filter(filter_name, values):
    logger._log_to_console_and_log_file(
        "Adding data to %s filter on san endpoints" % filter_name)
    selenium2lib = ui_lib.get_s2l()
    selenium2lib.maximize_browser_window()

    if (filter_name == 'endpoint'):
        xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_ENDPOINT
    elif (filter_name == 'wwpn'):
        xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_WWPN
    elif (filter_name == 'alias'):
        xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_ALIAS
    elif (filter_name == 'online'):
        xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_ONLINE
    elif (filter_name == 'zone'):
        xpath_filter = FusionSANPage.ID_SAN_ENDPOINTS_FILTER_ZONE

    else:
        logger._log_to_console_and_log_file(
            "Invalid action requested for san endpoints filter")
        return False

    try:
        ui_lib.wait_for_element_visible(xpath_filter, 20)
    except:
        pass

    ui_lib.wait_for_element_and_click(xpath_filter, 20)
    ui_lib.wait_for_element_and_input_text(xpath_filter, values)
コード例 #23
0
def check_content_resource(content_category, content_resource):
    """
        Verify if a resource is displayed on System Profile Contents section.
        This function can also be used to verify the number of a specific resource.

        e.g.: check_content_element("Clusters", "4 Server Profiles")
              check_content_element("Clusters", "Server Profiles")
              check_content_element("Clusters", "4")
    """
    if not ui_lib.wait_for_element_visible(systemprofilesPage.ID_PAGE_LABEL):
        navigate()
    if not ui_lib.wait_for_element_visible(
            systemprofilesPage.ID_LABEL_CONTENTS):
        navigateOverview()
    logger._log_to_console_and_log_file(
        "\n -Verifying if category \"%s\" contains \"%s\" in Contents section."
        % (content_category, content_resource))
    if ui_lib.wait_for_element_visible(
            systemprofilesPage.MAP_CONTENT_RESOURCE_ITEM %
        (content_category, content_resource)):
        logger._log_to_console_and_log_file(
            "\t- Found \"%s\" for category \"%s\"!" %
            (content_resource, content_category))
    else:
        ui_lib.fail_test(
            "Resource and/or category not found in Contents section",
            captureScreenshot=True)
コード例 #24
0
def validate_general_section_titles():
    xpath_section = FusionSANPage.ID_SAN_MENU_ACTION_MAIN_BTN
    xpath_title1 = FusionSANPage.ID_SAN_TYPE
    xpath_title2 = FusionSANPage.ID_SAN_STATE
    xpath_title3 = FusionSANPage.ID_SAN_PRINCIPAL_SWITCH
    xpath_title4 = FusionSANPage.ID_SAN_MANAGER_LINK
    xpath_title5 = FusionSANPage.ID_SAN_ASSOCIATED_NETWORK

    try:
        ui_lib.wait_for_element_visible(xpath_section, 5)
    except:
        pass
    logger._log_to_console_and_log_file("Validate General Section titles")
    title = "Type"
    BuiltIn().should_be_true(ui_lib.wait_for_element_visible(xpath_title1),
                             title)
    title = "State"
    BuiltIn().should_be_true(ui_lib.wait_for_element_visible(xpath_title2),
                             title)
    title = "Principal switch"
    BuiltIn().should_be_true(ui_lib.wait_for_element_visible(xpath_title3),
                             title)
    title = "SAN manager"
    BuiltIn().should_be_true(ui_lib.wait_for_element_visible(xpath_title4),
                             title)
    title = "Associated network"
    BuiltIn().should_be_true(ui_lib.wait_for_element_visible(xpath_title5),
                             title)
コード例 #25
0
def checkGeneralContents():
    # Using checkElements to verify if the elements were displayed
    if mantraUtils.checkElements([
        [systemprofilesPage.ID_PRODUCT_NUMBER_LABEL, "'Product Number LABEL'"],
        [
            systemprofilesPage.ID_PRODUCT_NUMBER_CONTENT,
            "'Product Number CONTENT'"
        ], [systemprofilesPage.ID_SYSTEM_TYPE_LABEL, "'System Type LABEL'"],
        [systemprofilesPage.ID_SYSTEM_TYPE_CONTENT, "'System Type CONTENT'"],
        [
            systemprofilesPage.ID_SYSTEM_TYPE_VERSION_LABEL,
            "'System Type Version LABEL'"
        ],
        [
            systemprofilesPage.ID_SYSTEM_TYPE_VERSION_CONTENT,
            "'System Type Version CONTENT'"
        ], [systemprofilesPage.ID_MODEL_LABEL, "'Model LABEL'"],
        [systemprofilesPage.ID_MODEL_CONTENT, "'Model CONTENT'"],
        [systemprofilesPage.ID_LAST_REFRESH_LABEL, "'Refresh LABEL'"],
        [systemprofilesPage.ID_LAST_REFRESH_CONTENT, "'Refresh CONTENT'"]
    ]):
        ui_lib.fail_test(
            "\t- At least one element was not found. Please check the 'Overview' page"
        )
    else:
        logger._log_to_console_and_log_file("\t- All the elements were found")
コード例 #26
0
def clear_out_san_edit_input_box(field_name):
    logger._log_to_console_and_log_file("Clear %s textbox on edit san screen" %
                                        field_name)
    if (field_name == 'zonename'):
        xpath_name = FusionSANPage.ID_SAN_EDIT_ZONE_NAME
        xpath_name_label = FusionSANPage.ID_SAN_EDIT_ZONE_NAME_LABEL

    elif (field_name == 'initiatoralias'):
        xpath_name = FusionSANPage.ID_SAN_EDIT_INITIATOR_ALIAS
        xpath_name_label = FusionSANPage.ID_SAN_EDIT_INITIATOR_ALIAS_LABEL

    elif (field_name == 'targetalias'):
        xpath_name = FusionSANPage.ID_SAN_EDIT_TARGET_ALIAS
        xpath_name_label = FusionSANPage.ID_SAN_EDIT_TARGET_ALIAS_LABEL

    elif (field_name == 'targetgrpalias'):
        xpath_name = FusionSANPage.ID_SAN_EDIT_TARGET_GRP_ALIAS
        xpath_name_label = FusionSANPage.ID_SAN_EDIT_TARGET_GRP_ALIAS_LABEL

    else:
        return False

    try:
        ui_lib.wait_for_element_visible(xpath_name_label, 10)
    except:
        pass


#    ui_lib.wait_for_element_and_input_text(xpath_name, Keys.CLEAR)
    ui_lib.wait_for_element_and_input_text(xpath_name, Keys.END)
    ui_lib.wait_for_element_and_input_text(xpath_name, Keys.BACKSPACE)
    ui_lib.wait_for_element_and_input_text(xpath_name, Keys.BACKSPACE)
    ui_lib.wait_for_element_and_input_text(xpath_name, Keys.BACKSPACE)
コード例 #27
0
def DCS_change_fan_status(ipaddr, bay_number, enclosure_id, status):
    """
        Change an enclosure's fan status in DCS. Works for C7000 only.
    """

    logger._log_to_console("\n- Setting status " + status +
                           " to Fanbay number " + bay_number)
    if status not in DCSConstants.FAN_OP_STATUS_LIST:
        ui_lib.fail_test(
            "\nInvalid status [%s] for enclosure's fan. Valid values are: %s" %
            (status, DCSConstants.FAN_OP_STATUS_LIST), False)

    # mount URL based on the informed enclosure id
    url_dcs_instance = "http://" + str(
        ipaddr[8:]
    ) + DCSConstants.DCS_PORT + DCSConstants.DCS_REST_INSTANCES + "/" + enclosure_id

    # create the URI to change the fan status
    changeFanURI = url_dcs_instance + "?action=changeFanStatus&bayNum=" + bay_number + "&operationalStatus=" + status
    logger._log_to_console("\t- URI: " + changeFanURI)
    response = requests.post(changeFanURI, stream=True)

    if (response.status_code == DCSConstants.HTTP_STATUS_CODE_OK):
        logger._log_to_console_and_log_file(
            "\t- Fan status changed successfully.")
    else:
        ui_lib.fail_test("\tChange fan status failed: " + response.content,
                         False)
コード例 #28
0
    def _download_with_accelerator(self):
        """
        Download file using aria2c cli using subprocess module
        :return: Name of the file downloaded or None
        """
        cmd = 'aria2c' if platform.system() is 'Linux' else 'aria2c.exe'
        cmd += ' -x 16 -s 16 '
        cmd += '-d %s ' % self.dest

        if self.proxy:
            cmd += '--all-proxy=%s ' % self.proxy

        if self.c_sum:
            cmd += '--checksum=sha-256=%s ' % self.c_sum

        cmd += self.url
        cmd = shlex.split(cmd)
        proc = subprocess.Popen(cmd, stderr=subprocess.PIPE,
                                stdout=subprocess.PIPE)
        out, err = proc.communicate()

        if proc.returncode == 0 :
            m = "INFO: Download successful.\n%s\nOutput\n%s" % (cmd, out)
            log._log_to_console_and_log_file(m)
            return self.url.split('/')[-1]
        else:
            m = "Error: Something went wrong. \n%s\n%s" % (out, err)
            log._log_to_console_and_log_file(m)
            return None
コード例 #29
0
def download_updatebin_file(dir, url, chunk_size=StorageSize.OneMB.value):
    """
    Download update.bin file from url
    :param dir:
    :param url:
    :param chunk_size: default 10240000
    """
    urllib3.disable_warnings()
    filename = url.split('/')[-1]
    localfile = os.path.join(dir, filename)

    try:
        logger._log_to_console_and_log_file("Downloading file from %s..." %
                                            url)
        resp = requests.get(url, stream=True, verify=False)

        with open(localfile, 'wb') as f:
            for chunk in resp.iter_content(chunk_size=chunk_size):
                if chunk:
                    f.write(chunk)
                    f.flush()
        logger._log_to_console_and_log_file("Downloaded file from %s" % url)
        return True

    except Exception as e:
        raise AssertionError("Exceptions occurred while download %s" % url)
コード例 #30
0
def edit_services_access(isEnabled):
    """
    Edit Support Access: function to enable or disable support access

    """
    s2l = ui_lib.get_s2l()
    if not ui_lib.wait_for_element(FusionSettingsPage.ID_PAGE_LABEL):
        navigate()

    logger._log_to_console_and_log_file("Edit services access")
    ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_MENU_ACTION_MAIN_BTN)
    ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_MENU_ACTION_EDIT_SUPPORT_ACCESS)
    ui_lib.wait_for_element_visible(FusionSettingsPage.ID_LABEL_EDIT_SUPPORT_ACCESS)
    editoption = s2l.get_text(FusionSettingsPage.ID_TOGGLE_BTN_SERVICE_ACCESS)
    if editoption.lower() == isEnabled.lower():
        ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_OK_SUPPORT_ACCESS)
    elif editoption == "Enabled" and isEnabled == "Disabled":
        ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_TOGGLE_OFF)
        ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_OK_SUPPORT_ACCESS)
    else:
        ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_TOGGLE_ON)
        ui_lib.wait_for_element_and_click(FusionSettingsPage.ID_BTN_OK_SUPPORT_ACCESS)
    ui_lib.wait_for_element(FusionSettingsPage.ID_LABEL_STATUS)
    lablestatus = s2l.get_text(FusionSettingsPage.ID_LABEL_STATUS)
    if lablestatus.lower() == isEnabled.lower():
        logger._log_to_console_and_log_file("Services access is successfully updated from '%s' to '%s'" % (editoption, isEnabled))
        return True
    else:
        logger._warn("Failed to edit Services access ")
        return False