Esempio n. 1
0
def select_provision_image(template_name, provider):
    """
    Navigate to provision and select the template+click continue, leaving UI on provision form

    :param template_name: The image/template name to select
    :param provider: Provider where the image/template resides
    :return: none
    """
    logger.debug(
        'Selecting an image {} from provider {} for provisioning'.format(
            template_name, provider.name))
    navigate_to(Instance, 'Provision')
    template = image_select_form.template_table.find_row_by_cells({
        'Name':
        template_name,
        'Provider':
        provider.name
    })
    if template:
        sel.click(template)
        # In order to mitigate the sometimes very long spinner timeout, raise the timeout
        with sel.ajax_timeout(90):
            sel.click(form_buttons.FormButton("Continue", force_click=True))

    else:
        raise TemplateNotFound(
            'Unable to find template "{}" for provider "{}"'.format(
                template_name, provider.key))
Esempio n. 2
0
    def f(context):
        # Here it also can have long spinners
        with sel.ajax_timeout(90):
            toolbar.select('Lifecycle', tb_item)
        provider = context['provider']
        template_name = context['template_name']
        template_select_form.template_table._update_cache()
        template = template_select_form.template_table.find_row_by_cells({
            'Name':
            template_name,
            'Provider':
            provider if isinstance(provider, basestring) else provider.name
        })
        if template:
            sel.click(template)
            # In order to mitigate the sometimes very long spinner timeout, raise the timeout
            with sel.ajax_timeout(90):
                if current_version() < "5.4":
                    sel.click(submit_button)
                else:
                    sel.click(
                        form_buttons.FormButton("Continue", force_click=True))

        else:
            raise TemplateNotFound(
                'Unable to find template "{}" for provider "{}"'.format(
                    template_name, provider.key))
Esempio n. 3
0
 def _select_template(self, template_name, provider_name):
     try:
         row = self.parent.image_table.row(name=template_name, provider=provider_name)
         row.click()
     except IndexError:
         raise TemplateNotFound('Cannot find template "{}" for provider "{}"'
                                .format(template_name, provider_name))
Esempio n. 4
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))
Esempio n. 5
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:
                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:
                        sel.force_navigate(self.provider.instances_page_name)
                    else:
                        sel.force_navigate(self.provider.templates_page_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))
Esempio n. 6
0
 def _select_template(self, template_name, provider_name):
     try:
         self.parent.paginator.find_row_on_pages(
             self.parent.image_table,
             name=template_name,
             provider=provider_name).click()
     # image was not found, therefore raise an exception
     except IndexError:
         raise TemplateNotFound(
             'Cannot find template "{}" for provider "{}"'.format(
                 template_name, provider_name))
Esempio n. 7
0
 def before_fill(self, values):
     # Provision from image is a two part form,
     # this completes the image selection before the tabular parent form is filled
     template_name = values.get('template_name',
                                self.parent_view.context['object'].template_name)
     provider_name = self.parent_view.context['object'].provider.name
     try:
         row = self.image_table.row(name=template_name,
                                    provider=provider_name)
     except IndexError:
         raise TemplateNotFound('Cannot find template "{}" for provider "{}"'
                                .format(template_name, provider_name))
     row.click()
     self.continue_button.click()
     # TODO timing, wait_displayed is timing out and can't get it to stop in is_displayed
     sleep(3)
     self.flush_widget_cache()
Esempio n. 8
0
    def step(self, *args, **kwargs):
        lcl_btn("Provision VMs")

        # choosing template and going further
        template_select_form.template_table._update_cache()
        template = template_select_form.template_table.find_row_by_cells({
            'Name': self.obj.template_name,
            'Provider': self.obj.provider.name
        })
        if template:
            sel.click(template)
            # In order to mitigate the sometimes very long spinner timeout, raise the timeout
            with sel.ajax_timeout(90):
                sel.click(form_buttons.FormButton("Continue", force_click=True))

        else:
            raise TemplateNotFound('Unable to find template "{}" for provider "{}"'.format(
                self.obj.template_name, self.obj.provider.key))
Esempio n. 9
0
 def before_fill(self, values):
     # Provision from image is a two part form,
     # this completes the image selection before the tabular parent form is filled
     template_name = values.get('template_name')
     provider_name = values.get('provider_name')
     if template_name is None or provider_name is None:
         logger.error('template_name "{}", or provider_name "{}" not passed to '
                      'provisioning form', template_name, provider_name)
     # try to find the template anyway, even if values weren't passed
     try:
         row = self.parent.image_table.row(name=template_name, provider=provider_name)
     except IndexError:
         raise TemplateNotFound('Cannot find template "{}" for provider "{}"'
                                .format(template_name, provider_name))
     row.click()
     self.continue_button.click()
     # TODO timing, wait_displayed is timing out and can't get it to stop in is_displayed
     sleep(3)
     self.flush_widget_cache()
Esempio n. 10
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 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:
                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')
        elif 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)
        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))