Documentation for Neighborpolicy Module¶
NeighborPolicy
¶
Bases: ABC
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
accept_connection(source, joining=False)
abstractmethod
async
¶
Determine whether to accept a connection request from a given node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
The identifier of the node requesting the connection. |
required | |
joining
|
bool
|
Whether this is an initial joining request. |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the connection is accepted, False otherwise. |
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
any_leftovers_neighbors()
abstractmethod
async
¶
Return True if there are any neighbors that are no longer needed or should be replaced.
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
20 21 22 23 |
|
forget_nodes(nodes, forget_all=False)
abstractmethod
async
¶
Remove the specified nodes from internal memory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes
|
A list of node identifiers to forget. |
required | |
forget_all
|
bool
|
If True, forget all nodes. |
False
|
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
59 60 61 62 63 64 65 66 67 68 |
|
get_actions()
abstractmethod
async
¶
Return a list of actions (e.g., add or remove neighbors) that should be executed to maintain the policy.
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
44 45 46 47 |
|
get_neighbors_to_remove()
abstractmethod
async
¶
Return a list of neighbors that should be removed based on current policy constraints or evaluation.
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
25 26 27 28 |
|
get_nodes_known(neighbors_too=False, neighbors_only=False)
abstractmethod
async
¶
Retrieve a list of nodes known by the current policy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
neighbors_too
|
bool
|
If True, include current neighbors in the result. |
False
|
neighbors_only
|
bool
|
If True, return only current neighbors. |
False
|
Returns:
Name | Type | Description |
---|---|---|
list |
A list of node identifiers. |
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
get_posible_neighbors()
abstractmethod
async
¶
Return set of posible neighbors to connect to.
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
15 16 17 18 |
|
meet_node(node)
abstractmethod
async
¶
Register the discovery or interaction with a new node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
The node being encountered or added to internal memory. |
required |
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
49 50 51 52 53 54 55 56 57 |
|
need_more_neighbors()
abstractmethod
async
¶
Return True if the current node requires additional neighbors to fulfill its connectivity policy.
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
10 11 12 13 |
|
set_config(config)
abstractmethod
async
¶
Set internal configuration parameters for the neighbor policy, typically from a shared configuration object.
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
5 6 7 8 |
|
stricted_topology_status(stricted_topology)
abstractmethod
async
¶
Update the policy with the current strict topology status.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stricted_topology
|
bool
|
True if the topology should be preserved. |
required |
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
95 96 97 98 99 100 101 102 103 |
|
update_neighbors(node, remove=False)
abstractmethod
async
¶
Add or remove a neighbor in the current neighbor set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
The node to be added or removed. |
required | |
remove
|
bool
|
If True, remove the node instead of adding. |
False
|
Source code in nebula/core/situationalawareness/awareness/sanetwork/neighborpolicies/neighborpolicy.py
84 85 86 87 88 89 90 91 92 93 |
|