IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32942


Ignore:
Timestamp:
Dec 13, 2011, 11:12:04 AM (14 years ago)
Author:
bills
Message:

add disttool -updateprocessedcomponent mode

Location:
trunk/ippTools/src
Files:
3 edited

Legend:

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

    r32833 r32942  
    3737static bool pendingcomponentMode(pxConfig *config);
    3838static bool addprocessedcomponentMode(pxConfig *config);
     39static bool updateprocessedcomponentMode(pxConfig *config);
     40static bool revertcomponentMode(pxConfig *config);
    3941static bool revertcomponentMode(pxConfig *config);
    4042static bool processedcomponentMode(pxConfig *config);
     
    8789        MODECASE(DISTTOOL_MODE_PENDINGCOMPONENT, pendingcomponentMode);
    8890        MODECASE(DISTTOOL_MODE_ADDPROCESSEDCOMPONENT, addprocessedcomponentMode);
     91        MODECASE(DISTTOOL_MODE_UPDATEPROCESSEDCOMPONENT, updateprocessedcomponentMode);
    8992        MODECASE(DISTTOOL_MODE_PROCESSEDCOMPONENT, processedcomponentMode);
    9093        MODECASE(DISTTOOL_MODE_REVERTCOMPONENT, revertcomponentMode);
     
    969972    return true;
    970973}
     974static bool updateprocessedcomponentMode(pxConfig *config)
     975{
     976
     977    // required values
     978    PXOPT_LOOKUP_S64(dist_id, config->args, "-dist_id", true, false);
     979    PXOPT_LOOKUP_STR(component, config->args, "-component", true, false);
     980
     981    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     982    PXOPT_LOOKUP_BOOL(clearfault, config->args, "-clearfault", false);
     983    PXOPT_LOOKUP_S32(bytes, config->args, "-bytes", false, false);
     984    PXOPT_LOOKUP_STR(md5sum, config->args, "-md5sum", false, false);
     985    PXOPT_LOOKUP_STR(outdir, config->args, "-outdir", false, false);
     986    PXOPT_LOOKUP_STR(name, config->args, "-name", false, false);
     987
     988    bool setfault = clearfault || fault;
     989
     990    if (!bytes && !md5sum && !outdir && !name && !setfault && !fault) {
     991        psError(PS_ERR_UNKNOWN, true, "at least one of bytes md5sum outdir name fault or setfault is required");
     992        return false;
     993    }
     994
     995    char *sep = "";
     996    psString query = psStringCopy("UPDATE distComponent SET ");
     997    if (setfault) {
     998        psStringAppend(&query, "%s fault = %d", sep, fault ? 1 : 0);
     999        sep = ", ";
     1000    }
     1001    if (bytes) {
     1002        psStringAppend(&query, "%s bytes = %d", sep, bytes);
     1003        sep = ", ";
     1004    }
     1005    if (md5sum) {
     1006        psStringAppend(&query, "%s md5sum = '%s'", sep, md5sum);
     1007        sep = ", ";
     1008    }
     1009    if (outdir) {
     1010        psStringAppend(&query, "%s outdir = '%s'", sep, outdir);
     1011        sep = ", ";
     1012    }
     1013    if (name) {
     1014        psStringAppend(&query, "%s name = '%s'", sep, name);
     1015        sep = ", ";
     1016    }
     1017
     1018    psStringAppend(&query, "\nWHERE dist_id = %"PRId64 " AND component = '%s'",
     1019        dist_id, component);
     1020
     1021    if (!p_psDBRunQuery(config->dbh, query)) {
     1022        psError(PS_ERR_UNKNOWN, false, "database error");
     1023        psFree(query);
     1024        return false;
     1025    }
     1026    psFree(query);
     1027
     1028    return true;
     1029}
    9711030
    9721031static bool toadvanceMode(pxConfig *config)
     
    10481107    psMetadata *where = psMetadataAlloc();
    10491108    PXOPT_COPY_S64(config->args, where, "-dist_id", "dist_id", "==");
     1109    PXOPT_COPY_STR(config->args, where, "-component", "component", "==");
    10501110
    10511111    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     
    21852245    psMetadata *where = psMetadataAlloc();
    21862246    PXOPT_COPY_S64(config->args, where, "-fs_id", "fs_id", "==");
     2247    PXOPT_COPY_S64(config->args, where, "-dist_id", "dist_id", "==");
    21872248
    21882249    if (!psListLength(where->list)) {
  • trunk/ippTools/src/disttool.h

    r28938 r32942  
    3333    DISTTOOL_MODE_REVERTCOMPONENT,
    3434    DISTTOOL_MODE_PROCESSEDCOMPONENT,
     35    DISTTOOL_MODE_UPDATEPROCESSEDCOMPONENT,
    3536    DISTTOOL_MODE_TOADVANCE,
    3637    DISTTOOL_MODE_PENDINGCLEANUP,
  • trunk/ippTools/src/disttoolConfig.c

    r32696 r32942  
    151151    psMetadata *processedcomponentArgs = psMetadataAlloc();
    152152    psMetadataAddS64(processedcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
     153    psMetadataAddStr(processedcomponentArgs, PS_LIST_TAIL, "-component", 0, "define component", NULL);
    153154    psMetadataAddU64(processedcomponentArgs, PS_LIST_TAIL, "-limit",  0,  "limit result set to N items", 0);
    154155    psMetadataAddBool(processedcomponentArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
     156
     157    // -updateprocessedcomponentArgs
     158    psMetadata *updateprocessedcomponentArgs = psMetadataAlloc();
     159    psMetadataAddS64(updateprocessedcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
     160    psMetadataAddStr(updateprocessedcomponentArgs, PS_LIST_TAIL, "-component", 0, "define component (required)", NULL);
     161    psMetadataAddStr(updateprocessedcomponentArgs, PS_LIST_TAIL, "-outdir", 0, "define output directory", NULL);
     162    psMetadataAddStr(updateprocessedcomponentArgs, PS_LIST_TAIL, "-name", 0, "define file name", NULL);
     163    psMetadataAddS32(updateprocessedcomponentArgs, PS_LIST_TAIL, "-bytes", 0, "define file size", 0);
     164    psMetadataAddStr(updateprocessedcomponentArgs, PS_LIST_TAIL, "-md5sum", 0, "define stage for bundle", NULL);
     165    psMetadataAddS32(updateprocessedcomponentArgs, PS_LIST_TAIL, "-fault", 0, "define fault code", 0);
     166    psMetadataAddBool(updateprocessedcomponentArgs, PS_LIST_TAIL, "-clearfault", 0, "set fault to zero", false);
    155167
    156168    // -toadvance
     
    180192    psMetadata *updatefilesetArgs = psMetadataAlloc();
    181193    psMetadataAddS64(updatefilesetArgs, PS_LIST_TAIL, "-fs_id", 0, "define fs_id", 0);
    182 //    psMetadataAddS64(updatefilesetArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
     194    psMetadataAddS64(updatefilesetArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
    183195    psMetadataAddStr(updatefilesetArgs, PS_LIST_TAIL, "-set_state",0, "new value for state", NULL);
    184196    psMetadataAddS32(updatefilesetArgs, PS_LIST_TAIL, "-fault",   0, "define fault code", 0);
     
    347359    PXOPT_ADD_MODE("-pendingcomponent",   "", DISTTOOL_MODE_PENDINGCOMPONENT,    pendingcomponentArgs);
    348360    PXOPT_ADD_MODE("-addprocessedcomponent", "", DISTTOOL_MODE_ADDPROCESSEDCOMPONENT, addprocessedcomponentArgs);
     361    PXOPT_ADD_MODE("-updateprocessedcomponent", "", DISTTOOL_MODE_UPDATEPROCESSEDCOMPONENT, updateprocessedcomponentArgs);
    349362    PXOPT_ADD_MODE("-revertcomponent",    "revert faulted components", DISTTOOL_MODE_REVERTCOMPONENT, revertcomponentArgs);
    350363    PXOPT_ADD_MODE("-processedcomponent", "", DISTTOOL_MODE_PROCESSEDCOMPONENT, processedcomponentArgs);
Note: See TracChangeset for help on using the changeset viewer.