How to use _disable_host_installation method in autotest

Best Python code snippet using autotest_python

monitor_db_cleanup.py

Source:monitor_db_cleanup.py Github

copy

Full Screen

...43 self._abort_jobs_past_max_runtime()44 self._clear_inactive_blocks()45 self._check_for_db_inconsistencies()46 self._reverify_dead_hosts()47 def _disable_host_installation(self, host):48 server_info = remote.get_install_server_info()49 if remote.install_server_is_configured():50 timeout = settings.get_value('INSTALL_SERVER',51 'default_install_timeout',52 type=int,53 default=3600)54 end_time = time.time() + (timeout / 10)55 step = int(timeout / 100)56 ServerInterface = remote.RemoteHost.INSTALL_SERVER_MAPPING[server_info['type']]57 server_interface = None58 while time.time() < end_time:59 try:60 server_interface = ServerInterface(**server_info)61 break62 except socket.error:63 logging.error('Install server unavailable. Trying '64 'again in %s s...', step)65 time.sleep(step)66 if server_interface is None:67 raise InstallServerUnavailable("%s install server at (%s) "68 "unavailable. Tried to "69 "communicate for %s s" %70 (server_info['type'],71 server_info['xmlrpc_url'],72 timeout / 10))73 server_interface._disable_host_installation(host)74 def _abort_timed_out_jobs(self):75 msg = 'Aborting all jobs that have timed out and are not complete'76 logging.info(msg)77 query = models.Job.objects.filter(hostqueueentry__complete=False).extra(78 where=['created_on + INTERVAL timeout HOUR < NOW()'])79 for job in query.distinct():80 logging.warning('Aborting job %d due to job timeout', job.id)81 rows = self._db.execute("""82 SELECT hqe.id83 FROM afe_host_queue_entries AS hqe84 INNER JOIN afe_jobs ON (hqe.job_id = %s)""" % job.id)85 query2 = models.HostQueueEntry.objects.filter(86 id__in=[row[0] for row in rows])87 for queue_entry in query2.distinct():88 # ensure we only disable installation on actually scheduled hosts89 if queue_entry.host is not None:90 logging.info('Disabling installation on %s' % queue_entry.host.hostname)91 self._disable_host_installation(queue_entry.host)92 job.abort()93 def _abort_jobs_past_max_runtime(self):94 """95 Abort executions that have started and are past the job's max runtime.96 """97 logging.info('Aborting all jobs that have passed maximum runtime')98 rows = self._db.execute("""99 SELECT hqe.id100 FROM afe_host_queue_entries AS hqe101 INNER JOIN afe_jobs ON (hqe.job_id = afe_jobs.id)102 WHERE NOT hqe.complete AND NOT hqe.aborted AND103 hqe.started_on + INTERVAL afe_jobs.max_runtime_hrs HOUR < NOW()""")104 query = models.HostQueueEntry.objects.filter(105 id__in=[row[0] for row in rows])106 for queue_entry in query.distinct():107 logging.warning('Aborting entry %s due to max runtime', queue_entry)108 logging.info('Disabling installation on %s' % queue_entry.host.hostname)109 self._disable_host_installation(queue_entry.host.hostname)110 queue_entry.abort()111 def _check_for_db_inconsistencies(self):112 logging.info('Cleaning db inconsistencies')113 self._check_all_invalid_related_objects()114 def _check_invalid_related_objects_one_way(self, first_model,115 relation_field, second_model):116 if 'invalid' not in first_model.get_field_dict():117 return []118 invalid_objects = list(first_model.objects.filter(invalid=True))119 first_model.objects.populate_relationships(invalid_objects,120 second_model,121 'related_objects')122 error_lines = []123 for invalid_object in invalid_objects:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful