Exemple #1
0
def db_deviceagent_agentindices(value):
    """Get all agent indices from the DB.

    Args:
        idx_device: Index value of device

    Returns:
        List of agent indices reporting on the device

    """
    # Initialize key variables
    idx_device = int(value)

    # Get data from cache
    key = ('DB/Device/idx_device/{}/agents'.format(idx_device))
    cache_value = CACHE.get(key)

    # Process cache miss
    if cache_value is None:
        data = db_deviceagent.agent_indices(idx_device)
        CACHE.set(key, data)
    else:
        data = cache_value

    # Return
    return jsonify(data)
Exemple #2
0
def db_deviceagent_agentindices(idx_device):
    """Get all agent indices from the DB.

    Args:
        idx_device: Index value of device

    Returns:
        List of agent indices reporting on the device

    """
    # Return
    data = db_deviceagent.agent_indices(_integer(idx_device))
    return jsonify(data)
Exemple #3
0
def db_deviceagent_agentindices(value):
    """Get all agent indices from the DB.

    Args:
        idx_device: Index value of device

    Returns:
        List of agent indices reporting on the device

    """
    # Initialize key variables
    idx_device = int(value)

    # Process cache miss
    data = db_deviceagent.agent_indices(idx_device)

    # Return
    return jsonify(data)
Exemple #4
0
 def test_agent_indices(self):
     """Testing function agent_indices."""
     # Testing with known good value
     result = db_deviceagent.agent_indices(self.expected['idx_device'])
     self.assertEqual(result, [1])