Merge branch 'ent-3595-discovery-fase-2' of https://brutus.artica.lan:8081/artica/pandorafms into ent-3595-discovery-fase-2

Former-commit-id: dbfc5603652eacc4214e6503b5603bd79f834984
This commit is contained in:
alejandro-campos 2019-03-05 15:06:18 +01:00
commit da0f0b492a
1 changed files with 18 additions and 6 deletions

View File

@ -386,8 +386,7 @@ function networkmap_generate_dot(
'unknown_count', 'unknown_count',
'total_count', 'total_count',
'notinit_count', 'notinit_count',
], ]
$strict_user
); );
} else { } else {
$agents = agents_get_agents( $agents = agents_get_agents(
@ -1641,10 +1640,17 @@ function networkmap_cidr_match($ip, $cidr_mask)
} }
/**
* Retrieve agent list matching desired network.
*
* @param string $ip_mask Networks.
* @param array $fields Extra fields.
*
* @return array Of agents.
*/
function networkmap_get_new_nodes_from_ip_mask( function networkmap_get_new_nodes_from_ip_mask(
$ip_mask, $ip_mask,
$fields=[], $fields=[]
$strict_user=false
) { ) {
$list_ip_masks = explode(',', $ip_mask); $list_ip_masks = explode(',', $ip_mask);
@ -1663,14 +1669,20 @@ function networkmap_get_new_nodes_from_ip_mask(
['id_a' => $address['id_a']] ['id_a' => $address['id_a']]
); );
// Orphan address. Ignore.
if (empty($id_agent)) { if (empty($id_agent)) {
continue; continue;
} }
if (empty($fields)) { if (empty($fields)) {
$agents[] = db_get_value_filter('id_agent', 'taddress_agent', ['id_a' => $address['id_a']]); $target_agent = db_get_value_filter('id_agent', 'taddress_agent', ['id_a' => $address['id_a']]);
} else { } else {
$agents[] = db_get_row('tagente', 'id_agente', $id_agent, $fields); $target_agent = db_get_row('tagente', 'id_agente', $id_agent, $fields);
}
// Agent exists. Add to pool.
if ($target_agent !== false) {
$agents[$id_agent] = $target_agent;
} }
} }
} }