예제 #1
0
int _setup_assoc_list(void)
{
	slurmdb_update_object_t update;
	slurmdb_assoc_rec_t *assoc = NULL;

	/* make the main list */
	assoc_mgr_assoc_list =
		list_create(slurmdb_destroy_assoc_rec);
	assoc_mgr_user_list =
		list_create(slurmdb_destroy_user_rec);
	assoc_mgr_qos_list =
		list_create(slurmdb_destroy_qos_rec);

	/* we just want make it so we setup_children so just pretend
	 * we are running off cache */
	running_cache = 1;
	assoc_mgr_init(NULL, NULL, SLURM_SUCCESS);

	/* Here we make the associations we want to add to the system.
	 * We do this as an update to avoid having to do setup. */
	memset(&update, 0, sizeof(slurmdb_update_object_t));
	update.type = SLURMDB_ADD_ASSOC;
	update.objects = list_create(slurmdb_destroy_assoc_rec);

	/* root assoc */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 1;
	assoc->acct = xstrdup("root");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 2;
	assoc->parent_id = 1;
	assoc->shares_raw = 40;
	assoc->acct = xstrdup("aA");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 21;
	assoc->parent_id = 2;
	assoc->shares_raw = 30;
	assoc->acct = xstrdup("aAA");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 211;
	assoc->parent_id = 21;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 20;
	assoc->acct = xstrdup("aAA");
	assoc->user = xstrdup("uAA1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 22;
	assoc->parent_id = 2;
	assoc->shares_raw = 10;
	assoc->acct = xstrdup("aAB");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 221;
	assoc->parent_id = 22;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 25;
	assoc->acct = xstrdup("aAB");
	assoc->user = xstrdup("uAB1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 222;
	assoc->parent_id = 22;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("aAB");
	assoc->user = xstrdup("uAB2");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 3;
	assoc->parent_id = 1;
	assoc->shares_raw = 60;
	assoc->acct = xstrdup("aB");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 31;
	assoc->parent_id = 3;
	assoc->shares_raw = 25;
	assoc->acct = xstrdup("aBA");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 311;
	assoc->parent_id = 31;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 25;
	assoc->acct = xstrdup("aBA");
	assoc->user = xstrdup("uBA1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 32;
	assoc->parent_id = 3;
	assoc->shares_raw = 35;
	assoc->acct = xstrdup("aBB");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 321;
	assoc->parent_id = 32;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("aBB");
	assoc->user = xstrdup("uBB1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 4;
	assoc->parent_id = 1;
	assoc->shares_raw = 0;
	assoc->usage->usage_raw = 30;
	assoc->acct = xstrdup("aC");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 41;
	assoc->parent_id = 4;
	assoc->shares_raw = 0;
	assoc->usage->usage_raw = 30;
	assoc->acct = xstrdup("aC");
	assoc->user = xstrdup("uC1");
	list_append(update.objects, assoc);

	/* Check for proper handling of Fairshare=parent */

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 5;
	assoc->parent_id = 1;
	assoc->shares_raw = 50;
	assoc->acct = xstrdup("aD");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 51;
	assoc->parent_id = 5;
	assoc->shares_raw = SLURMDB_FS_USE_PARENT;
	assoc->usage->usage_raw = 35;
	assoc->acct = xstrdup("aDA");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 511;
	assoc->parent_id = 51;
	assoc->shares_raw = SLURMDB_FS_USE_PARENT;
	assoc->usage->usage_raw = 10;
	assoc->acct = xstrdup("aDA");
	assoc->user = xstrdup("uDA1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 512;
	assoc->parent_id = 51;
	assoc->shares_raw = 30;
	assoc->usage->usage_raw = 10;
	assoc->acct = xstrdup("aDA");
	assoc->user = xstrdup("uDA2");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 513;
	assoc->parent_id = 51;
	assoc->shares_raw = 50;
	assoc->usage->usage_raw = 25;
	assoc->acct = xstrdup("aDA");
	assoc->user = xstrdup("uDA3");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 52;
	assoc->parent_id = 5;
	assoc->shares_raw = SLURMDB_FS_USE_PARENT;
	assoc->usage->usage_raw = 20;
	assoc->acct = xstrdup("aD");
	assoc->user = xstrdup("uD1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 53;
	assoc->parent_id = 5;
	assoc->shares_raw = 40;
	assoc->usage->usage_raw = 20;
	assoc->acct = xstrdup("aD");
	assoc->user = xstrdup("uD2");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 54;
	assoc->parent_id = 5;
	assoc->shares_raw = 50;
	assoc->usage->usage_raw = 25;
	assoc->acct = xstrdup("aD");
	assoc->user = xstrdup("uD3");
	list_append(update.objects, assoc);

	/* Check for proper tie handling */

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 6;
	assoc->parent_id = 1;
	assoc->shares_raw = 10;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("aE");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 61;
	assoc->parent_id = 6;
	assoc->shares_raw = 10;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("aE");
	assoc->user = xstrdup("aE1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 62;
	assoc->parent_id = 6;
	assoc->shares_raw = 10;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("aE");
	assoc->user = xstrdup("aE2");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 7;
	assoc->parent_id = 1;
	assoc->shares_raw = 10;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("root");
	assoc->user = xstrdup("u1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 8;
	assoc->parent_id = 1;
	assoc->shares_raw = 20;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("aF");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 81;
	assoc->parent_id = 8;
	assoc->shares_raw = 10;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("aF");
	assoc->user = xstrdup("uF1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 82;
	assoc->parent_id = 8;
	assoc->shares_raw = 20;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("aF");
	assoc->user = xstrdup("uF2");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 9;
	assoc->parent_id = 1;
	assoc->shares_raw = 8;
	assoc->usage->usage_raw = 20;
	assoc->acct = xstrdup("aG");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 91;
	assoc->parent_id = 9;
	assoc->shares_raw = 10;
	assoc->usage->usage_raw = 10;
	assoc->acct = xstrdup("aG");
	assoc->user = xstrdup("uG1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 92;
	assoc->parent_id = 9;
	assoc->shares_raw = 10;
	assoc->usage->usage_raw = 10;
	assoc->acct = xstrdup("aGA");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 921;
	assoc->parent_id = 92;
	assoc->shares_raw = 20;
	assoc->usage->usage_raw = 4;
	assoc->acct = xstrdup("aGA");
	assoc->user = xstrdup("uGA1");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 921;
	assoc->parent_id = 92;
	assoc->shares_raw = 20;
	assoc->usage->usage_raw = 6;
	assoc->acct = xstrdup("aGA");
	assoc->user = xstrdup("uGA2");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 1001;
	assoc->parent_id = 1;
	assoc->shares_raw = 10;
	assoc->usage->usage_raw = 10;
	assoc->acct = xstrdup("root");
	assoc->user = xstrdup("u2");
	list_append(update.objects, assoc);

	if (assoc_mgr_update_assocs(&update, false))
		error("assoc_mgr_update_assocs: %m");
	list_destroy(update.objects);

	return SLURM_SUCCESS;
}
예제 #2
0
int _setup_assoc_list(void)
{
	slurmdb_update_object_t update;
	slurmdb_assoc_rec_t *assoc = NULL;

	/* make the main list */
	assoc_mgr_assoc_list =
		list_create(slurmdb_destroy_assoc_rec);
	assoc_mgr_user_list =
		list_create(slurmdb_destroy_user_rec);
	assoc_mgr_qos_list =
		list_create(slurmdb_destroy_qos_rec);

	/* we just want make it so we setup_children so just pretend
	 * we are running off cache */
	running_cache = 1;
	assoc_mgr_init(NULL, NULL, SLURM_SUCCESS);

	/* Here we make the associations we want to add to the system.
	 * We do this as an update to avoid having to do setup. */
	memset(&update, 0, sizeof(slurmdb_update_object_t));
	update.type = SLURMDB_ADD_ASSOC;
	update.objects = list_create(slurmdb_destroy_assoc_rec);

	/* Just so we don't have to worry about lft's and rgt's we
	 * will just append these on in order.
	 * Note: the commented out lfts and rgts as of 10-29-10 are
	 * correct.  By doing an append they go on
	 * sorted in hierarchy order.  The sort that happens inside
	 * the internal slurm code will sort alpha automatically, (You can
	 * test this by putting AccountF before AccountE.
	 */

	/* First only add the accounts */
	/* root association */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 1;
	/* assoc->lft = 1; */
	/* assoc->rgt = 28; */
	assoc->acct = xstrdup("root");
	list_append(update.objects, assoc);

	/* sub of root id 1 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 2;
	assoc->parent_id = 1;
	assoc->shares_raw = 40;
	/* assoc->lft = 2; */
	/* assoc->rgt = 13; */
	assoc->acct = xstrdup("AccountA");
	list_append(update.objects, assoc);

	/* sub of AccountA id 2 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 21;
	/* assoc->lft = 3; */
	/* assoc->rgt = 6; */
	assoc->parent_id = 2;
	assoc->shares_raw = 30;
	assoc->acct = xstrdup("AccountB");
	list_append(update.objects, assoc);

	/* sub of AccountB id 21 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 211;
	/* assoc->lft = 4; */
	/* assoc->rgt = 5; */
	assoc->parent_id = 21;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 20;
	assoc->acct = xstrdup("AccountB");
	assoc->user = xstrdup("User1");
	list_append(update.objects, assoc);

	/* sub of AccountA id 2 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 22;
	/* assoc->lft = 7; */
	/* assoc->rgt = 12; */
	assoc->parent_id = 2;
	assoc->shares_raw = 10;
	assoc->acct = xstrdup("AccountC");
	list_append(update.objects, assoc);

	/* sub of AccountC id 22 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 221;
	/* assoc->lft = 8; */
	/* assoc->rgt = 9; */
	assoc->parent_id = 22;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 25;
	assoc->acct = xstrdup("AccountC");
	assoc->user = xstrdup("User2");
	list_append(update.objects, assoc);

	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 222;
	/* assoc->lft = 10; */
	/* assoc->rgt = 11; */
	assoc->parent_id = 22;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("AccountC");
	assoc->user = xstrdup("User3");
	list_append(update.objects, assoc);

	/* sub of root id 1 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 3;
	/* assoc->lft = 14; */
	/* assoc->rgt = 23; */
	assoc->parent_id = 1;
	assoc->shares_raw = 60;
	assoc->acct = xstrdup("AccountD");
	list_append(update.objects, assoc);

	/* sub of AccountD id 3 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 31;
	/* assoc->lft = 19; */
	/* assoc->rgt = 22; */
	assoc->parent_id = 3;
	assoc->shares_raw = 25;
	assoc->acct = xstrdup("AccountE");
	list_append(update.objects, assoc);

	/* sub of AccountE id 31 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 311;
	/* assoc->lft = 20; */
	/* assoc->rgt = 21; */
	assoc->parent_id = 31;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 25;
	assoc->acct = xstrdup("AccountE");
	assoc->user = xstrdup("User4");
	list_append(update.objects, assoc);

	/* sub of AccountD id 3 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 32;
	/* assoc->lft = 15; */
	/* assoc->rgt = 18; */
	assoc->parent_id = 3;
	assoc->shares_raw = 35;
	assoc->acct = xstrdup("AccountF");
	list_append(update.objects, assoc);

	/* sub of AccountF id 32 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 321;
	/* assoc->lft = 16; */
	/* assoc->rgt = 17; */
	assoc->parent_id = 32;
	assoc->shares_raw = 1;
	assoc->usage->usage_raw = 0;
	assoc->acct = xstrdup("AccountF");
	assoc->user = xstrdup("User5");
	list_append(update.objects, assoc);

	/* sub of root id 1 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 4;
	/* assoc->lft = 24; */
	/* assoc->rgt = 27; */
	assoc->parent_id = 1;
	assoc->shares_raw = 0;
	assoc->acct = xstrdup("AccountG");
	list_append(update.objects, assoc);

	/* sub of AccountG id 4 */
	assoc = xmalloc(sizeof(slurmdb_assoc_rec_t));
	assoc->usage = create_assoc_mgr_assoc_usage();
	assoc->id = 41;
	/* assoc->lft = 25; */
	/* assoc->rgt = 26; */
	assoc->parent_id = 4;
	assoc->shares_raw = 0;
	assoc->usage->usage_raw = 30;
	assoc->acct = xstrdup("AccountG");
	assoc->user = xstrdup("User6");
	list_append(update.objects, assoc);

	if (assoc_mgr_update_assocs(&update))
		error("assoc_mgr_update_assocs: %m");
	list_destroy(update.objects);

	return SLURM_SUCCESS;
}