daemon/core/conf.py
def configure(cls, mgr, msg):
        ''' Handle configuration messages for this object.
        '''
        reply = None
        nodenum = msg.gettlv(coreapi.CORE_TLV_CONF_NODE)
        objname = msg.gettlv(coreapi.CORE_TLV_CONF_OBJ)
        conftype = msg.gettlv(coreapi.CORE_TLV_CONF_TYPE)

        if mgr.verbose:
            mgr.info("received configure message for %s" % cls._name)
        if conftype == coreapi.CONF_TYPE_FLAGS_REQUEST:
            if mgr.verbose:
                mgr.info("replying to configure request for %s model" %
                           cls._name)
            # when object name is "all", the reply to this request may be None
            # if this node has not been configured for this model; otherwise we
            # reply with the defaults for this model
            if objname == "all":
                defaults = None
                typeflags = coreapi.CONF_TYPE_FLAGS_UPDATE
            else:
                defaults = cls.getdefaultvalues()
                typeflags = coreapi.CONF_TYPE_FLAGS_NONE
            values = mgr.getconfig(nodenum, cls._name, defaults)[1]
            if values is None:
                # node has no active config for this model (don't send defaults)
                return None
            # reply with config options
            reply = cls.toconfmsg(0, nodenum, typeflags, values)
        elif conftype == coreapi.CONF_TYPE_FLAGS_RESET:
            if objname == "all":
                mgr.clearconfig(nodenum)
        #elif conftype == coreapi.CONF_TYPE_FLAGS_UPDATE:
        else:
            # store the configuration values for later use, when the node
            # object has been created
            if objname is None:
                mgr.info("no configuration object for node %s" % nodenum)
                return None
            values_str = msg.gettlv(coreapi.CORE_TLV_CONF_VALUES)
            defaults = cls.getdefaultvalues()
            if values_str is None:
                # use default or preconfigured values
                values = mgr.getconfig(nodenum, cls._name, defaults)[1]
            else:
                # use new values supplied from the conf message
                values = values_str.split('|')
                # determine new or old style config
                new = cls.haskeyvalues(values)
                if new:
                    new_values = list(defaults)
                    keys = cls.getnames()
                    for v in values:
                        key, value = v.split('=', 1)
                        try:
                            new_values[keys.index(key)] = value
                        except ValueError:
                            mgr.info("warning: ignoring invalid key '%s'" % key)
                    values = new_values
            mgr.setconfig(nodenum, objname, values)
        return reply
 Handle configuration messages for this object.
        
Handle configuration messages for this object.
Handle configuration messages for this object .
def configure(cls, mgr, msg):
        reply = None
        nodenum = msg.gettlv(coreapi.CORE_TLV_CONF_NODE)
        objname = msg.gettlv(coreapi.CORE_TLV_CONF_OBJ)
        conftype = msg.gettlv(coreapi.CORE_TLV_CONF_TYPE)
        if mgr.verbose:
            mgr.info("received configure message for %s" % cls._name)
        if conftype == coreapi.CONF_TYPE_FLAGS_REQUEST:
            if mgr.verbose:
                mgr.info("replying to configure request for %s model" %
                           cls._name)
            if objname == "all":
                defaults = None
                typeflags = coreapi.CONF_TYPE_FLAGS_UPDATE
            else:
                defaults = cls.getdefaultvalues()
                typeflags = coreapi.CONF_TYPE_FLAGS_NONE
            values = mgr.getconfig(nodenum, cls._name, defaults)[1]
            if values is None:
                return None
            reply = cls.toconfmsg(0, nodenum, typeflags, values)
        elif conftype == coreapi.CONF_TYPE_FLAGS_RESET:
            if objname == "all":
                mgr.clearconfig(nodenum)
        else:
            if objname is None:
                mgr.info("no configuration object for node %s" % nodenum)
                return None
            values_str = msg.gettlv(coreapi.CORE_TLV_CONF_VALUES)
            defaults = cls.getdefaultvalues()
            if values_str is None:
                values = mgr.getconfig(nodenum, cls._name, defaults)[1]
            else:
                values = values_str.split('|')
                new = cls.haskeyvalues(values)
                if new:
                    new_values = list(defaults)
                    keys = cls.getnames()
                    for v in values:
                        key, value = v.split('=', 1)
                        try:
                            new_values[keys.index(key)] = value
                        except ValueError:
                            mgr.info("warning: ignoring invalid key '%s'" % key)
                    values = new_values
            mgr.setconfig(nodenum, objname, values)
        return reply
def configure ( cls , mgr , msg ) : reply = None nodenum = msg . gettlv ( coreapi . CORE_TLV_CONF_NODE ) objname = msg . gettlv ( coreapi . CORE_TLV_CONF_OBJ ) conftype = msg . gettlv ( coreapi . CORE_TLV_CONF_TYPE ) if mgr . verbose : mgr . info ( "received configure message for %s" % cls . _name ) if conftype == coreapi . CONF_TYPE_FLAGS_REQUEST : if mgr . verbose : mgr . info ( "replying to configure request for %s model" % cls . _name ) if objname == "all" : defaults = None typeflags = coreapi . CONF_TYPE_FLAGS_UPDATE else : defaults = cls . getdefaultvalues ( ) typeflags = coreapi . CONF_TYPE_FLAGS_NONE values = mgr . getconfig ( nodenum , cls . _name , defaults ) [ 1 ] if values is None : return None reply = cls . toconfmsg ( 0 , nodenum , typeflags , values ) elif conftype == coreapi . CONF_TYPE_FLAGS_RESET : if objname == "all" : mgr . clearconfig ( nodenum ) else : if objname is None : mgr . info ( "no configuration object for node %s" % nodenum ) return None values_str = msg . gettlv ( coreapi . CORE_TLV_CONF_VALUES ) defaults = cls . getdefaultvalues ( ) if values_str is None : values = mgr . getconfig ( nodenum , cls . _name , defaults ) [ 1 ] else : values = values_str . split ( '|' ) new = cls . haskeyvalues ( values ) if new : new_values = list ( defaults ) keys = cls . getnames ( ) for v in values : key , value = v . split ( '=' , 1 ) try : new_values [ keys . index ( key ) ] = value except ValueError : mgr . info ( "warning: ignoring invalid key '%s'" % key ) values = new_values mgr . setconfig ( nodenum , objname , values ) return reply
Handle configuration messages for this object.
Handle configuration messages for this object .
''' Handle configuration messages for this object.
        ''' # when object name is "all", the reply to this request may be None # if this node has not been configured for this model; otherwise we # reply with the defaults for this model # node has no active config for this model (don't send defaults) # reply with config options #elif conftype == coreapi.CONF_TYPE_FLAGS_UPDATE: # store the configuration values for later use, when the node # object has been created # use default or preconfigured values # use new values supplied from the conf message # determine new or old style config
cls
mgr
msg