/****** sge_resource_quota_qmaster/rqs_mod() ************************************** * NAME * rqs_mod() -- gdi callback function for modifing resource quota sets * * SYNOPSIS * int rqs_mod(lList **alpp, lListElem *new_rqs, lListElem *rqs, int add, * const char *ruser, const char *rhost, gdi_object_t *object, int * sub_command, monitoring_t *monitor) * * FUNCTION * This function is called from the framework that * add/modify/delete generic gdi objects. * The purpose of this function is it to add new rqs * objects or modify existing resource quota sets. * * INPUTS * lList **alpp - reference to an answer list * lListElem *new_rqs - if a new rqs object will be created by this * function, then new_rqs is a newly initialized * CULL object. * if this function was called due to a modify request * than new_rqs will contain the old data * lListElem *rqs - a reduced rqs object which contains all * necessary information to create a new object * or modify parts of an existing one * int add - 1 if a new element should be added to the master list * 0 to modify an existing object * const char *ruser - username who invoked this gdi request * const char *rhost - hostname of where the gdi request was invoked * gdi_object_t *object - structure of the gdi framework which contains * additional information to perform the request * int sub_command - how should we handle sublist elements * SGE_GDI_CHANGE - modify sublist elements * SGE_GDI_APPEND - add elements to a sublist * SGE_GDI_REMOVE - remove sublist elements * SGE_GDI_SET - replace the complete sublist * monitoring_t *monitor - monitoring structure * * RESULT * int - 0 on success * STATUS_EUNKNOWN if an error occured * * NOTES * MT-NOTE: rqs_mod() is MT safe *******************************************************************************/ int rqs_mod(sge_gdi_ctx_class_t *ctx, lList **alpp, lListElem *new_rqs, lListElem *rqs, int add, const char *ruser, const char *rhost, gdi_object_t *object, int sub_command, monitoring_t *monitor) { const char *rqs_name = NULL; bool rules_changed = false; bool previous_enabled = (bool)lGetBool(new_rqs, RQS_enabled); DENTER(TOP_LAYER, "rqs_mod"); /* ---- RQS_name */ if (add) { if (attr_mod_str(alpp, rqs, new_rqs, RQS_name, object->object_name)) goto ERROR; } rqs_name = lGetString(new_rqs, RQS_name); /* Name has to be a valid name */ if (add && verify_str_key(alpp, rqs_name, MAX_VERIFY_STRING, MSG_OBJ_RQS, KEY_TABLE) != STATUS_OK) { goto ERROR; } /* ---- RQS_description */ attr_mod_zerostr(rqs, new_rqs, RQS_description, "description"); /* ---- RQS_enabled */ attr_mod_bool(rqs, new_rqs, RQS_enabled, "enabled"); /* ---- RQS_rule */ if (lGetPosViaElem(rqs, RQS_rule, SGE_NO_ABORT)>=0) { rules_changed = true; if (SGE_GDI_IS_SUBCOMMAND_SET(sub_command, SGE_GDI_SET_ALL)) { normalize_sublist(rqs, RQS_rule); attr_mod_sub_list(alpp, new_rqs, RQS_rule, RQS_name, rqs, sub_command, SGE_ATTR_RQSRULES, SGE_OBJ_RQS, 0, NULL); } else { /* *attr cases */ lList *rule_list = lGetList(rqs, RQS_rule); lListElem *rule = NULL; for_each(rule, rule_list) { lList *new_rule_list = lGetList(new_rqs, RQS_rule); lListElem *new_rule = NULL; new_rule = rqs_rule_locate(new_rule_list, lGetString(rule, RQR_name)); if (new_rule != NULL) { /* ---- RQR_limit */ attr_mod_sub_list(alpp, new_rule, RQR_limit, RQRL_name, rule, sub_command, SGE_ATTR_RQSRULES, SGE_OBJ_RQS, 0, NULL); } else { ERROR((SGE_EVENT, SFNMAX, MSG_RESOURCEQUOTA_NORULEDEFINED)); answer_list_add(alpp, SGE_EVENT, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR); goto ERROR; } } }
/****** qmaster/ckpt/ckpt_mod() *********************************************** * NAME * ckpt_mod -- add/modify ckpt object in Master_Ckpt_List * * SYNOPSIS * int ckpt_mod (lList **alpp, lListElem *new_ckpt, lListElem *ckpt, * int add, char *ruser, char *rhost, gdi_object_t *object, * int sub_command); * * FUNCTION * This function will be called from the framework which will * add/modify/delete generic gdi objects. * The purpose of this function is it to add new ckpt * objects or modify existing checkpointing interfaces. * * * INPUTS * alpp - reference to an answer list. * new_ckpt - if a new ckpt object will be created by this * function, than new_ckpt is new uninitialized * CULL object * if this function was called due to a modify request * than new_ckpt will contain the old data * (see add parameter) * ckpt - a reduced ckpt object which contains all * necessary information to create a new object * or modify parts of an existing one * add - 1 if a new element should be added to the master list * 0 to modify an existing object * ruser - username of person who invoked this gdi request * rhost - hostname of the host where someone initiated an gdi call * object - structure of the gdi framework which contains * additional information to perform the request * (function pointers, names, CULL-types) * sub_command - how should we handle sublist elements * SGE_GDI_CHANGE - modify sublist elements * SGE_GDI_APPEND - add elements to a sublist * SGE_GDI_REMOVE - remove sublist elements * SGE_GDI_SET - replace the complete sublist * * RESULT * [alpp] - error messages will be added to this list * 0 - success * STATUS_EUNKNOWN - an error occured ******************************************************************************/ int ckpt_mod(sge_gdi_ctx_class_t *ctx, lList **alpp, lListElem *new_ckpt, lListElem *ckpt, int add, const char *ruser, const char *rhost, gdi_object_t *object, int sub_command, monitoring_t *monitor) { const char *ckpt_name; DENTER(TOP_LAYER, "ckpt_mod"); /* ---- CK_name */ if (lGetPosViaElem(ckpt, CK_name, SGE_NO_ABORT) >= 0) { if (add) { if (attr_mod_str(alpp, ckpt, new_ckpt, CK_name, SGE_ATTR_CKPT_NAME)) { goto ERROR; } } ckpt_name = lGetString(new_ckpt, CK_name); if (add && verify_str_key( alpp, ckpt_name, MAX_VERIFY_STRING, SGE_ATTR_CKPT_NAME, KEY_TABLE) != STATUS_OK) { DEXIT; return STATUS_EUNKNOWN; } } else { ERROR((SGE_EVENT, MSG_SGETEXT_MISSINGCULLFIELD_SS, lNm2Str(CK_name), SGE_FUNC)); answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR); goto ERROR; } /* ---- CK_interface */ attr_mod_str(alpp, ckpt, new_ckpt, CK_interface, SGE_ATTR_INTERFACE); /* ---- CK_ckpt_command */ attr_mod_str(alpp, ckpt, new_ckpt, CK_ckpt_command, SGE_ATTR_CKPT_COMMAND); /* ---- CK_migr_command */ attr_mod_str(alpp, ckpt, new_ckpt, CK_migr_command, SGE_ATTR_MIGR_COMMAND); /* ---- CK_rest_command */ attr_mod_str(alpp, ckpt, new_ckpt, CK_rest_command, SGE_ATTR_RESTART_COMMAND); /* ---- CK_ckpt_dir */ attr_mod_str(alpp, ckpt, new_ckpt, CK_ckpt_dir, SGE_ATTR_CKPT_DIR); /* ---- CK_when */ if (lGetPosViaElem(ckpt, CK_when, SGE_NO_ABORT) >= 0) { int new_flags, flags; new_flags = sge_parse_checkpoint_attr(lGetString(new_ckpt, CK_when)); flags = sge_parse_checkpoint_attr(lGetString(ckpt, CK_when)); if (SGE_GDI_IS_SUBCOMMAND_SET(sub_command, SGE_GDI_APPEND) || SGE_GDI_IS_SUBCOMMAND_SET(sub_command, SGE_GDI_CHANGE)) { new_flags |= flags; } else if (SGE_GDI_IS_SUBCOMMAND_SET(sub_command, SGE_GDI_REMOVE)) { new_flags &= (~flags); } else { new_flags = flags; } if (is_checkpoint_when_valid(new_flags)) { lSetString(new_ckpt, CK_when, get_checkpoint_when(new_flags)); } else { ERROR((SGE_EVENT, MSG_CKPT_INVALIDWHENATTRIBUTE_S, ckpt_name)); answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR); goto ERROR; } } /* ---- CK_signal */ attr_mod_str(alpp, ckpt, new_ckpt, CK_signal, SGE_ATTR_SIGNAL); /* ---- CK_clean_command */ attr_mod_str(alpp, ckpt, new_ckpt, CK_clean_command, SGE_ATTR_CLEAN_COMMAND); /* ---- CK_job_pid */ attr_mod_ulong(ckpt, new_ckpt, CK_job_pid, "job_pid"); /* validate ckpt data */ if (ckpt_validate(new_ckpt, alpp) != STATUS_OK) { goto ERROR; } DEXIT; return 0; ERROR: DEXIT; return STATUS_EUNKNOWN; }