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