@@ -463,7 +463,111 @@ PyObject * ls_load_py(char *resreq, int *numhosts, int options, char *fromhost)
463463 return result;
464464}
465465
466+ PyObject * ls_info_py () {
467+ struct resItem * allRes = NULL ;
468+ struct lsInfo * allInfo = NULL ;
469+ char *type = NULL ;
470+ char *model = NULL ;
471+ char *arch = NULL ;
472+
473+ int i = 0 , j = 0 ;
474+
475+ allInfo = ls_info ();
476+ if (allInfo == NULL ) {
477+ ls_perror (" ls_info_py" );
478+ exit (-1 );
479+ }
480+
481+ PyObject * result = PyDict_New ();
482+ PyObject * nRes = Py_BuildValue (" i" ,allInfo->nRes );
483+ PyDict_SetItemString (result, " nRes" ,nRes);
484+ PyObject * nTypes = Py_BuildValue (" i" , allInfo->nTypes );
485+ PyDict_SetItemString (result, " nTypes" , nTypes);
486+ PyObject * nModels = Py_BuildValue (" i" , allInfo->nModels );
487+ PyDict_SetItemString (result, " nModels" , nModels);
488+ PyObject * numIndx = Py_BuildValue (" i" , allInfo->numIndx );
489+ PyDict_SetItemString (result, " numIndx" , numIndx);
490+ PyObject * numUsrIndx = Py_BuildValue (" i" , allInfo->numUsrIndx );
491+ PyDict_SetItemString (result, " numUsrIndx" , numUsrIndx);
492+
493+ allRes = allInfo->resTable ;
494+ for (i = 0 ; i < allInfo->nRes ; i++) {
495+ int size_string = sizeof (allRes[i].name );
496+ int len_string = strlen (allRes[i].name );
497+ for (j = len_string; j < size_string; j++) {
498+ allRes[i].name [j] = 0 ;
499+ }
500+ size_string = sizeof (allRes[i].des );
501+ len_string = strlen (allRes[i].des );
502+ for (j = len_string; j < size_string; j++) {
503+ allRes[i].des [j] = 0 ;
504+ }
505+ }
506+
507+ PyObject * resRst = PyList_New (allInfo->nRes );
508+ for (i = 0 ; i < allInfo->nRes ; i++) {
509+ PyObject *o = SWIG_NewPointerObj (SWIG_as_voidptr (&allRes[i]),
510+ SWIGTYPE_p_resItem, 0 | 0 );
511+ PyList_SetItem (resRst,i,o);
512+ }
513+ PyDict_SetItemString (result, " resTable" , resRst);
514+
515+ PyObject * typeRst = PyList_New (allInfo->nTypes );
516+ for (i = 0 ; i < allInfo->nTypes ; i++) {
517+ type = strdup (allInfo->hostTypes [i]);
518+ int size_string = sizeof (type);
519+ int len_string = strlen (type);
520+ for (j = len_string; j < size_string; j++) {
521+ type[j] = 0 ;
522+ }
523+ PyObject * pyType = Py_BuildValue (" s" ,type);
524+ PyList_SetItem (typeRst,i,pyType);
525+ if (type != NULL ) {
526+ free (type);
527+ }
528+ }
529+ PyDict_SetItemString (result, " hostTypes" , typeRst);
530+
531+ PyObject * modelRst = PyList_New (allInfo->nModels );
532+ PyObject * archRst = PyList_New (allInfo->nModels );
533+ PyObject * refRst = PyList_New (allInfo->nModels );
534+ PyObject * factorRst = PyList_New (allInfo->nModels );
535+
536+ for (i = 0 ; i < allInfo->nModels ; i++) {
537+ model = strdup (allInfo->hostModels [i]);
538+ int size_string = sizeof (model);
539+ int len_string = strlen (model);
540+ for (j = len_string; j < size_string; j++) {
541+ model[j] = 0 ;
542+ }
543+ PyObject *pyModel = Py_BuildValue (" s" ,model);
544+ PyList_SetItem (modelRst,i,pyModel);
545+
546+ arch = strdup (allInfo->hostArchs [i]);
547+ size_string = sizeof (arch);
548+ len_string = strlen (arch);
549+ for (j = len_string; j < size_string; j++) {
550+ arch[j] = 0 ;
551+ }
552+ PyObject *pyArch = Py_BuildValue (" s" ,arch);
553+ PyList_SetItem (archRst,i,pyArch);
554+
555+ PyObject *pyRef = Py_BuildValue (" i" ,allInfo->modelRefs [i]);
556+ PyList_SetItem (refRst,i,pyRef);
557+
558+ PyObject *pyFactor = Py_BuildValue (" f" ,allInfo->cpuFactor [i]);
559+ PyList_SetItem (factorRst,i,pyFactor);
560+ }
561+
562+ PyDict_SetItemString (result," hostModels" ,modelRst);
563+ PyDict_SetItemString (result," hostArchs" ,archRst);
564+ PyDict_SetItemString (result," modelRefs" ,refRst);
565+ PyDict_SetItemString (result," cpuFactor" ,factorRst);
566+
567+ return result;
568+ }
466569
570+
467571PyObject * get_queue_info_by_name (char ** name, int num) {
468572 struct queueInfoEnt * queueinfo;
469573 int numqueues = num;
0 commit comments