Example #1
0
int
remoteStructFileBundle( rsComm_t *rsComm,
                        structFileExtAndRegInp_t *structFileBundleInp, rodsServerHost_t *rodsServerHost ) {
    int status;

    if ( rodsServerHost == NULL ) {
        rodsLog( LOG_NOTICE,
                 "remoteStructFileBundle: Invalid rodsServerHost" );
        return SYS_INVALID_SERVER_HOST;
    }

    if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
        return status;
    }

    status = rcStructFileBundle( rodsServerHost->conn, structFileBundleInp );
    return status;
}
Example #2
0
int
bunUtil( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs,
         rodsPathInp_t *rodsPathInp ) {
    rodsPath_t *collPath, *structFilePath;
    structFileExtAndRegInp_t structFileExtAndRegInp;

    if ( rodsPathInp == NULL ) {
        return USER__NULL_INPUT_ERR;
    }

    int savedStatus = initCondForBunOpr( myRodsEnv, myRodsArgs, &structFileExtAndRegInp );
    if ( savedStatus < 0 ) {
        return savedStatus;
    }

    for ( int i = 0; i < rodsPathInp->numSrc; i++ ) {
        collPath = &rodsPathInp->destPath[i];	/* iRODS Collection */
        structFilePath = &rodsPathInp->srcPath[i];	/* iRODS StructFile */

        getRodsObjType( conn, collPath );

        rstrcpy( structFileExtAndRegInp.collection, collPath->outPath,
                 MAX_NAME_LEN );
        rstrcpy( structFileExtAndRegInp.objPath, structFilePath->outPath,
                 MAX_NAME_LEN );

        int status = 0;
        if ( myRodsArgs->extract == True ) {		/* -x */
            if ( myRodsArgs->condition == True ) {
                rodsLog( LOG_ERROR, "bunUtil: cannot use -x and -c at the same time" );
                return -1;
            }
            status = rcStructFileExtAndReg( conn, &structFileExtAndRegInp );
        }
        else if ( myRodsArgs->condition == True ) {  /* -c - create */
            status = rcStructFileBundle( conn, &structFileExtAndRegInp );
        }
        else if ( myRodsArgs->add == True ) {  /* add to tar */ // JMC - backport 4643
            status = rcStructFileBundle( conn, &structFileExtAndRegInp );
        }
        else {
            rodsLog( LOG_ERROR,
                     "bunUtil: -x or -c must be specified" );
            return -1;
        }

        /* XXXX may need to return a global status */
        if ( status < 0 &&
                status != CAT_NO_ROWS_FOUND ) {
            if ( status == SYS_CACHE_STRUCT_FILE_RESC_ERR &&
                    myRodsArgs->condition == True ) {
                rodsLogError( LOG_ERROR, status,
                              "bunUtil: A resc must be entered for non-existing structFile" );
            }
            else {
                rodsLogError( LOG_ERROR, status,
                              "bunUtil: opr error for %s, status = %d",
                              collPath->outPath, status );
                savedStatus = status;
            }
        }
    }
    return savedStatus;
}
Example #3
0
int
rsStructFileBundle( rsComm_t *rsComm,
                    structFileExtAndRegInp_t *structFileBundleInp ) {
    int status;
    rodsServerHost_t *rodsServerHost;
    int remoteFlag;
    dataObjInp_t dataObjInp;


    memset( &dataObjInp, 0, sizeof( dataObjInp ) );
    rstrcpy( dataObjInp.objPath, structFileBundleInp->objPath,
             MAX_NAME_LEN );

    remoteFlag = getAndConnRemoteZone( rsComm, &dataObjInp, &rodsServerHost,
                                       REMOTE_CREATE );

    if ( remoteFlag < 0 ) {
        return remoteFlag;
    }
    else if ( remoteFlag == REMOTE_HOST ) {
        status = rcStructFileBundle( rodsServerHost->conn,
                                     structFileBundleInp );
        return status;
    }

    // =-=-=-=-=-=-=-
    // working on the "home zone", determine if we need to redirect to a different
    // server in this zone for this operation.  if there is a RESC_HIER_STR_KW then
    // we know that the redirection decision has already been made
    std::string       hier;
    int               local = LOCAL_HOST;
    rodsServerHost_t* host  =  0;
    dataObjInp_t      data_inp;
    bzero( &data_inp, sizeof( data_inp ) );
    rstrcpy( data_inp.objPath, structFileBundleInp->objPath, MAX_NAME_LEN );
    copyKeyValPairStruct( &structFileBundleInp->condInput, &data_inp.condInput );
    if ( getValByKey( &structFileBundleInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
        irods::error ret = irods::resource_redirect( irods::CREATE_OPERATION, rsComm,
                           &data_inp, hier, host, local );
        if ( !ret.ok() ) {
            std::stringstream msg;
            msg << "rsStructFileBundle :: failed in irods::resource_redirect for [";
            msg << &data_inp.objPath << "]";
            irods::log( PASSMSG( msg.str(), ret ) );
            return ret.code();
        }

        // =-=-=-=-=-=-=-
        // we resolved the redirect and have a host, set the hier str for subsequent
        // api calls, etc.
        addKeyVal( &structFileBundleInp->condInput, RESC_HIER_STR_KW, hier.c_str() );

    } // if keyword

    if ( LOCAL_HOST == local ) {
        status = _rsStructFileBundle( rsComm, structFileBundleInp );
    }
    else {
        status = rcStructFileBundle( host->conn, structFileBundleInp );
    } // else remote host


    return status;
}
int
rsStructFileBundle (rsComm_t *rsComm,
structFileExtAndRegInp_t *structFileBundleInp)
{
#if 0
    char *destRescName = NULL;
#endif
    int status;
    rodsServerHost_t *rodsServerHost;
    int remoteFlag;
    rodsHostAddr_t rescAddr;
    dataObjInp_t dataObjInp;
    rescGrpInfo_t *rescGrpInfo = NULL;

    memset (&dataObjInp, 0, sizeof (dataObjInp));
    rstrcpy (dataObjInp.objPath, structFileBundleInp->objPath,
      MAX_NAME_LEN);

    remoteFlag = getAndConnRemoteZone (rsComm, &dataObjInp, &rodsServerHost,
      REMOTE_CREATE);

    if (remoteFlag < 0) {
        return (remoteFlag);
    } else if (remoteFlag == REMOTE_HOST) {
        status = rcStructFileBundle (rodsServerHost->conn,
          structFileBundleInp);
        return status;
    }

#if 0
    if ((destRescName = 
     getValByKey (&structFileBundleInp->condInput, DEST_RESC_NAME_KW)) == NULL 
     && (destRescName = 
     getValByKey (&structFileBundleInp->condInput, DEF_RESC_NAME_KW)) == NULL) {
        return USER_NO_RESC_INPUT_ERR;
    }

    status = _getRescInfo (rsComm, destRescName, &rescGrpInfo);
    if (status < 0) {
         rodsLog (LOG_ERROR,
          "rsStructFileBundle: _getRescInfo of %s error for %s. stat = %d",
          destRescName, structFileBundleInp->collection, status);
        return status;
    }
#else
    /* borrow conInput */
    dataObjInp.condInput = structFileBundleInp->condInput;
    status = getRescGrpForCreate (rsComm, &dataObjInp, &rescGrpInfo);
    if (status < 0) return status;
#endif

    bzero (&rescAddr, sizeof (rescAddr));
    rstrcpy (rescAddr.hostAddr, rescGrpInfo->rescInfo->rescLoc, NAME_LEN);
    remoteFlag = resolveHost (&rescAddr, &rodsServerHost);

    if (remoteFlag == LOCAL_HOST) {
        status = _rsStructFileBundle (rsComm, structFileBundleInp);
    } else if (remoteFlag == REMOTE_HOST) {
        status = remoteStructFileBundle (rsComm, structFileBundleInp, 
	  rodsServerHost);
    } else if (remoteFlag < 0) {
            status = remoteFlag;
    }
    freeAllRescGrpInfo (rescGrpInfo);
    return status;
}