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_resources_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
00155 } else {
00156 if ( strlen( rescInfo.rescContext ) != 0 ) {
00157 addRErrorMsg( &_rsComm->rError, 0, "resource host:path string is empty" );
00158 }
00159 strncpy( rescInfo.rescLoc, eirods::EMPTY_RESC_HOST.c_str(), sizeof rescInfo.rescLoc );
00160 strncpy( rescInfo.rescVaultPath, eirods::EMPTY_RESC_PATH.c_str(), sizeof rescInfo.rescVaultPath );
00161
00162 }
00163
00164
00165
00166 strncpy(rescInfo.rescName, _generalAdminInp->arg2, sizeof rescInfo.rescName);
00167 strncpy(rescInfo.rescType, _generalAdminInp->arg3, sizeof rescInfo.rescType);
00168 strncpy(rescInfo.rescClass, "cache", sizeof rescInfo.rescClass );
00169 strncpy(rescInfo.zoneName, _generalAdminInp->arg6, sizeof rescInfo.zoneName);
00170 strncpy(rescInfo.rescChildren, "", 1);
00171 strncpy(rescInfo.rescParent, "", 1);
00172
00173
00174
00175 args[0] = rescInfo.rescName;
00176 args[1] = rescInfo.rescType;
00177 args[2] = rescInfo.rescClass;
00178 args[3] = rescInfo.rescLoc;
00179 args[4] = rescInfo.rescVaultPath;
00180 args[5] = rescInfo.rescContext;
00181 args[6] = rescInfo.zoneName;
00182
00183
00184 eirods::plugin_name_generator name_gen;
00185 if(!name_gen.exists(rescInfo.rescType, eirods::EIRODS_RESOURCES_HOME)) {
00186 std::stringstream msg;
00187 msg << __FUNCTION__;
00188 msg << " - No plugin exists to provide resource type \"";
00189 msg << rescInfo.rescType << "\".";
00190 eirods::log(ERROR(SYS_INVALID_RESC_TYPE, msg.str()));
00191 result = SYS_INVALID_RESC_TYPE;
00192 }
00193
00194
00195
00196 else if((result = applyRuleArg("acPreProcForCreateResource", args, argc, &_rei2, NO_SAVE_REI)) < 0) {
00197 if (_rei2.status < 0) {
00198 result = _rei2.status;
00199 }
00200 rodsLog( LOG_ERROR, "rsGeneralAdmin:acPreProcForCreateResource error for %s,stat=%d",
00201 rescInfo.rescName, result );
00202
00203 }
00204
00205
00206
00207 else if((result = chlRegResc( _rsComm, &rescInfo )) != 0) {
00208 chlRollback( _rsComm );
00209 }
00210
00211
00212
00213
00214 else if((result = applyRuleArg( "acPostProcForCreateResource", args, argc, &_rei2, NO_SAVE_REI )) < 0) {
00215 if (_rei2.status < 0) {
00216 result = _rei2.status;
00217 }
00218 rodsLog( LOG_ERROR, "rsGeneralAdmin:acPostProcForCreateResource error for %s,stat=%d",
00219 rescInfo.rescName, result );
00220 }
00221
00222
00223 return result;
00224 }
00225
00226 int
00227 _listRescTypes(rsComm_t* _rsComm)
00228 {
00229 int result = 0;
00230 eirods::plugin_name_generator name_gen;
00231 eirods::plugin_name_generator::plugin_list_t plugin_list;
00232 eirods::error ret = name_gen.list_plugins(eirods::EIRODS_RESOURCES_HOME, plugin_list);
00233 if(ret.ok()) {
00234 std::stringstream msg;
00235 for(eirods::plugin_name_generator::plugin_list_t::iterator it = plugin_list.begin();
00236 result == 0 && it != plugin_list.end(); ++it)
00237 {
00238 msg << *it << std::endl;
00239 }
00240 if(result == 0) {
00241 addRErrorMsg( &_rsComm->rError, STDOUT_STATUS, msg.str().c_str() );
00242 }
00243 } else {
00244 std::stringstream msg;
00245 msg << __FUNCTION__;
00246 msg << " - Failed to generate the list of resource plugins.";
00247 eirods::error res = PASSMSG(msg.str(), ret);
00248 eirods::log(res);
00249 result = res.code();
00250 }
00251 return result;
00252 }
00253
00254 int
00255 _rsGeneralAdmin(rsComm_t *rsComm, generalAdminInp_t *generalAdminInp )
00256 {
00257 int status;
00258 userInfo_t userInfo;
00259 collInfo_t collInfo;
00260 rescInfo_t rescInfo;
00261 ruleExecInfo_t rei;
00262 char *args[MAX_NUM_OF_ARGS_IN_ACTION];
00263 int i, argc;
00264 ruleExecInfo_t rei2;
00265
00266 memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t));
00267 rei2.rsComm = rsComm;
00268 if (rsComm != NULL) {
00269 rei2.uoic = &rsComm->clientUser;
00270 rei2.uoip = &rsComm->proxyUser;
00271 }
00272
00273
00274 rodsLog (LOG_DEBUG,
00275 "_rsGeneralAdmin arg0=%s",
00276 generalAdminInp->arg0);
00277
00278 if (strcmp(generalAdminInp->arg0,"pvacuum")==0) {
00279 char *args[2];
00280 char argStr[100];
00281 memset((char*)&rei,0,sizeof(rei));
00282 rei.rsComm = rsComm;
00283 rei.uoic = &rsComm->clientUser;
00284 rei.uoip = &rsComm->proxyUser;
00285 rstrcpy(argStr,"",sizeof argStr);
00286 if (atoi(generalAdminInp->arg1) > 0) {
00287 snprintf(argStr,sizeof argStr,"<ET>%s</ET>",generalAdminInp->arg1);
00288 }
00289 if (atoi(generalAdminInp->arg2) > 0) {
00290 strncat(argStr,"<EF>",100);
00291 strncat(argStr,generalAdminInp->arg2,100);
00292 strncat(argStr,"</EF>",100);
00293 }
00294 args[0]=argStr;
00295 status = applyRuleArg("acVacuum", args, 1, &rei, SAVE_REI);
00296 return(status);
00297 }
00298
00299 if (strcmp(generalAdminInp->arg0,"add")==0) {
00300 if (strcmp(generalAdminInp->arg1,"user")==0) {
00301
00302 char *args[2];
00303 memset((char*)&rei,0,sizeof(rei));
00304 rei.rsComm = rsComm;
00305 strncpy(userInfo.userName, generalAdminInp->arg2,
00306 sizeof userInfo.userName);
00307 strncpy(userInfo.userType, generalAdminInp->arg3,
00308 sizeof userInfo.userType);
00309 strncpy(userInfo.rodsZone, generalAdminInp->arg4,
00310 sizeof userInfo.rodsZone);
00311 strncpy(userInfo.authInfo.authStr, generalAdminInp->arg5,
00312 sizeof userInfo.authInfo.authStr);
00313 rei.uoio = &userInfo;
00314 rei.uoic = &rsComm->clientUser;
00315 rei.uoip = &rsComm->proxyUser;
00316 status = applyRuleArg("acCreateUser", args, 0, &rei, SAVE_REI);
00317 if (status != 0) chlRollback(rsComm);
00318 return(status);
00319 }
00320 if (strcmp(generalAdminInp->arg1,"dir")==0) {
00321 memset((char*)&collInfo,0,sizeof(collInfo));
00322 strncpy(collInfo.collName, generalAdminInp->arg2,
00323 sizeof collInfo.collName);
00324 if (strlen(generalAdminInp->arg3) > 0) {
00325 strncpy(collInfo.collOwnerName, generalAdminInp->arg3,
00326 sizeof collInfo.collOwnerName);
00327 status = chlRegCollByAdmin(rsComm, &collInfo);
00328 if (status == 0) {
00329 if( !chlCommit( rsComm ) ) {
00330
00331 }
00332 }
00333 }
00334 else {
00335 status = chlRegColl(rsComm, &collInfo);
00336 }
00337 if (status != 0) chlRollback(rsComm);
00338 return(status);
00339 }
00340 if (strcmp(generalAdminInp->arg1,"zone")==0) {
00341 status = chlRegZone(rsComm, generalAdminInp->arg2,
00342 generalAdminInp->arg3,
00343 generalAdminInp->arg4,
00344 generalAdminInp->arg5);
00345 if (status == 0) {
00346 if (strcmp(generalAdminInp->arg3,"remote")==0) {
00347 memset((char*)&collInfo,0,sizeof(collInfo));
00348 strncpy(collInfo.collName, "/", sizeof collInfo.collName);
00349 strncat(collInfo.collName, generalAdminInp->arg2,
00350 sizeof collInfo.collName);
00351 strncpy(collInfo.collOwnerName, rsComm->proxyUser.userName,
00352 sizeof collInfo.collOwnerName);
00353 status = chlRegCollByAdmin(rsComm, &collInfo);
00354 if (status == 0) {
00355 chlCommit(rsComm);
00356 }
00357 }
00358 }
00359 return(status);
00360 }
00361
00362
00363
00364 if (strcmp(generalAdminInp->arg1,"resource")==0) {
00365 return _addResource(generalAdminInp, rei2, rsComm);
00366 }
00367
00368
00369 if (strcmp(generalAdminInp->arg1, "childtoresc")==0) {
00370 return _addChildToResource(generalAdminInp, rei2, rsComm);
00371 }
00372
00373 if (strcmp(generalAdminInp->arg1,"token")==0) {
00374
00375 args[0] = generalAdminInp->arg2;
00376 args[1] = generalAdminInp->arg3;
00377 args[2] = generalAdminInp->arg4;
00378 args[3] = generalAdminInp->arg5;
00379 args[4] = generalAdminInp->arg6;
00380 args[5] = generalAdminInp->arg7;
00381 argc = 6;
00382 i = applyRuleArg("acPreProcForCreateToken", args, argc, &rei2, NO_SAVE_REI);
00383 if (i < 0) {
00384 if (rei2.status < 0) {
00385 i = rei2.status;
00386 }
00387 rodsLog (LOG_ERROR,
00388 "rsGeneralAdmin:acPreProcForCreateToken error for %s.%s=%s,stat=%d",
00389 args[0],args[1],args[2],i);
00390 return i;
00391 }
00392
00393
00394 status = chlRegToken(rsComm, generalAdminInp->arg2,
00395 generalAdminInp->arg3,
00396 generalAdminInp->arg4,
00397 generalAdminInp->arg5,
00398 generalAdminInp->arg6,
00399 generalAdminInp->arg7);
00400
00401 if (status == 0) {
00402 i = applyRuleArg("acPostProcForCreateToken", args, argc, &rei2, NO_SAVE_REI);
00403 if (i < 0) {
00404 if (rei2.status < 0) {
00405 i = rei2.status;
00406 }
00407 rodsLog (LOG_ERROR,
00408 "rsGeneralAdmin:acPostProcForCreateToken error for %s.%s=%s,stat=%d",
00409 args[0],args[1],args[2],i);
00410 return i;
00411 }
00412 }
00413
00414
00415 if (status != 0) chlRollback(rsComm);
00416 return(status);
00417 }
00418
00419 if (strcmp(generalAdminInp->arg1,"specificQuery")==0) {
00420 status = chlAddSpecificQuery(rsComm, generalAdminInp->arg2,
00421 generalAdminInp->arg3);
00422 return(status);
00423 }
00424
00425 }
00426
00427 if (strcmp(generalAdminInp->arg0,"modify")==0) {
00428 if (strcmp(generalAdminInp->arg1,"user")==0) {
00429
00430 args[0] = generalAdminInp->arg2;
00431 args[1] = generalAdminInp->arg3;
00432 #if 0
00433 args[2] = generalAdminInp->arg4;
00434 #else
00435
00436
00437
00438
00439
00440 args[2] = "obfuscatedPw";
00441 #endif
00442 argc = 3;
00443 i = applyRuleArg("acPreProcForModifyUser",args,argc, &rei2, NO_SAVE_REI);
00444 if (i < 0) {
00445 if (rei2.status < 0) {
00446 i = rei2.status;
00447 }
00448 rodsLog (LOG_ERROR,
00449 "rsGeneralAdmin:acPreProcForModifyUser error for %s and option %s,stat=%d",
00450 args[0],args[1], i);
00451 return i;
00452 }
00453
00454
00455 status = chlModUser(rsComm, generalAdminInp->arg2,
00456 generalAdminInp->arg3, generalAdminInp->arg4);
00457
00458
00459 if (status == 0) {
00460 i = applyRuleArg("acPostProcForModifyUser",args,argc, &rei2, NO_SAVE_REI);
00461 if (i < 0) {
00462 if (rei2.status < 0) {
00463 i = rei2.status;
00464 }
00465 rodsLog (LOG_ERROR,
00466 "rsGeneralAdmin:acPostProcForModifyUser error for %s and option %s,stat=%d",
00467 args[0],args[1], i);
00468 return i;
00469 }
00470 }
00471
00472 if (status != 0) chlRollback(rsComm);
00473 return(status);
00474 }
00475 if (strcmp(generalAdminInp->arg1,"group")==0) {
00476
00477 args[0] = generalAdminInp->arg2;
00478 args[1] = generalAdminInp->arg3;
00479 args[2] = generalAdminInp->arg4;
00480 args[3] = generalAdminInp->arg5;
00481 argc = 4;
00482 i = applyRuleArg("acPreProcForModifyUserGroup",args,argc, &rei2, NO_SAVE_REI);
00483 if (i < 0) {
00484 if (rei2.status < 0) {
00485 i = rei2.status;
00486 }
00487 rodsLog (LOG_ERROR,
00488 "rsGeneralAdmin:acPreProcForModifyUserGroup error for %s and option %s,stat=%d",
00489 args[0],args[1], i);
00490 return i;
00491 }
00492
00493
00494 status = chlModGroup(rsComm, generalAdminInp->arg2,
00495 generalAdminInp->arg3, generalAdminInp->arg4,
00496 generalAdminInp->arg5);
00497
00498 if (status == 0) {
00499 i = applyRuleArg("acPostProcForModifyUserGroup",args,argc, &rei2, NO_SAVE_REI);
00500 if (i < 0) {
00501 if (rei2.status < 0) {
00502 i = rei2.status;
00503 }
00504 rodsLog (LOG_ERROR,
00505 "rsGeneralAdmin:acPostProcForModifyUserGroup error for %s and option %s,stat=%d",
00506 args[0],args[1], i);
00507 return i;
00508 }
00509 }
00510
00511
00512 if (status != 0) chlRollback(rsComm);
00513 return(status);
00514 }
00515 if (strcmp(generalAdminInp->arg1,"zone")==0) {
00516 status = chlModZone(rsComm, generalAdminInp->arg2,
00517 generalAdminInp->arg3, generalAdminInp->arg4);
00518 if (status != 0) chlRollback(rsComm);
00519 if (status == 0 &&
00520 strcmp(generalAdminInp->arg3, "name")==0) {
00521 char oldName[MAX_NAME_LEN];
00522 char newName[MAX_NAME_LEN];
00523 strncpy(oldName, "/", sizeof oldName);
00524 strncat(oldName, generalAdminInp->arg2, sizeof oldName);
00525 strncpy(newName, generalAdminInp->arg4, sizeof newName);
00526 status = chlRenameColl(rsComm, oldName, newName);
00527 if (status==0) chlCommit(rsComm);
00528 }
00529 return(status);
00530 }
00531 if (strcmp(generalAdminInp->arg1,"localzonename")==0) {
00532
00533 char *args[2];
00534 memset((char*)&rei,0,sizeof(rei));
00535 rei.rsComm = rsComm;
00536 memset((char*)&rei,0,sizeof(rei));
00537 rei.rsComm = rsComm;
00538 rei.uoic = &rsComm->clientUser;
00539 rei.uoip = &rsComm->proxyUser;
00540 args[0]=generalAdminInp->arg2;
00541 args[1]=generalAdminInp->arg3;
00542 status = applyRuleArg("acRenameLocalZone", args, 2, &rei,
00543 NO_SAVE_REI);
00544 return(status);
00545 }
00546 if (strcmp(generalAdminInp->arg1,"resourcedatapaths")==0) {
00547 status = chlModRescDataPaths(rsComm, generalAdminInp->arg2,
00548 generalAdminInp->arg3, generalAdminInp->arg4,
00549 generalAdminInp->arg5);
00550
00551 return(status);
00552 }
00553 if (strcmp(generalAdminInp->arg1,"resource")==0) {
00554
00555
00556 args[0] = generalAdminInp->arg2;
00557 args[1] = generalAdminInp->arg3;
00558 args[2] = generalAdminInp->arg4;
00559 argc = 3;
00560 i = applyRuleArg("acPreProcForModifyResource",args,argc, &rei2, NO_SAVE_REI);
00561 if (i < 0) {
00562 if (rei2.status < 0) {
00563 i = rei2.status;
00564 }
00565 rodsLog (LOG_ERROR,
00566 "rsGeneralAdmin:acPreProcForModifyResource error for %s and option %s,stat=%d",
00567 args[0],args[1], i);
00568 return i;
00569 }
00570
00571
00572 status = chlModResc(rsComm, generalAdminInp->arg2,
00573 generalAdminInp->arg3, generalAdminInp->arg4);
00574
00575
00576 if (status == 0) {
00577 i = applyRuleArg("acPostProcForModifyResource",args,argc, &rei2, NO_SAVE_REI);
00578 if (i < 0) {
00579 if (rei2.status < 0) {
00580 i = rei2.status;
00581 }
00582 rodsLog (LOG_ERROR,
00583 "rsGeneralAdmin:acPostProcForModifyResource error for %s and option %s,stat=%d",
00584 args[0],args[1], i);
00585 return i;
00586 }
00587 }
00588
00589
00590 if (status != 0) chlRollback(rsComm);
00591 return(status);
00592 }
00593 if (strcmp(generalAdminInp->arg1,"resourcegroup")==0) {
00594
00595 args[0] = generalAdminInp->arg2;
00596 args[1] = generalAdminInp->arg3;
00597 args[2] = generalAdminInp->arg4;
00598 argc = 3;
00599 i = applyRuleArg("acPreProcForModifyResourceGroup",args,argc, &rei2, NO_SAVE_REI);
00600 if (i < 0) {
00601 if (rei2.status < 0) {
00602 i = rei2.status;
00603 }
00604 rodsLog (LOG_ERROR,
00605 "rsGeneralAdmin:acPreProcForModifyResourceGroup error for %s and option %s,stat=%d",
00606 args[0],args[1], i);
00607 return i;
00608 }
00609
00610
00611 status = chlModRescGroup(rsComm, generalAdminInp->arg2,
00612 generalAdminInp->arg3, generalAdminInp->arg4);
00613
00614
00615 if (status == 0) {
00616 i = applyRuleArg("acPostProcForModifyResourceGroup",args,argc, &rei2, NO_SAVE_REI);
00617 if (i < 0) {
00618 if (rei2.status < 0) {
00619 i = rei2.status;
00620 }
00621 rodsLog (LOG_ERROR,
00622 "rsGeneralAdmin:acPostProcForModifyResourceGroup error for %s and option %s,stat=%d",
00623 args[0],args[1], i);
00624 return i;
00625 }
00626 }
00627
00628
00629 if (status != 0) chlRollback(rsComm);
00630 return(status);
00631 }
00632 }
00633 if (strcmp(generalAdminInp->arg0,"rm")==0) {
00634 if (strcmp(generalAdminInp->arg1,"user")==0) {
00635
00636 char *args[2];
00637 memset((char*)&rei,0,sizeof(rei));
00638 rei.rsComm = rsComm;
00639 strncpy(userInfo.userName, generalAdminInp->arg2,
00640 sizeof userInfo.userName);
00641 strncpy(userInfo.rodsZone, generalAdminInp->arg3,
00642 sizeof userInfo.rodsZone);
00643 rei.uoio = &userInfo;
00644 rei.uoic = &rsComm->clientUser;
00645 rei.uoip = &rsComm->proxyUser;
00646 status = applyRuleArg("acDeleteUser", args, 0, &rei, SAVE_REI);
00647 if (status != 0) chlRollback(rsComm);
00648 return(status);
00649 }
00650 if (strcmp(generalAdminInp->arg1,"dir")==0) {
00651 memset((char*)&collInfo,0,sizeof(collInfo));
00652 strncpy(collInfo.collName, generalAdminInp->arg2,
00653 sizeof collInfo.collName);
00654 status = chlDelColl(rsComm, &collInfo);
00655 if (status != 0) chlRollback(rsComm);
00656 return(status);
00657 }
00658 if (strcmp(generalAdminInp->arg1,"resource")==0) {
00659
00660
00661
00662
00663 if ( strcmp( generalAdminInp->arg3, "--dryrun" ) == 0 ) {
00664 strncpy( rescInfo.rescName, generalAdminInp->arg2, sizeof rescInfo.rescName );
00665 rodsLog( LOG_STATUS, "Executing a dryrun of removal of resource [%s]", generalAdminInp->arg2 );
00666
00667 status = chlDelResc( rsComm, &rescInfo, 1 );
00668 if( 0 == status ) {
00669 rodsLog( LOG_STATUS, "DRYRUN REMOVING RESOURCE [%s] :: SUCCESS", generalAdminInp->arg2 );
00670 } else {
00671 rodsLog( LOG_STATUS, "DRYRUN REMOVING RESOURCE [%s] :: FAILURE", generalAdminInp->arg2 );
00672 }
00673
00674 return status;
00675 }
00676
00677
00678 strncpy(rescInfo.rescName, generalAdminInp->arg2,
00679 sizeof rescInfo.rescName);
00680
00681
00682 args[0] = rescInfo.rescName;
00683 argc = 1;
00684 i = applyRuleArg("acPreProcForDeleteResource", args, argc, &rei2, NO_SAVE_REI);
00685 if (i < 0) {
00686 if (rei2.status < 0) {
00687 i = rei2.status;
00688 }
00689 rodsLog (LOG_ERROR,
00690 "rsGeneralAdmin:acPreProcForDeleteResource error for %s,stat=%d",
00691 rescInfo.rescName,i);
00692 return i;
00693 }
00694
00695
00696 status = chlDelResc(rsComm, &rescInfo);
00697 if (status == 0) {
00698
00699 i = applyRuleArg("acPostProcForDeleteResource",args,argc, &rei2, NO_SAVE_REI);
00700 if (i < 0) {
00701 if (rei2.status < 0) {
00702 i = rei2.status;
00703 }
00704 rodsLog (LOG_ERROR,
00705 "rsGeneralAdmin:acPostProcForDeleteResource error for %s,stat=%d",
00706 rescInfo.rescName,i);
00707 return i;
00708 }
00709 }
00710
00711
00712 if (status != 0) chlRollback(rsComm);
00713 return(status);
00714 }
00715
00716
00717 if (strcmp(generalAdminInp->arg1, "childfromresc")==0) {
00718 return _removeChildFromResource(generalAdminInp, rei2, rsComm);
00719 }
00720
00721 if (strcmp(generalAdminInp->arg1,"zone")==0) {
00722 status = chlDelZone(rsComm, generalAdminInp->arg2);
00723 if (status == 0) {
00724 memset((char*)&collInfo,0,sizeof(collInfo));
00725 strncpy(collInfo.collName, "/", sizeof collInfo.collName);
00726 strncat(collInfo.collName, generalAdminInp->arg2,
00727 sizeof collInfo.collName);
00728 status = chlDelCollByAdmin(rsComm, &collInfo);
00729 }
00730 if (status == 0) {
00731 status = chlCommit(rsComm);
00732 }
00733 return(status);
00734 }
00735 if (strcmp(generalAdminInp->arg1,"token")==0) {
00736
00737
00738 args[0] = generalAdminInp->arg2;
00739 args[1] = generalAdminInp->arg3;
00740 argc = 2;
00741 i = applyRuleArg("acPreProcForDeleteToken", args, argc, &rei2, NO_SAVE_REI);
00742 if (i < 0) {
00743 if (rei2.status < 0) {
00744 i = rei2.status;
00745 }
00746 rodsLog (LOG_ERROR,
00747 "rsGeneralAdmin:acPreProcForDeleteToken error for %s.%s,stat=%d",
00748 args[0],args[1],i);
00749 return i;
00750 }
00751
00752
00753 status = chlDelToken(rsComm, generalAdminInp->arg2,
00754 generalAdminInp->arg3);
00755
00756
00757 if (status == 0) {
00758 i = applyRuleArg("acPostProcForDeleteToken", args, argc, &rei2, NO_SAVE_REI);
00759 if (i < 0) {
00760 if (rei2.status < 0) {
00761 i = rei2.status;
00762 }
00763 rodsLog (LOG_ERROR,
00764 "rsGeneralAdmin:acPostProcForDeleteToken error for %s.%s,stat=%d",
00765 args[0],args[1],i);
00766 return i;
00767 }
00768 }
00769
00770
00771 if (status != 0) chlRollback(rsComm);
00772 return(status);
00773 }
00774 if (strcmp(generalAdminInp->arg1,"unusedAVUs")==0) {
00775 status = chlDelUnusedAVUs(rsComm);
00776 return(status);
00777 }
00778 if (strcmp(generalAdminInp->arg1,"specificQuery")==0) {
00779 status = chlDelSpecificQuery(rsComm, generalAdminInp->arg2);
00780 return(status);
00781 }
00782 }
00783 if (strcmp(generalAdminInp->arg0,"calculate-usage")==0) {
00784 status = chlCalcUsageAndQuota(rsComm);
00785 return(status);
00786 }
00787 if (strcmp(generalAdminInp->arg0,"set-quota")==0) {
00788 status = chlSetQuota(rsComm,
00789 generalAdminInp->arg1,
00790 generalAdminInp->arg2,
00791 generalAdminInp->arg3,
00792 generalAdminInp->arg4);
00793
00794 return(status);
00795 }
00796
00797 if(strcmp(generalAdminInp->arg0, "lt") == 0) {
00798 status = CAT_INVALID_ARGUMENT;
00799 if(strcmp(generalAdminInp->arg1, "resc_type") == 0) {
00800 status = _listRescTypes(rsComm);
00801 }
00802 return status;
00803 }
00804
00805 return(CAT_INVALID_ARGUMENT);
00806 }
00807 #endif