def get_immediately_available_nodes(self, list_of_clusters, walltime, ignore_besteffort=False): planning = get_planning(list_of_clusters, ignore_besteffort=False) slots = compute_slots(planning, walltime) wanted = {cluster: 0 for cluster in list_of_clusters} start_date, end_date, resources = find_first_slot(slots, wanted) actual_resources = { resource: n_nodes for resource, n_nodes in resources.iteritems() if resource in list_of_clusters and n_nodes > 0 } return start_date, end_date, actual_resources
def _get_nodes(self, starttime, endtime): """ """ planning = get_planning(elements=[self.cluster], starttime=starttime, endtime=endtime, out_of_chart=self.options.outofchart) slots = compute_slots(planning, self.options.walltime) startdate = slots[0][0] i_slot = 0 n_nodes = slots[i_slot][2][self.cluster] while n_nodes < self.n_nodes: logger.debug(slots[i_slot]) startdate = slots[i_slot][0] n_nodes = slots[i_slot][2][self.cluster] i_slot += 1 if i_slot == len(slots) - 1: return False, False return startdate, self.n_nodes
def make_reservation(self): """ """ logger.info('Performing reservation') starttime = int(time.time() + timedelta_to_seconds(datetime.timedelta(minutes=1))) planning = get_planning(elements=['grid5000'], starttime=starttime) slots = compute_slots(planning, self.options.walltime) wanted = {"grid5000": 0} start_date, end_date, resources = find_first_slot(slots, wanted) wanted['grid5000'] = min(resources['grid5000'], self.options.n_nodes) actual_resources = distribute_hosts(resources, wanted) job_specs = get_jobs_specs(actual_resources, name='Paasage_Simu') logger.info("try to reserve " + str(actual_resources)) self.oargrid_job_id, _ = oargridsub(job_specs, start_date, walltime=end_date - start_date, job_type="deploy") logger.info("Reservation done")
def get_hosts_jobs(hosts, walltime, out_of_chart=False): """Find the first slot when the hosts are available and return a list of jobs_specs :param hosts: list of hosts :param walltime: duration of reservation """ hosts = map(lambda x: x.address if isinstance(x, Host) else x, hosts) planning = get_planning(elements=hosts, out_of_chart=out_of_chart) limits = _slots_limits(planning) walltime = get_seconds(walltime) for limit in limits: all_host_free = True for site_planning in planning.itervalues(): for cluster, cluster_planning in site_planning.iteritems(): if cluster in get_g5k_clusters(): for host_planning in cluster_planning.itervalues(): host_free = False for free_slot in host_planning['free']: if free_slot[0] <= limit and free_slot[ 1] >= limit + walltime: host_free = True if not host_free: all_host_free = False if all_host_free: startdate = limit break else: logger.error('Unable to find a slot for %s', hosts) return None jobs_specs = [] for site in planning.keys(): site_hosts = map(get_host_longname, filter(lambda h: get_host_site(h) == site, hosts)) sub_res = "{host in ('" + "','".join(site_hosts) + "')}/nodes=" + str( len(site_hosts)) jobs_specs.append((OarSubmission(resources=sub_res, reservation_date=startdate), site)) return jobs_specs
def get_hosts_jobs(hosts, walltime, out_of_chart=False): """Find the first slot when the hosts are available and return a list of jobs_specs :param hosts: list of hosts :param walltime: duration of reservation """ hosts = map(lambda x: x.address if isinstance(x, Host) else x, hosts) planning = get_planning(elements=hosts, out_of_chart=out_of_chart) limits = _slots_limits(planning) walltime = get_seconds(walltime) for limit in limits: all_host_free = True for site_planning in planning.itervalues(): for cluster, cluster_planning in site_planning.iteritems(): if cluster in get_g5k_clusters(): for host_planning in cluster_planning.itervalues(): host_free = False for free_slot in host_planning['free']: if free_slot[0] <= limit and free_slot[1] >= limit + walltime: host_free = True if not host_free: all_host_free = False if all_host_free: startdate = limit break else: logger.error('Unable to find a slot for %s', hosts) return None jobs_specs = [] for site in planning.keys(): site_hosts = map(get_host_longname, filter(lambda h: get_host_site(h) == site, hosts)) sub_res = "{host in ('" + "','".join(site_hosts) + "')}/nodes=" + str(len(site_hosts)) jobs_specs.append((OarSubmission(resources=sub_res, reservation_date=startdate), site)) return jobs_specs
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 get_immediately_available_nodes(self, list_of_clusters, walltime, ignore_besteffort=False): planning = get_planning(list_of_clusters, ignore_besteffort=False) slots = compute_slots(planning, walltime) wanted = {cluster: 0 for cluster in list_of_clusters} start_date, end_date, resources = find_first_slot(slots, wanted) g_nodes = 0 actual_resources = {} for resource, n_nodes in resources.iteritems(): if resource in list_of_clusters and n_nodes > 0: if g_nodes >= 83: break elif g_nodes + n_nodes >= 83: l_nodes = 83 - g_nodes actual_resources = {resource: l_nodes} break else: actual_resources = {resource: n_nodes} g_nodes += n_nodes return start_date, end_date, actual_resources