Example #1
0
    def equal_drift_results(self, row_text, section, *indexes):
        """ Compares drift analysis results of a row specified by it's title text

        Args:
            row_text: Title text of the row to compare
            section: Accordion section where the change happened; this section must be activated
            indexes: Indexes of results to compare starting with 0 for first row (latest result).
                     Compares all available drifts, if left empty (default).

        Note:
            There have to be at least 2 drift results available for this to work.

        Returns:
            ``True`` if equal, ``False`` otherwise.
        """
        # mark by indexes or mark all
        navigate_to(self, 'Details')
        list_acc.select(
            'Relationships',
            version.pick({
                version.LOWEST: 'Show host drift history',
                '5.4': 'Show Host drift history'
            }))
        if indexes:
            drift_table.select_rows_by_indexes(*indexes)
        else:
            # We can't compare more than 10 drift results at once
            # so when selecting all, we have to limit it to the latest 10
            if len(list(drift_table.rows())) > 10:
                drift_table.select_rows_by_indexes(*range(0, 10))
            else:
                drift_table.select_all()
        tb.select("Select up to 10 timestamps for Drift Analysis")

        # Make sure the section we need is active/open
        sec_loc_map = {
            'Properties': 'Properties',
            'Security': 'Security',
            'Configuration': 'Configuration',
            'My Company Tags': 'Categories'
        }
        active_sec_loc = "//div[@id='all_sections_treebox']//li[contains(@id, 'group_{}')]"\
            "/span[contains(@class, 'dynatree-selected')]".format(sec_loc_map[section])
        sec_checkbox_loc = "//div[@id='all_sections_treebox']//li[contains(@id, 'group_{}')]"\
            "//span[contains(@class, 'dynatree-checkbox')]".format(sec_loc_map[section])
        sec_apply_btn = "//div[@id='accordion']/a[contains(normalize-space(text()), 'Apply')]"

        # If the section is not active yet, activate it
        if not sel.is_displayed(active_sec_loc):
            sel.click(sec_checkbox_loc)
            sel.click(sec_apply_btn)

        if not tb.is_active("All attributes"):
            tb.select("All attributes")
        d_grid = DriftGrid()
        if any(
                d_grid.cell_indicates_change(row_text, i)
                for i in range(0, len(indexes))):
            return False
        return True
Example #2
0
    def equal_drift_results(self, row_text, *indexes):
        """ Compares drift analysis results of a row specified by it's title text

        Args:
            row_text: Title text of the row to compare
            indexes: Indexes of results to compare starting with 0 for first row (latest result).
                     Compares all available drifts, if left empty (default).

        Note:
            There have to be at least 2 drift results available for this to work.

        Returns:
            ``True`` if equal, ``False`` otherwise.
        """
        # mark by indexes or mark all
        sel.force_navigate('infrastructure_host', context={'host': self})
        list_acc.select('Relationships', 'Show host drift history')
        if indexes:
            drift_table.select_rows_by_indexes(*indexes)
        else:
            # We can't compare more than 10 drift results at once
            # so when selecting all, we have to limit it to the latest 10
            if len(list(drift_table.rows())) > 10:
                drift_table.select_rows_by_indexes(*range(0, 10))
            else:
                drift_table.select_all()
        tb.select("Select up to 10 timestamps for Drift Analysis")

        d_grid = DriftGrid()
        if not tb.is_active("All attributes"):
            tb.select("All attributes")
        if any(d_grid.cell_indicates_change(row_text, i) for i in range(0, len(indexes))):
            return False
        return True
Example #3
0
 def step(self):
     navigate_to(self.obj.provider, 'Details')
     list_acc.select('Relationships',
                     'Show all managed Clusters',
                     by_title=True,
                     partial=False)
     sel.click(Quadicon(self.obj.name, self.obj.quad_name))
Example #4
0
def nav_to_datastore_through_provider(context):
    sel.force_navigate('infrastructure_provider', context=context)
    list_acc.select('Relationships',
                    'Datastores',
                    by_title=False,
                    partial=True)
    sel.click(Quadicon(context['datastore'].name, 'datastore'))
Example #5
0
 def get_datastores(self):
     """ Gets list of all datastores used by this host"""
     navigate_to(self, 'Details')
     list_acc.select('Relationships',
                     'Datastores',
                     by_title=False,
                     partial=True)
     return [q.name for q in Quadicon.all("datastore")]
def test_clear_host_filter_results(provider):
    """ Test for clearing filter results for hosts."""

    pytest.sel.force_navigate("infrastructure_hosts")
    list_acc.select("Filters", "Status / Stopped", by_title=False)
    pytest.sel.click(search_box.clear_advanced_search)
    page_title = pytest.sel.text(host.page_title_loc)
    assert page_title == "Hosts", "Clear filter results failed"
Example #7
0
def test_clear_host_filter_results(provider):
    """ Test for clearing filter results for hosts."""

    pytest.sel.force_navigate('infrastructure_hosts')
    list_acc.select('Filters', 'Status / Stopped', by_title=False)
    pytest.sel.click(search_box.clear_advanced_search)
    page_title = pytest.sel.text(host.page_title_loc)
    assert page_title == 'Hosts', 'Clear filter results failed'
def test_clear_host_filter_results(provider):
    """ Test for clearing filter results for hosts."""

    navigate_to(Host, 'All')
    list_acc.select('Filters', 'Status / Stopped', by_title=False)
    pytest.sel.click(search_box.clear_advanced_search)
    page_title = pytest.sel.text(host.page_title_loc)
    assert page_title == 'Hosts', 'Clear filter results failed'
def test_clear_datastore_filter_results(provider):
    """ Test for clearing filter results for datastores."""

    pytest.sel.force_navigate('infrastructure_datastores')
    list_acc.select('Filters', 'Store Type / VMFS', by_title=False)
    pytest.sel.click(search_box.clear_advanced_search)
    page_title = pytest.sel.text(datastore.page_title_loc)
    assert page_title == 'Datastores', 'Clear filter results failed'
Example #10
0
def test_clear_host_filter_results():
    """ Test for clearing filter results for hosts."""

    navigate_to(Host, 'All')
    list_acc.select('Filters', 'Status / Stopped', by_title=False)
    pytest.sel.click(search_box.clear_advanced_search)
    page_title = pytest.sel.text(host.page_title_loc)
    assert page_title == 'Hosts', 'Clear filter results failed'
Example #11
0
def test_clear_datastore_filter_results(provider):
    """ Test for clearing filter results for datastores."""

    pytest.sel.force_navigate('infrastructure_datastores')
    list_acc.select('Filters', 'Store Type / VMFS', by_title=False)
    pytest.sel.click(search_box.clear_advanced_search)
    page_title = pytest.sel.text(datastore.page_title_loc)
    assert page_title == 'Datastores', 'Clear filter results failed'
def test_clear_host_filter_results():
    """ Test for clearing filter results for hosts."""

    # TODO many parts of this test and others in this file need to be replaced with WT calls
    view = navigate_to(Host, 'All')
    list_acc.select('Filters', 'Status / Stopped', by_title=False)
    pytest.sel.click(search_box.clear_advanced_search)
    page_title = view.title.text
    assert page_title == 'Hosts', 'Clear filter results failed'
Example #13
0
    def equal_drift_results(self, row_text, section, *indexes):
        """ Compares drift analysis results of a row specified by it's title text

        Args:
            row_text: Title text of the row to compare
            section: Accordion section where the change happened; this section must be activated
            indexes: Indexes of results to compare starting with 0 for first row (latest result).
                     Compares all available drifts, if left empty (default).

        Note:
            There have to be at least 2 drift results available for this to work.

        Returns:
            ``True`` if equal, ``False`` otherwise.
        """
        # mark by indexes or mark all
        navigate_to(self, 'Details')
        list_acc.select('Relationships',
            version.pick({
                version.LOWEST: 'Show host drift history',
                '5.4': 'Show Host drift history'}))
        if indexes:
            drift_table.select_rows_by_indexes(*indexes)
        else:
            # We can't compare more than 10 drift results at once
            # so when selecting all, we have to limit it to the latest 10
            if len(list(drift_table.rows())) > 10:
                drift_table.select_rows_by_indexes(*range(0, 10))
            else:
                drift_table.select_all()
        tb.select("Select up to 10 timestamps for Drift Analysis")

        # Make sure the section we need is active/open
        sec_loc_map = {
            'Properties': 'Properties',
            'Security': 'Security',
            'Configuration': 'Configuration',
            'My Company Tags': 'Categories'}
        active_sec_loc = "//div[@id='all_sections_treebox']//li[contains(@id, 'group_{}')]"\
            "/span[contains(@class, 'dynatree-selected')]".format(sec_loc_map[section])
        sec_checkbox_loc = "//div[@id='all_sections_treebox']//li[contains(@id, 'group_{}')]"\
            "//span[contains(@class, 'dynatree-checkbox')]".format(sec_loc_map[section])
        sec_apply_btn = "//div[@id='accordion']/a[contains(normalize-space(text()), 'Apply')]"

        # If the section is not active yet, activate it
        if not sel.is_displayed(active_sec_loc):
            sel.click(sec_checkbox_loc)
            sel.click(sec_apply_btn)

        if not tb.is_active("All attributes"):
            tb.select("All attributes")
        d_grid = DriftGrid()
        if any(d_grid.cell_indicates_change(row_text, i) for i in range(0, len(indexes))):
            return False
        return True
Example #14
0
    def get_datastores(self):
        """ Gets list of all datastores used by this host"""
        sel.force_navigate('infrastructure_host', context={'host': self})
        list_acc.select('Relationships', 'Datastores', by_title=False, partial=True)

        datastores = set([])
        for page in paginator.pages():
            for title in sel.elements(
                    "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'storage/show')]"):
                datastores.add(sel.get_attribute(title, "title"))
        return datastores
Example #15
0
    def get_vms(self):
        """ Returns names of VMs (from quadicons) that use this datastore

        Returns: List of strings with names or `[]` if no vms found.
        """
        self.load_details()
        try:
            list_acc.select('Relationships', "VMs", by_title=False, partial=True)
        except (sel.NoSuchElementException, ListAccordionLinkNotFound):
            sel.click(InfoBlock('Relationships', 'Managed VMs'))
        return [q.name for q in Quadicon.all("vm")]
Example #16
0
    def get_datastores(self):
        """ Gets list of all datastores used by this host"""
        sel.force_navigate('infrastructure_host', context={'host': self})
        list_acc.select('Relationships', 'Show all Datastores')

        datastores = set([])
        for page in paginator.pages():
            for title in sel.elements(
                    "//div[@id='quadicon']/../../../tr/td/a[contains(@href,'storage/show')]"):
                datastores.add(sel.get_attribute(title, "title"))
        return datastores
Example #17
0
    def get_hosts(self):
        """ Returns names of hosts (from quadicons) that use this datastore

        Returns: List of strings with names or `[]` if no hosts found.
        """
        if not self._on_hosts_page():
            sel.force_navigate('infrastructure_datastore', context=self._get_context())
            try:
                list_acc.select('Relationships', 'Show all registered Hosts')
            except sel.NoSuchElementException:
                return []
        return [q.name for q in Quadicon.all("host")]
Example #18
0
    def get_vms(self):
        """ Returns names of VMs (from quadicons) that use this datastore

        Returns: List of strings with names or `[]` if no vms found.
        """
        if not self._on_vms_page():
            sel.force_navigate('infrastructure_datastore', context=self._get_context())
            try:
                list_acc.select('Relationships', "VMs", by_title=False, partial=True)
            except (sel.NoSuchElementException, ListAccordionLinkNotFound):
                return []
        return [q.name for q in Quadicon.all("vm")]
Example #19
0
    def get_hosts(self):
        """ Returns names of hosts (from quadicons) that use this datastore

        Returns: List of strings with names or `[]` if no hosts found.
        """
        if not self._on_hosts_page():
            sel.force_navigate('infrastructure_datastore', context=self._get_context())
            try:
                list_acc.select('Relationships', 'Show all registered Hosts')
            except sel.NoSuchElementException:
                return []
        return [q.name for q in Quadicon.all("host")]
Example #20
0
    def get_vms(self):
        """ Returns names of VMs (from quadicons) that use this datastore

        Returns: List of strings with names or `[]` if no vms found.
        """
        if not self._on_vms_page():
            sel.force_navigate('infrastructure_datastore', context=self._get_context())
            try:
                path = "Show registered VMs"
                list_acc.select('Relationships', path)
            except (sel.NoSuchElementException, ListAccordionLinkNotFound):
                return []
        return [q.name for q in Quadicon.all("vm")]
    def get_vms(self):
        """ Returns names of VMs (from quadicons) that use this datastore

        Returns: List of strings with names or `[]` if no vms found.
        """
        self.load_details()
        try:
            list_acc.select('Relationships',
                            "VMs",
                            by_title=False,
                            partial=True)
        except (sel.NoSuchElementException, ListAccordionLinkNotFound):
            sel.click(InfoBlock('Relationships', 'Managed VMs'))
        return [q.name for q in Quadicon.all("vm")]
Example #22
0
    def get_vms(self):
        """ Returns names of VMs (from quadicons) that use this datastore

        Returns: List of strings with names or `[]` if no vms found.
        """
        if not self._on_vms_page():
            sel.force_navigate('infrastructure_datastore', context=self._get_context())
            try:
                path = version.pick({
                    version.LOWEST: "Show all registered VMs",
                    "5.3": "Show registered VMs"})
                list_acc.select('Relationships', path)
            except sel.NoSuchElementException:
                return []
        return [q.name for q in Quadicon.all("vm")]
Example #23
0
    def get_vms(self):
        """ Returns names of VMs (from quadicons) that use this datastore

        Returns: List of strings with names or `[]` if no vms found.
        """
        if not self._on_vms_page():
            sel.force_navigate('infrastructure_datastore',
                               context=self._get_context())
            try:
                path = version.pick({
                    version.LOWEST: "Show all registered VMs",
                    "5.3": "Show registered VMs"
                })
                list_acc.select('Relationships', path)
            except sel.NoSuchElementException:
                return []
        return [q.name for q in Quadicon.all("vm")]
Example #24
0
def test_set_default_datastore_filter(provider, request):
    """ Test for setting default filter for datastores."""

    # Add cleanup finalizer
    def unset_default_datastore_filter():
        pytest.sel.force_navigate('infrastructure_datastores')
        list_acc.select('Filters', 'ALL', by_title=False)
        pytest.sel.click(datastore.default_datastore_filter_btn)
    request.addfinalizer(unset_default_datastore_filter)

    pytest.sel.force_navigate('infrastructure_datastores')
    list_acc.select('Filters', 'Store Type / NFS', by_title=False)
    pytest.sel.click(datastore.default_datastore_filter_btn)
    logout()
    login_admin()
    pytest.sel.force_navigate('infrastructure_datastores')
    assert (list_acc.is_selected('Filters', 'Store Type / NFS (Default)', by_title=False),
        'Store Type / NFS not set as default')
Example #25
0
def test_set_default_host_filter(request, appliance):
    """ Test for setting default filter for hosts."""

    # Add cleanup finalizer
    def unset_default_host_filter():
        navigate_to(Host, 'All')
        list_acc.select('Filters', 'ALL', by_title=False)
        pytest.sel.click(host.default_host_filter_btn)
    request.addfinalizer(unset_default_host_filter)

    navigate_to(Host, 'All')
    list_acc.select('Filters', 'Status / Running', by_title=False)
    pytest.sel.click(host.default_host_filter_btn)
    appliance.server.logout()
    appliance.server.login_admin()
    navigate_to(Host, 'All')
    assert list_acc.is_selected('Filters', 'Status / Running (Default)', by_title=False),\
        'Status / Running filter not set as default'
Example #26
0
def test_set_default_host_filter(provider, request):
    """ Test for setting default filter for hosts."""

    # Add cleanup finalizer
    def unset_default_host_filter():
        pytest.sel.force_navigate('infrastructure_hosts')
        list_acc.select('Filters', 'ALL', by_title=False)
        pytest.sel.click(host.default_host_filter_btn)
    request.addfinalizer(unset_default_host_filter)

    pytest.sel.force_navigate('infrastructure_hosts')
    list_acc.select('Filters', 'Status / Running', by_title=False)
    pytest.sel.click(host.default_host_filter_btn)
    logout()
    login_admin()
    pytest.sel.force_navigate('infrastructure_hosts')
    assert (list_acc.is_selected('Filters', 'Status / Running (Default)', by_title=False),
        'Status / Running filter not set as default')
def test_set_default_datastore_filter(provider, request):
    """ Test for setting default filter for datastores."""

    # Add cleanup finalizer
    def unset_default_datastore_filter():
        navigate_to(Datastore, 'All')
        list_acc.select('Filters', 'ALL', by_title=False)
        pytest.sel.click(datastore.default_datastore_filter_btn)
    request.addfinalizer(unset_default_datastore_filter)

    navigate_to(Datastore, 'All')
    list_acc.select('Filters', 'Store Type / NFS', by_title=False)
    pytest.sel.click(datastore.default_datastore_filter_btn)
    logout()
    login_admin()
    navigate_to(Datastore, 'All')
    assert list_acc.is_selected('Filters', 'Store Type / NFS (Default)', by_title=False),\
        'Store Type / NFS not set as default'
def test_set_default_host_filter(provider, request):
    """ Test for setting default filter for hosts."""

    # Add cleanup finalizer
    def unset_default_host_filter():
        navigate_to(Host, 'All')
        list_acc.select('Filters', 'ALL', by_title=False)
        pytest.sel.click(host.default_host_filter_btn)
    request.addfinalizer(unset_default_host_filter)

    navigate_to(Host, 'All')
    list_acc.select('Filters', 'Status / Running', by_title=False)
    pytest.sel.click(host.default_host_filter_btn)
    logout()
    login_admin()
    navigate_to(Host, 'All')
    assert list_acc.is_selected('Filters', 'Status / Running (Default)', by_title=False),\
        'Status / Running filter not set as default'
Example #29
0
def test_set_default_datastore_filter(request):
    """ Test for setting default filter for datastores."""

    # Add cleanup finalizer
    def unset_default_datastore_filter():
        navigate_to(Datastore, 'All')
        list_acc.select('Filters', 'ALL', by_title=False)
        pytest.sel.click(datastore.default_datastore_filter_btn)

    request.addfinalizer(unset_default_datastore_filter)

    navigate_to(Datastore, 'All')
    list_acc.select('Filters', 'Store Type / NFS', by_title=False)
    pytest.sel.click(datastore.default_datastore_filter_btn)
    logout()
    login_admin()
    navigate_to(Datastore, 'All')
    assert list_acc.is_selected('Filters', 'Store Type / NFS (Default)', by_title=False),\
        'Store Type / NFS not set as default'
def test_set_default_datastore_filter(provider, request):
    """ Test for setting default filter for datastores."""

    # Add cleanup finalizer
    def unset_default_datastore_filter():
        pytest.sel.force_navigate("infrastructure_datastores")
        list_acc.select("Filters", "ALL", by_title=False)
        pytest.sel.click(datastore.default_datastore_filter_btn)

    request.addfinalizer(unset_default_datastore_filter)

    pytest.sel.force_navigate("infrastructure_datastores")
    list_acc.select("Filters", "Store Type / NFS", by_title=False)
    pytest.sel.click(datastore.default_datastore_filter_btn)
    logout()
    login_admin()
    pytest.sel.force_navigate("infrastructure_datastores")
    assert list_acc.is_selected(
        "Filters", "Store Type / NFS (Default)", by_title=False
    ), "Store Type / NFS not set as default"
def test_set_default_host_filter(provider, request):
    """ Test for setting default filter for hosts."""

    # Add cleanup finalizer
    def unset_default_host_filter():
        pytest.sel.force_navigate("infrastructure_hosts")
        list_acc.select("Filters", "ALL", by_title=False)
        pytest.sel.click(host.default_host_filter_btn)

    request.addfinalizer(unset_default_host_filter)

    pytest.sel.force_navigate("infrastructure_hosts")
    list_acc.select("Filters", "Status / Running", by_title=False)
    pytest.sel.click(host.default_host_filter_btn)
    logout()
    login_admin()
    pytest.sel.force_navigate("infrastructure_hosts")
    assert list_acc.is_selected(
        "Filters", "Status / Running (Default)", by_title=False
    ), "Status / Running filter not set as default"
Example #32
0
    def get_hosts(self):
        """ Gets quadicons of hosts that use this datastore

        Returns: List of :py:class:`cfme.web_ui.Quadicon` objects or `[]` if no hosts found.
        """
        quad_title_locator = ".//div[@id='quadicon']/../../../tr[2]//a"
        quads_root_locator = "//table[@id='content']//td[@id='maincol']"
        if not self._on_hosts_page():
            sel.force_navigate('infrastructure_datastore', context=self._get_context())
            try:
                list_acc.select('Relationships', 'Show all registered Hosts')
            except sel.NoSuchElementException:
                return []

        all_host_quads = []
        for page in paginator.pages():
            quads_root = sel.element(quads_root_locator)
            for quad_title in sel.elements(quad_title_locator, root=quads_root):
                all_host_quads.append(Quadicon(quad_title.get_attribute('title'), 'host'))
        return all_host_quads
def test_set_default_datastore_filter(request, appliance):
    """ Test for setting default filter for datastores."""

    # I guess this test has to be redesigned
    # Add cleanup finalizer
    dc = DatastoreCollection(appliance)

    def unset_default_datastore_filter():
        navigate_to(dc, 'All')
        list_acc.select('Filters', 'ALL', by_title=False)
        sel.click(datastore.default_datastore_filter_btn)
    request.addfinalizer(unset_default_datastore_filter)

    navigate_to(dc, 'All')
    list_acc.select('Filters', 'Store Type / NFS', by_title=False)
    sel.click(datastore.default_datastore_filter_btn)
    appliance.server.logout()
    appliance.server.login_admin()
    navigate_to(dc, 'All')
    assert list_acc.is_selected('Filters', 'Store Type / NFS (Default)', by_title=False),\
        'Store Type / NFS not set as default'
Example #34
0
    def get_hosts(self):
        """ Gets quadicons of hosts that use this datastore

        Returns: List of :py:class:`cfme.web_ui.Quadicon` objects or `[]` if no hosts found.
        """
        quad_title_locator = ".//div[@id='quadicon']/../../../tr[2]//a"
        quads_root_locator = "//table[@id='content']//td[@id='maincol']"
        if not self._on_hosts_page():
            sel.force_navigate('infrastructure_datastore',
                               context=self._get_context())
            try:
                list_acc.select('Relationships', 'Show all registered Hosts')
            except sel.NoSuchElementException:
                return []

        all_host_quads = []
        for page in paginator.pages():
            quads_root = sel.element(quads_root_locator)
            for quad_title in sel.elements(quad_title_locator,
                                           root=quads_root):
                all_host_quads.append(
                    Quadicon(quad_title.get_attribute('title'), 'host'))
        return all_host_quads
def test_clear_datastore_filter_results(provider):
    """ Test for clearing filter results for datastores."""

    if version.current_version() >= 5.6:
        expected_page_title = "All Datastores"
        datastore_select = lambda: accordion.tree("Datastores", "All Datastores", "Global Filters", "Store Type / VMFS")
    else:
        expected_page_title = "Datastores"
        datastore_select = lambda: list_acc.select("Filters", "Store Type / VMFS", by_title=False)

    pytest.sel.force_navigate("infrastructure_datastores")
    datastore_select()
    pytest.sel.click(search_box.clear_advanced_search)
    page_title = pytest.sel.text(datastore.page_title_loc)
    assert page_title == expected_page_title, "Clear filter results failed"
def test_clear_datastore_filter_results(provider):
    """ Test for clearing filter results for datastores."""

    if version.current_version() >= 5.6:
        expected_page_title = 'All Datastores'
        datastore_select = lambda: accordion.tree(
            'Datastores', 'All Datastores', 'Global Filters',
            'Store Type / VMFS')
    else:
        expected_page_title = 'Datastores'
        datastore_select = lambda: list_acc.select(
            'Filters', 'Store Type / VMFS', by_title=False)

    pytest.sel.force_navigate('infrastructure_datastores')
    datastore_select()
    pytest.sel.click(search_box.clear_advanced_search)
    page_title = pytest.sel.text(datastore.page_title_loc)
    assert page_title == expected_page_title, 'Clear filter results failed'
def test_run_host_analysis(request, setup_provider, provider, host_type,
                           host_name, register_event, soft_assert, bug):
    """ Run host SmartState analysis

    Metadata:
        test_flag: host_analysis
    """
    # Add credentials to host
    host_data = get_host_data_by_name(provider.key, host_name)
    test_host = host.Host(name=host_name)

    wait_for(lambda: test_host.exists,
             delay=10,
             num_sec=120,
             fail_func=sel.refresh)

    if not test_host.has_valid_credentials:
        test_host.update(
            updates={
                'credentials':
                host.get_credentials_from_config(host_data['credentials'])
            })
        wait_for(lambda: test_host.has_valid_credentials,
                 delay=10,
                 num_sec=120,
                 fail_func=sel.refresh)

        # Remove creds after test
        def test_host_remove_creds():
            test_host.update(
                updates={
                    'credentials':
                    host.Host.Credential(
                        principal="", secret="", verify_secret="")
                })

        request.addfinalizer(test_host_remove_creds)

    register_event(None, "host", host_name,
                   ["host_analysis_request", "host_analysis_complete"])

    # Initiate analysis
    test_host.run_smartstate_analysis()

    # Wait for the task to finish
    def is_host_analysis_finished():
        """ Check if analysis is finished - if not, reload page
        """
        if not sel.is_displayed(tasks.tasks_table) or not tabs.is_tab_selected(
                'All Other Tasks'):
            sel.force_navigate('tasks_all_other')
        host_analysis_finished = tasks.tasks_table.find_row_by_cells({
            'task_name':
            "SmartState Analysis for '{}'".format(host_name),
            'state':
            'Finished'
        })
        return host_analysis_finished is not None

    wait_for(is_host_analysis_finished,
             delay=15,
             num_sec=480,
             fail_func=lambda: tb.select('Reload'))

    # Delete the task
    tasks.tasks_table.select_row_by_cells({
        'task_name':
        "SmartState Analysis for '{}'".format(host_name),
        'state':
        'Finished'
    })
    tb.select('Delete Tasks', 'Delete', invokes_alert=True)
    sel.handle_alert()

    # Check results of the analysis
    # This is done on purpose; we cannot use the "bug" fixture here as
    # the bug doesnt block streams other than 5.3
    services_bug = BZ(1156028)
    if provider.type == "rhevm" and (not services_bug.data.is_opened):
        soft_assert(
            test_host.get_detail('Configuration', 'Services') != '0',
            'No services found in host detail')

    if host_type in ('rhel', 'rhev'):
        soft_assert(
            test_host.get_detail('Security', 'Users') != '0',
            'No users found in host detail')
        soft_assert(
            test_host.get_detail('Security', 'Groups') != '0',
            'No groups found in host detail')
        soft_assert(
            test_host.get_detail('Configuration', 'Packages') != '0',
            'No packages found in host detail')

    elif host_type in ('esx', 'esxi'):
        soft_assert(
            test_host.get_detail('Configuration', 'Advanced Settings') != '0',
            'No advanced settings found in host detail')

        fw_bug = bug(1055657)
        if not (fw_bug is not None and provider.type == "virtualcenter"
                and provider.version < "5"):
            # If the Firewall Rules are 0, the element can't be found (it's not a link)
            try:
                # This fails for vsphere4...  https://bugzilla.redhat.com/show_bug.cgi?id=1055657
                list_acc.select('Security',
                                'Show the firewall rules on this Host')
            except ListAccordionLinkNotFound:
                # py.test's .fail would wipe the soft_assert data
                soft_assert(
                    False, "No firewall rules found in host detail accordion")
 def unset_default_host_filter():
     navigate_to(Host, 'All')
     list_acc.select('Filters', 'ALL', by_title=False)
     pytest.sel.click(host.default_host_filter_btn)
Example #39
0
def nav_to_datastore_through_provider(context):
    sel.force_navigate('infrastructure_provider', context=context)
    list_acc.select('Relationships', 'Show all managed Datastores')
    sel.click(Quadicon(context['datastore'].name, 'datastore'))
def test_run_host_analysis(request, setup_provider, provider_key, provider_type, provider_ver,
                           host_type, host_name, register_event, soft_assert):
    """ Run host SmartState analysis

    Metadata:
        test_flag: host_analysis
    """
    # Add credentials to host
    host_data = get_host_data_by_name(provider_key, host_name)
    test_host = host.Host(name=host_name)

    wait_for(lambda: test_host.exists, delay=10, num_sec=120, fail_func=sel.refresh)

    if not test_host.has_valid_credentials:
        test_host.update(
            updates={'credentials': host.get_credentials_from_config(host_data['credentials'])}
        )
        wait_for(
            lambda: test_host.has_valid_credentials,
            delay=10,
            num_sec=120,
            fail_func=sel.refresh
        )

        # Remove creds after test
        def test_host_remove_creds():
            test_host.update(
                updates={
                    'credentials': host.Host.Credential(
                        principal="",
                        secret="",
                        verify_secret=""
                    )
                }
            )
        request.addfinalizer(test_host_remove_creds)

    register_event(None, "host", host_name, ["host_analysis_request", "host_analysis_complete"])

    # Initiate analysis
    test_host.run_smartstate_analysis()

    # Wait for the task to finish
    def is_host_analysis_finished():
        """ Check if analysis is finished - if not, reload page
        """
        if not sel.is_displayed(tasks.tasks_table) or not tabs.is_tab_selected('All Other Tasks'):
            sel.force_navigate('tasks_all_other')
        host_analysis_finished = tasks.tasks_table.find_row_by_cells({
            'task_name': "SmartState Analysis for '{}'".format(host_name),
            'state': 'Finished'
        })
        return host_analysis_finished is not None

    wait_for(
        is_host_analysis_finished,
        delay=15,
        num_sec=480,
        fail_func=lambda: tb.select('Reload')
    )

    # Delete the task
    tasks.tasks_table.select_row_by_cells({
        'task_name': "SmartState Analysis for '{}'".format(host_name),
        'state': 'Finished'
    })
    tb.select('Delete Tasks', 'Delete', invokes_alert=True)
    sel.handle_alert()

    # Check results of the analysis
    soft_assert(test_host.get_detail('Configuration', 'Services') != '0',
        'No services found in host detail')

    if host_type in ('rhel', 'rhev'):
        soft_assert(test_host.get_detail('Security', 'Users') != '0',
            'No users found in host detail')
        soft_assert(test_host.get_detail('Security', 'Groups') != '0',
            'No groups found in host detail')
        soft_assert(test_host.get_detail('Configuration', 'Packages') != '0',
            'No packages found in host detail')

    elif host_type in ('esx', 'esxi'):
        soft_assert(test_host.get_detail('Configuration', 'Advanced Settings') != '0',
            'No advanced settings found in host detail')

        # If the Firewall Rules are 0, the element can't be found (it's not a link)
        try:
            # This fails for vsphere4...  https://bugzilla.redhat.com/show_bug.cgi?id=1055657
            list_acc.select('Security', 'Show the firewall rules on this Host')
        except ListAccordionLinkNotFound:
            # py.test's .fail would wipe the soft_assert data
            soft_assert(False, "No firewall rules found in host detail accordion")
Example #41
0
 def list_acc_select(option):
     list_acc.select('Relationships',
                     'Show all managed {}'.format(option),
                     by_title=True,
                     partial=False)
Example #42
0
def nav_to_cluster_through_provider(context):
    sel.force_navigate('infrastructure_provider', context=context)
    list_acc.select('Relationships', 'Show all managed Clusters')
    sel.click(Quadicon(context['cluster'].name, 'cluster'))
 def unset_default_datastore_filter():
     pytest.sel.force_navigate('infrastructure_datastores')
     list_acc.select('Filters', 'ALL', by_title=False)
     pytest.sel.click(datastore.default_datastore_filter_btn)
Example #44
0
 def get_datastores(self):
     """ Gets list of all datastores used by this host"""
     navigate_to(self, 'Details')
     list_acc.select('Relationships', 'Datastores', by_title=False, partial=True)
     return [q.name for q in Quadicon.all("datastore")]
Example #45
0
def nav_to_cluster_through_provider(context):
    # TODO: replace this navigation via navmazing and a CFMENavigateStep destination
    navigate_to(context['provider'], 'Details')
    list_acc.select('Relationships', 'Show all managed Clusters', by_title=True, partial=False)
    sel.click(Quadicon(context['cluster'].name, 'cluster'))
Example #46
0
 def step(self):
     navigate_to(self.obj.provider, 'Details')
     list_acc.select('Relationships', 'Datastores', by_title=False, partial=True)
     sel.click(Quadicon(self.obj.name, self.obj.quad_name))
Example #47
0
 def step(self):
     list_acc.select('Relationships',
                     'Show all managed Deployment Roles',
                     by_title=True,
                     partial=False)
Example #48
0
 def unset_default_datastore_filter():
     navigate_to(Datastore, 'All')
     list_acc.select('Filters', 'ALL', by_title=False)
     pytest.sel.click(datastore.default_datastore_filter_btn)
 def step(self):
     list_acc.select('Relationships',
                     'Datastores',
                     by_title=False,
                     partial=True)
     sel.click(Quadicon(self.obj.name, self.obj.quad_name))
Example #50
0
def test_run_host_analysis(request, provider_key, host_type, host_name,
                           register_event, soft_assert):
    """ Run host SmartState analysis """
    # Add credentials to host
    host_data = get_host_data_by_name(provider_key, host_name)
    test_host = host.Host(name=host_name)

    wait_for(lambda: test_host.exists,
             delay=10,
             num_sec=120,
             fail_func=sel.refresh)

    if not test_host.has_valid_credentials:
        test_host.update(
            updates={
                'credentials':
                host.get_credentials_from_config(host_data['credentials'])
            })
        wait_for(lambda: test_host.has_valid_credentials,
                 delay=10,
                 num_sec=120,
                 fail_func=sel.refresh)

        # Remove creds after test
        def test_host_remove_creds():
            test_host.update(
                updates={
                    'credentials':
                    host.Host.Credential(
                        principal="", secret="", verify_secret="")
                })

        request.addfinalizer(test_host_remove_creds)

    register_event(None, "host", host_name,
                   ["host_analysis_request", "host_analysis_complete"])

    # Initiate analysis
    sel.force_navigate('infrastructure_host', context={'host': test_host})
    tb.select('Configuration',
              'Perform SmartState Analysis',
              invokes_alert=True)
    sel.handle_alert()
    flash.assert_message_contain(
        '"{}": Analysis successfully initiated'.format(host_name))

    # Wait for the task to finish
    def is_host_analysis_finished():
        """ Check if analysis is finished - if not, reload page
        """
        if not sel.is_displayed(tasks.tasks_table) or not tabs.is_tab_selected(
                'All Other Tasks'):
            sel.force_navigate('tasks_all_other')
        host_analysis_finished = tasks.tasks_table.find_row_by_cells({
            'task_name':
            "SmartState Analysis for '{}'".format(host_name),
            'state':
            'Finished'
        })
        return host_analysis_finished is not None

    wait_for(is_host_analysis_finished,
             delay=10,
             num_sec=120,
             fail_func=lambda: tb.select('Reload'))

    # Delete the task
    tasks.tasks_table.select_row_by_cells({
        'task_name':
        "SmartState Analysis for '{}'".format(host_name),
        'state':
        'Finished'
    })
    tb.select('Delete Tasks', 'Delete', invokes_alert=True)
    sel.handle_alert()

    # Check results of the analysis
    soft_assert(
        test_host.get_detail('Configuration', 'Services') != '0',
        'No services found in host detail')

    if host_type in ('rhel', 'rhev'):
        soft_assert(
            test_host.get_detail('Security', 'Users') != '0',
            'No users found in host detail')
        soft_assert(
            test_host.get_detail('Security', 'Groups') != '0',
            'No groups found in host detail')
        soft_assert(
            test_host.get_detail('Configuration', 'Packages') != '0',
            'No packages found in host detail')

    elif host_type in ('esx', 'esxi'):
        soft_assert(
            test_host.get_detail('Configuration', 'Advanced Settings') != '0',
            'No advanced settings found in host detail')

        # If the Firewall Rules are 0, the element can't be found (it's not a link)
        try:
            # This fails for vsphere4...  https://bugzilla.redhat.com/show_bug.cgi?id=1055657
            list_acc.select('Security', 'Show the firewall rules on this Host')
        except ListAccordionLinkNotFound:
            # py.test's .fail would wipe the soft_assert data
            soft_assert(False,
                        "No firewall rules found in host detail accordion")
 def unset_default_host_filter():
     navigate_to(Host, "All")
     list_acc.select("Filters", "ALL", by_title=False)
     pytest.sel.click(host.default_host_filter_btn)
Example #52
0
 def unset_default_host_filter():
     navigate_to(Host, 'All')
     list_acc.select('Filters', 'ALL', by_title=False)
     pytest.sel.click(host.default_host_filter_btn)
 def unset_default_datastore_filter():
     pytest.sel.force_navigate("infrastructure_datastores")
     list_acc.select("Filters", "ALL", by_title=False)
     pytest.sel.click(datastore.default_datastore_filter_btn)
 def unset_default_datastore_filter():
     navigate_to(Datastore, "All")
     list_acc.select("Filters", "ALL", by_title=False)
     pytest.sel.click(datastore.default_datastore_filter_btn)
Example #55
0
 def step(self):
     navigate_to(self.obj.provider, 'Details')
     list_acc.select('Relationships', 'Show all managed Clusters', by_title=True, partial=False)
     sel.click(Quadicon(self.obj.name, self.obj.quad_name))
Example #56
0
def test_run_host_analysis(request, setup_provider, provider, host_type,
                           host_name, register_event, soft_assert, bug):
    """ Run host SmartState analysis

    Metadata:
        test_flag: host_analysis
    """
    # Add credentials to host
    host_data = get_host_data_by_name(provider.key, host_name)
    test_host = host.Host(name=host_name)

    wait_for(lambda: test_host.exists, delay=10, num_sec=120)

    if not test_host.has_valid_credentials:
        with update(test_host):
            test_host.credentials = host.get_credentials_from_config(
                host_data['credentials'])

        wait_for(lambda: test_host.has_valid_credentials,
                 delay=10,
                 num_sec=120)

        # Remove creds after test
        @request.addfinalizer
        def _host_remove_creds():
            with update(test_host):
                test_host.credentials = host.Host.Credential(principal="",
                                                             secret="",
                                                             verify_secret="")

    register_event(None, "host", host_name,
                   ["host_analysis_request", "host_analysis_complete"])

    # Initiate analysis
    test_host.run_smartstate_analysis()

    wait_for(lambda: is_host_analysis_finished(host_name),
             delay=15,
             timeout="10m",
             fail_func=lambda: toolbar.select('Reload'))

    # Check results of the analysis
    drift_history = test_host.get_detail('Relationships', 'Drift History')
    soft_assert(drift_history != '0', 'No drift history change found')

    if provider.type == "rhevm":
        soft_assert(
            test_host.get_detail('Configuration', 'Services') != '0',
            'No services found in host detail')

    if host_type in ('rhel', 'rhev'):
        soft_assert(
            InfoBlock.text('Security', 'Users') != '0',
            'No users found in host detail')
        soft_assert(
            InfoBlock.text('Security', 'Groups') != '0',
            'No groups found in host detail')
        soft_assert(
            InfoBlock.text('Security', 'SSH Root') != '',
            'No packages found in host detail')
        soft_assert(
            InfoBlock.text('Configuration', 'Packages') != '0',
            'No packages found in host detail')
        soft_assert(
            InfoBlock.text('Configuration', 'Files') != '0',
            'No files found in host detail')
        soft_assert(
            InfoBlock.text('Security', 'Firewall Rules') != '0',
            'No firewall rules found in host detail')

    elif host_type in ('esx', 'esxi'):
        soft_assert(
            InfoBlock.text('Configuration', 'Advanced Settings') != '0',
            'No advanced settings found in host detail')

        if not (provider.type == "virtualcenter" and provider.version < "5"):
            # If the Firewall Rules are 0, the element can't be found (it's not a link)
            try:
                # This fails for vsphere4...  https://bugzilla.redhat.com/show_bug.cgi?id=1055657
                list_acc.select('Security',
                                'Show the firewall rules on this Host')
            except ListAccordionLinkNotFound:
                # py.test's .fail would wipe the soft_assert data
                soft_assert(
                    False, "No firewall rules found in host detail accordion")
Example #57
0
def nav_to_cluster_through_provider(context):
    sel.force_navigate('infrastructure_provider', context=context)
    list_acc.select('Relationships', 'Show all managed Clusters')
    sel.click(Quadicon(context['cluster'].name, 'cluster'))
 def unset_default_datastore_filter():
     navigate_to(Datastore, 'All')
     list_acc.select('Filters', 'ALL', by_title=False)
     pytest.sel.click(datastore.default_datastore_filter_btn)
Example #59
0
def test_run_host_analysis(request, setup_provider, provider, host_type, host_name, register_event,
                           soft_assert, bug):
    """ Run host SmartState analysis

    Metadata:
        test_flag: host_analysis
    """
    # Add credentials to host
    host_data = get_host_data_by_name(provider.key, host_name)
    test_host = host.Host(name=host_name, provider=provider)

    wait_for(lambda: test_host.exists, delay=10, num_sec=120)

    if not test_host.has_valid_credentials:
        with update(test_host):
            test_host.credentials = host.get_credentials_from_config(host_data['credentials'])

        wait_for(lambda: test_host.has_valid_credentials, delay=10, num_sec=120)

        # Remove creds after test
        @request.addfinalizer
        def _host_remove_creds():
            with update(test_host):
                test_host.credentials = host.Host.Credential(
                    principal="", secret="", verify_secret="")

    builder = EventBuilder(get_or_create_current_appliance())
    base_evt = partial(builder.new_event, target_type='Host', target_name=host_name)

    register_event(base_evt(event_type='request_host_scan'),
                   base_evt(event_type='host_scan_complete'))

    # Initiate analysis
    test_host.run_smartstate_analysis()

    wait_for(lambda: is_host_analysis_finished(host_name),
             delay=15, timeout="10m", fail_func=lambda: toolbar.select('Reload'))

    # Check results of the analysis
    drift_history = test_host.get_detail('Relationships', 'Drift History')
    soft_assert(drift_history != '0', 'No drift history change found')

    if provider.type == "rhevm":
        soft_assert(test_host.get_detail('Configuration', 'Services') != '0',
            'No services found in host detail')

    if host_type in ('rhel', 'rhev'):
        soft_assert(InfoBlock.text('Security', 'Users') != '0',
            'No users found in host detail')
        soft_assert(InfoBlock.text('Security', 'Groups') != '0',
            'No groups found in host detail')
        soft_assert(InfoBlock.text('Security', 'SSH Root') != '',
            'No packages found in host detail')
        soft_assert(InfoBlock.text('Configuration', 'Packages') != '0',
            'No packages found in host detail')
        soft_assert(InfoBlock.text('Configuration', 'Files') != '0',
            'No files found in host detail')
        soft_assert(InfoBlock.text('Security', 'Firewall Rules') != '0',
            'No firewall rules found in host detail')

    elif host_type in ('esx', 'esxi'):
        soft_assert(InfoBlock.text('Configuration', 'Advanced Settings') != '0',
            'No advanced settings found in host detail')

        if not(provider.type == "virtualcenter" and provider.version < "5"):
            # If the Firewall Rules are 0, the element can't be found (it's not a link)
            try:
                # This fails for vsphere4...  https://bugzilla.redhat.com/show_bug.cgi?id=1055657
                list_acc.select('Security', 'Show the firewall rules on this Host')
            except ListAccordionLinkNotFound:
                # py.test's .fail would wipe the soft_assert data
                soft_assert(False, "No firewall rules found in host detail accordion")
Example #60
0
def nav_to_datastore_through_provider(context):
    sel.force_navigate('infrastructure_provider', context=context)
    list_acc.select('Relationships', 'Show all managed Datastores')
    sel.click(Quadicon(context['datastore'].name, 'datastore'))