diff --git a/src/server/node_manager.c b/src/server/node_manager.c index 371a1b1..8bbbbe8 100644 --- a/src/server/node_manager.c +++ b/src/server/node_manager.c @@ -2446,6 +2446,41 @@ void node_unreserve( +int hasres(struct pbsnode *pnode, char *name, char *value) + { + resource_def *rd; + resource *total, *used, req, tmp; + int rc; + + rd = find_resc_def(svr_resc_def,name,svr_resc_size); + + if (rd == NULL) /* unknown resource */ + return 0; + + total = find_resc_entry(&pnode->attributes[0],rd); + + if (total == NULL) /* resource not present on node */ + return 0; + + used = find_resc_entry(&pnode->attributes[1],rd); + + rd->rs_decode(&req.rs_value,0,name,value); /* encode the request into resource */ + rd->rs_set(&tmp.rs_value,&total->rs_value,SET); /* set the total */ + + if (used != NULL) + rd->rs_set(&tmp.rs_value,&used->rs_value,DECR); /* decrement the used amount */ + + rc = rd->rs_comp(&tmp.rs_value,&req.rs_value); /* finally compare the result */ + + rd->rs_free(&tmp.rs_value); + rd->rs_free(&req.rs_value); + + if (rc >= 0) + return 1; + else + return 0; + } + /* ** Look through the property list and make sure that all @@ -2466,18 +2501,26 @@ int hasprop( struct prop *pp; - if (need->mark == 0) /* not marked, skip */ - continue; + if (need->mark == 0 && (props->value == NULL)) /* not marked, skip */ + continue; /* do not skip resources */ - for (pp = pnode->nd_first;pp != NULL;pp = pp->next) + if (props->value == NULL) { - if (strcmp(pp->name, need->name) == 0) - break; /* found it */ - } + for (pp = pnode->nd_first;pp != NULL;pp = pp->next) + { + if (strcmp(pp->name, need->name) == 0) + break; /* found it */ + } - if (pp == NULL) + if (pp == NULL) + { + return(0); + } + } + else { - return(0); + if (!hasres(pnode,props->name,props->value)) + return 0; } }