IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 14, 2009, 3:57:09 PM (17 years ago)
Author:
bills
Message:

disttool -revertfileset

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/disttool.c

    r23861 r23864  
    4141static bool pendingfilesetMode(pxConfig *config);
    4242static bool addfilesetMode(pxConfig *config);
     43static bool revertfilesetMode(pxConfig *config);
     44static bool queuercrunMode(pxConfig *config);
     45static bool updatercrunMode(pxConfig *config);
     46static bool revertrcrunMode(pxConfig *config);
    4347static bool pendingdatastoresMode(pxConfig *config);
    4448
     
    7276        MODECASE(DISTTOOL_MODE_PENDINGFILESET, pendingfilesetMode);
    7377        MODECASE(DISTTOOL_MODE_ADDFILESET, addfilesetMode);
     78        MODECASE(DISTTOOL_MODE_REVERTFILESET, revertfilesetMode);
     79        MODECASE(DISTTOOL_MODE_QUEUERCRUN, queuercrunMode);
     80        MODECASE(DISTTOOL_MODE_UPDATERCRUN, updatercrunMode);
     81        MODECASE(DISTTOOL_MODE_REVERTRCRUN, revertrcrunMode);
    7482        MODECASE(DISTTOOL_MODE_PENDINGDATASTORES, pendingdatastoresMode);
    7583        default:
     
    894902    return true;
    895903}
     904static bool revertfilesetMode(pxConfig *config)
     905{
     906    psMetadata *where = psMetadataAlloc();
     907    PXOPT_COPY_S64(config->args, where, "-fs_id", "fs_id", "==");
     908    PXOPT_COPY_S64(config->args, where, "-dist_id", "rcDSFileset.dist_id", "==");
     909    PXOPT_COPY_S64(config->args, where, "-prod_id", "prod_id", "==");
     910    PXOPT_COPY_STR(config->args, where, "-stage", "stage", "==");;
     911    PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "==");
     912    PXOPT_COPY_STR(config->args, where, "-state", "state", "==");
     913    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     914    PXOPT_COPY_S16(config->args, where, "-fault", "rcDSFileset.fault", "==");
     915
     916    // It might be useful to be able to query by the parameters of the underlying runs
     917
     918    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
     919        psFree(where);
     920        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     921        return false;
     922    }
     923
     924    psString query = pxDataGet("disttool_revertfileset.sql");
     925    if (!query) {
     926        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     927        psFree(where);
     928        return false;
     929    }
     930
     931    if (psListLength(where->list)) {
     932        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     933        psStringAppend(&query, " AND %s", whereClause);
     934        psFree(whereClause);
     935    }
     936
     937    if (!p_psDBRunQuery(config->dbh, query)) {
     938        psError(PS_ERR_UNKNOWN, false, "database error");
     939        psFree(query);
     940        if (!psDBRollback(config->dbh)) {
     941            psError(PS_ERR_UNKNOWN, false, "database error");
     942        }
     943        return false;
     944    }
     945    psFree(query);
     946
     947    int numUpdated = psDBAffectedRows(config->dbh);
     948
     949    psLogMsg("disttool", PS_LOG_INFO, "deleted %d rcDSFilesets", numUpdated);
     950
     951    return true;
     952}
    896953
    897954static bool pendingdatastoresMode(pxConfig *config)
     
    9681025    return true;
    9691026}
     1027
     1028static bool queuercrunMode(pxConfig *config)
     1029{
     1030    PS_ASSERT_PTR_NON_NULL(config, false);
     1031    return true;
     1032}
     1033static bool updatercrunMode(pxConfig *config)
     1034{
     1035    PS_ASSERT_PTR_NON_NULL(config, false);
     1036    return true;
     1037}
     1038static bool revertrcrunMode(pxConfig *config)
     1039{
     1040    PS_ASSERT_PTR_NON_NULL(config, false);
     1041    return true;
     1042}
Note: See TracChangeset for help on using the changeset viewer.