def step(self): try: row = self.prerequisite_view.entities.get_entity(name=self.obj.name, surf_pages=True, use_search=True) except ItemNotFound: raise InstanceNotFound('Failed to locate instance with name "{}"'.format(self.obj.name)) row.click()
def power_control_from_cfme(self, *args, **kwargs): """Power controls a VM from within CFME using details or collection Raises: InstanceNotFound: the instance wasn't found when navigating OptionNotAvailable: option param is not visible or enabled """ # TODO push this to common.vm when infra vm classes have widgets if not kwargs.get('option'): raise ValueError( 'Need to provide option for power_control_from_cfme, no default.' ) if kwargs.get('from_details', True): view = navigate_to(self, 'Details') else: view = navigate_to(self, 'AllForProvider') view.toolbar.view_selector.select('List View') try: row = view.entities.get_entity(by_name=self.name) except ItemNotFound: raise InstanceNotFound( 'Failed to find instance in table: {}'.format(self.name)) row.check() # cancel is the kwarg, when true we want item_select to dismiss the alert, flip the bool view.toolbar.power.item_select( kwargs.get('option'), handle_alert=not kwargs.get('cancel', False))
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))
def step(self): # Use list view to match name and provider self.prerequisite_view.toolbar.view_selector.select('List View') # Instance may be in a state where the provider is not displayed in the table # Try first to match name and provider, fall back to just name # Matching only on name has the potential to select the wrong instance try: row = self.prerequisite_view.paginator.find_row_on_pages( self.prerequisite_view.entities.table, name=self.obj.name, provider=self.obj.provider.name) self.log_message('Matched table row on instance name and provider') except NoSuchElementException: logger.warning( 'Could not match instance row using name "{}" and provider "{}"' .format(self.obj.name, self.obj.provider.name)) row = None if not row: logger.warning( 'Attempting to match instance using name only: "{}"'.format( self.obj.name)) try: row = self.prerequisite_view.paginator.find_row_on_pages( self.prerequisite_view.entities.table, name=self.obj.name) self.log_message('Matched table row on instance name only') except NoSuchElementException: raise InstanceNotFound( 'Could not match instance by name only: {}'.format( self.obj.name)) if row: row.click()
def step(self): self.prerequisite_view.toolbar.view_selector.select('List View') try: row = self.prerequisite_view.entities.get_entity( by_name=self.obj.name, surf_pages=True) except ItemNotFound: raise InstanceNotFound( 'Failed to locate instance with name "{}"'.format( self.obj.name)) row.click()
def find_quadicon(instance_name, do_not_navigate=False): """Find and return a quadicon belonging to a specific instance Args: instance_name: instance name as displayed at the quadicon Returns: :py:class:`cfme.web_ui.Quadicon` instance """ if not do_not_navigate: sel.force_navigate('clouds_instances') if not paginator.page_controls_exist(): raise InstanceNotFound("Instance '{}' not found in UI!".format(instance_name)) paginator.results_per_page(1000) for page in paginator.pages(): quadicon = Quadicon(instance_name, "instance") if sel.is_displayed(quadicon): return quadicon else: raise InstanceNotFound("Instance '{}' not found in UI!".format(instance_name))
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: entity of appropriate type """ view = navigate_to(self, 'All') view.toolbar.view_selector.select('Grid View') try: return view.entities.get_entity(name=self.name, surf_pages=True) except ItemNotFound: raise InstanceNotFound("Instance '{}' not found in UI!".format(self.name))
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))
def find_quadicon(self, *args, **kwargs): """Find and return a quadicon belonging to a specific instance Args: Returns: :py:class:`cfme.web_ui.Quadicon` instance """ if not kwargs.get('do_not_navigate', False): navigate_to(self, 'All') tb.select('Grid View') for page in 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))
def find_quadicon(self, **kwargs): """Find and return a quadicon belonging to a specific instance Args: Returns: :py:class:`cfme.web_ui.Quadicon` instance """ # TODO refactor a bit when quadicon is widget 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') for _ in view.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))