def discoverPhysicalVolumes(wmiProvider, OSHVec, hostOSH): queryBuilder = wmiProvider.getBuilder("MSFT_Disk") queryBuilder.addWmiObjectProperties("ObjectId", "Path", "FriendlyName", "SerialNumber", "Number", "Size") wmicAgent = wmiProvider.getAgent() idToOshMap = {} numberToOshMap = {} try: phyVolumes = wmicAgent.getWmiData(queryBuilder) except: logger.debugException("Failed getting partition to volume map via wmi") return idToOshMap for volume in phyVolumes: id = volume.ObjectId and volume.ObjectId.strip() or "" id = id.replace("&", "&") name = volume.Path and volume.Path.strip() or "" name = name.replace("&", "&") description = volume.FriendlyName serialNumber = volume.SerialNumber number = volume.Number size = volume.Size phyVolumeOsh = ObjectStateHolder("physicalvolume") phyVolumeOsh.setStringAttribute("name", name) phyVolumeOsh.setStringAttribute("description", description) phyVolumeOsh.setStringAttribute("serial_number", serialNumber) phyVolumeOsh.setStringAttribute("volume_id", id) phyVolumeOsh.setDoubleAttribute("volume_size", _bytesToMB(size)) phyVolumeOsh.setContainer(hostOSH) OSHVec.add(phyVolumeOsh) idToOshMap[id] = phyVolumeOsh numberToOshMap[number] = phyVolumeOsh return idToOshMap, numberToOshMap
def createInterfaceIndexOsh(networkInterface, hostOsh): if hostOsh and networkInterface and networkInterface.interfaceIndex and networkInterface.speed: ifaceIndexOsh = ObjectStateHolder('interfaceindex') ifaceIndexOsh.setContainer(hostOsh) ifaceIndexOsh.setIntegerAttribute('interfaceindex_index', networkInterface.interfaceIndex) ifaceIndexOsh.setDoubleAttribute('interfaceindex_speed', networkInterface.speed) return ifaceIndexOsh
def discoverPhysicalVolumes(wmiProvider, OSHVec, hostOSH): queryBuilder = wmiProvider.getBuilder('MSFT_Disk') queryBuilder.addWmiObjectProperties('ObjectId', 'Path', 'FriendlyName', 'SerialNumber', 'Number', 'Size') wmicAgent = wmiProvider.getAgent() idToOshMap = {} numberToOshMap = {} try: phyVolumes = wmicAgent.getWmiData(queryBuilder) except: logger.debugException('Failed getting partition to volume map via wmi') return idToOshMap for volume in phyVolumes: id = volume.ObjectId and volume.ObjectId.strip() or '' id = id.replace('&', '&') name = volume.Path and volume.Path.strip() or '' name = name.replace('&', '&') description = volume.FriendlyName serialNumber = volume.SerialNumber number = volume.Number size = volume.Size phyVolumeOsh = ObjectStateHolder("physicalvolume") phyVolumeOsh.setStringAttribute("name", name) phyVolumeOsh.setStringAttribute("description", description) phyVolumeOsh.setStringAttribute("serial_number", serialNumber) phyVolumeOsh.setStringAttribute("volume_id", id) phyVolumeOsh.setDoubleAttribute("volume_size", _bytesToMB(size)) phyVolumeOsh.setContainer(hostOSH) OSHVec.add(phyVolumeOsh) idToOshMap[id] = phyVolumeOsh numberToOshMap[number] = phyVolumeOsh return idToOshMap, numberToOshMap
def build(self): osh = ObjectStateHolder('fcport') osh.setIntegerAttribute('fcport_portid', int(self.portId)) osh.setIntegerAttribute('port_index', int(self.portId)) setAttribute(osh, 'port_number', self.portId) setAttribute(osh, 'name', self.name) setAttribute(osh, 'fcport_wwn', self.wwn) setAttribute(osh, 'fcport_status', self.status) setAttribute(osh, 'fcport_state', self.state) osh.setDoubleAttribute('fcport_speed', float(self.speed)) self.osh = osh return osh
def discoverDiskMountPoints(wmiProvider, OSHVec, hostOSH, phyVolumeNumberToOshMap={}): queryBuilder = wmiProvider.getBuilder('MSFT_Partition') queryBuilder.addWmiObjectProperties('AccessPaths', 'DiskId', 'DiskNumber', 'DriveLetter', 'Size') wmicAgent = wmiProvider.getAgent() partitionItems = [] try: partitionItems = wmicAgent.getWmiData(queryBuilder) except: logger.debugException('Failed getting partition information') return for partition in partitionItems: mountedTo = "" mountVolumeName = "" if isinstance(partition.AccessPaths, list): if len(partition.AccessPaths) >= 2: mountedTo = partition.AccessPaths[0] mountVolumeName = partition.AccessPaths[1] else: mountVolumeName = partition.AccessPaths[0] else: items = partition.AccessPaths.split(",") if len(items) >= 2: mountedTo = items[0] mountVolumeName = items[1] pysicalDiskNumber = partition.DiskNumber size = partition.Size if mountedTo: mountedTo = mountedTo.rstrip(":\\") fsOsh = modeling.createFileSystemOSH(hostOSH, mountedTo, "FixedDisk", size=size) OSHVec.add(fsOsh) logicalVolOsh = ObjectStateHolder("logical_volume") logicalVolOsh.setStringAttribute("name", mountVolumeName) logicalVolOsh.setDoubleAttribute("logicalvolume_size", _bytesToMB(size)) logicalVolOsh.setContainer(hostOSH) OSHVec.add(logicalVolOsh) OSHVec.add( modeling.createLinkOSH("dependency", fsOsh, logicalVolOsh)) phyVolumeOsh = phyVolumeNumberToOshMap.get(pysicalDiskNumber) if phyVolumeOsh: OSHVec.add( modeling.createLinkOSH("usage", logicalVolOsh, phyVolumeOsh))
def report(self, region_osh): vector = ObjectStateHolderVector() image_osh = ObjectStateHolder('openstack_image') image_osh.setStringAttribute('image_id', self.id) if self.name: image_osh.setStringAttribute('name', self.name) if self.disk_format: image_osh.setStringAttribute('disk_format', self.disk_format) if self.size: image_osh.setDoubleAttribute('size', self.size) vector.add(image_osh) vector.add(modeling.createLinkOSH('membership', region_osh, image_osh)) return image_osh, vector
def createPhysicalVolumeOsh(physicalVolume, parentOsh): """ Creates Object State Holder for Physical Volume CI @param physicalVolume: the discovered Physical Volume @type physicalVolume: instance of the PhysicalVolume Data Object @param parentOsh: Object State Holder of the Host this Physical Volume belongs to @type parentOsh: OSH instance of a Host CI or any of its siblings @return: Physical Volume OSH """ if physicalVolume and physicalVolume.pvName: pvOsh = ObjectStateHolder("physicalvolume") pvOsh.setStringAttribute("data_name", physicalVolume.pvName) if physicalVolume.pvId: pvOsh.setStringAttribute("volume_id", physicalVolume.pvId) if physicalVolume.pvSize: pvOsh.setDoubleAttribute("volume_size", physicalVolume.pvSize) pvOsh.setContainer(parentOsh) return pvOsh
def discoverDiskMountPoints(wmiProvider, OSHVec, hostOSH, phyVolumeNumberToOshMap={}): queryBuilder = wmiProvider.getBuilder("MSFT_Partition") queryBuilder.addWmiObjectProperties("AccessPaths", "DiskId", "DiskNumber", "DriveLetter", "Size") wmicAgent = wmiProvider.getAgent() partitionItems = [] try: partitionItems = wmicAgent.getWmiData(queryBuilder) except: logger.debugException("Failed getting partition information") return for partition in partitionItems: mountedTo = "" mountVolumeName = "" if isinstance(partition.AccessPaths, list): if len(partition.AccessPaths) >= 2: mountedTo = partition.AccessPaths[0] mountVolumeName = partition.AccessPaths[1] else: mountVolumeName = partition.AccessPaths[0] else: items = partition.AccessPaths.split(",") if len(items) >= 2: mountedTo = items[0] mountVolumeName = items[1] pysicalDiskNumber = partition.DiskNumber size = partition.Size if mountedTo: mountedTo = mountedTo.rstrip(":\\") fsOsh = modeling.createFileSystemOSH(hostOSH, mountedTo, "FixedDisk", size=size) OSHVec.add(fsOsh) logicalVolOsh = ObjectStateHolder("logical_volume") logicalVolOsh.setStringAttribute("name", mountVolumeName) logicalVolOsh.setDoubleAttribute("logicalvolume_size", _bytesToMB(size)) logicalVolOsh.setContainer(hostOSH) OSHVec.add(logicalVolOsh) OSHVec.add(modeling.createLinkOSH("dependency", fsOsh, logicalVolOsh)) phyVolumeOsh = phyVolumeNumberToOshMap.get(pysicalDiskNumber) if phyVolumeOsh: OSHVec.add(modeling.createLinkOSH("usage", logicalVolOsh, phyVolumeOsh))
def build_sr(self, sr): sr_osh = ObjectStateHolder('citrix_storage_repository') sr_osh.setStringAttribute('uuid', sr.uuid) sr_osh.setStringAttribute('name', sr.getLabel()) sr_osh.setStringAttribute('logicalvolume_fstype', sr.getType()) sr_osh.setStringAttribute('description', sr.getDescription()) sr_osh.setDoubleAttribute('logicalvolume_size', sr.getPhysicalSize()) sr_osh.setDoubleAttribute('logicalvolume_used', sr.getPhysicalUtilisation()) sr_osh.setDoubleAttribute('logicalvolume_free', sr.getPhysicalSize() - sr.getPhysicalUtilisation()) return sr_osh
def build_sr(self, sr): sr_osh = ObjectStateHolder('citrix_storage_repository') sr_osh.setStringAttribute('uuid', sr.uuid) sr_osh.setStringAttribute('name', sr.getLabel()) sr_osh.setStringAttribute('logicalvolume_fstype', sr.getType()) sr_osh.setStringAttribute('description', sr.getDescription()) sr_osh.setDoubleAttribute('logicalvolume_size', sr.getPhysicalSize()) sr_osh.setDoubleAttribute('logicalvolume_used', sr.getPhysicalUtilisation()) sr_osh.setDoubleAttribute( 'logicalvolume_free', sr.getPhysicalSize() - sr.getPhysicalUtilisation()) return sr_osh
def osh_createASPOsh(lparOsh, ASPList, DiskList): spDict = {} str_name = 'name' str_storagepool_poolid = 'storagepool_poolid' str_storagepool_mbavailable = 'storagepool_mbavailable' str_storagepool_mbtotal = 'storagepool_mbtotal' str_storagepool_capacitynum = 'storagepool_capacitynum' str_serial_number = 'serial_number' str_logicalvolume_fstype = 'logicalvolume_fstype' str_logicalvolume_id = 'logicalvolume_id' str_logicalvolume_free = 'logicalvolume_free' str_logicalvolume_size = 'logicalvolume_size' _vector = ObjectStateHolderVector() if isNotNull(ASPList): for asp in ASPList: if isNotNull(asp[0]): aspname = ('ASP' + asp[0]) spOsh = ObjectStateHolder('storagepool') spOsh.setAttribute(str_name, aspname) spOsh.setIntegerAttribute(str_storagepool_poolid, int(asp[0])) spOsh.setDoubleAttribute(str_storagepool_mbavailable, asp[3]) spOsh.setDoubleAttribute(str_storagepool_mbtotal, asp[2]) spOsh.setIntegerAttribute(str_storagepool_capacitynum, asp[1]) spOsh.setContainer(lparOsh) spDict[asp[0]] = spOsh _vector.add(spOsh) if isNotNull(DiskList): for disk in DiskList: if isNotNull(disk[0]): aspid = disk[0] diskOsh = ObjectStateHolder('logical_volume') diskOsh.setAttribute(str_name, disk[4]) diskOsh.setAttribute(str_serial_number, disk[3]) diskOsh.setAttribute(str_logicalvolume_fstype, disk[1]) diskOsh.setIntegerAttribute(str_logicalvolume_id, int(disk[5])) diskOsh.setDoubleAttribute(str_logicalvolume_free, disk[7]) diskOsh.setDoubleAttribute(str_logicalvolume_size, disk[6]) diskOsh.setContainer(lparOsh) _vector.add(diskOsh) if spDict.has_key(aspid): memberOsh = modeling.createLinkOSH('membership', spDict[aspid], diskOsh) _vector.add(memberOsh) return _vector
def osh_createASPOsh(lparOsh, ASPList, DiskList): spDict = {} str_name = 'name' str_storagepool_poolid = 'storagepool_poolid' str_storagepool_mbavailable = 'storagepool_mbavailable' str_storagepool_mbtotal = 'storagepool_mbtotal' str_storagepool_capacitynum = 'storagepool_capacitynum' str_serial_number = 'serial_number' str_logicalvolume_fstype = 'logicalvolume_fstype' str_logicalvolume_id = 'logicalvolume_id' str_logicalvolume_free = 'logicalvolume_free' str_logicalvolume_size = 'logicalvolume_size' _vector = ObjectStateHolderVector() if isNotNull(ASPList): for asp in ASPList: if isNotNull(asp[0]): aspname = ('ASP' + asp[0]) spOsh = ObjectStateHolder('storagepool') spOsh.setAttribute(str_name, aspname ) spOsh.setIntegerAttribute(str_storagepool_poolid, int(asp[0])) spOsh.setDoubleAttribute(str_storagepool_mbavailable, asp[3]) spOsh.setDoubleAttribute(str_storagepool_mbtotal, asp[2]) spOsh.setIntegerAttribute(str_storagepool_capacitynum, asp[1]) spOsh.setContainer(lparOsh) spDict[asp[0]] = spOsh _vector.add(spOsh) if isNotNull(DiskList): for disk in DiskList: if isNotNull(disk[0]): aspid = disk[0] diskOsh = ObjectStateHolder('logical_volume') diskOsh.setAttribute(str_name, disk[4]) diskOsh.setAttribute(str_serial_number, disk[3]) diskOsh.setAttribute(str_logicalvolume_fstype, disk[1]) diskOsh.setIntegerAttribute(str_logicalvolume_id, int(disk[5])) diskOsh.setDoubleAttribute(str_logicalvolume_free, disk[7]) diskOsh.setDoubleAttribute(str_logicalvolume_size, disk[6]) diskOsh.setContainer(lparOsh) _vector.add(diskOsh) if spDict.has_key(aspid): memberOsh = modeling.createLinkOSH('membership', spDict[aspid], diskOsh) _vector.add(memberOsh) return _vector
def createLogicalVolumeOsh(logicalVolume, parentOsh): """ Creates Object State Holder for Logical Volume CI @param logicalVolume: the discovered Logical Volume @type logicalVolume: instance of the LogicalVolume Data Object @param parentOsh: Object State Holder of the Host this Logical Volume belongs to @type parentOsh: OSH instance of a Host CI or any of its siblings @return: Logical Volume OSH """ if logicalVolume and logicalVolume.lvName: lvOsh = ObjectStateHolder("logicalvolume") lvOsh.setStringAttribute("data_name", logicalVolume.lvName) if logicalVolume.lvId: lvOsh.setIntegerAttribute("logicalvolume_id", logicalVolume.lvId) if logicalVolume.lvSize: lvOsh.setDoubleAttribute("logicalvolume_size", logicalVolume.lvSize) if logicalVolume.lvState: lvOsh.setStringAttribute("logicalvolume_status", logicalVolume.lvState) if logicalVolume.lvStorCapabilities: lvOsh.setStringAttribute("logicalvolume_stotagecapabilities", logicalVolume.lvStorCapabilities) if logicalVolume.lvAccType: lvOsh.setStringAttribute("logicalvolume_accesstype", logicalVolume.lvAccType) if logicalVolume.lvAvailability: lvOsh.setStringAttribute("logicalvolume_availability", logicalVolume.lvAvailability) if logicalVolume.lvDomainId: lvOsh.setStringAttribute("logicalvolume_domainid", logicalVolume.lvDomainId) if logicalVolume.lvFsType: lvOsh.setStringAttribute("logicalvolume_fstype", logicalVolume.lvFsType) if logicalVolume.lvShareName: lvOsh.setStringAttribute("logicalvolume_sharename", logicalVolume.lvShareName) if logicalVolume.lvFree: lvOsh.setDoubleAttribute("logicalvolume_free", logicalVolume.lvFree) if logicalVolume.lvUsed: lvOsh.setDoubleAttribute("logicalvolume_used", logicalVolume.lvUsed) lvOsh.setContainer(parentOsh) return lvOsh
def processObjects(allObjects): vector = ObjectStateHolderVector() iter = allObjects.iterator() #ciList = [[id, type, props]] ciList = [] ciDict = {} createCi = 1 while iter.hasNext(): #attributes = [name, type, key, value] attributes = [] objectElement = iter.next() mamId = objectElement.getAttribute('mamId').getValue() cit = objectElement.getAttribute('name').getValue() if mamId != None and cit != None: # add the attributes... allAttributes = objectElement.getChildren('field') iterAtt = allAttributes.iterator() while iterAtt.hasNext(): attElement = iterAtt.next() attName = attElement.getAttribute('name').getValue() attType = attElement.getAttribute('datatype').getValue() #print 'GOT TYPE: ', attType attKey = attElement.getAttribute('key') attValue = attElement.getText() if attType == None or attType == "": attType = "string" if attKey == None or attKey == "": attKey = "false" else: attKey = attKey.getValue() if attName != "" and attType != "": attributes.append([attName, attType, attKey, attValue]) # create CI or not? Is key empty or none? if attKey == "true": # print 'KEY ATTRIB <', attName, '> with value <', attValue, '> for CIT <', cit, '> with MAMID <', mamId, '>' if attValue != None and attValue.strip() != "": createCi = 1 else: createCi = 0 #info (concatenate("Id: ", mamId, ", Type: ", cit, ", Properties: ", attributes)) if createCi == 1: ciList.append([mamId, cit, attributes]) ciDict[mamId] = [mamId, cit, attributes] for ciVal in ciList: dontCreateCI = 0 #info("\tAdding %s [%s] => [%s]" % (ciVal[1], ciVal[0], ciVal[2]) ) id = ciVal[0] type = ciVal[1] osh = ObjectStateHolder(type) if ciVal[2] != None: props = ciVal[2] createContainer = 0 containerOsh = None for prop in props: if prop[0] == 'root_container': if dontCreateCI or prop[3] not in ciDict.keys(): # print 'MAM ID <', prop[3], '> not found!' dontCreateCI = 1 continue parent = ciDict[prop[3]] # create the container osh if parent != None: #parentId = parent[0] parentType = parent[1] parentProps = parent[2] containerOsh = ObjectStateHolder(parentType) if parentProps != None: for parentProp in parentProps: containerOsh.setAttribute(parentProp[0], parentProp[3]) createContainer = 1 #print 'Props <', prop, '>' try: if prop[1] == 'StrProp': osh.setStringAttribute(prop[0], prop[3]) elif prop[1] == 'StrListProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setListAttribute(prop[0], [prop[3]]) elif prop[1] == 'DoubleProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setDoubleAttribute(prop[0], prop[3]) elif prop[1] == 'FloatProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setFloatAttribute(prop[0], prop[3]) elif prop[1] == 'IntProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: #print '[VINAY] Got int <', prop[3], '>' osh.setIntegerAttribute(prop[0], prop[3]) elif prop[1] == 'LongProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: #print '[VINAY] Got long <', prop[3], '>' osh.setLongAttribute(prop[0], prop[3]) elif prop[1] == 'BoolProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setBoolAttribute(prop[0], prop[3]) elif prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setAttribute(prop[0], prop[3]) if createContainer == 1: osh.setContainer(containerOsh) except: stacktrace = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) logger.warn('Exception setting attribute <', prop[0], '> with value <', prop[3], '>:\n', stacktrace) pass if dontCreateCI: continue vector.add(osh) return (vector, ciDict)
def createInterfaceObjects(ifList, host_id, ucmdbversion = None): result = ObjectStateHolderVector() discoveredHostOSH = modeling.createOshByCmdbId('host', host_id) for interface in ifList: if interface.ifType and int(interface.ifType) == 24: continue if not modeling.isValidInterface(interface.ifMac, interface.ifDescr, interface.ifName): continue interface.ifDescr = _stripVirtualMiniportInfo(interface.ifDescr) interfaceOSH = modeling.createInterfaceOSH(interface.ifMac, discoveredHostOSH, interface.ifDescr, interface.ifIndex, interface.ifType, interface.ifAdminStatus, interface.ifOperStatus, interface.ifSpeed, interface.ifName, interface.ifAlias) if not interfaceOSH: continue result.add(interfaceOSH) if ucmdbversion and ucmdbversion < 9: interfaceIndexOSH = ObjectStateHolder("interfaceindex") interfaceIndexOSH.setIntegerAttribute("interfaceindex_index", interface.ifIndex) if interface.ifAdminStatus: intValue = None try: intValue = int(interface.ifAdminStatus) except: logger.warn("Failed to convert the interface admin status '%s'" % interface.ifAdminStatus) else: if intValue > 0: interfaceIndexOSH.setEnumAttribute("interfaceindex_adminstatus", intValue) if interface.ifDescr != None and interface.ifDescr != '': interfaceIndexOSH.setStringAttribute("interfaceindex_description", interface.ifDescr) if interface.ifIndex != None and interface.ifIndex != '': interfaceIndexOSH.setIntegerAttribute("interfaceindex_index", interface.ifIndex) if interface.ifSpeed != None and interface.ifSpeed != '': interfaceIndexOSH.setDoubleAttribute("interfaceindex_speed", interface.ifSpeed) if interface.ifType: intValue = None try: intValue = int(interface.ifType) except: logger.warn("Failed to convert the interface type '%s'" % interface.ifType) else: if intValue > 0: interfaceIndexOSH.setEnumAttribute("interfaceindex_type", intValue) interfaceIndexOSH.setContainer(discoveredHostOSH) result.add(interfaceIndexOSH) parentLinkOSH = modeling.createLinkOSH('parent', interfaceIndexOSH, interfaceOSH) result.add(parentLinkOSH) for ip in interface.ipList: if str(ip.ipAddr).startswith('0.') or str(ip.ipAddr).startswith('127.'): continue ipOSH = modeling.createIpOSH(ip.ipAddr) parentLinkOSH = modeling.createLinkOSH('containment', interfaceOSH, ipOSH) result.add(parentLinkOSH) return result
def processObjects(allObjects): vector = ObjectStateHolderVector() iter = allObjects.iterator() #ciList = [[id, type, props]] ciList = [] ciDict = {} createCi = 1 while iter.hasNext(): #attributes = [name, type, key, value] attributes = [] objectElement = iter.next() mamId = objectElement.getAttribute('mamId').getValue() cit = objectElement.getAttribute('name').getValue() if mamId != None and cit != None: # add the attributes... allAttributes = objectElement.getChildren('field') iterAtt = allAttributes.iterator() while iterAtt.hasNext(): attElement = iterAtt.next() attName = attElement.getAttribute('name').getValue() attType = attElement.getAttribute('datatype').getValue() #print 'GOT TYPE: ', attType attKey = attElement.getAttribute('key') attValue = attElement.getText() if attType == None or attType == "": attType = "string" if attKey == None or attKey == "": attKey = "false" else: attKey = attKey.getValue() if attName != "" and attType != "": attributes.append([attName, attType, attKey, attValue]) # create CI or not? Is key empty or none? if attKey == "true": # print 'KEY ATTRIB <', attName, '> with value <', attValue, '> for CIT <', cit, '> with MAMID <', mamId, '>' if attValue != None and attValue.strip() != "": createCi = 1 else: createCi = 0 #info (concatenate("Id: ", mamId, ", Type: ", cit, ", Properties: ", attributes)) if createCi == 1: ciList.append([mamId, cit, attributes]) ciDict[mamId] = [mamId, cit, attributes] for ciVal in ciList: dontCreateCI = 0 #info("\tAdding %s [%s] => [%s]" % (ciVal[1], ciVal[0], ciVal[2]) ) id = ciVal[0] type = ciVal[1] osh = ObjectStateHolder(type) if ciVal[2] != None: props = ciVal[2] createContainer = 0 containerOsh = None for prop in props: if prop[0] == 'root_container': if dontCreateCI or prop[3] not in ciDict.keys(): # print 'MAM ID <', prop[3], '> not found!' dontCreateCI = 1 continue parent = ciDict[prop[3]] # create the container osh if parent != None: #parentId = parent[0] parentType = parent[1] parentProps = parent[2] containerOsh = ObjectStateHolder(parentType) if parentProps != None: for parentProp in parentProps: containerOsh.setAttribute( parentProp[0], parentProp[3]) createContainer = 1 #print 'Props <', prop, '>' try: if prop[1] == 'StrProp': osh.setStringAttribute(prop[0], prop[3]) elif prop[1] == 'StrListProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: osh.setListAttribute(prop[0], [prop[3]]) elif prop[1] == 'DoubleProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: osh.setDoubleAttribute(prop[0], prop[3]) elif prop[1] == 'FloatProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: osh.setFloatAttribute(prop[0], prop[3]) elif prop[1] == 'IntProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: #print '[VINAY] Got int <', prop[3], '>' osh.setIntegerAttribute(prop[0], prop[3]) elif prop[1] == 'LongProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: #print '[VINAY] Got long <', prop[3], '>' osh.setLongAttribute(prop[0], prop[3]) elif prop[1] == 'BoolProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: osh.setBoolAttribute(prop[0], prop[3]) elif prop[3] != None and prop[3] != '' and len( prop[3]) > 0: osh.setAttribute(prop[0], prop[3]) if createContainer == 1: osh.setContainer(containerOsh) except: stacktrace = traceback.format_exception( sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) logger.warn('Exception setting attribute <', prop[0], '> with value <', prop[3], '>:\n', stacktrace) pass if dontCreateCI: continue vector.add(osh) return (vector, ciDict)