def _make_reservation(self): """Make a new reservation.""" # Extract the list of criteria (ie, `oarsub -l # *criteria*`) in order to compute a specification for the # reservation. criteria = {} # Actual criteria are : # - Number of node per site for cluster, roles in self.config["resources"].items(): site = get_cluster_site(cluster) nb_nodes = reduce(operator.add, map(int, roles.values())) criterion = "{cluster='%s'}/nodes=%s" % (cluster, nb_nodes) criteria.setdefault(site, []).append(criterion) for site, vlan in self.config["vlans"].items(): criteria.setdefault(site, []).append(vlan) # Compute the specification for the reservation jobs_specs = [(OarSubmission(resources = '+'.join(c), name = self.config["name"]), s) for s, c in criteria.items()] logger.info("Criteria for the reservation: %s" % pf(jobs_specs)) # Make the reservation gridjob, _ = EX5.oargridsub( jobs_specs, reservation_date=self.config['reservation'], walltime=self.config['walltime'].encode('ascii', 'ignore'), job_type='deploy' ) # TODO - move this upper to not have a side effect here if gridjob is not None: self.gridjob = gridjob logger.info("Using new oargrid job %s" % style.emph(self.gridjob)) else: logger.error("No oar job was created.") sys.exit(26)
def make_reservation(self): """ """ logger.info('Performing reservation') starttime = int(time.time() + timedelta_to_seconds(datetime.timedelta(minutes=1))) planning = get_planning(elements=[self.options.selected_cluster], starttime=starttime) slots = compute_slots(planning, self.options.walltime) wanted = {self.options.selected_cluster: 0} start_date, end_date, resources = find_first_slot(slots, wanted) wanted[self.options.selected_cluster] = resources[ self.options.selected_cluster] actual_resources = distribute_hosts(resources, wanted) job_specs = get_jobs_specs(actual_resources, name='Aevol_diff_area') logger.info("try to reserve " + str(actual_resources)) self.oargrid_job_id, _ = oargridsub( job_specs, walltime=end_date - start_date, job_type=['besteffort"' 'allow_classic_ssh']) logger.info("Reservation done")
def make_reservation(job_name=JOB_NAME, job_type='allow_classic_ssh'): plan = ex5.planning end = ex.time_utils.format_date(time.time() + 12600) logging.basicConfig(level=logging.DEBUG) oargrid_job_id, _ = ex5.planning.get_job_by_name(job_name) if oargrid_job_id is None: logging.info("Starting a new job") planning = plan.get_planning(endtime=end) slots = plan.compute_slots(planning, walltime=WALLTIME, excluded_elements=excluded) startdate, enddate, resources = plan.find_free_slot( slots, {'grid5000': 1}) logging.info("startdate = %s, enddate = %s resources = %s" % (startdate, enddate, resources)) resources = plan.distribute_hosts(resources, {'grid5000': 1}, excluded_elements=excluded) # shuffling to load balance load accros nodes random.shuffle(resources) specs = plan.get_jobs_specs(resources, excluded_elements=excluded) spec, frontend = specs[0] spec.name = job_name logging.info("specs = %s" % spec) oargrid_job_id, _ = ex5.oargridsub(specs, job_type=job_type, walltime=WALLTIME) logging.info("Using running oargrid job %s" % oargrid_job_id) jobs = ex5.oargrid.get_oargrid_job_oar_jobs(oargrid_job_id=oargrid_job_id) # Get the frontend _, frontend = jobs[0] # Get the host hosts = ex5.get_oargrid_job_nodes(oargrid_job_id) logging.info("The slave will be running on %s,%s" % (hosts[0], frontend)) return hosts[0], frontend