def createSharedResourceOsh(resource, containerOsh, oshVector): ''' Shared resource OSH creation helper method @return: None, returned value are stored in parameter oshVector ''' is90 = modeling.checkAttributeExists('file_system_export', LOCAL_NAMES) if is90: shareOsh = ObjectStateHolder(NETWORK_SHARE) shareOsh.setAttribute("data_name", resource.path) shareOsh.setAttribute("share_path", resource.path) stringVector = StringVector() for instance in resource.getInstances(): stringVector.add(instance.name) shareOsh.setAttribute(LOCAL_NAMES, stringVector) shareOsh.setContainer(containerOsh) oshVector.add(shareOsh) else: for instance in resource.getInstances(): shareOsh = ObjectStateHolder(NETWORK_SHARE) shareOsh.setAttribute("data_name", instance.name) shareOsh.setAttribute("share_path", resource.path) if instance.description: shareOsh.setAttribute("data_description", instance.description) shareOsh.setContainer(containerOsh) oshVector.add(shareOsh)
def __setRemotePortNumber(self, portOsh, remoteNumber): 'osh, number -> None' if remoteNumber: try: remoteIndex = int(remoteNumber) except: if not modeling.checkAttributeExists(portOsh.getObjectClass(), 'port_remote_index'): portOsh.setAttribute('port_remotestpptid', remoteNumber) else: modeling._CMDB_CLASS_MODEL.setAttributeIfExists(portOsh, 'port_remote_index', remoteIndex, AppilogTypes.INTEGER_DEF)
def __setRemotePortNumber(self, portOsh, remoteNumber): 'osh, number -> None' if remoteNumber: try: remoteIndex = int(remoteNumber) except: if not modeling.checkAttributeExists(portOsh.getObjectClass(), 'port_remote_index'): portOsh.setAttribute('port_remotestpptid', remoteNumber) else: modeling._CMDB_CLASS_MODEL.setAttributeIfExists( portOsh, 'port_remote_index', remoteIndex, AppilogTypes.INTEGER_DEF)
def createCardOsh(cardObj, hostOSH): cardOsh = ObjectStateHolder('hardware_board') cardOsh.setAttribute('data_description', cardObj.descr) if modeling.checkAttributeExists('hardware_board', 'board_index'): cardOsh.setAttribute('board_index', cardObj.index) else: cardOsh.setAttribute('hardware_board_index', int(cardObj.index)) #cardOsh.setAttribute('serial_number', cardObj.serial) cardOsh.setAttribute('firmware_version', cardObj.firmVer) cardOsh.setAttribute('hardware_version', cardObj.hwVer) cardOsh.setAttribute('software_version', cardObj.swVer) cardOsh.setAttribute('data_name', cardObj.name) # TODO: classmodel attribute doesn't exist cardOsh.setAttribute('type', cardObj.type) cardOsh.setContainer(hostOSH) return cardOsh