def delete(self, from_dest='All'): """ Delete the catalog, starting from the destination provided by from_dest Throws cfme.DestinationNotFound exception :param from_dest: A valid navigation destination to start the delete from :return: none """ if from_dest in navigator.list_destinations(self): navigate_to(self, from_dest) else: msg = 'cfme.services.catalogs.catalog does not have destination {}'.format(from_dest) raise DestinationNotFound(msg) # Delete using the appropriate method if from_dest == 'All': # Select the row to delete, assuming default List View for All listview_table.select_row_by_cells({'Name': self.name, 'Description': self.description}) cfg_btn(version.pick({version.LOWEST: 'Remove Items from the VMDB', '5.7': 'Remove Catalog Items'}), invokes_alert=True) elif from_dest == 'Details': cfg_btn(version.pick({version.LOWEST: 'Remove Item from the VMDB', '5.7': 'Remove Catalog'}), invokes_alert=True) sel.handle_alert() flash.assert_success_message( 'Catalog "{}": Delete successful'.format(self.description or self.name))
def validate(self): """ Validates that the detail page matches the Providers information. This method logs into the provider using the mgmt_system interface and collects a set of statistics to be matched against the UI. The details page is then refreshed continuously until the matching of all items is complete. A error will be raised if the match is not complete within a certain defined time period. """ if not self._on_detail_page(): sel.force_navigate('cloud_provider', context={'provider': self}) stats_to_match = ['num_template', 'num_vm'] client = self.get_mgmt_system() # Bail out here if the stats match. if self._do_stats_match(client, stats_to_match): client.disconnect() return # Otherwise refresh relationships and hand off to wait_for tb.select("Configuration", "Refresh Relationships and Power States", invokes_alert=True) sel.handle_alert() ec, tc = wait_for(self._do_stats_match, [client, stats_to_match], message="do_stats_match", fail_func=sel.refresh, num_sec=1000, delay=10) client.disconnect()
def is_task_finished(tab, page, task_name, expected_status, clear_tasks_after_success=True): el = None try: if not sel.is_displayed(tasks_table) or not tabs.is_tab_selected(tab): sel.force_navigate(page) el = tasks_table.find_row_by_cells({ 'task_name': task_name, 'state': expected_status }) if el is None: return False except Exception: return False # throw exception if status is error if 'Error' in sel.get_attribute(sel.element('.//td/img', root=el), 'title'): raise Exception("Task {} errored".format(task_name)) if clear_tasks_after_success: # Remove all finished tasks so they wouldn't poison other tests toolbar.select('Delete Tasks', 'Delete All', invokes_alert=True) sel.handle_alert(cancel=False) return True
def delete(self): sel.force_navigate("my_settings_time_profiles") row = timeprofile_table.find_row_by_cells({"description": self.description}) sel.check(sel.element(".//input[@type='checkbox']", root=row[0])) cfg_btn("Delete selected Time Profiles", invokes_alert=True) sel.handle_alert() flash.assert_success_message('Time Profile "{}": Delete successful'.format(self.description))
def delete(self): sel.force_navigate("cfg_accesscontrol_group_ed", context={"group": self}) tb_select('Delete this Group', invokes_alert=True) sel.handle_alert() flash.assert_success_message( 'EVM Group "{}": Delete successful'.format(self.description))
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()
def delete_all(self, cancel=False): self._nav_to_snapshot_mgmt() toolbar.select('Delete Snapshots', 'Delete All Existing Snapshots', invokes_alert=True) sel.handle_alert(cancel=cancel) if not cancel: flash.assert_message_match('Remove All Snapshots initiated for 1 VM and ' 'Instance from the CFME Database')
def delete(self, cancel=False, wait_deleted=True, force=False): """Deletes the manager through UI Args: cancel (bool): Whether to cancel out of the deletion, when the alert pops up. wait_deleted (bool): Whether we want to wait for the manager to disappear from the UI. True will wait; False will only delete it and move on. force (bool): Whether to try to delete the manager even though it doesn't exist. True will try to delete it anyway; False will check for its existence and leave, if not present. """ if not force and not self.exists: return navigate_to(self, 'All') sel.check(Quadicon(self.quad_name, None).checkbox()) item_text = version.pick({'5.6': 'Remove selected items from the VMDB', '5.7': 'Remove selected items'}) cfg_btn(item_text, invokes_alert=True) sel.handle_alert(cancel) if not cancel: flash_msg = version.pick({'5.6': 'Delete initiated for 1 provider', '5.7': 'Delete initiated for 1 Provider'}) flash.assert_message_match(flash_msg) if wait_deleted: wait_for(func=lambda: self.exists, fail_condition=True, delay=15, num_sec=60)
def delete(self): navigate_to(self, 'Saved') self.saved_table.select_row(header='Run At', value=self.datetime) cfg_btn("Delete this Saved Report from the Database", invokes_alert=True) sel.handle_alert() flash.assert_no_errors()
def delete(self, cancel=False): navigate_to(self, 'Details') toolbar.select("Configuration", "Delete this Report from the Database", invokes_alert=True) sel.handle_alert(cancel) flash.assert_no_errors()
def revert_to(self, cancel=False): self._nav_to_snapshot_mgmt() self.snapshot_tree.click_path(*self.snapshot_tree.find_path_to(re.compile(self.name))) toolbar.select('Revert to selected snapshot', invokes_alert=True) sel.handle_alert(cancel=cancel) flash.assert_message_match('Revert To Snapshot initiated for 1 VM and Instance from ' 'the CFME Database')
def delete(self, from_dest='All'): """ Delete the stack, starting from the destination provided by from_dest @param from_dest: where to delete from, a valid navigation destination for Stack """ # Navigate to the starting destination if from_dest in navigator.list_destinations(self): navigate_to(self, from_dest) else: msg = 'cfme.cloud.stack does not have destination {}'.format(from_dest) raise DestinationNotFound(msg) # Delete using the method appropriate for the starting destination if from_dest == 'All': sel.check(Quadicon(self.name, self.quad_name).checkbox()) cfg_btn("Remove Orchestration Stacks", invokes_alert=True) elif from_dest == 'Details': cfg_btn("Remove this Orchestration Stack", invokes_alert=True) sel.handle_alert() # The delete initiated message may get missed if the delete is fast try: flash.assert_message_contain("Delete initiated for 1 Orchestration Stacks") except FlashMessageException as ex: if 'No flash message contains' in ex.message: flash.assert_message_contain("The selected Orchestration Stacks was deleted") self.wait_for_delete()
def is_vm_analysis_finished(vm_name): """ Check if analysis is finished - if not, reload page """ el = None try: if not pytest.sel.is_displayed(tasks.tasks_table) or \ not tabs.is_tab_selected('All VM Analysis Tasks'): pytest.sel.force_navigate('tasks_all_vm') el = tasks.tasks_table.find_row_by_cells({ 'task_name': "Scan from Vm {}".format(vm_name), 'state': 'finished' }) if el is None: return False except: return False # throw exception if status is error if 'Error' in sel.get_attribute(sel.element('.//td/img', root=el), 'title'): raise Exception("Smart State Analysis errored") # Remove all finished tasks so they wouldn't poison other tests tb.select('Delete Tasks', 'Delete All', invokes_alert=True) sel.handle_alert(cancel=False) return True
def delete_all_attached_hosts(self): self.load_details() sel.click(details_page.infoblock.element("Relationships", "Hosts")) for q in Quadicon.all('host'): fill(q.checkbox(), True) cfg_btn("Remove items", invokes_alert=True) sel.handle_alert(cancel=False)
def terminate(self, cancel=False): sel.force_navigate('clouds_instance', context={'instance': self}) toolbar.select("Power", "Terminate", invokes_alert=True) sel.handle_alert(cancel) if not cancel: wait_for(self.provider_mgmt.is_vm_state, [self.name, self.provider_mgmt.states['deleted']])
def delete(self, cancel=False): sel.force_navigate("reports_dashboard", context={"dashboard": self}) toolbar.select("Configuration", "Delete this Dashboard from the Database", invokes_alert=True) sel.handle_alert(cancel) flash.assert_no_errors()
def power_control_from_cfme(self, *args, **kwargs): """Power controls a VM from within CFME using instance details screen Raises: OptionNotAvailable: option param is not visible or enabled """ # TODO push this to common.vm when infra and cloud have navmazing destinations if kwargs.get('from_details', True): navigate_to(self, 'Details') else: navigate_to(self, 'AllForProvider') self.find_quadicon(mark=True) if not kwargs.get('option'): raise ValueError( 'Need to provide option for power_control_from_cfme, no default.' ) try: if not pwr_btn(kwargs.get('option'), invokes_alert=True): raise ToolbarOptionGreyedOrUnavailable( 'Failed to click power button') except NoSuchElementException: raise OptionNotAvailable( kwargs.get('option') + " is not visible or enabled") sel.handle_alert(cancel=kwargs.get('cancel', False))
def validate(self): """ Validates that the detail page matches the Providers information. This method logs into the provider using the mgmt_system interface and collects a set of statistics to be matched against the UI. The details page is then refreshed continuously until the matching of all items is complete. A error will be raised if the match is not complete within a certain defined time period. """ if not self._on_detail_page(): sel.force_navigate('infrastructure_provider', context={'provider': self}) stats_to_match = ['num_template', 'num_vm', 'num_datastore', 'num_host', 'num_cluster'] client = self.get_mgmt_system() # Bail out here if the stats match. if self._do_stats_match(client, stats_to_match): client.disconnect() return refresh_timer = RefreshTimer() # Otherwise refresh relationships and hand off to wait_for tb.select("Configuration", "Refresh Relationships and Power States", invokes_alert=True) sel.handle_alert() ec, tc = wait_for(self._do_stats_match, [client, stats_to_match, refresh_timer], message="do_stats_match", fail_func=sel.refresh, num_sec=1000, delay=10) client.disconnect()
def power(self, on=True, cancel=False): sel.force_navigate('clouds_instance', context={'instance': self}) toolbar.select("Power", "Start" if on else "Stop", invokes_alert=True) sel.handle_alert(cancel) if not cancel: wait_for(self.provider_mgmt.is_vm_state, [self.name, self.provider_mgmt.states['running' if on else 'stopped']])
def check_compliance(self): """Clicks the Check compliance button.""" self.load_details(refresh=True) pol_btn("Check Compliance of Last Known Configuration", invokes_alert=True) sel.handle_alert() flash.assert_no_errors()
def delete(self): sel.force_navigate('button', context={'buttongroup': self.btngrp, 'button': self.btn_text}) cfg_btn("Remove this Button", invokes_alert=True) sel.handle_alert() flash.assert_success_message('Button "%s": Delete successful' % self.btn_hvr_text)
def delete(self): sel.force_navigate('button_group', context={'buttongroup': self.group_text}) cfg_btn("Remove this Button Group", invokes_alert=True) sel.handle_alert() flash.assert_success_message('Buttons Group "%s": Delete successful' % self.group_hover_text)
def delete(self, cancel=False): self.go_to_detail() toolbar.select("Configuration", "Delete this Widget from the Database", invokes_alert=True) sel.handle_alert(cancel) flash.assert_no_errors()
def delete(self, from_dest='All'): """ Delete the stack, starting from the destination provided by from_dest @param from_dest: where to delete from, a valid navigation destination for Stack """ # Navigate to the starting destination if from_dest in navigator.list_destinations(self): navigate_to(self, from_dest) else: msg = 'cfme.cloud.stack does not have destination {}'.format( from_dest) raise DestinationNotFound(msg) # Delete using the method appropriate for the starting destination if from_dest == 'All': sel.check(Quadicon(self.name, self.quad_name).checkbox()) cfg_btn("Remove Orchestration Stacks", invokes_alert=True) elif from_dest == 'Details': cfg_btn("Remove this Orchestration Stack", invokes_alert=True) sel.handle_alert() # The delete initiated message may get missed if the delete is fast try: flash.assert_message_contain( "Delete initiated for 1 Orchestration Stacks") except FlashMessageException as ex: if 'No flash message contains' in ex.message: flash.assert_message_contain( "The selected Orchestration Stacks was deleted") self.wait_for_delete()
def delete(self, cancel=False, wait_deleted=True, force=False): """Deletes the manager through UI Args: cancel (bool): Whether to cancel out of the deletion, when the alert pops up. wait_deleted (bool): Whether we want to wait for the manager to disappear from the UI. True will wait; False will only delete it and move on. force (bool): Whether to try to delete the manager even though it doesn't exist. True will try to delete it anyway; False will check for its existence and leave, if not present. """ if not force and not self.exists: return navigate_to(self, 'All') sel.check(Quadicon(self.quad_name, None).checkbox()) item_text = version.pick({ '5.6': 'Remove selected items from the VMDB', '5.7': 'Remove selected items' }) cfg_btn(item_text, invokes_alert=True) sel.handle_alert(cancel) if not cancel: flash_msg = version.pick({ '5.6': 'Delete initiated for 1 provider', '5.7': 'Delete initiated for 1 Provider' }) flash.assert_message_match(flash_msg) if wait_deleted: wait_for(func=lambda: self.exists, fail_condition=True, delay=15, num_sec=60)
def edit_schema(self, add_fields=None, remove_fields=None): sel.force_navigate("automate_explorer_schema_edit", context={'tree_item': self}) for remove_field in remove_fields or []: f = remove_field.get_form() fill(f, {}, action=f.remove_entry_button, action_always=True) sel.handle_alert() for add_field in add_fields or []: sel.click(self.schema_edit_page.add_field_btn) f = add_field.get_form(blank=True) fill(f, {'name_text': add_field.name, 'type_select': add_field.type_, 'data_type_select': add_field.data_type, 'default_value_text': add_field.default_value, 'description_text': add_field.description, 'sub_cb': add_field.sub, 'collect_text': add_field.collect, 'message_text': add_field.message, 'on_entry_text': add_field.on_entry, 'on_exit_text': add_field.on_exit, 'max_retries_text': add_field.max_retries, 'max_time_text': add_field.max_time}, action=f.add_entry_button) sel.click(form_buttons.save) flash.assert_success_message('Schema for Automate Class "%s" was saved' % self.name)
def configure_db_replication(db_address): """Enables the sync role and configures the appliance to replicate to the db_address specified. Then, it waits for the UI to show the replication as active and the backlog as empty. """ conf.set_replication_worker_host(db_address) flash.assert_message_contain( "Configuration settings saved for CFME Server") try: sel.force_navigate("cfg_settings_currentserver_server") except WebDriverException: sel.handle_alert() sel.force_navigate("cfg_settings_currentserver_server") conf.set_server_roles(database_synchronization=True) sel.force_navigate("cfg_diagnostics_region_replication") wait_for(lambda: conf.get_replication_status(navigate=False), fail_condition=False, num_sec=360, delay=10, fail_func=sel.refresh, message="get_replication_status") assert conf.get_replication_status() wait_for(lambda: conf.get_replication_backlog(navigate=False) == 0, fail_condition=False, num_sec=120, delay=10, fail_func=sel.refresh, message="get_replication_backlog")
def edit_schema(self, add_fields=None, remove_fields=None): sel.force_navigate("automate_explorer_schema_edit", context={'tree_item': self}) for remove_field in remove_fields or []: f = remove_field.get_form() fill(f, {}, action=f.remove_entry_button) sel.handle_alert() for add_field in add_fields or []: sel.click(self.schema_edit_page.add_field_btn) f = add_field.get_form(blank=True) fill(f, { 'name_text': add_field.name, 'type_select': add_field.type_, 'data_type_select': add_field.data_type, 'default_value_text': add_field.default_value, 'description_text': add_field.description, 'sub_cb': add_field.sub, 'collect_text': add_field.collect, 'message_text': add_field.message, 'on_entry_text': add_field.on_entry, 'on_exit_text': add_field.on_exit, 'max_retries_text': add_field.max_retries, 'max_time_text': add_field.max_time }, action=f.add_entry_button) sel.click(self.schema_edit_page.save_btn) flash.assert_success_message( 'Schema for Automate Class "%s" was saved' % self.name)
def validate(self, db=True): """ Validates that the detail page matches the Providers information. This method logs into the provider using the mgmt_system interface and collects a set of statistics to be matched against the UI. The details page is then refreshed continuously until the matching of all items is complete. A error will be raised if the match is not complete within a certain defined time period. """ client = self.get_mgmt_system() # If we're not using db, make sure we are on the provider detail page if not db: sel.force_navigate('clouds_provider', context={'provider': self}) # Initial bullet check if self._do_stats_match(client, self.STATS_TO_MATCH, db=db): client.disconnect() return else: # Set off a Refresh Relationships sel.force_navigate('clouds_provider', context={'provider': self}) tb.select("Configuration", "Refresh Relationships and Power States", invokes_alert=True) sel.handle_alert() refresh_timer = RefreshTimer(time_for_refresh=300) wait_for(self._do_stats_match, [client, self.STATS_TO_MATCH, refresh_timer], {'db': db}, message="do_stats_match_db", num_sec=1000, delay=60) client.disconnect()
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)
def retire(self): self.load_details(refresh=True) lcl_btn(self.TO_RETIRE, invokes_alert=True) sel.handle_alert() flash.assert_success_message({ version.LOWEST: "Retire initiated for 1 VM and Instance from the CFME Database", "5.5": "Retirement initiated for 1 VM and Instance from the CFME Database"})
def delete(self, cancel=False): sel.force_navigate("automate_explorer_tree_path", context={"tree_item": self}) cfg_btn("Remove this Domain", invokes_alert=True) sel.handle_alert(cancel) flash.assert_message_match( 'Automate Domain "{}": Delete successful'.format(self.description or self.name))
def delete(self): navigate_to(self, 'Details') menu_item = version.pick({ version.LOWEST: 'Remove from the VMDB', '5.7': 'Remove item' }) cfg_btn(menu_item, invokes_alert=True) sel.handle_alert(wait=60)
def delete(self, cancel=False): sel.force_navigate("automate_explorer_delete", context={ 'tree_item': self.parent, 'table_item': self }) sel.handle_alert(cancel) return flash.assert_no_errors()
def delete_all_attached_vms(self): sel.force_navigate('infrastructure_datastore', context=self._get_context()) sel.click( details_page.infoblock.element("Relationships", "Managed VMs")) sel.click(pg.check_all()) cfg_btn("Remove selected items from the VMDB", invokes_alert=True) sel.handle_alert(cancel=False)
def remove(self): """ Clicks on "Remove" button of "Operations" menu item and verifies message shown """ self.load_details() operations_btn("Remove", invokes_alert=True) sel.handle_alert() flash.assert_success_message('The selected datasources were removed')
def retire(self): self.load_details(refresh=True) lcl_btn(self.TO_RETIRE, invokes_alert=True) sel.handle_alert() flash.assert_success_message( 'Retirement initiated for 1 VM and Instance from the {} Database'.format(version.pick({ version.LOWEST: 'CFME', 'upstream': 'ManageIQ'})))
def reset_widgets(cancel=False): """Resets the widgets on the dashboard page. Args: cancel: Set whether to accept the popup confirmation box. Defaults to ``False``. """ sel.click(page.reset_widgets_button, wait_ajax=False) sel.handle_alert(cancel)
def run_smartstate_analysis(self): navigate_to(self, 'Details') tb.select('Configuration', 'Perform SmartState Analysis', invokes_alert=True) sel.handle_alert(cancel=False) flash.assert_message_contain( 'Cluster / Deployment Role: scan successfully initiated')
def delete(self): sel.force_navigate('select_template', context={'template_type': self.template_type, 'template_name': self.template_name}) cfg_btn("Remove this Orchestration Template", invokes_alert=True) sel.handle_alert() flash.assert_success_message('Orchestration Template "{}" was deleted.'.format( self.template_name))
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)