コード例 #1
0
ファイル: CDB.py プロジェクト: ydc92546169/ACS
    def handleCDB(self, name):
        '''
        Handles an individual CDB entry. This means that if parameter, "name",
        exists within the ACS CDB; we take all info found within the CDB XML
        and add it to this object instance overriding previous 
        method/attribute defininitions where applicable.
        
        Parameters: name is the name of the CDB XML within the /alma/simulated
        section we are searching for.
        
        Returns: True if the current XML allows us to look at superinterfaces.
        False otherwise.
        
        Raises: Nothing
        '''
        ret_val = True

        #create an xml helper object
        xml_obj = getComponentXMLObj(name)

        # self.__logger.logInfo("xml_obj: " + xml_obj.toxml())
        # work around for some odd behaviour of the CDB. If the simulated component
        # node has sub nodes, then the SimulatedComponent element is replaced by the
        # name of the root component
        if xml_obj is not None:
            try:
                xml_obj.SimulatedComponent
            except AttributeError:
                new_el = xml_obj.createElement("SimulatedComponent")
                for item in xml_obj.firstChild.attributes.items():
                    new_el.setAttribute(item[0], item[1])
                for n in xml_obj.firstChild.childNodes:
                    if n.nodeType == xml_obj.ELEMENT_NODE:
                        new_el.appendChild(n)
                xml_obj.removeChild(xml_obj.firstChild)
                xml_obj.appendChild(new_el)
                xml_obj = XmlObject(xml_obj.toxml())

        if xml_obj != None:
            #at least one entry exists. good!
            self.exists = 1

            #get the corba methods
            self.getCorbaMethods(xml_obj)

            #get the corba attributes
            self.getCorbaAttributes(xml_obj)

            #setup the lifecycle methods
            self.setupLifecyleMethods(xml_obj)

            #allow inheritance?
            ret_val = xml_obj.SimulatedComponent.getAttribute(
                'AllowInheritance')
#            self.__logger.logInfo("returning: " + str(ret_val))

        return ret_val
コード例 #2
0
ファイル: CDB.py プロジェクト: ACS-Community/ACS
    def handleCDB(self, name):
        '''
        Handles an individual CDB entry. This means that if parameter, "name",
        exists within the ACS CDB; we take all info found within the CDB XML
        and add it to this object instance overriding previous 
        method/attribute defininitions where applicable.
        
        Parameters: name is the name of the CDB XML within the /alma/simulated
        section we are searching for.
        
        Returns: True if the current XML allows us to look at superinterfaces.
        False otherwise.
        
        Raises: Nothing
        '''
        ret_val = True
        
        #create an xml helper object
        xml_obj = getComponentXMLObj(name)
       
        # self.__logger.logInfo("xml_obj: " + xml_obj.toxml())
        # work around for some odd behaviour of the CDB. If the simulated component
        # node has sub nodes, then the SimulatedComponent element is replaced by the
        # name of the root component
        if xml_obj is not None:
            try:
                xml_obj.SimulatedComponent
            except AttributeError:
                new_el = xml_obj.createElement("SimulatedComponent")
                for item in xml_obj.firstChild.attributes.items():
                    new_el.setAttribute(item[0], item[1])
                for n in xml_obj.firstChild.childNodes:
                    if n.nodeType == xml_obj.ELEMENT_NODE:
                        new_el.appendChild(n)
                xml_obj.removeChild(xml_obj.firstChild)
                xml_obj.appendChild(new_el)
                xml_obj = XmlObject(xml_obj.toxml())
 
        if xml_obj!=None:
            #at least one entry exists. good!
            self.exists = 1
            
            #get the corba methods
            self.getCorbaMethods(xml_obj)

            #get the corba attributes
            self.getCorbaAttributes(xml_obj)
            
            #setup the lifecycle methods
            self.setupLifecyleMethods(xml_obj)
            
            #allow inheritance?
            ret_val = xml_obj.SimulatedComponent.getAttribute('AllowInheritance')
#            self.__logger.logInfo("returning: " + str(ret_val))
            
        return ret_val
コード例 #3
0
ファイル: GenericProperty.py プロジェクト: ydc92546169/ACS
    def __init__(self, name, charCompRef):
        '''
        Constructor

        Params:
        - name is the quite literally the name of the property
        - charCompRef is the characteristic component object which contains this
        property

        Returns: Nothing

        Raises: Nothing.
        '''
        #just call the superclass constructor
        Property.__init__(self, name, charCompRef)

        #setup a default value for all attributes
        self.cdbDict = {}

        try:
            #need access to the CDB to determine characteristics of this property
            cdbAccess = CDBaccess()

            #make sure the entry exists first of all...
            t_xml = cdbAccess.getField(
                "alma/" + self._get_characteristic_component_name())

            #create an xml helper object
            xml_obj = XmlObject(xmlString=t_xml)

            #get the top-level element
            xml_obj = xml_obj.firstChild

            t_prop_name = self._get_name().split('/')[1]

            #get the property we're looking for
            xml_obj = xml_obj.getElementsByTagName(t_prop_name)[0]

            #setup the CDB dict using attributes found within the CDB
            for attr in xml_obj.attributes.keys():
                self.cdbDict[attr] = xml_obj.getAttribute(attr)
        except:
            #print_exc()
            self.getLogger().logWarning(
                "Some problem occurred when attempting to retrieve data from the ACS CDB for: alma/"
                + self._get_characteristic_component_name() + "/" +
                self._get_name().split('/')[1])

        return
コード例 #4
0
def getComponentXMLObj(comp_name):
    '''
    Returns an XMLObjectifier for the given component name provided
    it exists within the ACS CDB. If this is not the case, simply 
    returns None. Probably not of much use outside the simulator
    framework.
    
    Params:
        comp_name - name of the component
        
    Returns:
        An Acspy.Util.XMLObjectifier.XmlObject if there's a description
        of the component found in $ACS_CDB/CDB/alma/simulated/*. If
        this is not the case, None is returned.
	
	Raises: Nothing
    '''
    try:
        #make sure the entry exists first of all...
        t_xml = CDB_ACCESS.getField("alma/simulated/" + comp_name)

        #create an xml helper object
        xml_obj = XmlObject(xmlString=t_xml)

    except:
        xml_obj = None

    return xml_obj
コード例 #5
0
    def __init__(self, name, charCompRef):
        '''
        Constructor

        Params:
        - name is the quite literally the name of the property
        - charCompRef is the characteristic component object which contains this
        property

        Returns: Nothing

        Raises: Nothing.
        '''
        #just call the superclass constructor
        Property.__init__(self, name, charCompRef)

        #setup a default value for all attributes
        self.cdbDict = {}

        try:
            #need access to the CDB to determine characteristics of this property
            cdbAccess = CDBaccess()
            
            #make sure the entry exists first of all...
            t_xml = cdbAccess.getField("alma/" + self._get_characteristic_component_name())
            
            #create an xml helper object
            xml_obj = XmlObject(xmlString = t_xml)

            #get the top-level element
            xml_obj = xml_obj.firstChild

            t_prop_name = self._get_name().split('/')[1]

            #get the property we're looking for
            xml_obj = xml_obj.getElementsByTagName(t_prop_name)[0]

            #setup the CDB dict using attributes found within the CDB
            for attr in xml_obj.attributes.keys():
                self.cdbDict[attr] = xml_obj.getAttribute(attr)
        except:
            #print_exc()
            self.getLogger().logWarning("Some problem occurred when attempting to retrieve data from the ACS CDB for: alma/" +
                                        self._get_characteristic_component_name()  + "/" + self._get_name().split('/')[1])
        
        return
コード例 #6
0
ファイル: CDBProperties.py プロジェクト: ydc92546169/ACS
def getEventHandlerTimeoutDict(channel_name):
    '''
    The following returns a dict where each key is the
    name of an event and the value is the maximum amount of time
    an event handler has to process the event before a warning
    message is logged.
    
    Params: channelName - name of the channel

    Return: a dictionary mapping event types to the maximum amount of time a
    handler has to process the event.

    Raises: ???
    '''
    ret_val = {}

    #sanity check to see if the CDB entry is present
    if cdb_channel_config_exists(channel_name) == 0:
        return ret_val

    #get the raw XML
    t_xml = get_cdb_access().getField("MACI/Channels/" + channel_name)

    #create an xml helper object
    xml_obj = XmlObject(xmlString=t_xml)

    #get the events section
    try:
        events = xml_obj.EventChannel.Events._
    except:
        #if there's an except, obviously the optional
        #events section was not added to this particular
        #event channel XML. OK to bail
        return ret_val

    #XmlObject will not convert to a sequence if only one
    #element is present. this we must do ourselves.
    if isSequenceType(events) == 0:
        events = [events]

    #for each event in the list populate our dict
    for dom in events:
        #get the event type
        event_name = dom.getAttribute('Name')
        #set the max timeout
        ret_val[event_name] = float(dom.getAttribute('MaxProcessTime'))

    return ret_val