Changeset 37272
- Timestamp:
- Aug 20, 2014, 12:05:13 PM (12 years ago)
- File:
-
- 1 edited
-
tags/ipp-pv3-20140717/ippTools/src/remotetool.c (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-pv3-20140717/ippTools/src/remotetool.c
r37054 r37272 92 92 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 93 93 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 94 94 95 95 set_label = set_label ? set_label : label; 96 96 … … 105 105 return(false); 106 106 } 107 107 108 108 if (label) { 109 109 psStringAppend(&whereOption, "\n AND (label = '%s')", label); … … 116 116 return(false); 117 117 } 118 118 119 119 if (label) { 120 120 psStringAppend(&whereOption, "\n AND (label = '%s')", label); 121 121 } 122 } 122 } 123 123 else if (!strcmp(stage,"warp")) { 124 124 query = pxDataGet("remotetool_definebyquery_warp.sql"); … … 127 127 return(false); 128 128 } 129 129 130 130 if (label) { 131 131 // Because warp has to check to see if something other than the state is set correctly, I have to use this wonky way to pass the label in. … … 133 133 psStringAppend(&whereOption, "\n AND (label = '%s')", label); 134 134 } 135 } 135 } 136 136 else if (!strcmp(stage,"stack")) { 137 137 query = pxDataGet("remotetool_definebyquery_stack.sql"); … … 140 140 return(false); 141 141 } 142 142 143 143 if (label) { 144 144 psStringAppend(&whereOption, "\n AND (label = '%s')", label); 145 145 } 146 } 146 } 147 147 else { 148 148 psError(PS_ERR_UNKNOWN, true, "unknown value for stage: %s", stage); … … 191 191 // Insert the top level run object 192 192 remoteRunRow *run = remoteRunRowAlloc(0, // remote_id 193 "new", // state194 stage,195 set_label,196 path_base,197 -1, // job_id198 NULL, // last_poll199 0 // fault200 );193 "new", // state 194 stage, 195 set_label, 196 path_base, 197 -1, // job_id 198 NULL, // last_poll 199 0 // fault 200 ); 201 201 if (!run) { 202 202 psError(PS_ERR_UNKNOWN, false, "failed to alloc lapRun object"); 203 203 return(true); 204 204 } 205 205 206 206 if (!remoteRunInsertObject(config->dbh, run)) { 207 207 if (!psDBRollback(config->dbh)) { … … 213 213 } 214 214 psS64 remote_id = psDBLastInsertID(config->dbh); 215 215 216 216 psArray *list = psArrayAllocEmpty(limit); 217 217 for (long i=0; i < psArrayLength(output); i++) { … … 220 220 221 221 remoteComponentRow *comp = remoteComponentRowAlloc(remote_id, 222 stage_id);222 stage_id); 223 223 if (!comp) { 224 224 psError(PS_ERR_UNKNOWN, false, "failed to alloc lapRun object"); 225 225 return(true); 226 226 } 227 227 228 228 if (!remoteComponentInsertObject(config->dbh, comp)) { 229 229 if (!psDBRollback(config->dbh)) { 230 psError(PS_ERR_UNKNOWN, false, "database error");230 psError(PS_ERR_UNKNOWN, false, "database error"); 231 231 } 232 232 psError(PS_ERR_UNKNOWN, false, "database error"); … … 237 237 psArrayAdd(list, list->n, comp); 238 238 psFree(comp); 239 239 240 240 } 241 241 psFree(run); … … 245 245 return false; 246 246 } 247 247 248 248 if (!remoteComponentPrintObjects(stdout, list, !simple)) { 249 249 if (!psDBRollback(config->dbh)) { … … 254 254 return false; 255 255 } 256 256 257 257 psFree(list); 258 258 psFree(output); 259 259 260 260 return true; 261 261 } … … 265 265 { 266 266 psMetadata *where = psMetadataAlloc(); 267 267 268 268 PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "=="); 269 269 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); … … 274 274 PXOPT_COPY_TIME(config->args, where, "-poll_begin", "last_poll", ">="); 275 275 PXOPT_COPY_TIME(config->args, where, "-poll_end", "last_poll", "<="); 276 276 277 277 PXOPT_COPY_S16(config->args, where, "-fault", "fault", "=="); 278 278 279 279 PXOPT_LOOKUP_S16(limit, config->args, "-limit", false, false); 280 280 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 281 281 282 282 283 283 psArray *remRuns = NULL; 284 284 remRuns = psDBSelectRows(config->dbh, "remoteRun", where, limit); 285 285 286 286 if (!ippdbPrintMetadatas(stdout, remRuns, "remoteRun", !simple)) { 287 287 psError(PS_ERR_UNKNOWN, false, "failed to print array"); … … 300 300 PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "=="); 301 301 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 302 302 303 303 psArray *remComps = NULL; 304 304 remComps = psDBSelectRows(config->dbh, "remoteComponent", where, 0); 305 305 306 306 if (!ippdbPrintMetadatas(stdout, remComps, "remoteComponent", !simple)) { 307 307 psError(PS_ERR_UNKNOWN, false, "failed to print array"); … … 329 329 return false; 330 330 } 331 331 332 332 if (!psDBTransaction(config->dbh)) { 333 333 psError(PS_ERR_UNKNOWN, false, "database error"); … … 341 341 } 342 342 psFree(query); 343 344 343 344 345 345 346 346 // point of no return … … 349 349 return false; 350 350 } 351 351 352 352 return true; 353 353 } … … 364 364 // Wheres 365 365 PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "=="); 366 366 367 367 // Values to set 368 368 PXOPT_COPY_STR(config->args, values, "-set_label", "label", "=="); … … 375 375 376 376 if (rows < 1) { 377 psError(PS_ERR_UNKNOWN,false, "no rows affected"); 378 return(false); 379 } 380 377 fprintf (stderr, "no rows changed (run may already be in desired state)\n"); 378 } 381 379 return(true); 382 380 } … … 393 391 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 394 392 psFree(where); 395 393 396 394 psString query = NULL; 397 395 query = pxDataGet("remotetool_updatepoll.sql"); … … 412 410 return(true); 413 411 } 414 415 416 412 413 414 417 415 418 416 static bool revertrunMode(pxConfig *config) … … 426 424 PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "=="); 427 425 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 428 426 429 427 // Value to set 430 428 PXOPT_COPY_S16(config->args, values, "-fault", "fault", "=="); … … 451 449 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 452 450 453 psMetadataAddStr(where, PS_LIST_TAIL, "state", 0, "==", "auth"); 451 psMetadataAddStr(where, PS_LIST_TAIL, "state", 0, "==", "auth"); 454 452 455 453 // Value to set 456 454 psMetadataAddStr(values, PS_LIST_TAIL, "state", 0, "==", "run"); 457 455 458 456 long rows = psDBUpdateRows(config->dbh, "remoteRun", where, values); 459 457 psFree(values); … … 466 464 return(true); 467 465 } 468 466
Note:
See TracChangeset
for help on using the changeset viewer.
