/** * @brief * Recover server information and attributes from server database * * @par FunctionalitY: * This function is only called on Server initialization at start up. * * @par Note: * server structure, extern struct server server, must be preallocated and * all default values should already be set. * * @see pbsd_init.c * * @return Error code * @retval 0 : On successful recovery and creation of server structure * @retval -1 : On failutre to open or read file. * */ int svr_recov_db(void) { pbs_db_conn_t *conn = (pbs_db_conn_t *) svr_db_conn; pbs_db_svr_info_t dbsvr; pbs_db_obj_info_t obj; /* load server_qs */ dbsvr.attr_list.attr_count = 0; dbsvr.attr_list.attributes = NULL; obj.pbs_db_obj_type = PBS_DB_SVR; obj.pbs_db_un.pbs_db_svr = &dbsvr; /* read in job fixed sub-structure */ if (pbs_db_load_obj(conn, &obj) != 0) goto db_err; if (db_to_svr_svr(&server, &dbsvr) != 0) goto db_err; pbs_db_reset_obj(&obj); return (0); db_err: return -1; }
/** * @brief * Recover server information and attributes from server database * * @par FunctionalitY: * This function is only called on Server initialization at start up. * * @par Note: * server structure, extern struct server server, must be preallocated and * all default values should already be set. * * @see pbsd_init.c * * @return Error code * @retval 0 : On successful recovery and creation of server structure * @retval -1 : On failutre to open or read file. * */ int svr_recov_db(void) { pbs_db_conn_t *conn = (pbs_db_conn_t *) svr_db_conn; pbs_db_svr_info_t dbsvr; pbs_db_attr_info_t attr_info; pbs_db_obj_info_t obj; /* load server_qs */ strcpy(dbsvr.sv_name, pbs_server_id); if (pbs_db_begin_trx(conn, 0, 0) !=0) goto db_err; obj.pbs_db_obj_type = PBS_DB_SVR; obj.pbs_db_un.pbs_db_svr = &dbsvr; /* read in job fixed sub-structure */ if (pbs_db_load_obj(conn, &obj) != 0) goto db_err; db_to_svr_svr(&server, &dbsvr); attr_info.parent_id = pbs_server_id; attr_info.parent_obj_type = PARENT_TYPE_SERVER; /* svr attr */ /* read in server attributes */ if (recov_attr_db(conn, &server, &attr_info, svr_attr_def, server.sv_attr, (int)SRV_ATR_LAST, 0) != 0) goto db_err; if (pbs_db_end_trx(conn, PBS_DB_COMMIT) != 0) goto db_err; return (0); db_err: log_err(-1, "svr_recov", "error on recovering server attr"); (void) pbs_db_end_trx(conn, PBS_DB_ROLLBACK); return -1; }