• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ slurm_addto_char_list函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中slurm_addto_char_list函数的典型用法代码示例。如果您正苦于以下问题:C++ slurm_addto_char_list函数的具体用法?C++ slurm_addto_char_list怎么用?C++ slurm_addto_char_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了slurm_addto_char_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: parse_command_line

/*
 * parse_command_line, fill in params data structure with data
 */
void parse_command_line(int argc, char *argv[])
{
	int opt_char;
	int option_index;

	static struct option long_options[] = {
		{"all",       no_argument,       0, 'a'},
		{"bgblock",   required_argument, 0, 'b'},
		{"partition", required_argument, 0, 'p'},
		{"remove",    no_argument,       0, 'r'},
		{"wait",      no_argument,       0, 'w'},
		{"version",   no_argument,       0, 'V'},
		{"help",      no_argument,       0, 'h'},
		{"usage",     no_argument,       0, 'u'},
		{NULL, 0, 0, 0}
	};

	while ((opt_char =
		getopt_long(argc, argv, "ab:hp:ruVw",
			    long_options, &option_index)) != -1) {
		switch (opt_char) {
		case (int) '?':
			fprintf(stderr,
				"Try \"sfree --help\" for more information\n");
		        exit(1);
			break;
		case (int) 'a':
			all_blocks = 1;
		        break;
		case (int) 'b':
		case (int) 'p':
			if (!block_list)
				block_list = list_create(slurm_destroy_char);
		slurm_addto_char_list(block_list, optarg);
		break;
		case (int) 'h':
		case (int) OPT_LONG_HELP:
			_help();
		exit(0);
		case (int) 'r':
			remove_blocks = 1;
			break;
		case (int) 'u':
		case (int) OPT_LONG_USAGE:
			_usage();
		exit(0);
		case (int) 'V':
			print_slurm_version();
			exit(0);
		case (int) 'w':
			wait_full = true;
			break;
		}
	}

}
开发者ID:A1ve5,项目名称:slurm,代码行数:59,代码来源:opts.c


示例2: _parse_commandline

/*
 * _parse_commandline - parse and process any command line arguments
 * IN argc - number of command line arguments
 * IN argv - the command line arguments
 * IN/OUT conf_ptr - pointer to current configuration, update as needed
 */
static void _parse_commandline(int argc, char **argv)
{
	int c = 0;
	char *tmp_char;

	opterr = 0;
	while ((c = getopt(argc, argv, "Dhn:R::vV")) != -1)
		switch (c) {
		case 'D':
			foreground = 1;
			break;
		case 'h':
			_usage(argv[0]);
			exit(0);
			break;
		case 'n':
			if (!optarg) /* CLANG fix */
				break;
			new_nice = strtol(optarg, &tmp_char, 10);
			if (tmp_char[0] != '\0') {
				error("Invalid option for -n option (nice "
				      "value), ignored");
				new_nice = 0;
			}
			break;
		case 'R':
			reset_lft_rgt = 1;
			if (optarg) {
				lft_rgt_list = list_create(slurm_destroy_char);
				slurm_addto_char_list(lft_rgt_list, optarg);
			}
			break;
		case 'v':
			debug_level++;
			break;
		case 'V':
			print_slurm_version();
			exit(0);
			break;
		default:
			_usage(argv[0]);
			exit(1);
		}
}
开发者ID:HPCNow,项目名称:slurm,代码行数:50,代码来源:slurmdbd.c


示例3: _set_res_cond

static int _set_res_cond(int *start, int argc, char *argv[],
			     slurmdb_res_cond_t *res_cond,
			     List format_list)
{
	int i;
	int set = 0;
	int end = 0;
	int command_len = 0;

	if (!res_cond) {
		error("No res_cond given");
		return -1;
	}

	for (i=(*start); i<argc; i++) {
		end = parse_option_end(argv[i]);
		if (!end)
			command_len=strlen(argv[i]);
		else {
			command_len=end-1;
			if (argv[i][end] == '=') {
				end++;
			}
		}

		if (!strncasecmp(argv[i], "Set", MAX(command_len, 3))) {
			i--;
			break;
		} else if (!end && !strncasecmp(argv[i], "WithDeleted",
						 MAX(command_len, 5))) {
			res_cond->with_deleted = 1;
		} else if (!end && !strncasecmp(argv[i], "WithClusters",
						 MAX(command_len, 5))) {
			res_cond->with_clusters = 1;
		} else if (!end && !strncasecmp(argv[i], "where",
						MAX(command_len, 5))) {
			continue;
		} else if (!end
			   || !strncasecmp(argv[i], "Names",
					   MAX(command_len, 1))) {
			if (!res_cond->name_list) {
				res_cond->name_list =
					list_create(slurm_destroy_char);
			}
			if (slurm_addto_char_list(res_cond->name_list,
						  argv[i]+end))
				set = 1;
		} else if (!end
			   || !strncasecmp(argv[i], "Clusters",
					   MAX(command_len, 1))) {
			if (!res_cond->cluster_list) {
				res_cond->cluster_list =
					list_create(slurm_destroy_char);
			}

			slurm_addto_char_list(res_cond->cluster_list,
					      argv[i]+end);
			if (sacctmgr_validate_cluster_list(
				    res_cond->cluster_list) != SLURM_SUCCESS) {
				exit_code=1;
				fprintf(stderr,
					" Need a valid cluster name to "
					"add a cluster resource.\n");
			} else
				set = 1;
		} else if (!strncasecmp(argv[i], "Descriptions",
				MAX(command_len, 1))) {
		if (!res_cond->description_list) {
			res_cond->description_list =
					list_create(slurm_destroy_char);
			}
			if (slurm_addto_char_list(
				    res_cond->description_list,
				    argv[i]+end))
				set = 1;
		} else if (!strncasecmp(argv[i], "Format",
					 MAX(command_len, 1))) {
			if (format_list)
				slurm_addto_char_list(format_list, argv[i]+end);
		} else if (!strncasecmp(argv[i], "Ids", MAX(command_len, 1))) {
			ListIterator itr = NULL;
			char *temp = NULL;
			uint32_t id = 0;

			if (!res_cond->id_list) {
				res_cond->id_list =
					list_create(slurm_destroy_char);
			}
			if (slurm_addto_char_list(res_cond->id_list,
						  argv[i]+end))
				set = 1;

			/* check to make sure user gave ints here */
			itr = list_iterator_create(res_cond->id_list);
			while ((temp = list_next(itr))) {
				if (get_uint(temp, &id, "RES ID")
				    != SLURM_SUCCESS) {
					exit_code = 1;
					list_delete_item(itr);
				}
//.........这里部分代码省略.........
开发者ID:CornellCAC,项目名称:slurm,代码行数:101,代码来源:resource_functions.c


示例4: _set_cond

static int _set_cond(int *start, int argc, char **argv,
		     slurmdb_tres_cond_t *tres_cond,
		     List format_list)
{
	int i;
	int set = 0;
	int end = 0;
	int command_len = 0;

	if (!tres_cond) {
		exit_code=1;
		fprintf(stderr, "No tres_cond given");
		return -1;
	}

	for (i=(*start); i<argc; i++) {
		end = parse_option_end(argv[i]);
		if (!end)
			command_len=strlen(argv[i]);
		else {
			command_len=end-1;
			if (argv[i][end] == '=') {
				end++;
			}
		}

		if (!xstrncasecmp(argv[i], "Set", MAX(command_len, 3))) {
			i--;
			break;
		} else if (!end && !xstrncasecmp(argv[i], "WithDeleted",
						 MAX(command_len, 5))) {
			tres_cond->with_deleted = 1;
		} else if (!end && !xstrncasecmp(argv[i], "where",
						 MAX(command_len, 5))) {
			continue;
		} else if (!end
			  || !xstrncasecmp(argv[i], "Type",
					   MAX(command_len, 2))) {
			if (!tres_cond->type_list) {
				tres_cond->type_list =
					list_create(slurm_destroy_char);
			}
			if (slurm_addto_char_list(
				   tres_cond->type_list,
				   argv[i]+end))
				set = 1;
		} else if (!xstrncasecmp(argv[i], "Names",
					 MAX(command_len, 1))) {
			if (!tres_cond->name_list) {
				tres_cond->name_list =
					list_create(slurm_destroy_char);
			}
			if (slurm_addto_char_list(tres_cond->name_list,
						  argv[i]+end))
				set = 1;
		} else if (!xstrncasecmp(argv[i], "Format",
					 MAX(command_len, 1))) {
			if (format_list)
				slurm_addto_char_list(format_list, argv[i]+end);
		} else if (!xstrncasecmp(argv[i], "Ids",
					 MAX(command_len, 1))) {
			if (!tres_cond->id_list) {
				tres_cond->id_list =
					list_create(slurm_destroy_char);
			}
			if (slurm_addto_char_list(tres_cond->id_list,
						 argv[i]+end))
				set = 1;
		} else {
			exit_code=1;
			fprintf(stderr, " Unknown condition: %s\n"
				" Use keyword 'set' to modify value\n",
				argv[i]);
		}
	}

	(*start) = i;

	if (set)
		return 1;

	return 0;
}
开发者ID:SchedMD,项目名称:slurm,代码行数:83,代码来源:tres_function.c


示例5: _process_resv_usage

/* process reservation usage data */
static int
_process_resv_usage(pgsql_conn_t *pg_conn, char *cluster, time_t start,
		    time_t end, List cu_list, List ru_list)
{
	DEF_VARS;
	local_cluster_usage_t *c_usage = NULL;
	local_resv_usage_t *r_usage = NULL;

	char *gr_fields = "id_resv,assoclist,cpus,flags,time_start,time_end";
	enum {
		F_ID,
		F_ASSOCS,
		F_CPU,
		F_FLAGS,
		F_START,
		F_END,
		F_COUNT
	};

	// now get the reservations during this time
	query = xstrdup_printf(
		"SELECT %s FROM %s.%s WHERE (time_start<%ld AND time_end >= %ld)"
		" ORDER BY time_start", gr_fields, cluster, resv_table, end,
		start);
	result = DEF_QUERY_RET;
	if (!result) {
		error("failed to get resv");
		return SLURM_ERROR;
	}

	/* If a reservation overlaps another reservation we
	   total up everything here as if they didn't but when
	   calculating the total time for a cluster we will
	   remove the extra time received.  This may result in
	   unexpected results with association based reports
	   since the association is given the total amount of
	   time of each reservation, thus equaling more time
	   that is available.  Job/Cluster/Reservation reports
	   should be fine though since we really don't over
	   allocate resources.
	*/
	FOR_EACH_ROW {
		int row_start = atoi(ROW(F_START));
		int row_end = atoi(ROW(F_END));
		int row_cpu = atoi(ROW(F_CPU));
		int row_flags = atoi(ROW(F_FLAGS));

		if (row_start < start)
			row_start = start;
		if (!row_end || row_end > end)
			row_end = end;
		/* ignore time less than 1 seconds */
		if ((row_end - row_start) < 1)
			continue;

		r_usage = xmalloc(sizeof(local_resv_usage_t));
		r_usage->id = atoi(ROW(F_ID));
		r_usage->local_assocs = list_create(slurm_destroy_char);
		slurm_addto_char_list(r_usage->local_assocs,
				      ROW(F_ASSOCS));
		r_usage->total_time = (row_end - row_start) * row_cpu;
		r_usage->start = row_start;
		r_usage->end = row_end;
		list_append(ru_list, r_usage);

		/* Since this reservation was added to the
		   cluster and only certain people could run
		   there we will use this as allocated time on
		   the system.  If the reservation was a
		   maintenance then we add the time to planned
		   down time.
		*/
		c_usage = list_peek(cu_list); /* only one c_usage in cluster usage list in one hour */
		
		if (!c_usage)
			continue;
		if (row_flags & RESERVE_FLAG_MAINT)
			c_usage->pd_cpu += r_usage->total_time;
		else
			c_usage->a_cpu += r_usage->total_time;
	} END_EACH_ROW;
	PQclear(result);
	return SLURM_SUCCESS;
}
开发者ID:IFCA,项目名称:slurm,代码行数:85,代码来源:as_pg_rollup.c


示例6: _set_cond

static int _set_cond(int *start, int argc, char *argv[],
		     slurmdb_event_cond_t *event_cond,
		     List format_list)
{
	int i, end = 0;
	int set = 0;
	int command_len = 0;
	int local_cluster_flag = 0;
	int all_time_flag = 0;

	if(!event_cond->cluster_list)
		event_cond->cluster_list = list_create(slurm_destroy_char);
	for (i=(*start); i<argc; i++) {
		end = parse_option_end(argv[i]);
		if(!end)
			command_len=strlen(argv[i]);
		else {
			command_len=end-1;
			if (argv[i][end] == '=') {
				end++;
			}
		}

		if(!end && !strncasecmp(argv[i], "all_clusters",
					       MAX(command_len, 5))) {
			local_cluster_flag = 1;
		} else if(!end && !strncasecmp(argv[i], "all_time",
					       MAX(command_len, 5))) {
			all_time_flag = 1;
		} else if(!end && !strncasecmp(argv[i], "where",
					MAX(command_len, 5))) {
			continue;
		} else if(!end || (!strncasecmp (argv[i], "Events",
						 MAX(command_len, 1)))) {
			ListIterator itr = NULL;
			List tmp_list = list_create(slurm_destroy_char);
			char *temp = NULL;

			if(slurm_addto_char_list(tmp_list,
						 argv[i]+end))
				set = 1;

			/* check to make sure user gave ints here */
			itr = list_iterator_create(tmp_list);
			while ((temp = list_next(itr))) {
				if(!strncasecmp("Node", temp,
						MAX(strlen(temp), 1))) {
					if(event_cond->event_type)
						event_cond->event_type =
							SLURMDB_EVENT_ALL;
					else
						event_cond->event_type =
							SLURMDB_EVENT_NODE;
				} else if(!strncasecmp("Cluster", temp,
						MAX(strlen(temp), 1))) {
					if(event_cond->event_type)
						event_cond->event_type =
							SLURMDB_EVENT_ALL;
					else
						event_cond->event_type =
							SLURMDB_EVENT_CLUSTER;
				} else {
					exit_code=1;
					fprintf(stderr,
						" Unknown event type: '%s'  "
						"Valid events are Cluster "
						"and Node.\n",
						temp);

				}
			}
			list_iterator_destroy(itr);
			list_destroy(tmp_list);
		} else if (!strncasecmp (argv[i], "Clusters",
					 MAX(command_len, 1))) {
			if(!event_cond->cluster_list)
				event_cond->cluster_list =
					list_create(slurm_destroy_char);
			if(slurm_addto_char_list(event_cond->cluster_list,
						 argv[i]+end))
				set = 1;
		} else if (!strncasecmp (argv[i], "End", MAX(command_len, 1))) {
			event_cond->period_end = parse_time(argv[i]+end, 1);
			set = 1;
		} else if (!strncasecmp (argv[i], "Format",
					 MAX(command_len, 1))) {
			if(format_list)
				slurm_addto_char_list(format_list, argv[i]+end);
		} else if (!strncasecmp (argv[i], "MinCpus",
					 MAX(command_len, 2))) {
			if (get_uint(argv[i]+end, &event_cond->cpus_min,
			    "MinCpus") == SLURM_SUCCESS)
				set = 1;
		} else if (!strncasecmp (argv[i], "MaxCpus",
					 MAX(command_len, 2))) {
			if (get_uint(argv[i]+end, &event_cond->cpus_max,
			    "MaxCpus") == SLURM_SUCCESS)
				set = 1;
		} else if (!strncasecmp (argv[i], "Nodes",
					 MAX(command_len, 1))) {
//.........这里部分代码省略.........
开发者ID:Xarthisius,项目名称:slurm,代码行数:101,代码来源:event_functions.c


示例7: _set_rec

static int _set_rec(int *start, int argc, char *argv[],
                    List acct_list,
                    List cluster_list,
                    slurmdb_account_rec_t *acct,
                    slurmdb_association_rec_t *assoc)
{
    int i;
    int u_set = 0;
    int a_set = 0;
    int end = 0;
    int command_len = 0;
    int option = 0;

    for (i=(*start); i<argc; i++) {
        end = parse_option_end(argv[i]);
        if (!end)
            command_len=strlen(argv[i]);
        else {
            command_len=end-1;
            if (argv[i][end] == '=') {
                option = (int)argv[i][end-1];
                end++;
            }
        }

        if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))) {
            i--;
            break;
        } else if (!end && !strncasecmp(argv[i], "set",
                                        MAX(command_len, 3))) {
            continue;
        } else if (!end
                   || !strncasecmp(argv[i], "Accounts",
                                   MAX(command_len, 1))
                   || !strncasecmp(argv[i], "Names",
                                   MAX(command_len, 1))
                   || !strncasecmp(argv[i], "Acct",
                                   MAX(command_len, 4))) {
            if (acct_list)
                slurm_addto_char_list(acct_list, argv[i]+end);
            else {
                exit_code=1;
                fprintf(stderr,
                        " Can't modify the name "
                        "of an account\n");
            }
        } else if (!strncasecmp(argv[i], "Clusters",
                                MAX(command_len, 1))) {
            if (cluster_list)
                slurm_addto_char_list(cluster_list,
                                      argv[i]+end);
            else {
                exit_code=1;
                fprintf(stderr,
                        " Can't modify the cluster "
                        "of an account\n");
            }
        } else if (!strncasecmp(argv[i], "Description",
                                MAX(command_len, 1))) {
            acct->description =  strip_quotes(argv[i]+end, NULL, 1);
            u_set = 1;
        } else if (!strncasecmp(argv[i], "Organization",
                                MAX(command_len, 1))) {
            acct->organization = strip_quotes(argv[i]+end, NULL, 1);
            u_set = 1;
        } else if (!strncasecmp (argv[i], "RawUsage",
                                 MAX(command_len, 7))) {
            uint32_t usage;
            if (!assoc)
                continue;
            assoc->usage = xmalloc(sizeof(
                                       assoc_mgr_association_usage_t));
            if (get_uint(argv[i]+end, &usage,
                         "RawUsage") == SLURM_SUCCESS) {
                assoc->usage->usage_raw = usage;
                a_set = 1;
            }
        } else if (!assoc ||
                   (assoc && !(a_set = sacctmgr_set_association_rec(
                                           assoc, argv[i], argv[i]+end,
                                           command_len, option)))) {
            exit_code=1;
            fprintf(stderr, " Unknown option: %s\n"
                    " Use keyword 'where' to modify condition\n",
                    argv[i]);
        }
    }

    (*start) = i;

    if (u_set && a_set)
        return 3;
    else if (a_set)
        return 2;
    else if (u_set)
        return 1;

    return 0;
}
开发者ID:schelcj,项目名称:slurm,代码行数:99,代码来源:account_functions.c


示例8: _set_cond

static int _set_cond(int *start, int argc, char *argv[],
                     slurmdb_account_cond_t *acct_cond,
                     List format_list)
{
    int i;
    int a_set = 0;
    int u_set = 0;
    int end = 0;
    slurmdb_association_cond_t *assoc_cond = NULL;
    int command_len = 0;
    int option = 0;

    if (!acct_cond) {
        exit_code=1;
        fprintf(stderr, "No acct_cond given");
        return -1;
    }

    if (!acct_cond->assoc_cond) {
        acct_cond->assoc_cond =
            xmalloc(sizeof(slurmdb_association_cond_t));
    }

    assoc_cond = acct_cond->assoc_cond;

    for (i=(*start); i<argc; i++) {
        end = parse_option_end(argv[i]);
        if (!end)
            command_len=strlen(argv[i]);
        else {
            command_len=end-1;
            if (argv[i][end] == '=') {
                option = (int)argv[i][end-1];
                end++;
            }
        }

        if (!strncasecmp(argv[i], "Set", MAX(command_len, 3))) {
            i--;
            break;
        } else if (!end &&
                   !strncasecmp(argv[i], "WithAssoc",
                                MAX(command_len, 5))) {
            acct_cond->with_assocs = 1;
        } else if (!end &&
                   !strncasecmp(argv[i], "WithCoordinators",
                                MAX(command_len, 5))) {
            acct_cond->with_coords = 1;
        } else if (!end &&
                   !strncasecmp(argv[i], "WithDeleted",
                                MAX(command_len, 5))) {
            acct_cond->with_deleted = 1;
            assoc_cond->with_deleted = 1;
        } else if (!end &&
                   !strncasecmp(argv[i], "WithRawQOSLevel",
                                MAX(command_len, 5))) {
            assoc_cond->with_raw_qos = 1;
        } else if (!end && !strncasecmp(argv[i], "WOPLimits",
                                        MAX(command_len, 4))) {
            assoc_cond->without_parent_limits = 1;
        } else if (!end && !strncasecmp(argv[i], "where",
                                        MAX(command_len, 5))) {
            continue;
        } else if (!end
                   || !strncasecmp(argv[i], "Names",
                                   MAX(command_len, 1))
                   || !strncasecmp(argv[i], "Accounts",
                                   MAX(command_len, 1))
                   || !strncasecmp(argv[i], "Acct",
                                   MAX(command_len, 4))) {
            if (!assoc_cond->acct_list) {
                assoc_cond->acct_list =
                    list_create(slurm_destroy_char);
            }
            if (slurm_addto_char_list(
                        assoc_cond->acct_list,
                        argv[i]+end))
                u_set = 1;
        } else if (!strncasecmp(argv[i], "Descriptions",
                                MAX(command_len, 1))) {
            if (!acct_cond->description_list) {
                acct_cond->description_list =
                    list_create(slurm_destroy_char);
            }
            if (slurm_addto_char_list(acct_cond->description_list,
                                      argv[i]+end))
                u_set = 1;
        } else if (!strncasecmp(argv[i], "Format",
                                MAX(command_len, 1))) {
            if (format_list)
                slurm_addto_char_list(format_list, argv[i]+end);
        } else if (!strncasecmp(argv[i], "Organizations",
                                MAX(command_len, 1))) {
            if (!acct_cond->organization_list) {
                acct_cond->organization_list =
                    list_create(slurm_destroy_char);
            }
            if (slurm_addto_char_list(acct_cond->organization_list,
                                      argv[i]+end))
                u_set = 1;
//.........这里部分代码省略.........
开发者ID:schelcj,项目名称:slurm,代码行数:101,代码来源:account_functions.c


示例9: _set_cond

static int _set_cond(int *start, int argc, char **argv,
		     slurmdb_federation_cond_t *federation_cond,
		     List format_list)
{
	int i;
	int a_set = 0;
	int end = 0;
	int command_len = 0;

	for (i=(*start); i<argc; i++) {
		end = parse_option_end(argv[i]);
		if (!end)
			command_len=strlen(argv[i]);
		else {
			command_len=end-1;
			if (argv[i][end] == '=') {
				end++;
			}
		}

		if (!strncasecmp(argv[i], "Set", MAX(command_len, 3))) {
			i--;
			break;
		} else if (!end && !strncasecmp(argv[i], "where",
					       MAX(command_len, 5))) {
			continue;
		} else if (!end &&
			   !strncasecmp(argv[i], "WithDeleted",
					 MAX(command_len, 5))) {
			federation_cond->with_deleted = 1;
		} else if (!end && !strncasecmp (argv[i], "Tree",
					  MAX(command_len, 4))) {
			tree_display = 1;
		} else if (!end || !strncasecmp(argv[i], "Names",
						MAX(command_len, 1))
			  || !strncasecmp(argv[i], "Federations",
					   MAX(command_len, 3))) {
			if (!federation_cond->federation_list)
				federation_cond->federation_list =
					list_create(slurm_destroy_char);
			if (slurm_addto_char_list(
					federation_cond->federation_list,
					argv[i]+end))
				a_set = 1;
		} else if (!end || !strncasecmp(argv[i], "Clusters",
						MAX(command_len, 3))) {
			if (!federation_cond->cluster_list)
				federation_cond->cluster_list =
					list_create(slurm_destroy_char);
			if (slurm_addto_char_list(
						  federation_cond->cluster_list,
						  argv[i]+end))
				a_set = 1;
		} else if (!strncasecmp(argv[i], "Format",
					 MAX(command_len, 2))) {
			if (format_list)
				slurm_addto_char_list(format_list, argv[i]+end);
		} else {
			exit_code=1;
			fprintf(stderr, " Unknown condition: %s\n"
				" Use keyword 'set' to modify value\n",
				argv[i]);
			break;
		}
	}
	(*start) = i;

	return a_set;
}
开发者ID:HPCNow,项目名称:slurm,代码行数:69,代码来源:federation_functions.c


示例10: sacctmgr_list_federation

extern int sacctmgr_list_federation(int argc, char **argv)
{
	int rc = SLURM_SUCCESS;
	slurmdb_federation_cond_t *federation_cond =
		xmalloc(sizeof(slurmdb_federation_cond_t));
	List federation_list;
	int i=0;
	ListIterator itr = NULL;
	ListIterator itr2 = NULL;
	slurmdb_federation_rec_t *fed = NULL;
	bool print_clusters = false;

	int field_count = 0;

	print_field_t *field = NULL;

	List format_list = list_create(slurm_destroy_char);
	List print_fields_list; /* types are of print_field_t */

	slurmdb_init_federation_cond(federation_cond, 0);
	federation_cond->federation_list = list_create(slurm_destroy_char);
	for (i=0; i<argc; i++) {
		int command_len = strlen(argv[i]);
		if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))
		    || !strncasecmp(argv[i], "Set", MAX(command_len, 3)))
			i++;
		_set_cond(&i, argc, argv, federation_cond, format_list);
	}

	if (exit_code) {
		slurmdb_destroy_federation_cond(federation_cond);
		FREE_NULL_LIST(format_list);
		return SLURM_ERROR;
	}

	if (!list_count(format_list)) {
		slurm_addto_char_list(format_list,
				      "Federation,Cluster,ID%2,"
				      "Features,FedState");
	}

	print_fields_list = sacctmgr_process_format_list(format_list);
	FREE_NULL_LIST(format_list);

	if (exit_code) {
		slurmdb_destroy_federation_cond(federation_cond);
		FREE_NULL_LIST(print_fields_list);
		return SLURM_ERROR;
	}

	federation_list = acct_storage_g_get_federations(db_conn, my_uid,
							 federation_cond);
	slurmdb_destroy_federation_cond(federation_cond);

	if (!federation_list) {
		exit_code=1;
		fprintf(stderr, " Problem with query.\n");
		FREE_NULL_LIST(print_fields_list);
		return SLURM_ERROR;
	}

	itr = list_iterator_create(federation_list);
	itr2 = list_iterator_create(print_fields_list);
	print_fields_header(print_fields_list);

	field_count = list_count(print_fields_list);

	/* only print clusters if a cluster field is requested */
	while((field = list_next(itr2))) {
		switch (field->type) {
		case PRINT_CLUSTER:
		case PRINT_FEDSTATE:
		case PRINT_FEDSTATERAW:
		case PRINT_ID:
			print_clusters = true;
			break;
		}
	}
	list_iterator_reset(itr2);

	while ((fed = list_next(itr))) {
		int      curr_inx   = 1;
		char    *tmp_str    = NULL;
		uint32_t tmp_uint32 = 0;
		slurmdb_cluster_rec_t *tmp_cluster = NULL;
		ListIterator itr3 =
			list_iterator_create(fed->cluster_list);

		if (!tree_display && print_clusters)
			tmp_cluster = list_next(itr3);

		do {
			while((field = list_next(itr2))) {
				switch(field->type) {
				/* Federation Specific Fields */
				case PRINT_FEDERATION:
					if (tree_display && tmp_cluster)
						tmp_str = NULL;
					else
						tmp_str = fed->name;
//.........这里部分代码省略.........
开发者ID:HPCNow,项目名称:slurm,代码行数:101,代码来源:federation_functions.c


示例11: _set_rec

static int _set_rec(int *start, int argc, char **argv,
		    List name_list, slurmdb_federation_rec_t *fed)
{
	int i;
	int set = 0;
	int end = 0;
	int command_len = 0;
	int option = 0;

	for (i=(*start); i<argc; i++) {
		end = parse_option_end(argv[i]);
		if (!end)
			command_len=strlen(argv[i]);
		else {
			command_len=end-1;
			if (argv[i][end] == '=') {
				option = (int)argv[i][end-1];
				end++;
			}
		}

		if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))) {
			i--;
			break;
		} else if (!end && !strncasecmp(argv[i], "set",
					       MAX(command_len, 3))) {
			continue;
		} else if (!end
			  || !strncasecmp (argv[i], "Name",
					   MAX(command_len, 1))) {
			if (name_list)
				slurm_addto_char_list(name_list, argv[i]+end);
		} else if (!fed) {
			continue;
		} else if (!strncasecmp (argv[i], "Clusters",
					 MAX(command_len, 2))) {
			char *name = NULL;
			ListIterator itr;

			if (*(argv[i]+end) == '\0' &&
			    (option == '+' || option == '-')) {
				printf(" You didn't specify any clusters to"
				       " %s\n",
				       (option == '-') ? "remove" : "add");
				exit_code = 1;
				break;
			}

			List cluster_names = list_create(slurm_destroy_char);
			if (slurm_addto_mode_char_list(cluster_names,
						       argv[i]+end, option) < 0)
			{
				FREE_NULL_LIST(cluster_names);
				exit_code = 1;
				break;
			}
			itr = list_iterator_create(cluster_names);
			fed->cluster_list =
				list_create(slurmdb_destroy_cluster_rec);
			while((name = list_next(itr))) {
				if (name[0] == '\0')
					continue;
				slurmdb_cluster_rec_t *cluster =
					xmalloc(sizeof(slurmdb_cluster_rec_t));
				slurmdb_init_cluster_rec(cluster, 0);
				cluster->name = xstrdup(name);
				list_append(fed->cluster_list, cluster);
			}
			list_iterator_destroy(itr);
			FREE_NULL_LIST(cluster_names);
			set = 1;
		} else if (!strncasecmp (argv[i], "Flags",
					 MAX(command_len, 2))) {
			fed->flags = str_2_federation_flags(argv[i]+end,
								   option);
			if (fed->flags == FEDERATION_FLAG_NOTSET) {
				char *tmp_char = NULL;
				fed->flags = INFINITE;
				fed->flags &= (~FEDERATION_FLAG_NOTSET &
					       ~FEDERATION_FLAG_ADD &
					       ~FEDERATION_FLAG_REMOVE);
				tmp_char =
					slurmdb_federation_flags_str(
							fed->flags);
				printf(" Unknown federation flag used in:\n"
				       " '%s'\n"
				       " Valid federation flags are\n  '%s'\n",
				       argv[i]+end, tmp_char);
				xfree(tmp_char);
				exit_code = 1;
			} else
				set = 1;
		} else {
			exit_code = 1;
			printf(" Unknown option: %s\n"
			       " Use keyword 'where' to modify condition\n",
			       argv[i]);
		}
	}

//.........这里部分代码省略.........
开发者ID:HPCNow,项目名称:slurm,代码行数:101,代码来源:federation_functions.c


示例12: sacctmgr_list_cluster

extern int sacctmgr_list_cluster(int argc, char *argv[])
{
	int rc = SLURM_SUCCESS;
	slurmdb_cluster_cond_t *cluster_cond =
		xmalloc(sizeof(slurmdb_cluster_cond_t));
	List cluster_list;
	int i=0;
	ListIterator itr = NULL;
	ListIterator itr2 = NULL;
	slurmdb_cluster_rec_t *cluster = NULL;
	char *tmp_char = NULL;

	int field_count = 0;

	print_field_t *field = NULL;

	List format_list = list_create(slurm_destroy_char);
	List print_fields_list; /* types are of print_field_t */

	slurmdb_init_cluster_cond(cluster_cond, 0);
	cluster_cond->cluster_list = list_create(slurm_destroy_char);
	for (i=0; i<argc; i++) {
		int command_len = strlen(argv[i]);
		if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))
		    || !strncasecmp(argv[i], "Set", MAX(command_len, 3)))
			i++;
		_set_cond(&i, argc, argv, cluster_cond, format_list);
	}

	if(exit_code) {
		slurmdb_destroy_cluster_cond(cluster_cond);
		list_destroy(format_list);
		return SLURM_ERROR;
	}

	if(!list_count(format_list)) {
		slurm_addto_char_list(format_list,
				      "Cl,Controlh,Controlp,RPC");
		if(!without_limits)
			slurm_addto_char_list(format_list,
					      "Fa,GrpJ,GrpN,GrpS,MaxJ,MaxN,"
					      "MaxS,MaxW,QOS,DefaultQOS");
	}

	cluster_cond->with_deleted = with_deleted;

	print_fields_list = sacctmgr_process_format_list(format_list);
	list_destroy(format_list);

	if(exit_code) {
		slurmdb_destroy_cluster_cond(cluster_cond);
		list_destroy(print_fields_list);
		return SLURM_ERROR;
	}

	cluster_list = acct_storage_g_get_clusters(db_conn, my_uid,
						   cluster_cond);
	slurmdb_destroy_cluster_cond(cluster_cond);

	if(!cluster_list) {
		exit_code=1;
		fprintf(stderr, " Problem with query.\n");
		list_destroy(print_fields_list);
		return SLURM_ERROR;
	}

	itr = list_iterator_create(cluster_list);
	itr2 = list_iterator_create(print_fields_list);
	print_fields_header(print_fields_list);

	field_count = list_count(print_fields_list);

	while((cluster = list_next(itr))) {
		int curr_inx = 1;
		slurmdb_association_rec_t *assoc = cluster->root_assoc;
		/* set up the working cluster rec so nodecnt's and node names
		 * are handled correctly */
		working_cluster_rec = cluster;
		while((field = list_next(itr2))) {
			switch(field->type) {
			case PRINT_CLUSTER:
				field->print_routine(field,
						     cluster->name,
						     (curr_inx == field_count));
				break;
			case PRINT_CHOST:
				field->print_routine(field,
						     cluster->control_host,
						     (curr_inx == field_count));
				break;
			case PRINT_CPORT:
				field->print_routine(field,
						     cluster->control_port,
						     (curr_inx == field_count));
				break;
			case PRINT_CLASS:
				field->print_routine(field,
						     get_classification_str(
							     cluster->
							     classification),
//.........这里部分代码省略.........
开发者ID:alepharchives,项目名称:slurm,代码行数:101,代码来源:cluster_functions.c


示例13: _set_rec

static int _set_rec(int *start, int argc, char *argv[],
		    List name_list,
		    slurmdb_association_rec_t *assoc,
		    uint16_t *classification)
{
	int i;
	int set = 0;
	int end = 0;
	int command_len = 0;
	int option = 0;

	for (i=(*start); i<argc; i++) {
		end = parse_option_end(argv[i]);
		if(!end)
			command_len=strlen(argv[i]);
		else {
			command_len=end-1;
			if(argv[i][end] == '=') {
				option = (int)argv[i][end-1];
				end++;
			}
		}

		if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))) {
			i--;
			break;
		} else if(!end && !strncasecmp(argv[i], "set",
					       MAX(command_len, 3))) {
			continue;
		} else if(!end
			  || !strncasecmp(argv[i], "Names",
					   MAX(command_len, 1))
			  || !strncasecmp(argv[i], "Clusters",
					   MAX(command_len, 3))) {
			if(name_list)
				slurm_addto_char_list(name_list,
						      argv[i]+end);
		} else if (!strncasecmp(argv[i], "Classification",
					 MAX(command_len, 3))) {
			if(classification) {
				*classification =
					str_2_classification(argv[i]+end);
				if(*classification)
					set = 1;
			}
		} else if (!strncasecmp(argv[i], "GrpCPUMins",
					 MAX(command_len, 7))) {
			exit_code=1;
			fprintf(stderr, "GrpCPUMins is not a valid option "
				"for the root association of a cluster.\n");
			break;
		} else if (!strncasecmp(argv[i], "GrpWall",
					 MAX(command_len, 4))) {
			exit_code=1;
			fprintf(stderr, "GrpWall is not a valid option "
				"for the root association of a cluster.\n");
		} else if(!assoc ||
			  (assoc && !(set = sacctmgr_set_association_rec(
					      assoc, argv[i], argv[i]+end,
					      command_len, option)))) {
			exit_code=1;
			fprintf(stderr, " Unknown option: %s\n"
				" Use keyword 'where' to modify condition\n",
				argv[i]);
		}
	}
	(*start) = i;

	return set;

}
开发者ID:alepharchives,项目名称:slurm,代码行数:71,代码来源:cluster_functions.c


示例14: _set_res_rec

static int _set_res_rec(int *start, int argc, char *argv[],
			List name_list, List cluster_list,
			slurmdb_res_rec_t *res)
{
	int i;
	int set = 0;
	int end = 0;
	int command_len = 0;
	int option = 0;

	xassert(res);

	for (i=(*start); i<argc; i++) {
		end = parse_option_end(argv[i]);
		if (!end)
			command_len=strlen(argv[i]);
		else {
			command_len=end-1;
			if (argv[i][end] == '=') {
				option = (int)argv[i][end-1];
				end++;
			}
		}

		if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))) {
			i--;
			break;
		} else if (!end && !strncasecmp(argv[i], "set",
						MAX(command_len, 3))) {
			continue;
		} else if (!end
			  || !strncasecmp(argv[i], "Names",
					  MAX(command_len, 1))
			   || !strncasecmp(argv[i], "Resources",
					   MAX(command_len, 1))) {
			if (name_list)
				slurm_addto_char_list(name_list, argv[i]+end);
		} else if (!strncasecmp(argv[i], "Clusters",
					 MAX(command_len, 1))) {
			if (cluster_list) {
				slurm_addto_char_list(cluster_list,
						      argv[i]+end);
				if (sacctmgr_validate_cluster_list(
					    cluster_list) != SLURM_SUCCESS) {
					exit_code=1;
					fprintf(stderr,
						" Need a valid cluster name to "
						"add a cluster resource.\n");
				}
			} else {
				exit_code=1;
				fprintf(stderr,
					" Can't modify the cluster "
					"of an resource\n");
			}
		} else if (!strncasecmp(argv[i], "Count",
					MAX(command_len, 3))) {
			if (get_uint(argv[i]+end, &res->count,
				     "count") == SLURM_SUCCESS) {
				set = 1;
			}
		} else if (!strncasecmp(argv[i], "Description",
					 MAX(command_len, 1))) {
			if (!res->description)
				res->description =
					strip_quotes(argv[i]+end, NULL, 1);
			set = 1;
		} else if (!strncasecmp(argv[i], "Flags",
					 MAX(command_len, 2))) {
			res->flags = str_2_res_flags(argv[i]+end, option);
			if (res->flags == SLURMDB_RES_FLAG_NOTSET) {
				char *tmp_char = slurmdb_res_flags_str(
					SLURMDB_RES_FLAG_BASE);
				printf(" Unknown Server Resource flag used "
				       "in:\n  '%s'\n"
				       " Valid Server Resource flags are\n"
				       " '%s'\n", argv[i]+end, tmp_char);
				xfree(tmp_char);
				exit_code = 1;
			} else
				set = 1;
		} else if (!strncasecmp(argv[i], "Manager",
					 MAX(command_len, 1))) {
			if (!res->manager)
				res->manager =
					strip_quotes(argv[i]+end, NULL, 1);
			set = 1;
		} else if (!strncasecmp(argv[i], "PercentAllowed",
					MAX(command_len, 1))) {
			/* overload percent_used here */
			if (get_uint16(argv[i]+end, &res->percent_used,
				       "PercentAllowed") == SLURM_SUCCESS) {
				set = 1;
			}
		} else if (!strncasecmp(argv[i], "Server",
					  MAX(command_len, 1))) {
			if (!res->server) {
				res->server=
					strip_quotes(argv[i]+end, NULL, 1);
			}
//.........这里部分代码省略.........
开发者ID:CornellCAC,项目名称:slurm,代码行数:101,代码来源:resource_functions.c


示例15: sacctmgr_list_account

extern int sacctmgr_list_account(int argc, char *argv[])
{
    int rc = SLURM_SUCCESS;
    slurmdb_account_cond_t *acct_cond =
        xmalloc(sizeof(slurmdb_account_cond_t));
    List acct_list;
    int i=0, cond_set=0, prev_set=0;
    ListIterator itr = NULL;
    ListIterator itr2 = NULL;
    slurmdb_account_rec_t *acct = NULL;
    slurmdb_association_rec_t *assoc = NULL;

    int field_count = 0;

    print_field_t *field = NULL;

    List format_list = list_create(slurm_destroy_char);
    List print_fields_list; /* types are of print_field_t */

    acct_cond->with_assocs = with_assoc_flag;

    for (i=0; i<argc; i++) {
        int command_len = strlen(argv[i]);
        if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))
                || !strncasecmp(argv[i], "Set", MAX(command_len, 3)))
            i++;
        prev_set = _set_cond(&i, argc, argv, acct_cond, format_list);
        cond_set |=  prev_set;
    }

    if (exit_code) {
        slurmdb_destroy_account_cond(acct_cond);
        list_destroy(format_list);
        return SLURM_ERROR;
    } else if (!list_count(format_list)) {
        slurm_addto_char_list(format_list, "Acc,Des,O");
        if (acct_cond->with_assocs)
            slurm_addto_char_list(format_list,
                                  "Cl,ParentN,U,Share,GrpJ,GrpN,"
                                  "GrpCPUs,GrpMEM,GrpS,GrpWall,GrpCPUMins,"
                                  "MaxJ,MaxN,MaxCPUs,MaxS,MaxW,"
                                  "MaxCPUMins,QOS,DefaultQOS");

        if (acct_cond->with_coords)
            slurm_addto_char_list(format_list, "Coord");

    }

    if (!acct_cond->with_assocs && cond_set > 1) {
        if (!commit_check("You requested options that are only vaild "
                          "when querying with the withassoc option.\n"
                          "Are you sure you want to continue?")) {
            printf("Aborted\n");
            list_destroy(format_list);
            slurmdb_destroy_account_cond(acct_cond);
            return SLURM_SUCCESS;
        }
    }

    print_fields_list = sacctmgr_process_format_list(format_list);
    list_destroy(format_list);

    if (exit_code) {
        slurmdb_destroy_account_cond(acct_cond);
        list_destroy(print_fields_list);
        return SLURM_ERROR;
    }

    acct_list = acct_storage_g_get_accounts(db_conn, my_uid, acct_cond);
    slurmdb_destroy_account_cond(acct_cond);

    if (!acct_list) {
        exit_code=1;
        fprintf(stderr, " Problem with query.\n");
        list_destroy(print_fields_list);
        return SLURM_ERROR;
    }

    itr = list_iterator_create(acct_list);
    itr2 = list_iterator_create(print_fields_list);
    print_fields_header(print_fields_list);

    field_count = list_count(print_fields_list);

    while((acct = list_next(itr))) {
        if (acct->assoc_list) {
            ListIterator itr3 =
                list_iterator_create(acct->assoc_list);
            while((assoc = list_next(itr3))) {
                int curr_inx = 1;
                while((field = list_next(itr2))) {
                    switch(field->type) {
                    case PRINT_ACCT:
                        field->print_routine(
                            field, acct->name,
                            (curr_inx ==
                             field_count));
                        break;
                    case PRINT_COORDS:
                        field->print_routine(
//.........这里部分代码省略.........
开发者ID:schelcj,项目名称:slurm,代码行数:101,代码来源:account_functions.c


示例16: sacctmgr_list_res

extern int sacctmgr_list_res(int argc, char *argv[])

{
	int rc = SLURM_SUCCESS;
	slurmdb_res_cond_t *res_cond = xmalloc(sizeof(slurmdb_res_cond_t));
 	int i=0;
	ListIterator itr = NULL;
	ListIterator itr2 = NULL;
	slurmdb_res_rec_t *res = NULL;
	slurmdb_clus_res_rec_t *clus_res = NULL;
	List res_list = NULL;
	int field_count = 0;
	List format_list = list_create(slurm_destroy_char);
	List print_fields_list; /* types are of print_field_t */

	slurmdb_init_res_cond(res_cond, 0);

	for (i=0; i<argc; i++) {
		int command_len = strlen(argv[i]);
		if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))
		    || !strncasecmp(argv[i], "Set", MAX(command_len, 3)))
			i++;
		_set_res_cond(&i, argc, argv, res_cond, format_list);
	}

	if (exit_code) {
		slurmdb_destroy_res_cond(res_cond);
		FREE_NULL_LIST(format_list);
		return SLURM_ERROR;
	} else if (!list_count(format_list)) {
		slurm_addto_char_list(
			format_list,
			"Name,Server,Type,Count,Used");
		if (res_cond->with_clusters)
			slurm_addto_char_list(
				format_list, "Cluster,Allowed");
	}

	print_fields_list = sacctmgr_process_format_list(format_list);
	FREE_NULL_LIST(format_list);

	if (exit_code) {
		FREE_NULL_LIST(print_fields_list);
		return SLURM_ERROR;
	}
	res_list = acct_storage_g_get_res(db_conn, my_uid, res_cond);
	slurmdb_destroy_res_cond(res_cond);

	if (!res_list) {
		exit_code=1;
		fprintf(stderr, " Problem with query.\n");
		FREE_NULL_LIST(print_fields_list);
		return SLURM_ERROR;
	}
	itr = list_iterator_create(res_list);
	itr2 = list_iterator_create(print_fields_list);
	print_fields_header(print_fields_list);

	field_count = list_count(print_fields_list);
	while ((res = list_next(itr))) {
		if (res_cond->with_clusters && res->clus_res_list
		    && list_count(res-> 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ slurm_atoul函数代码示例发布时间:2022-05-30
下一篇:
C++ slurm_acct_storage_init函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap