def install_errata(self, entity_name, errata_id, install_via=None): """Install errata on a content host :param name: content host name to apply errata on :param errata_id: errata id or title, e.g. 'RHEA-2012:0055' :param str install_via: via which mean to install errata. Available options: "katello", "rex", "rex_customize" :return: Returns a dict containing task status details """ view = self.navigate_to(self, 'Edit', entity_name=entity_name) view.errata.search(errata_id) view.errata.table.row(id=errata_id)[0].widget.fill(True) install_via_dict = { 'katello': 'via Katello agent', 'rex': 'via remote execution', 'rex_customize': 'via remote execution - customize first', } if install_via is not None: view.errata.apply_selected.fill(install_via_dict[install_via]) else: view.errata.apply_selected.fill('Apply Selected') view.dialog.confirm() view = JobInvocationStatusView(view.browser) view.wait_for_result() return view.read()
def execute_module_stream_action(self, entity_name, action_type, module_name, stream_version, customize=False, customize_values=None): """Execute remote module_stream action on a content :param entity_name: content host name :param action_type: remote action to execute on content host. Action value can be one of them e.g. 'Enable', 'Disable', 'Install', 'Update', 'Remove', 'Reset' :param module_name: Module Stream name to remotely install/upgrade/remove (depending on `action_type`) :param stream_version: String with Stream Version of Module :param customize: Boolean indicating if additional custom action should be called :param customize_values: Dict with custom actions to run. Mandatory if customize is True :return: Returns a dict containing job status details """ if customize_values is None: customize_values = {} view = self.navigate_to(self, 'Edit', entity_name=entity_name) view.module_streams.search('name = {} and stream = {}'.format(module_name, stream_version)) action_type = dict(is_customize=customize, action=action_type) view.module_streams.table.row( name=module_name, stream=stream_version)['Actions'].fill(action_type) if customize: view = JobInvocationCreateView(view.browser) view.fill(customize_values) view.submit.click() view = JobInvocationStatusView(view.browser) view.wait_for_result() return view.read()
def execute_package_action(self, entity_name, action_type, value, installed_via='rex'): """Execute remote package action on a content host. The installation method is not set here, but the path changes according to the method used. For katello-agent, the Content Hosts' Task tab displays the progress. If REX is used, the Job Invocation view displays the progress. In 6.10, REX became the default method. :param entity_name: content host name to remotely execute package action on :param action_type: remote action to execute. Can be one of 5: 'Package Install', 'Package Update', 'Package Remove', 'Group Install' or 'Group Remove' :param value: Package or package group group name to remotely install/upgrade/remove (depending on `action_type`) :param installed_via: what installation method was used (REX or katello-agent) :return: Returns a dict containing task status details """ view = self.navigate_to(self, 'Edit', entity_name=entity_name) view.packages_actions.action_type.fill(action_type) view.packages_actions.name.fill(value) view.packages_actions.perform.click() if installed_via == 'katello': view = ContentHostTaskDetailsView(view.browser) view.progressbar.wait_for_result() else: view = JobInvocationStatusView(view.browser) view.wait_for_result() return view.read()
def manage_packages( self, entity_name, content_type='Package', packages=None, action='install', action_via='via Katello Agent', job_values=None, ): """Manage host collection packages. :param str entity_name: The host collection name. :param str content_type: The content type to apply action on. Available options: Package, Package Group. :param str packages: a list of packages separated by a space to apply the action on. :param str action: The action to apply. Available options: install, update, update_all, delete. :param str action_via: Via which mean to apply action. Available options: "via Katello Agent", "via remote execution", "via remote execution - customize first" :param dict job_values: Remote Execution Job custom form values. When action_via is: "via remote execution - customize first", the new remote execution job form is opened and we can set custom values. """ if job_values is None: job_values = {} view = self.navigate_to(self, 'Edit', entity_name=entity_name) view.details.manage_packages.click() view = HostCollectionManagePackagesView(view.browser) if content_type is not None: view.content_type.fill(content_type) if packages is not None: view.packages.fill(packages) view.apply_action(action, action_via=action_via) view.flash.assert_no_error() view.flash.dismiss() if action_via == 'via Katello Agent': view.done.click() if action_via == 'via remote execution - customize first': # After this step the user is redirected to remote execution job # create view. job_create_view = HostCollectionActionRemoteExecutionJobCreate(view.browser) job_create_view.fill(job_values) job_create_view.submit.click() if action_via in ('via remote execution', 'via remote execution - customize first'): # After this step the user is redirected to job status view. job_status_view = JobInvocationStatusView(view.browser) wait_for( lambda: ( job_status_view.overview.job_status.read() != 'Pending' and job_status_view.overview.job_status_progress.read() == '100%' ), timeout=300, delay=10, logger=view.logger, ) return job_status_view.overview.read()
def run_playbook(self, entity_name, customize=False, customize_values=None): """Run Ansible playbook associated with given plan :param str entity_name: Name of plan :param bool customize: Whether remote job should be customized first :param dict customize_values: Values to fill on customize remote job screen """ action_name = 'Run Playbook' if customize: action_name = 'Customize Playbook Run' view = self.navigate_to(self, "Details", entity_name=entity_name).plan(entity_name) view.ansible_actions.fill(action_name) if customize: view = JobInvocationCreateView(self.browser) view.fill(customize_values) view.submit.click() view = JobInvocationStatusView(self.browser) view.wait_for_result() return view.read()
def install_errata(self, entity_name, errata_id, install_via='via Katello agent', job_values=None): """Install host collection errata :param str entity_name: The host collection name. :param str errata_id: the errata id to install. :param str install_via: Via which mean to install errata. Available options: "via Katello Agent", "via remote execution", "via remote execution - customize first" :param dict job_values: Remote Execution Job custom form values. When install_via is: "via remote execution - customize first", the new remote execution job form is opened and we can set custom values. :return: Task details view values when install "via kattelo agent" else returns job status view values. """ if job_values is None: job_values = {} view = self.navigate_to(self, 'Edit', entity_name=entity_name) view.details.install_errata.click() view = HostCollectionInstallErrataView(view.browser) view.search.fill(errata_id) view.table.row(Id=errata_id)[0].widget.fill(True) view.install.fill(install_via) if view.dialog.is_displayed: view.dialog.confirm() view.flash.assert_no_error() view.flash.dismiss() if install_via == 'via remote execution - customize first': # After this step the user is redirected to remote execution job # create view. job_create_view = HostCollectionActionRemoteExecutionJobCreate( view.browser) job_create_view.fill(job_values) job_create_view.submit.click() if install_via == 'via Katello agent': task_view = HostCollectionActionTaskDetailsView(view.browser) task_view.progressbar.wait_for_result() return task_view.read() else: # After this step the user is redirected to job status view. job_status_view = JobInvocationStatusView(view.browser) wait_for( lambda: (job_status_view.overview.job_status.read( ) != 'Pending' and job_status_view.overview.job_status_progress .read() == '100%'), timeout=300, delay=10, logger=view.logger, ) return job_status_view.overview.read()