Ejemplo n.º 1
0
 def delete(self):
     """Remove template from CFME VMDB"""
     sel.force_navigate("clouds_images")
     quad = Quadicon(self.name, 'image')
     sel.check(quad.checkbox())
     cfg_btn('Remove selected items from the VMDB', invokes_alert=True)
     sel.handle_alert()
Ejemplo n.º 2
0
    def find_quadicon(self, **kwargs):
        """Find and return a quadicon belonging to a specific instance

        TODO: remove this method and refactor callers to use view entities instead

        Args:
        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        """
        if not kwargs.get('do_not_navigate', False):
            navigate_to(self, 'All')

        # Make sure we're looking at the quad grid
        view = self.browser.create_view(InstanceAllView)
        view.toolbar.view_selector.select('Grid View')

        # Keeping paginator iteration here to create Quadicon object
        # using entities.get_first_entity won't give the quadicon object we need for compatibility
        for _ in view.entities.paginator.pages():
            quadicon = Quadicon(self.name, "instance")
            if quadicon.exists:
                if kwargs.get('mark', False):
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise InstanceNotFound("Instance '{}' not found in UI!".format(self.name))
Ejemplo n.º 3
0
    def find_quadicon(
            self, do_not_navigate=False, mark=False, refresh=True, from_any_provider=False):
        """Find and return a quadicon belonging to a specific instance

        Args:
            from_any_provider: Whether to look for it anywhere (root of the tree). Useful when
                looking up archived or orphaned VMs

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: InstanceNotFound
        """
        if not do_not_navigate:
            if from_any_provider:
                sel.force_navigate("clouds_instances")
            elif not self.provider_crud.load_all_provider_instances():
                raise InstanceNotFound("No instances for the provider!")
            toolbar.set_vms_grid_view()
        elif refresh:
            sel.refresh()
        if not paginator.page_controls_exist():
            raise InstanceNotFound("Instance '{}' not found in UI!".format(self.name))

        paginator.results_per_page(1000)
        for page in paginator.pages():
            quadicon = Quadicon(self.name, "instance")
            if sel.is_displayed(quadicon):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise InstanceNotFound("Instance '{}' not found in UI!".format(self.name))
Ejemplo n.º 4
0
def _tag_item_through_selecting(request, location, tag):
    """Add a tag to an item with going through the details page.

    Prerequisities:
        * Have a tag category and tag created.
        * Be on the page you want to test.

    Steps:
        * Select any quadicon.
        * Select ``Policy/Edit Tags`` and assign the tag to it.
        * Click on the quadicon and verify the tag is assigned. (TODO)
        * Go back to the quadicon view and select ``Policy/Edit Tags`` and remove the tag.
        * Click on the quadicon and verify the tag is not present. (TODO)
    """
    if not _navigate_and_check(location):
        pytest.skip("No Quadicon present, cannot test.")
    Quadicon.select_first_quad()

    def _delete():
        # Ignoring the result of the check here
        _navigate_and_check(location)
        Quadicon.select_first_quad()
        mixins.remove_tag(tag)
    request.addfinalizer(lambda: diaper(_delete))
    mixins.add_tag(tag)
    _delete()
Ejemplo n.º 5
0
    def _find_quadicon(self, is_vm=True, do_not_navigate=False, mark=False, refresh=True):
        """Find and return a quadicon belonging to a specific vm

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: VmNotFound
        """
        quadicon = Quadicon(self.name, "vm")
        if not do_not_navigate:
            if is_vm:
                self.provider_crud.load_all_provider_vms()
            else:
                self.provider_crud.load_all_provider_templates()
            toolbar.set_vms_grid_view()
        elif refresh:
            sel.refresh()
        if not paginator.page_controls_exist():
            if is_vm:
                raise VmNotFound("VM '{}' not found in UI!".format(self.name))
            else:
                raise TemplateNotFound("Template '{}' not found in UI!".format(self.name))

        paginator.results_per_page(1000)
        for page in paginator.pages():
            if sel.is_displayed(quadicon):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise VmNotFound("VM '{}' not found in UI!".format(self.name))
def test_tag_infra_item_through_selecting(location, tag):
    """Add a tag to a infra item
    """
    pytest.sel.force_navigate(location)
    Quadicon.select_first_quad()
    mixins.add_tag(tag)
    Quadicon.select_first_quad()  # It goes back to the list view.
    mixins.remove_tag(tag)
Ejemplo n.º 7
0
def _repo_nav_fn(context):
    repo = context['repository']
    if current_version() >= '5.4':
        quadicon = Quadicon(repo.name, "repository")
        sel.click(quadicon.locate())
    else:
        sel.click(_repo_row(repo.name)[1])
    sel.wait_for_element(repo._detail_page_identifying_loc)
Ejemplo n.º 8
0
def _check_repo(name, callback=None):
    if current_version() >= '5.4':
        quadicon = Quadicon(name, "repository")
        sel.check(quadicon.checkbox())
    else:
        sel.check(sel.element('.//img', root=_repo_row(name)[0]))
    if callback:
        return callback()
Ejemplo n.º 9
0
 def exists(self):
     sel.force_navigate('infrastructure_repositories')
     try:
         if current_version() >= '5.4':
             quadicon = Quadicon(self.name, "repository")
             return sel.is_displayed(quadicon.locate())
         else:
             return bool(_repo_row(self.name))
     except:  # exception?
         return False
Ejemplo n.º 10
0
def test_host_delete(provider):
    navigate_to(provider, 'ProviderNodes')
    quad_names = [q.name for q in Quadicon.all() if 'Compute' in q.name]
    host_name = random.choice(quad_names)
    host = Host(host_name, provider=provider)
    host.delete(cancel=False)
    flash.assert_no_errors()
    wait_for_host_delete(host)
    navigate_to(provider, 'ProviderNodes')
    assert host_name not in [q.name for q in Quadicon.all()]
Ejemplo n.º 11
0
def test_compressed_view(request, setup_a_provider, key):
    name = re.split(r"\/", key)
    default_view = get_default_view(name[0])
    set_compressed_view(name[0])
    sel.force_navigate(name[1])
    Quadicon.select_first_quad()
    select_second_quad()
    tb.select(name[2], name[3])
    assert tb.is_active('Compressed View'), "Compressed view setting failed"
    reset_default_view(name[0], default_view)
Ejemplo n.º 12
0
    def find_quadicon(
            self, do_not_navigate=False, mark=False, refresh=True, from_any_provider=False,
            use_search=True):
        """Find and return a quadicon belonging to a specific vm

        Args:
            from_any_provider: Whether to look for it anywhere (root of the tree). Useful when
                looking up archived or orphaned VMs

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: VmOrInstanceNotFound
        """
        quadicon = Quadicon(self.name, self.quadicon_type)
        if not do_not_navigate:
            if from_any_provider:
                # TODO implement as navigate_to when cfme.infra.virtual_machines has destination
                sel.force_navigate(self.ALL_LIST_LOCATION)
            elif self.is_vm:
                self.provider.load_all_provider_vms()
            else:
                self.provider.load_all_provider_templates()
            toolbar.select('Grid View')
        else:
            # Search requires navigation, we shouldn't use it then
            use_search = False
            if refresh:
                sel.refresh()
        if not paginator.page_controls_exist():
            if self.is_vm:
                raise VmOrInstanceNotFound("VM '{}' not found in UI!".format(self.name))
            else:
                raise TemplateNotFound("Template '{}' not found in UI!".format(self.name))

        # this is causing some issues in 5.5.0.9, commenting out for a bit
        # paginator.results_per_page(1000)
        if use_search:
            try:
                if not search.has_quick_search_box():
                    # We don't use provider-specific page (vm_templates_provider_branch) here
                    # as those don't list archived/orphaned VMs
                    if self.is_vm:
                        navigate_to(self.provider, 'Instances')
                    else:
                        navigate_to(self.provider, self.provider.templates_destination_name)
                search.normal_search(self.name)
            except Exception as e:
                logger.warning("Failed to use search: %s", str(e))

        for page in paginator.pages():
            if sel.is_displayed(quadicon, move_to=True):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise VmOrInstanceNotFound("VM '{}' not found in UI!".format(self.name))
Ejemplo n.º 13
0
def test_exists_view(request, setup_a_provider, key):
    name = re.split(r"\/", key)
    button_name = name[0] + " Mode"
    default_view = get_default_view(button_name)
    set_exist_view(button_name)
    sel.force_navigate(name[1])
    Quadicon.select_first_quad()
    select_second_quad()
    tb.select(name[2], name[3])
    assert tb.is_active('Exists Mode'), "Exists view setting failed"
    reset_default_view(button_name, default_view)
Ejemplo n.º 14
0
def test_role_delete(provider):
    navigate_to(DeploymentRoles, 'All')
    quads = list(Quadicon.all())
    assert quads > 0
    role_name = choice(quads).name
    dr = DeploymentRoles(role_name, provider)
    dr.delete()
    flash.assert_no_errors()
    navigate_to(dr, 'AllForProvider')
    names = [q.name for q in list(Quadicon.all())]
    assert role_name not in names
Ejemplo n.º 15
0
    def find_quadicon(
            self, do_not_navigate=False, mark=False, refresh=True, from_any_provider=False,
            use_search=True):
        """Find and return a quadicon belonging to a specific vm

        Args:
            from_any_provider: Whether to look for it anywhere (root of the tree). Useful when
                looking up archived or orphaned VMs

        Returns: :py:class:`cfme.web_ui.Quadicon` instance
        Raises: VmOrInstanceNotFound
        """
        quadicon = Quadicon(self.name, self.quadicon_type)
        if not do_not_navigate:
            if from_any_provider:
                # TODO implement as navigate_to when cfme.infra.virtual_machines has destination
                navigate_to(self, 'All')
            elif self.is_vm:
                navigate_to(self, 'AllForProvider', use_resetter=False)
            else:
                navigate_to(self, 'AllForProvider', use_resetter=False)
            toolbar.select('Grid View')
        else:
            # Search requires navigation, we shouldn't use it then
            use_search = False
            if refresh:
                sel.refresh()
        if not paginator.page_controls_exist():
            if self.is_vm:
                raise VmOrInstanceNotFound("VM '{}' not found in UI!".format(self.name))
            else:
                raise TemplateNotFound("Template '{}' not found in UI!".format(self.name))

        paginator.results_per_page(1000)
        if use_search:
            try:
                if not search.has_quick_search_box():
                    # TODO rework search for archived/orphaned VMs
                    if self.is_vm:
                        navigate_to(self, 'AllForProvider', use_resetter=False)
                    else:
                        navigate_to(self, 'AllForProvider', use_resetter=False)
                search.normal_search(self.name)
            except Exception as e:
                logger.warning("Failed to use search: %s", str(e))
        for page in paginator.pages():
            if sel.is_displayed(quadicon, move_to=True):
                if mark:
                    sel.check(quadicon.checkbox())
                return quadicon
        else:
            raise VmOrInstanceNotFound("VM '{}' not found in UI!".format(self.name))
Ejemplo n.º 16
0
def test_tag_item_through_selecting(request, location, tag):
    """Add a tag to an item."""
    pytest.sel.force_navigate(location)
    tb.set_vms_grid_view()
    if not Quadicon.any_present:
        pytest.skip("No Quadicon present, cannot test.")
    Quadicon.select_first_quad()

    def _delete():
        pytest.sel.force_navigate(location)
        tb.set_vms_grid_view()
        Quadicon.select_first_quad()
        mixins.remove_tag(tag)
    request.addfinalizer(lambda: diaper(_delete))
    mixins.add_tag(tag)
    _delete()
Ejemplo n.º 17
0
def test_tag_infra_item_through_details(location, tag):
    """Add a tag to a infra item
    """
    pytest.sel.force_navigate(location)
    pytest.sel.click(Quadicon.first())
    mixins.add_tag(tag)
    mixins.remove_tag(tag)
Ejemplo n.º 18
0
 def exists(self):
     """Returns whether the manager exists in the UI or not"""
     navigate_to(self, 'All')
     if (Quadicon.any_present() and
             Quadicon(self.quad_name, None).exists):
         return True
     return False
Ejemplo n.º 19
0
 def exists(self):
     """Returns whether the manager exists in the UI or not"""
     sel.force_navigate('infrastructure_config_managers')
     if (Quadicon.any_present() and
             Quadicon('{} Configuration Manager'.format(self.name), None).exists):
         return True
     return False
def test_data_integrity_for_topology(test_data):
    """ This test verifies that every status box value under Containers Overview is identical to the
    number present on its page.
    Steps:
        * Go to Containers / Overview
        * All cells should contain the correct relevant information
            # of nodes
            # of providers
            # ...
    """
    section_values = {}
    sel.force_navigate('container_dashboard')
    # We should wait ~2 seconds for the StatusBox population
    # (until we find a better solution)
    time.sleep(2)
    status_box = StatusBox(test_data[2])
    section_values[test_data[0]] = int(status_box.value())
    sel.force_navigate(test_data[1])
    if section_values[test_data[0]] > 0:
        if test_data[0] is Provider:
            assert len(map(lambda i: i, Quadicon.all())) == section_values[test_data[0]]
        else:
            assert len(map(lambda r: r, test_data[3].rows())
                       ) == section_values[test_data[0]]
    else:
        assert sel.is_displayed_text('No Records Found.')
Ejemplo n.º 21
0
 def delete_all_attached_vms(self):
     self.load_details()
     sel.click(details_page.infoblock.element("Relationships", "Managed VMs"))
     for q in Quadicon.all('vm'):
         fill(q.checkbox(), True)
     cfg_btn("Remove selected items from the VMDB", invokes_alert=True)
     sel.handle_alert(cancel=False)
Ejemplo n.º 22
0
def test_roles_summary(provider, soft_assert):
    err_ptrn = '{} are shown incorrectly'
    navigate_to(DeploymentRoles('', provider), 'AllForProvider')
    roles_names = [q.name for q in Quadicon.all()]

    for name in roles_names:
        dr = DeploymentRoles(name, provider)
        navigate_to(dr, 'DetailsFromProvider')

        for v in ('Nodes', 'Direct VMs', 'All VMs'):
            res = dr.get_detail('Relationships', v)
            soft_assert(res.isdigit(), err_ptrn.format(v))

        for v in ('Total CPUs', 'Total Node CPU Cores'):
            res = dr.get_detail('Totals for Nodes', v)
            soft_assert(res.isdigit() and int(res) > 0, err_ptrn.format(v))

        total_cpu = dr.get_detail('Totals for Nodes', 'Total CPU Resources')
        soft_assert('GHz' in total_cpu, err_ptrn.format('Total CPU Resources'))
        total_memory = dr.get_detail('Totals for Nodes', 'Total Memory')
        soft_assert('GB' in total_memory, err_ptrn.format('Total Memory'))

        for v in ('Total Configured Memory', 'Total Configured CPUs'):
            res = dr.get_detail('Totals for VMs', v)
            soft_assert(res, err_ptrn.format(v))
Ejemplo n.º 23
0
def select_two_quads():
    count = 0
    for quad in Quadicon.all("infra_prov", this_page=True):
        count += 1
        if count > 2:
            break
        fill(quad.checkbox(), True)
Ejemplo n.º 24
0
def test_host_devices(provider):
    navigate_to(provider, 'Details')
    sel.click(InfoBlock.element("Relationships", "Nodes"))
    my_quads = list(Quadicon.all())
    assert len(my_quads) > 0
    for quad in my_quads:
        host = Host(name=quad.name, provider=provider)
        assert int(host.get_detail("Properties", "Devices")) > 0
Ejemplo n.º 25
0
def test_host_hostname(provider, soft_assert):
    provider.summary.relationships.nodes.click()
    my_quads = list(Quadicon.all())
    assert len(my_quads) > 0
    for quad in my_quads:
        host = Host(name=quad.name, provider=provider)
        result = host.get_detail("Properties", "Hostname")
        soft_assert(result, "Missing hostname in: " + str(result))
Ejemplo n.º 26
0
 def get_first_vm_title(cls, do_not_navigate=False, provider=None):
     """Get the title of first VM/Instance."""
     if not do_not_navigate:
         if provider is None:
             navigate_to(cls, 'All')
         else:
             provider.load_all_provider_vms()
     return Quadicon.get_first_quad_title()
Ejemplo n.º 27
0
def test_delete_instance(new_instance):
    new_instance.power_control_from_cfme(from_details=True,
                                         option=OpenStackInstance.TERMINATE)
    new_instance.wait_for_instance_state_change(OpenStackInstance.STATE_UNKNOWN)

    assert new_instance.name not in new_instance.provider.mgmt.list_vm()
    navigate_to(new_instance, 'AllForProvider')
    assert new_instance.name not in [q.name for q in Quadicon.all()]
Ejemplo n.º 28
0
 def get_first_vm_title(cls, do_not_navigate=False, provider=None):
     """Get the title of first VM/Instance."""
     if not do_not_navigate:
         if provider is None:
             sel.force_navigate(cls.ALL_LIST_LOCATION)
         else:
             provider.load_all_provider_vms()
     return Quadicon.get_first_quad_title()
Ejemplo n.º 29
0
def get_all_clusters():
    """Returns list of all clusters"""

    sel.force_navigate('infrastructure_clusters')
    clusters = []
    for cluster in Quadicon.all(this_page=True):
        clusters.append(Cluster(cluster.name))
    return clusters
Ejemplo n.º 30
0
 def get_clusters(self):
     """returns the list of clusters belonging to the provider"""
     web_clusters = []
     navigate_to(self, "Details")
     sel.click(InfoBlock.element("Relationships", "Clusters"))
     icons = Quadicon.all(qtype="cluster")
     for icon in icons:
         web_clusters.append(Cluster(icon.name, self))
     return web_clusters
Ejemplo n.º 31
0
def _setup_providers(cloud_or_infra, validate, check_existing):
    """Helper to set up all cloud or infra providers, and then validate them

    Args:
        cloud_or_infra: Like the name says: 'cloud' or 'infra' (a string)
        validate: see description in :py:func:`setup_provider`
        check_existing: see description in :py:func:`setup_provider`

    Returns:
        A list of provider objects that have been created.

    """
    # Pivot behavior on cloud_or_infra
    options_map = {
        'cloud': {
            'navigate': 'clouds_providers',
            'quad': 'cloud_prov',
            'list': list_cloud_providers
        },
        'infra': {
            'navigate': 'infrastructure_providers',
            'quad': 'infra_prov',
            'list': list_infra_providers
        }
    }
    # Check for existing providers all at once, to prevent reloading
    # the providers page for every provider in cfme_data
    if not options_map[cloud_or_infra]['list']():
        return []
    if check_existing:
        sel.force_navigate(options_map[cloud_or_infra]['navigate'])
        add_providers = []
        for provider_key in options_map[cloud_or_infra]['list']():
            provider_name = conf.cfme_data['management_systems'][provider_key][
                'name']
            quad = Quadicon(provider_name, options_map[cloud_or_infra]['quad'])
            for page in paginator.pages():
                if sel.is_displayed(quad):
                    logger.debug('Provider "%s" exists, skipping' %
                                 provider_key)
                    break
            else:
                add_providers.append(provider_key)
    else:
        # Add all cloud or infra providers unconditionally
        add_providers = options_map[cloud_or_infra]['list']()

    if add_providers:
        logger.info('Providers to be added: %s' % ', '.join(add_providers))

    # Save the provider objects for validation and return
    added_providers = []

    for provider_name in add_providers:
        # Don't validate in this step; add all providers, then go back and validate in order
        provider = setup_provider(provider_name,
                                  validate=False,
                                  check_existing=False)
        added_providers.append(provider)

    if validate:
        map(methodcaller('validate'), added_providers)

    return added_providers
Ejemplo n.º 32
0
 def step(self):
     sel.check(Quadicon(self.obj.name, None))
     cfg_btn('Edit Tags')
Ejemplo n.º 33
0
 def step(self):
     sel.check(Quadicon(self.obj.name, None))
     cfg_btn('Provision Configured Systems')
Ejemplo n.º 34
0
])

details_page = Region(infoblock_type='detail')

cfg_btn = partial(tb.select, 'Configuration')
pol_btn = partial(tb.select, 'Policy')
mon_btn = partial(tb.select, 'Monitoring')

nav.add_branch(
    'clouds_providers', {
        'clouds_provider_new':
        lambda _: cfg_btn('Add a New Cloud Provider'),
        'clouds_provider_discover':
        lambda _: cfg_btn('Discover Cloud Providers'),
        'clouds_provider': [
            lambda ctx: sel.click(Quadicon(ctx[
                'provider'].name, 'cloud_prov')), {
                    'clouds_provider_edit':
                    lambda _: cfg_btn('Edit this Cloud Provider'),
                    'clouds_provider_policy_assignment':
                    lambda _: pol_btn('Manage Policies'),
                    'cloud_provider_timelines':
                    lambda _: mon_btn('Timelines')
                }
        ]
    })


class Provider(Pretty, CloudInfraProvider):
    """
    Abstract model of a cloud provider in cfme. See EC2Provider or OpenStackProvider.
Ejemplo n.º 35
0
 def step(self):
     sel.check(Quadicon(self.obj.name, self.obj.quad_name).checkbox())
     pol_btn('Edit Tags')
Ejemplo n.º 36
0
 def step(self):
     sel.check(Quadicon(self.obj.name, self.obj.quad_name).checkbox())
     cfg_btn('Edit Selected Infrastructure Providers')
Ejemplo n.º 37
0
 def step(self):
     sel.check(Quadicon(self.obj.quad_name, None).checkbox())
     cfg_btn('Edit Selected item')
Ejemplo n.º 38
0
def get_all_vms(do_not_navigate=False):
    """Returns list of all vms"""
    if not do_not_navigate:
        navigate_to(Vm, 'VMsOnly')
    return [q.name for q in Quadicon.all("vm")]
Ejemplo n.º 39
0
 def step(self):
     sel.check(Quadicon(self.obj.name, self.obj.quad_name).checkbox())
     pol_btn('Manage Policies')
Ejemplo n.º 40
0
details_page = Region(infoblock_type='detail')

cfg_btn = partial(tb.select, 'Configuration')
pol_btn = partial(tb.select, 'Policy')


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'))


nav.add_branch(
    'infrastructure_datastores', {
        'infrastructure_datastore':
        lambda ctx: sel.click(Quadicon(ctx['datastore'].name, 'datastore'))
        if 'provider' not in ctx else nav_to_datastore_through_provider(ctx)
    })


class Datastore(object):
    """ Model of an infrastructure datastore in cfme

    Args:
        name: Name of the datastore.
        provider_key: Name of the provider this datastore is attached to.

    Note:
        If given a provider_key, it will navigate through ``Infrastructure/Providers`` instead
        of the direct path through ``Infrastructure/Datastores``.
    """
Ejemplo n.º 41
0
 def check_image_exists(self):
     name = Quadicon.get_first_quad_title()
     quad = Quadicon(name, None)
     return quad.check_for_single_quadrant_icon
Ejemplo n.º 42
0
 def _delete():
     pytest.sel.force_navigate(location)
     tb.select('Grid View')
     Quadicon.select_first_quad()
     mixins.remove_tag(tag)
Ejemplo n.º 43
0
from cfme.web_ui import Quadicon, Region, toolbar as tb
from functools import partial
from utils.pretty import Pretty
from utils.providers import get_crud
from utils.wait import wait_for

details_page = Region(infoblock_type='detail')

cfg_btn = partial(tb.select, 'Configuration')
pol_btn = partial(tb.select, 'Policy')


nav.add_branch(
    'infrastructure_resource_pools', {
        'infrastructure_resource_pool':
        lambda ctx: sel.click(Quadicon(ctx['resource_pool'].name, 'resource_pool'))
    }
)


class ResourcePool(Pretty):
    """ Model of an infrastructure Resource pool in cfme

    Args:
        name: Name of the Resource pool.
        provider_key: Name of the provider this resource pool is attached to.

    Note:
        If given a provider_key, it will navigate through ``Infrastructure/Providers`` instead
        of the direct path through ``Infrastructure/Resourcepool``.
    """
Ejemplo n.º 44
0
def get_all_resourcepools(do_not_navigate=False):
    """Returns list of all resource pools"""
    if not do_not_navigate:
        sel.force_navigate('infrastructure_resource_pools')
    return [q.name for q in Quadicon.all("resource_pool")]
Ejemplo n.º 45
0
 def check_vm_add(self, add_vm_name):
     view = navigate_to(self, 'Details')
     # TODO - replace Quadicon later
     quadicon = Quadicon(add_vm_name, "vm")
     sel.click(quadicon)
     view.flash.assert_no_error()
Ejemplo n.º 46
0
def wait_for_host_to_appear(host):
    navigate_to(Host, 'All')
    quad = Quadicon(host.name, 'host')
    logger.info('Waiting for a host to appear...')
    wait_for(sel.is_displayed, func_args=[quad], fail_condition=False,
             message="Wait host to appear", num_sec=1000, fail_func=sel.refresh)
Ejemplo n.º 47
0
 def step(self):
     sel.check(Quadicon(self.obj.name, self.obj.quad_name).checkbox())
     cfg_btn('Edit Selected Middleware Provider')
Ejemplo n.º 48
0
def wait_for_host_delete(host):
    navigate_to(Host, 'All')
    quad = Quadicon(host.name, 'host')
    logger.info('Waiting for a host to delete...')
    wait_for(lambda: not sel.is_displayed(quad), fail_condition=False,
             message="Wait host to disappear", num_sec=500, fail_func=sel.refresh)
Ejemplo n.º 49
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'))
Ejemplo n.º 50
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")]
Ejemplo n.º 51
0
 def step(self):
     sel.click(Quadicon(self.obj.name, self.obj.quad_name))
Ejemplo n.º 52
0
 def _delete():
     pytest.sel.force_navigate(location)
     tb.set_vms_grid_view()
     Quadicon.select_first_quad()
     mixins.remove_tag(tag)
Ejemplo n.º 53
0
def test_delete(stack, provider, request):
    stack.delete()
    navigate_to(stack, 'All')
    assert not sel.is_displayed(Quadicon(stack.name, stack.quad_name))
    request.addfinalizer(provider.refresh_provider_relationships)
Ejemplo n.º 54
0
def test_run_datastore_analysis(request, setup_provider, provider,
                                datastore_type, datastore_name, soft_assert):
    """Tests smarthost analysis

    Metadata:
        test_flag: datastore_analysis
    """
    test_datastore = datastore.Datastore(datastore_name, provider.key)

    # Check if there is a host with valid credentials
    host_names = test_datastore.get_hosts()
    assert len(host_names) != 0, "No hosts attached to this datastore found"
    for host_name in host_names:
        host_qi = Quadicon(host_name, 'host')
        if host_qi.creds == 'checkmark':
            break
    else:
        # If not, get credentials for one of the present hosts
        found_host = False
        for host_name in host_names:
            host_data = get_host_data_by_name(provider.key, host_name)
            if host_data is None:
                continue

            found_host = True
            test_host = host.Host(name=host_name)

            # Add them to the host
            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)

                # And remove them again when the test is finished
                def test_host_remove_creds():
                    test_host.update(
                        updates={
                            'credentials':
                            host.Host.Credential(
                                principal="", secret="", verify_secret="")
                        })

                request.addfinalizer(test_host_remove_creds)
            break

        assert found_host,\
            "No credentials found for any of the hosts attached to datastore {}"\
            .format(datastore_name)

    # TODO add support for events
    # register_event(
    #     None,
    #     "datastore",
    #     datastore_name,
    #     ["datastore_analysis_request_req", "datastore_analysis_complete_req"]
    # )

    # Initiate analysis
    sel.force_navigate('infrastructure_datastore',
                       context={
                           'datastore': test_datastore,
                           'provider': test_datastore.provider
                       })
    tb.select('Configuration',
              'Perform SmartState Analysis',
              invokes_alert=True)
    sel.handle_alert()
    flash.assert_message_contain(
        '"{}": scan successfully initiated'.format(datastore_name))

    # Wait for the task to finish
    def is_datastore_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(datastore_name),
            'state':
            'Finished'
        })
        return host_analysis_finished is not None

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

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

    c_datastore = test_datastore.get_detail('Properties', 'Datastore Type')
    # Check results of the analysis and the datastore type
    soft_assert(
        c_datastore == datastore_type.upper(),
        'Datastore type does not match the type defined in yaml:' +
        'expected "{}" but was "{}"'.format(datastore_type.upper(),
                                            c_datastore))
    for row_name in CONTENT_ROWS_TO_CHECK:
        value = InfoBlock('Content', row_name).text
        soft_assert(value != '0',
                    'Expected value for {} to be non-empty'.format(row_name))
Ejemplo n.º 55
0
 def exists(self):
     """Returns whether the manager exists in the UI or not"""
     navigate_to(self, 'All')
     if (Quadicon.any_present() and Quadicon(self.quad_name, None).exists):
         return True
     return False
Ejemplo n.º 56
0
def get_all_hosts(do_not_navigate=False):
    """Returns list of all hosts"""
    if not do_not_navigate:
        navigate_to(Host, 'All')
    return [q.name for q in Quadicon.all("host")]
Ejemplo n.º 57
0
def test_credentials_quads(provider):
    navigate_to(provider, 'All')
    quad = Quadicon(provider.name, qtype='infra_prov')
    checked = str(quad.creds).split('-')[0]
    assert checked == 'checkmark'
Ejemplo n.º 58
0
    '5.5':
    Table('//div[@id="list_grid"]/table'),
    '5.4':
    SplitTable(
        ('//*[@id="list_grid"]//table[contains(@class, "hdr")]/tbody', 1),
        ('//*[@id="list_grid"]//table[contains(@class, "obj")]/tbody', 1))
})

edit_tags_form = Form(fields=[(
    "select_tag",
    ui.Select("select#tag_cat")), ("select_value",
                                   ui.Select("select#tag_add"))])

nav.add_branch('clouds_stacks', {
    'clouds_stack':
    lambda ctx: sel.click(Quadicon(ctx['stack'].name, 'stack'))
})


class Stack(Pretty):
    pretty_attrs = ['name']

    def __init__(self, name=None):
        self.name = name

    def delete(self):
        sel.force_navigate('clouds_stack', context={'stack': self})
        cfg_btn("Remove this Stack from the VMDB", invokes_alert=True)
        sel.handle_alert()
        flash.assert_success_message(
            'The selected Orchestration Stack was deleted')
Ejemplo n.º 59
0
def test_delete_provider(provider):
    provider.delete(cancel=False)
    navigate_to(provider, 'All')
    assert provider.name not in [q.name for q in Quadicon.all()]
Ejemplo n.º 60
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))