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