00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "generalAdmin.h"
00011 #include "reGlobalsExtern.h"
00012 #include "icatHighLevelRoutines.h"
00013
00014
00015
00016 #include <iostream>
00017 #include <string>
00018
00019
00020
00021 #include "eirods_children_parser.h"
00022 #include "eirods_string_tokenize.h"
00023
00024
00025 int
00026 rsGeneralAdmin (rsComm_t *rsComm, generalAdminInp_t *generalAdminInp )
00027 {
00028 rodsServerHost_t *rodsServerHost;
00029 int status;
00030
00031 rodsLog(LOG_DEBUG, "generalAdmin");
00032
00033 status = getAndConnRcatHost(rsComm, MASTER_RCAT, NULL, &rodsServerHost);
00034 if (status < 0) {
00035 return(status);
00036 }
00037
00038 if (rodsServerHost->localFlag == LOCAL_HOST) {
00039 #ifdef RODS_CAT
00040 status = _rsGeneralAdmin (rsComm, generalAdminInp);
00041 #else
00042 status = SYS_NO_RCAT_SERVER_ERR;
00043 #endif
00044 }
00045 else {
00046 status = rcGeneralAdmin(rodsServerHost->conn,
00047 generalAdminInp);
00048 if (status < 0) {
00049 replErrorStack (rodsServerHost->conn->rError, &rsComm->rError);
00050 }
00051 }
00052 if (status < 0) {
00053 rodsLog (LOG_NOTICE,
00054 "rsGeneralAdmin: rcGeneralAdmin error %d", status);
00055 }
00056 return (status);
00057 }
00058
00059 #ifdef RODS_CAT
00060 int
00061 _addChildToResource(
00062 generalAdminInp_t* _generalAdminInp,
00063 ruleExecInfo_t _rei2,
00064 rsComm_t* _rsComm)
00065 {
00066 int result = 0;
00067 rescInfo_t rescInfo;
00068 memset(&rescInfo, 0, sizeof(rescInfo));
00069 strncpy(rescInfo.rescName, _generalAdminInp->arg2, sizeof rescInfo.rescName);
00070 std::string rescChild(_generalAdminInp->arg3);
00071 std::string rescContext(_generalAdminInp->arg4);
00072 eirods::children_parser parser;
00073 parser.add_child(rescChild, rescContext);
00074 std::string rescChildren;
00075 parser.str(rescChildren);
00076 strncpy(rescInfo.rescChildren, rescChildren.c_str(), sizeof rescInfo.rescChildren);
00077
00078 rodsLog(LOG_NOTICE, "rsGeneralAdmin add child \"%s\" to resource \"%s\"", rescChildren.c_str(),
00079 rescInfo.rescName);
00080
00081 if((result = chlAddChildResc( _rsComm, &rescInfo)) != 0) {
00082 chlRollback(_rsComm);
00083 }
00084
00085 return result;
00086 }
00087
00088 int
00089 _removeChildFromResource(
00090 generalAdminInp_t* _generalAdminInp,
00091 ruleExecInfo_t _rei2,
00092 rsComm_t* _rsComm)
00093 {
00094 int result = 0;
00095 rescInfo_t rescInfo;
00096
00097 strncpy(rescInfo.rescName, _generalAdminInp->arg2, sizeof rescInfo.rescName);
00098 strncpy(rescInfo.rescChildren, _generalAdminInp->arg3, sizeof rescInfo.rescChildren);
00099
00100 rodsLog(LOG_NOTICE, "rsGeneralAdmin remove child \"%s\" from resource \"%s\"", rescInfo.rescChildren,
00101 rescInfo.rescName);
00102
00103 if((result = chlDelChildResc( _rsComm, &rescInfo)) != 0) {
00104 chlRollback(_rsComm);
00105 }
00106
00107 return result;
00108 }
00109
00110
00111 int
00112 _addResource(
00113 generalAdminInp_t* _generalAdminInp,
00114 ruleExecInfo_t _rei2,
00115 rsComm_t* _rsComm)
00116 {
00117 int result = 0;
00118 rescInfo_t rescInfo;
00119 bzero( &rescInfo, sizeof( rescInfo ) );
00120
00121 static const unsigned int argc = 7;
00122 char *args[argc];
00123
00124
00125
00126 std::string loc_path( _generalAdminInp->arg4 );
00127
00128 if( !loc_path.empty() ) {
00129
00130
00131 std::vector< std::string > tok;
00132 eirods::string_tokenize( loc_path, ":", tok );
00133
00134
00135
00136 if( 2 == tok.size() ) {
00137
00138
00139 strncpy( rescInfo.rescLoc, tok[0].c_str(), sizeof rescInfo.rescLoc );
00140 strncpy( rescInfo.rescVaultPath, tok[1].c_str(), sizeof rescInfo.rescVaultPath );
00141 } else {
00142 rodsLog( LOG_ERROR, "_addResource - unexpected number of tokens for location:vault_path pair [%d]", tok.size() );
00143 rodsLog( LOG_ERROR, "_addResource - location:path string [%s]", loc_path.c_str() );
00144 }
00145 } else {
00146 strncpy( rescInfo.rescLoc, eirods::EMPTY_RESC_HOST.c_str(), sizeof rescInfo.rescLoc );
00147 strncpy( rescInfo.rescVaultPath, eirods::EMPTY_RESC_PATH.c_str(), sizeof rescInfo.rescVaultPath );
00148
00149 }
00150
00151
00152
00153
00154 strncpy(rescInfo.rescName, _generalAdminInp->arg2, sizeof rescInfo.rescName);
00155 strncpy(rescInfo.rescType, _generalAdminInp->arg3, sizeof rescInfo.rescType);
00156 strncpy(rescInfo.rescClass, "cache", sizeof rescInfo.rescClass );
00157 strncpy(rescInfo.rescContext, _generalAdminInp->arg5, sizeof rescInfo.rescContext);
00158 strncpy(rescInfo.zoneName, _generalAdminInp->arg6, sizeof rescInfo.zoneName);
00159 strncpy(rescInfo.rescChildren, "", 1);
00160 strncpy(rescInfo.rescParent, "", 1);
00161
00162
00163
00164 args[0] = rescInfo.rescName;
00165 args[1] = rescInfo.rescType;
00166 args[2] = rescInfo.rescClass;
00167 args[3] = rescInfo.rescLoc;
00168 args[4] = rescInfo.rescVaultPath;
00169 args[5] = rescInfo.rescContext;
00170 args[6] = rescInfo.zoneName;
00171
00172
00173
00174 if((result = applyRuleArg("acPreProcForCreateResource", args, argc, &_rei2, NO_SAVE_REI)) < 0) {
00175 if (_rei2.status < 0) {
00176 result = _rei2.status;
00177 }
00178 rodsLog( LOG_ERROR, "rsGeneralAdmin:acPreProcForCreateResource error for %s,stat=%d",
00179 rescInfo.rescName, result );
00180
00181 }
00182
00183
00184
00185 else if((result = chlRegResc( _rsComm, &rescInfo )) != 0) {
00186 chlRollback( _rsComm );
00187 }
00188
00189
00190
00191
00192 else if((result = applyRuleArg( "acPostProcForCreateResource", args, argc, &_rei2, NO_SAVE_REI )) < 0) {
00193 if (_rei2.status < 0) {
00194 result = _rei2.status;
00195 }
00196 rodsLog( LOG_ERROR, "rsGeneralAdmin:acPostProcForCreateResource error for %s,stat=%d",
00197 rescInfo.rescName, result );
00198 }
00199
00200
00201 return result;
00202 }
00203
00204 int
00205 _rsGeneralAdmin(rsComm_t *rsComm, generalAdminInp_t *generalAdminInp )
00206 {
00207 int status;
00208 userInfo_t userInfo;
00209 collInfo_t collInfo;
00210 rescInfo_t rescInfo;
00211 ruleExecInfo_t rei;
00212 char *args[MAX_NUM_OF_ARGS_IN_ACTION];
00213 int i, argc;
00214 ruleExecInfo_t rei2;
00215
00216 memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t));
00217 rei2.rsComm = rsComm;
00218 if (rsComm != NULL) {
00219 rei2.uoic = &rsComm->clientUser;
00220 rei2.uoip = &rsComm->proxyUser;
00221 }
00222
00223
00224 rodsLog (LOG_DEBUG,
00225 "_rsGeneralAdmin arg0=%s",
00226 generalAdminInp->arg0);
00227
00228 if (strcmp(generalAdminInp->arg0,"pvacuum")==0) {
00229 char *args[2];
00230 char argStr[100];
00231 memset((char*)&rei,0,sizeof(rei));
00232 rei.rsComm = rsComm;
00233 rei.uoic = &rsComm->clientUser;
00234 rei.uoip = &rsComm->proxyUser;
00235 rstrcpy(argStr,"",sizeof argStr);
00236 if (atoi(generalAdminInp->arg1) > 0) {
00237 snprintf(argStr,sizeof argStr,"<ET>%s</ET>",generalAdminInp->arg1);
00238 }
00239 if (atoi(generalAdminInp->arg2) > 0) {
00240 strncat(argStr,"<EF>",100);
00241 strncat(argStr,generalAdminInp->arg2,100);
00242 strncat(argStr,"</EF>",100);
00243 }
00244 args[0]=argStr;
00245 status = applyRuleArg("acVacuum", args, 1, &rei, SAVE_REI);
00246 return(status);
00247 }
00248
00249 if (strcmp(generalAdminInp->arg0,"add")==0) {
00250 if (strcmp(generalAdminInp->arg1,"user")==0) {
00251
00252 char *args[2];
00253 memset((char*)&rei,0,sizeof(rei));
00254 rei.rsComm = rsComm;
00255 strncpy(userInfo.userName, generalAdminInp->arg2,
00256 sizeof userInfo.userName);
00257 strncpy(userInfo.userType, generalAdminInp->arg3,
00258 sizeof userInfo.userType);
00259 strncpy(userInfo.rodsZone, generalAdminInp->arg4,
00260 sizeof userInfo.rodsZone);
00261 strncpy(userInfo.authInfo.authStr, generalAdminInp->arg5,
00262 sizeof userInfo.authInfo.authStr);
00263 rei.uoio = &userInfo;
00264 rei.uoic = &rsComm->clientUser;
00265 rei.uoip = &rsComm->proxyUser;
00266 status = applyRuleArg("acCreateUser", args, 0, &rei, SAVE_REI);
00267 if (status != 0) chlRollback(rsComm);
00268 return(status);
00269 }
00270 if (strcmp(generalAdminInp->arg1,"dir")==0) {
00271 memset((char*)&collInfo,0,sizeof(collInfo));
00272 strncpy(collInfo.collName, generalAdminInp->arg2,
00273 sizeof collInfo.collName);
00274 if (strlen(generalAdminInp->arg3) > 0) {
00275 strncpy(collInfo.collOwnerName, generalAdminInp->arg3,
00276 sizeof collInfo.collOwnerName);
00277 status = chlRegCollByAdmin(rsComm, &collInfo);
00278 if (status == 0) {
00279 if( !chlCommit( rsComm ) ) {
00280
00281 }
00282 }
00283 }
00284 else {
00285 status = chlRegColl(rsComm, &collInfo);
00286 }
00287 if (status != 0) chlRollback(rsComm);
00288 return(status);
00289 }
00290 if (strcmp(generalAdminInp->arg1,"zone")==0) {
00291 status = chlRegZone(rsComm, generalAdminInp->arg2,
00292 generalAdminInp->arg3,
00293 generalAdminInp->arg4,
00294 generalAdminInp->arg5);
00295 if (status == 0) {
00296 if (strcmp(generalAdminInp->arg3,"remote")==0) {
00297 memset((char*)&collInfo,0,sizeof(collInfo));
00298 strncpy(collInfo.collName, "/", sizeof collInfo.collName);
00299 strncat(collInfo.collName, generalAdminInp->arg2,
00300 sizeof collInfo.collName);
00301 strncpy(collInfo.collOwnerName, rsComm->proxyUser.userName,
00302 sizeof collInfo.collOwnerName);
00303 status = chlRegCollByAdmin(rsComm, &collInfo);
00304 if (status == 0) {
00305 chlCommit(rsComm);
00306 }
00307 }
00308 }
00309 return(status);
00310 }
00311
00312
00313
00314 if (strcmp(generalAdminInp->arg1,"resource")==0) {
00315 return _addResource(generalAdminInp, rei2, rsComm);
00316 }
00317
00318
00319 if (strcmp(generalAdminInp->arg1, "childtoresc")==0) {
00320 return _addChildToResource(generalAdminInp, rei2, rsComm);
00321 }
00322
00323 if (strcmp(generalAdminInp->arg1,"token")==0) {
00324
00325 args[0] = generalAdminInp->arg2;
00326 args[1] = generalAdminInp->arg3;
00327 args[2] = generalAdminInp->arg4;
00328 args[3] = generalAdminInp->arg5;
00329 args[4] = generalAdminInp->arg6;
00330 args[5] = generalAdminInp->arg7;
00331 argc = 6;
00332 i = applyRuleArg("acPreProcForCreateToken", args, argc, &rei2, NO_SAVE_REI);
00333 if (i < 0) {
00334 if (rei2.status < 0) {
00335 i = rei2.status;
00336 }
00337 rodsLog (LOG_ERROR,
00338 "rsGeneralAdmin:acPreProcForCreateToken error for %s.%s=%s,stat=%d",
00339 args[0],args[1],args[2],i);
00340 return i;
00341 }
00342
00343
00344 status = chlRegToken(rsComm, generalAdminInp->arg2,
00345 generalAdminInp->arg3,
00346 generalAdminInp->arg4,
00347 generalAdminInp->arg5,
00348 generalAdminInp->arg6,
00349 generalAdminInp->arg7);
00350
00351 if (status == 0) {
00352 i = applyRuleArg("acPostProcForCreateToken", args, argc, &rei2, NO_SAVE_REI);
00353 if (i < 0) {
00354 if (rei2.status < 0) {
00355 i = rei2.status;
00356 }
00357 rodsLog (LOG_ERROR,
00358 "rsGeneralAdmin:acPostProcForCreateToken error for %s.%s=%s,stat=%d",
00359 args[0],args[1],args[2],i);
00360 return i;
00361 }
00362 }
00363
00364
00365 if (status != 0) chlRollback(rsComm);
00366 return(status);
00367 }
00368
00369 if (strcmp(generalAdminInp->arg1,"specificQuery")==0) {
00370 status = chlAddSpecificQuery(rsComm, generalAdminInp->arg2,
00371 generalAdminInp->arg3);
00372 return(status);
00373 }
00374
00375 }
00376
00377 if (strcmp(generalAdminInp->arg0,"modify")==0) {
00378 if (strcmp(generalAdminInp->arg1,"user")==0) {
00379
00380 args[0] = generalAdminInp->arg2;
00381 args[1] = generalAdminInp->arg3;
00382 #if 0
00383 args[2] = generalAdminInp->arg4;
00384 #else
00385
00386
00387
00388
00389
00390 args[2] = "obfuscatedPw";
00391 #endif
00392 argc = 3;
00393 i = applyRuleArg("acPreProcForModifyUser",args,argc, &rei2, NO_SAVE_REI);
00394 if (i < 0) {
00395 if (rei2.status < 0) {
00396 i = rei2.status;
00397 }
00398 rodsLog (LOG_ERROR,
00399 "rsGeneralAdmin:acPreProcForModifyUser error for %s and option %s,stat=%d",
00400 args[0],args[1], i);
00401 return i;
00402 }
00403
00404
00405 status = chlModUser(rsComm, generalAdminInp->arg2,
00406 generalAdminInp->arg3, generalAdminInp->arg4);
00407
00408
00409 if (status == 0) {
00410 i = applyRuleArg("acPostProcForModifyUser",args,argc, &rei2, NO_SAVE_REI);
00411 if (i < 0) {
00412 if (rei2.status < 0) {
00413 i = rei2.status;
00414 }
00415 rodsLog (LOG_ERROR,
00416 "rsGeneralAdmin:acPostProcForModifyUser error for %s and option %s,stat=%d",
00417 args[0],args[1], i);
00418 return i;
00419 }
00420 }
00421
00422 if (status != 0) chlRollback(rsComm);
00423 return(status);
00424 }
00425 if (strcmp(generalAdminInp->arg1,"group")==0) {
00426
00427 args[0] = generalAdminInp->arg2;
00428 args[1] = generalAdminInp->arg3;
00429 args[2] = generalAdminInp->arg4;
00430 args[3] = generalAdminInp->arg5;
00431 argc = 4;
00432 i = applyRuleArg("acPreProcForModifyUserGroup",args,argc, &rei2, NO_SAVE_REI);
00433 if (i < 0) {
00434 if (rei2.status < 0) {
00435 i = rei2.status;
00436 }
00437 rodsLog (LOG_ERROR,
00438 "rsGeneralAdmin:acPreProcForModifyUserGroup error for %s and option %s,stat=%d",
00439 args[0],args[1], i);
00440 return i;
00441 }
00442
00443
00444 status = chlModGroup(rsComm, generalAdminInp->arg2,
00445 generalAdminInp->arg3, generalAdminInp->arg4,
00446 generalAdminInp->arg5);
00447
00448 if (status == 0) {
00449 i = applyRuleArg("acPostProcForModifyUserGroup",args,argc, &rei2, NO_SAVE_REI);
00450 if (i < 0) {
00451 if (rei2.status < 0) {
00452 i = rei2.status;
00453 }
00454 rodsLog (LOG_ERROR,
00455 "rsGeneralAdmin:acPostProcForModifyUserGroup error for %s and option %s,stat=%d",
00456 args[0],args[1], i);
00457 return i;
00458 }
00459 }
00460
00461
00462 if (status != 0) chlRollback(rsComm);
00463 return(status);
00464 }
00465 if (strcmp(generalAdminInp->arg1,"zone")==0) {
00466 status = chlModZone(rsComm, generalAdminInp->arg2,
00467 generalAdminInp->arg3, generalAdminInp->arg4);
00468 if (status != 0) chlRollback(rsComm);
00469 if (status == 0 &&
00470 strcmp(generalAdminInp->arg3, "name")==0) {
00471 char oldName[MAX_NAME_LEN];
00472 char newName[MAX_NAME_LEN];
00473 strncpy(oldName, "/", sizeof oldName);
00474 strncat(oldName, generalAdminInp->arg2, sizeof oldName);
00475 strncpy(newName, generalAdminInp->arg4, sizeof newName);
00476 status = chlRenameColl(rsComm, oldName, newName);
00477 if (status==0) chlCommit(rsComm);
00478 }
00479 return(status);
00480 }
00481 if (strcmp(generalAdminInp->arg1,"localzonename")==0) {
00482
00483 char *args[2];
00484 memset((char*)&rei,0,sizeof(rei));
00485 rei.rsComm = rsComm;
00486 memset((char*)&rei,0,sizeof(rei));
00487 rei.rsComm = rsComm;
00488 rei.uoic = &rsComm->clientUser;
00489 rei.uoip = &rsComm->proxyUser;
00490 args[0]=generalAdminInp->arg2;
00491 args[1]=generalAdminInp->arg3;
00492 status = applyRuleArg("acRenameLocalZone", args, 2, &rei,
00493 NO_SAVE_REI);
00494 return(status);
00495 }
00496 if (strcmp(generalAdminInp->arg1,"resourcedatapaths")==0) {
00497 status = chlModRescDataPaths(rsComm, generalAdminInp->arg2,
00498 generalAdminInp->arg3, generalAdminInp->arg4,
00499 generalAdminInp->arg5);
00500
00501 return(status);
00502 }
00503 if (strcmp(generalAdminInp->arg1,"resource")==0) {
00504
00505
00506 args[0] = generalAdminInp->arg2;
00507 args[1] = generalAdminInp->arg3;
00508 args[2] = generalAdminInp->arg4;
00509 argc = 3;
00510 i = applyRuleArg("acPreProcForModifyResource",args,argc, &rei2, NO_SAVE_REI);
00511 if (i < 0) {
00512 if (rei2.status < 0) {
00513 i = rei2.status;
00514 }
00515 rodsLog (LOG_ERROR,
00516 "rsGeneralAdmin:acPreProcForModifyResource error for %s and option %s,stat=%d",
00517 args[0],args[1], i);
00518 return i;
00519 }
00520
00521
00522 status = chlModResc(rsComm, generalAdminInp->arg2,
00523 generalAdminInp->arg3, generalAdminInp->arg4);
00524
00525
00526 if (status == 0) {
00527 i = applyRuleArg("acPostProcForModifyResource",args,argc, &rei2, NO_SAVE_REI);
00528 if (i < 0) {
00529 if (rei2.status < 0) {
00530 i = rei2.status;
00531 }
00532 rodsLog (LOG_ERROR,
00533 "rsGeneralAdmin:acPostProcForModifyResource error for %s and option %s,stat=%d",
00534 args[0],args[1], i);
00535 return i;
00536 }
00537 }
00538
00539
00540 if (status != 0) chlRollback(rsComm);
00541 return(status);
00542 }
00543 if (strcmp(generalAdminInp->arg1,"resourcegroup")==0) {
00544
00545 args[0] = generalAdminInp->arg2;
00546 args[1] = generalAdminInp->arg3;
00547 args[2] = generalAdminInp->arg4;
00548 argc = 3;
00549 i = applyRuleArg("acPreProcForModifyResourceGroup",args,argc, &rei2, NO_SAVE_REI);
00550 if (i < 0) {
00551 if (rei2.status < 0) {
00552 i = rei2.status;
00553 }
00554 rodsLog (LOG_ERROR,
00555 "rsGeneralAdmin:acPreProcForModifyResourceGroup error for %s and option %s,stat=%d",
00556 args[0],args[1], i);
00557 return i;
00558 }
00559
00560
00561 status = chlModRescGroup(rsComm, generalAdminInp->arg2,
00562 generalAdminInp->arg3, generalAdminInp->arg4);
00563
00564
00565 if (status == 0) {
00566 i = applyRuleArg("acPostProcForModifyResourceGroup",args,argc, &rei2, NO_SAVE_REI);
00567 if (i < 0) {
00568 if (rei2.status < 0) {
00569 i = rei2.status;
00570 }
00571 rodsLog (LOG_ERROR,
00572 "rsGeneralAdmin:acPostProcForModifyResourceGroup error for %s and option %s,stat=%d",
00573 args[0],args[1], i);
00574 return i;
00575 }
00576 }
00577
00578
00579 if (status != 0) chlRollback(rsComm);
00580 return(status);
00581 }
00582 }
00583 if (strcmp(generalAdminInp->arg0,"rm")==0) {
00584 if (strcmp(generalAdminInp->arg1,"user")==0) {
00585
00586 char *args[2];
00587 memset((char*)&rei,0,sizeof(rei));
00588 rei.rsComm = rsComm;
00589 strncpy(userInfo.userName, generalAdminInp->arg2,
00590 sizeof userInfo.userName);
00591 strncpy(userInfo.rodsZone, generalAdminInp->arg3,
00592 sizeof userInfo.rodsZone);
00593 rei.uoio = &userInfo;
00594 rei.uoic = &rsComm->clientUser;
00595 rei.uoip = &rsComm->proxyUser;
00596 status = applyRuleArg("acDeleteUser", args, 0, &rei, SAVE_REI);
00597 if (status != 0) chlRollback(rsComm);
00598 return(status);
00599 }
00600 if (strcmp(generalAdminInp->arg1,"dir")==0) {
00601 memset((char*)&collInfo,0,sizeof(collInfo));
00602 strncpy(collInfo.collName, generalAdminInp->arg2,
00603 sizeof collInfo.collName);
00604 status = chlDelColl(rsComm, &collInfo);
00605 if (status != 0) chlRollback(rsComm);
00606 return(status);
00607 }
00608 if (strcmp(generalAdminInp->arg1,"resource")==0) {
00609
00610
00611
00612
00613 if ( strcmp( generalAdminInp->arg3, "--dryrun" ) == 0 ) {
00614 strncpy( rescInfo.rescName, generalAdminInp->arg2, sizeof rescInfo.rescName );
00615 rodsLog( LOG_STATUS, "Executing a dryrun of removal of resource [%s]", generalAdminInp->arg2 );
00616
00617 status = chlDelResc( rsComm, &rescInfo, 1 );
00618 if( 0 == status ) {
00619 rodsLog( LOG_STATUS, "DRYRUN REMOVING RESOURCE [%s] :: SUCCESS", generalAdminInp->arg2 );
00620 } else {
00621 rodsLog( LOG_STATUS, "DRYRUN REMOVING RESOURCE [%s] :: FAILURE", generalAdminInp->arg2 );
00622 }
00623
00624 return status;
00625 }
00626
00627
00628 strncpy(rescInfo.rescName, generalAdminInp->arg2,
00629 sizeof rescInfo.rescName);
00630
00631
00632 args[0] = rescInfo.rescName;
00633 argc = 1;
00634 i = applyRuleArg("acPreProcForDeleteResource", args, argc, &rei2, NO_SAVE_REI);
00635 if (i < 0) {
00636 if (rei2.status < 0) {
00637 i = rei2.status;
00638 }
00639 rodsLog (LOG_ERROR,
00640 "rsGeneralAdmin:acPreProcForDeleteResource error for %s,stat=%d",
00641 rescInfo.rescName,i);
00642 return i;
00643 }
00644
00645
00646 status = chlDelResc(rsComm, &rescInfo);
00647 if (status == 0) {
00648
00649 i = applyRuleArg("acPostProcForDeleteResource",args,argc, &rei2, NO_SAVE_REI);
00650 if (i < 0) {
00651 if (rei2.status < 0) {
00652 i = rei2.status;
00653 }
00654 rodsLog (LOG_ERROR,
00655 "rsGeneralAdmin:acPostProcForDeleteResource error for %s,stat=%d",
00656 rescInfo.rescName,i);
00657 return i;
00658 }
00659 }
00660
00661
00662 if (status != 0) chlRollback(rsComm);
00663 return(status);
00664 }
00665
00666
00667 if (strcmp(generalAdminInp->arg1, "childfromresc")==0) {
00668 return _removeChildFromResource(generalAdminInp, rei2, rsComm);
00669 }
00670
00671 if (strcmp(generalAdminInp->arg1,"zone")==0) {
00672 status = chlDelZone(rsComm, generalAdminInp->arg2);
00673 if (status == 0) {
00674 memset((char*)&collInfo,0,sizeof(collInfo));
00675 strncpy(collInfo.collName, "/", sizeof collInfo.collName);
00676 strncat(collInfo.collName, generalAdminInp->arg2,
00677 sizeof collInfo.collName);
00678 status = chlDelCollByAdmin(rsComm, &collInfo);
00679 }
00680 if (status == 0) {
00681 status = chlCommit(rsComm);
00682 }
00683 return(status);
00684 }
00685 if (strcmp(generalAdminInp->arg1,"token")==0) {
00686
00687
00688 args[0] = generalAdminInp->arg2;
00689 args[1] = generalAdminInp->arg3;
00690 argc = 2;
00691 i = applyRuleArg("acPreProcForDeleteToken", args, argc, &rei2, NO_SAVE_REI);
00692 if (i < 0) {
00693 if (rei2.status < 0) {
00694 i = rei2.status;
00695 }
00696 rodsLog (LOG_ERROR,
00697 "rsGeneralAdmin:acPreProcForDeleteToken error for %s.%s,stat=%d",
00698 args[0],args[1],i);
00699 return i;
00700 }
00701
00702
00703 status = chlDelToken(rsComm, generalAdminInp->arg2,
00704 generalAdminInp->arg3);
00705
00706
00707 if (status == 0) {
00708 i = applyRuleArg("acPostProcForDeleteToken", args, argc, &rei2, NO_SAVE_REI);
00709 if (i < 0) {
00710 if (rei2.status < 0) {
00711 i = rei2.status;
00712 }
00713 rodsLog (LOG_ERROR,
00714 "rsGeneralAdmin:acPostProcForDeleteToken error for %s.%s,stat=%d",
00715 args[0],args[1],i);
00716 return i;
00717 }
00718 }
00719
00720
00721 if (status != 0) chlRollback(rsComm);
00722 return(status);
00723 }
00724 if (strcmp(generalAdminInp->arg1,"unusedAVUs")==0) {
00725 status = chlDelUnusedAVUs(rsComm);
00726 return(status);
00727 }
00728 if (strcmp(generalAdminInp->arg1,"specificQuery")==0) {
00729 status = chlDelSpecificQuery(rsComm, generalAdminInp->arg2);
00730 return(status);
00731 }
00732 }
00733 if (strcmp(generalAdminInp->arg0,"calculate-usage")==0) {
00734 status = chlCalcUsageAndQuota(rsComm);
00735 return(status);
00736 }
00737 if (strcmp(generalAdminInp->arg0,"set-quota")==0) {
00738 status = chlSetQuota(rsComm,
00739 generalAdminInp->arg1,
00740 generalAdminInp->arg2,
00741 generalAdminInp->arg3,
00742 generalAdminInp->arg4);
00743
00744 return(status);
00745 }
00746 return(CAT_INVALID_ARGUMENT);
00747 }
00748 #endif