Ejemplo n.º 1
0
void
parse_resv_file(FBFILE *file)
{
  char *reason_field;
  char *host_field;
  char line[BUFSIZE];
  char *p;

  while(fbgets(line, sizeof(line), file))
  {
    if((p = strchr(line, '\n')))
      *p = '\0';

    if((*line == '\0') || (line[0] == '#'))
      continue;

    if((host_field = getfield(line)) == NULL)
      continue;

    if((reason_field = getfield(NULL)) == NULL)
      continue;

    if(IsChannelName(host_field))
      create_resv(host_field, reason_field, RESV_CHANNEL);
    else if(clean_resv_nick(host_field))
      create_resv(host_field, reason_field, RESV_NICK);
  }
}
Ejemplo n.º 2
0
/* Create reservations to contain hot-spare nodes
 * and purge vestigial reservations */
extern void create_hot_spare_resv(void)
{
	int i;
	char resv_name[1024];
	ListIterator part_iterator;
	struct part_record *part_ptr;
	/* Locks: Read partition */
	slurmctld_lock_t part_read_lock =
	    { NO_LOCK, NO_LOCK, NO_LOCK, READ_LOCK };
	reservation_name_msg_t delete_resv_msg;
	resv_desc_msg_t resv_msg;
	time_t now = time(NULL);
	uint32_t node_cnt[2];

	lock_slurmctld(part_read_lock);
	part_iterator = list_iterator_create(part_list);
	while ((part_ptr = (struct part_record *) list_next(part_iterator))) {
		snprintf(resv_name, sizeof(resv_name), "HOT_SPARE_%s",
			 part_ptr->name);
		for (i = 0; i < hot_spare_info_cnt; i++) {
			if (hot_spare_info[i].part_ptr != part_ptr)
				continue;
			memset(&resv_msg, 0, sizeof(resv_desc_msg_t));
			node_cnt[0] = hot_spare_info[i].node_cnt;
			node_cnt[1] = 0;
			resv_msg.duration	= 356 * 24 * 60 * 60;
			resv_msg.end_time	= (time_t) NO_VAL;
			resv_msg.flags		= RESERVE_FLAG_MAINT |
						  RESERVE_FLAG_IGN_JOBS;
			resv_msg.name		= resv_name;
			resv_msg.node_cnt	= node_cnt;
			resv_msg.partition	= xstrdup(part_ptr->name);
			resv_msg.start_time	= now;
			resv_msg.users		= xstrdup("root");
			if (find_resv_name(resv_name)) {
				info("Updating vestigial reservation %s",
				      resv_name);
				(void) update_resv(&resv_msg);
			} else {
				info("Creating vestigial reservation %s",
				     resv_name);
				(void) create_resv(&resv_msg);
			}
			xfree(resv_msg.partition);
			xfree(resv_msg.users);
			break;
		}
		if ((i >= hot_spare_info_cnt) && find_resv_name(resv_name)) {
			info("Deleting vestigial reservation %s", resv_name);
			delete_resv_msg.name = resv_name;
			(void) delete_resv(&delete_resv_msg);
		}
	}
	list_iterator_destroy(part_iterator);
	unlock_slurmctld(part_read_lock);
}
Ejemplo n.º 3
0
/* parse_resv()
 *
 * inputs	- source_p, NULL supported
 *		- thing to resv
 *		- time_t if tkline
 *		- reason
 * outputs	- none
 * side effects	- parse resv, create if valid
 */
static void
parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
{
  if (IsChanPrefix(*name))
  {
    struct MaskItem *conf = NULL;

    if ((conf = create_resv(name, reason, NULL)) == NULL)
    {
      if (IsClient(source_p))
        sendto_one_notice(source_p, &me, ":A RESV has already been placed on channel: %s", name);

      return;
    }

    conf->setat = CurrentTime;
    SetConfDatabase(conf);

    if (tkline_time)
    {
      if (IsClient(source_p))
        sendto_one_notice(source_p, &me, ":A %d minute %s RESV has been placed on channel: %s",
                          tkline_time/60, (MyClient(source_p) ? "local" : "remote"), name);

      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
                           "%s has placed a %d minute %s RESV on channel: %s [%s]",
                           get_oper_name(source_p),
                           tkline_time/60,
                           (MyClient(source_p) ? "local" : "remote"),
                           conf->name, conf->reason);
      ilog(LOG_TYPE_RESV, "%s added temporary %d min. RESV for [%s] [%s]",
           get_oper_name(source_p), (int)tkline_time/60,
           conf->name, conf->reason);
      conf->until = CurrentTime + tkline_time;
    }
    else
    {
      if (IsClient(source_p))
        sendto_one_notice(source_p, &me, ":A %s RESV has been placed on channel %s",
                          (MyClient(source_p) ? "local" : "remote"), name);

      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
                           "%s has placed a %s RESV on channel %s : [%s]",
                           get_oper_name(source_p),
                           (MyClient(source_p) ? "local" : "remote"),
                           conf->name, conf->reason);
      ilog(LOG_TYPE_RESV, "%s added RESV for [%s] [%s]",
           get_oper_name(source_p), conf->name, conf->reason);
    }
  }
  else
  {
    struct MaskItem *conf = NULL;

    if (!valid_wild_card_simple(name))
    {
      if (IsClient(source_p))
        sendto_one_notice(source_p, &me, ":Please include at least %u non-wildcard characters with the resv",
                          ConfigGeneral.min_nonwildcard_simple);

      return;
    }

    if (!HasUMode(source_p, UMODE_ADMIN) && has_wildcards(name))
    {
      if (IsClient(source_p))
        sendto_one_notice(source_p, &me, ":You must be an admin to perform a wildcard RESV");

      return;
    }

    if ((conf = create_resv(name, reason, NULL)) == NULL)
    {
      if (IsClient(source_p))
        sendto_one_notice(source_p, &me, ":A RESV has already been placed on nick %s", name);

      return;
    }

    conf->setat = CurrentTime;
    SetConfDatabase(conf);

    if (tkline_time)
    {
      if (IsClient(source_p))
        sendto_one_notice(source_p, &me, ":A %d minute %s RESV has been placed on nick %s : [%s]",
                          tkline_time/60, (MyClient(source_p) ? "local" : "remote"),
                          conf->name, conf->reason);

      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
                           "%s has placed a %d minute %s RESV on nick %s : [%s]",
                           get_oper_name(source_p), tkline_time/60,
                           (MyClient(source_p) ? "local" : "remote"),
                           conf->name, conf->reason);
      ilog(LOG_TYPE_RESV, "%s added temporary %d min. RESV for [%s] [%s]",
           get_oper_name(source_p), (int)tkline_time/60, conf->name, conf->reason);
      conf->until = CurrentTime + tkline_time;
    }
    else
    {
      if (IsClient(source_p))
        sendto_one_notice(source_p, &me, ":A %s RESV has been placed on nick %s : [%s]",
                          (MyClient(source_p) ? "local" : "remote"), conf->name, conf->reason);

      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
                           "%s has placed a %s RESV on nick %s : [%s]",
                           get_oper_name(source_p),
                           (MyClient(source_p) ? "local" : "remote"),
                           conf->name, conf->reason);
      ilog(LOG_TYPE_RESV, "%s added RESV for [%s] [%s]",
           get_oper_name(source_p), conf->name, conf->reason);
    }
  }
}