From 345579506938906a6b9db409004d9e99f4546bf0 Mon Sep 17 00:00:00 2001 From: Thijs Metsch Date: Tue, 8 Aug 2017 15:28:56 +0200 Subject: [PATCH] support for providing maxCPUs when adding host. --- lsf/lib/lib.xdrlim.c | 1 + lsf/lim/lim.conf.c | 5 +++++ lsf/lim/lim.h | 1 + lsf/lim/lim.info.c | 5 +++++ lsf/lsf.h | 2 ++ lsf/lstools/lsaddhost.c | 8 ++++++-- 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lsf/lib/lib.xdrlim.c b/lsf/lib/lib.xdrlim.c index 86b1abc..088e8af 100644 --- a/lsf/lib/lib.xdrlim.c +++ b/lsf/lib/lib.xdrlim.c @@ -1206,6 +1206,7 @@ xdr_hostEntry(XDR *xdrs, if (!xdr_int(xdrs, &hPtr->rcv) || !xdr_int(xdrs, &hPtr->nDisks) + || !xdr_int(xdrs, &hPtr->maxCPUs) || !xdr_float(xdrs, &hPtr->cpuFactor)) return FALSE; diff --git a/lsf/lim/lim.conf.c b/lsf/lim/lim.conf.c index db65cfb..3c8bfde 100644 --- a/lsf/lim/lim.conf.c +++ b/lsf/lim/lim.conf.c @@ -3043,6 +3043,11 @@ addHost_(struct clusterNode *clPtr, } hPtr->statInfo.nDisks = hEntPtr->nDisks; + if (hEntPtr->maxCPUs != NULL) { + hPtr->maxCPUs = hEntPtr->maxCPUs; + } else { + hPtr->maxCPUs = -1; + } hPtr->rexPriority = hEntPtr->rexPriority; for (i = 0; i < allInfo.numIndx; i++) diff --git a/lsf/lim/lim.h b/lsf/lim/lim.h index f23d41a..2c42d12 100644 --- a/lsf/lim/lim.h +++ b/lsf/lim/lim.h @@ -128,6 +128,7 @@ struct hostNode { struct hostNode *nextPtr; time_t expireTime; uint8_t migrant; + int maxCPUs; }; #define CLUST_ACTIVE 0x00010000 diff --git a/lsf/lim/lim.info.c b/lsf/lim/lim.info.c index 033340a..4fd1db9 100644 --- a/lsf/lim/lim.info.c +++ b/lsf/lim/lim.info.c @@ -452,6 +452,11 @@ hostInfoReq(XDR *xdrs, infoPtr->flags |= HINFO_SHARED_RESOURCE; } infoPtr->rexPriority = candidates[i]->rexPriority; + + if (candidates[i]->maxCPUs != -1) { + // this is the case lsaddhost was call with -M parameter. + infoPtr->maxCpus = candidates[i]->maxCPUs; + } } limReplyCode = LIME_NO_ERR; diff --git a/lsf/lsf.h b/lsf/lsf.h index 65d87f7..3264840 100644 --- a/lsf/lsf.h +++ b/lsf/lsf.h @@ -379,6 +379,7 @@ struct hostEntry { char **resList; int rexPriority; char *window; + int maxCPUs; }; struct config_param { @@ -570,6 +571,7 @@ struct hostEntryLog { char **resList; int rexPriority; char *window; + int maxCPUs; }; /* openlava error numbers diff --git a/lsf/lstools/lsaddhost.c b/lsf/lstools/lsaddhost.c index fcddbde..aad20f3 100644 --- a/lsf/lstools/lsaddhost.c +++ b/lsf/lstools/lsaddhost.c @@ -25,7 +25,7 @@ usage(void) fprintf(stderr, "\ lsaddhost: [-h] [-V] -m model -t type -f cpuFactor \ -D numDisks -R \"resource list\" -w \"windows\" \ --b \"busy onlist \" [-v] hostname\n"); +-M maxCPUs -b \"busy onlist \" [-v] hostname\n"); } static int getResList(struct hostEntry *, const char *); static int getBusyThr(struct hostEntry *, const char *); @@ -55,7 +55,7 @@ main(int argc, char **argv) for (cc = 0; cc < 11; cc++) hPtr->busyThreshold[cc] = INFINIT_LOAD; - while ((cc = getopt(argc, argv, "Vhvm:t:f:D:R:w:b:")) != EOF) { + while ((cc = getopt(argc, argv, "Vhvm:t:f:D:R:w:b:M:")) != EOF) { switch (cc) { case 'V': fputs(_LS_VERSION_, stderr); @@ -85,6 +85,9 @@ main(int argc, char **argv) case 'v': v = 1; /* verbose */ break; + case 'M': + hPtr->maxCPUs = atoi(optarg); + break; case 'h': case '?': default: @@ -187,4 +190,5 @@ printInfo(struct hostEntry *hPtr) printf("busyThresholds:\n"); for (cc = 0; cc < hPtr->numIndx; cc++) printf(" %4.2f\n", hPtr->busyThreshold[cc]); + printf("maxCPUs: %d\n", hPtr->maxCPUs); }