def AssocReferenceToNode(nameSpace, entity_host, assocInst): assocClass = assocInst.classname assocKeyValPairs = assocInst.keybindings # The natural conversion to a string makes a perfect url, But we need to extract the components: # str(valAssoc) = 'root/cimv2:LMI_DiskDrive.CreationClassName="LMI_DiskDrive",SystemName="Unknown-30-b5-c2-02-0c-b5-2.home"' assoc_entity_id = ",".join("%s=%s" % (k, assocKeyValPairs[k]) for k in assocKeyValPairs) # The association and the references are probably in the same namespace. wbemAssocUrl = lib_wbem.WbemInstanceUrl(nameSpace, assocClass, assoc_entity_id, entity_host) wbemAssocNode = lib_common.NodeUrl(wbemAssocUrl) return wbemAssocNode
def DisplayPlainClass(grph, inst_names, rootNode, nameSpace, entity_host, className, maxInstances, startIndex): maxCnt = 0 # This is for normal classes. for iname in inst_names: if startIndex > 0: startIndex -= 1 continue if maxCnt == maxInstances: break maxCnt += 1 entity_id = ",".join("%s=%s" % (k, iname[k]) for k in iname.keys()) wbemInstanceUrl = lib_wbem.WbemInstanceUrl(nameSpace, className, entity_id, entity_host) wbemInstanceNode = lib_common.NodeUrl(wbemInstanceUrl) grph.add((rootNode, pc.property_class_instance, wbemInstanceNode))
def DisplayPlainClass(grph, inst_names, rootNode, nameSpace, entity_host, className, maxInstances, startIndex): maxCnt = 0 # This is for normal classes. for iname in inst_names: if startIndex > 0: startIndex -= 1 continue if maxCnt == maxInstances: break maxCnt += 1 # This concatenates all the properties, even the ones which are not in the Survol ontology. # This makes sense because we do not know if this class if known by Survol. entity_id = ",".join("%s=%s" % (k, iname[k]) for k in iname.keys()) wbemInstanceUrl = lib_wbem.WbemInstanceUrl(nameSpace, className, entity_id, entity_host) wbemInstanceNode = lib_common.NodeUrl(wbemInstanceUrl) grph.add((rootNode, pc.property_class_instance, wbemInstanceNode))
def DisplayAssociatorsAsList(grph, inst_names, rootNode, nameSpace, entity_host, className, maxInstances, startIndex): maxCnt = 0 for iname in inst_names: if startIndex > 0: startIndex -= 1 continue if maxCnt == maxInstances: break maxCnt += 1 # For the moment, references are not added to the Moniker, otherwise the syntax would be too complicated, like: # wbemInstName=root/CIMv2:TUT_ProcessChild.Parent="root/cimv2:TUT_UnixProcess.Handle="1"",Child="root/cimv2:TUT_UnixProcess.Handle="621"",OSCreationClassName="Linux_OperatingSystem",CSName="Unknown-30-b5-c2-02-0c-b5-2.home",CSCreationClassName="Linux_ComputerSystem",CreationClassName="TUT_UnixProcess",OSName="Unknown-30-b5-c2-02-0c-b5-2.home" entity_id = ",".join("%s=%s" % (k, iname[k]) for k in iname.keys()) wbemInstanceUrl = lib_wbem.WbemInstanceUrl(nameSpace, className, entity_id, entity_host) wbemInstanceNode = lib_common.NodeUrl(wbemInstanceUrl) # On va ajouter une colonne par reference. for keyAssoc in iname.keys(): assocInst = iname[keyAssoc] wbemAssocNode = AssocReferenceToNode(nameSpace, entity_host, assocInst) grph.add((wbemInstanceNode, lib_common.MakeProp(keyAssoc), wbemAssocNode)) # On voudrait que la propriete soit un lien mais que ca soit afficher en colonne avec le bon nom, comme in lityeral. # pc.property_rdf_data_nolist1 ??? pc.property_rdf_data_nolist1, pc.property_rdf_data_nolist2 ????? ### TODO: BUG DAND L AFFICHAGE, DESFOIS CA RELIE AU NODE, DESFOIS CA RELIE A UN nd_0 grph.add((rootNode, pc.property_class_instance, wbemInstanceNode))