Ejemplo n.º 1
0
def parse_counters(data=None):
    if data is None:
        data = r.blpop(config.get('constants', 'REDIS_XML_QUEUE_KEY'))
    LOG.debug(data)
    data = eval(data[1])
    p_obj = Parser.parse_mfc_counters(data[0], data[1], data[2])
    r.rpush(config.get('constants', 'REDIS_PARSER_QUEUE_KEY'), Serialize.to_json(p_obj))
    return p_obj
Ejemplo n.º 2
0
def parse_counters(data=None):
    if data is None:
        data = r.blpop(config.get('constants', 'REDIS_XML_QUEUE_KEY'))
    LOG.debug(data)
    data = eval(data[1])
    p_obj = Parser.parse_mfc_counters(data[0], data[1], data[2])
    r.rpush(config.get('constants', 'REDIS_PARSER_QUEUE_KEY'),
            Serialize.to_json(p_obj))
    return p_obj
Ejemplo n.º 3
0
def parse_config_and_sync(data=None, sync_list=True):
    if sync_list:
        sync_list = List(key=config.get('constants',
                                        'REDIS_SYNC_DEV_LIST_KEY'),
                         redis=r)
    else:
        sync_list = List(key=config.get('constants',
                                        'REDIS_NEW_SYNC_DEV_LIST_KEY'),
                         redis=r)

    unsync_list = List(key=config.get('constants',
                                      'REDIS_UNSYNC_DEV_LIST_KEY'),
                       redis=r)
    if data is None:
        data = r.blpop(config.get('constants', 'REDIS_CONFIG_XML_QUEUE_KEY'))
    data = eval(data[1])
    device = data[0]
    xml = data[1]
    p_obj = Parser.parse_mfc_config(device, xml)
    if p_obj.header.status_code == 0:
        """ Update the gloabl DS

        extend the sync_dev_list with the device tuple
        Store the UUID in a global hashmap. will be retrieved using IP key.
        """
        try:
            mfc_uuid.update({device[2] + '_uuid': p_obj.data.config.host_id})
            mfc_uuid.update(
                {device[2] + '_hostname': p_obj.data.config.hostname})
            #Update to the sync list if its able to retrieve the data attributes
            sync_list.extend((device, ))
        except AttributeError:
            LOG.error("Something wrong with the Config data from MFC: " +
                      device[2])
            LOG.error("Restart agentd or make sure the config data is valid.")
            unsync_list.extend((device, ))
        finally:
            r.rpush(config.get('constants', 'REDIS_CONFIG_STORE_QUEUE_KEY'),
                    Serialize.to_json(p_obj))
    else:
        LOG.error("Unable to get config from MFC: " + device[2])
        LOG.error("Status Code: %s Message: %s" %
                  (p_obj.header.status_code, p_obj.header.status_msg))
        LOG.error("Check MFC state make sure Agentd is working fine.")
        unsync_list.extend((device, ))

    return p_obj
Ejemplo n.º 4
0
def parse_config_and_sync(data=None, sync_list=True):
    if sync_list:
        sync_list = List(key=config.get('constants', 'REDIS_SYNC_DEV_LIST_KEY'), redis=r)
    else:
        sync_list = List(key=config.get('constants', 'REDIS_NEW_SYNC_DEV_LIST_KEY'), redis=r)

    unsync_list = List(key=config.get('constants', 'REDIS_UNSYNC_DEV_LIST_KEY'), redis=r)
    if data is None:
        data = r.blpop(config.get('constants', 'REDIS_CONFIG_XML_QUEUE_KEY'))
    data = eval(data[1])
    device = data[0]
    xml = data[1]
    p_obj = Parser.parse_mfc_config(device, xml)
    if p_obj.header.status_code == 0:
        """ Update the gloabl DS

        extend the sync_dev_list with the device tuple
        Store the UUID in a global hashmap. will be retrieved using IP key.
        """
        try:
            mfc_uuid.update({device[2] + '_uuid': p_obj.data.config.host_id})
            mfc_uuid.update({device[2] + '_hostname': p_obj.data.config.hostname})
            #Update to the sync list if its able to retrieve the data attributes
            sync_list.extend((device,))
        except AttributeError:
            LOG.error("Something wrong with the Config data from MFC: " + device[2])
            LOG.error("Restart agentd or make sure the config data is valid.")
            unsync_list.extend((device,))
        finally:
            r.rpush(config.get('constants', 'REDIS_CONFIG_STORE_QUEUE_KEY'), Serialize.to_json(p_obj))
    else:
        LOG.error("Unable to get config from MFC: " + device[2])
        LOG.error("Status Code: %s Message: %s" % (p_obj.header.status_code, p_obj.header.status_msg))
        LOG.error("Check MFC state make sure Agentd is working fine.")
        unsync_list.extend((device,))

    return p_obj
Ejemplo n.º 5
0
 def to_json(self):
     return Serialize.to_json(self)