Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node.clone plugin cleanup #1639

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions netsim/extra/node.clone/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
clone:
node_name_pattern: "{name[:13]}-{id:02d}" # Result should be a valid identifier, can use '-' in node names

attributes:
node:
clone: { type: int, min_value: 1, _required: True } # Create N copies of this node anywhere it's used in groups or links
start: int # Optional ID to start with, default 1
step: int # Optional increment between clones, default 1
#
# As the plugin runs before attribute validation, this structure is never checked. Left for documentation purposes
#
# attributes:
# node:
# count: { type: int, min_value: 1, _required: True } # Create N copies of this node anywhere it's used in groups or links
# start: int # Optional ID to start with, default 1
# step: int # Optional increment between clones, default 1
7 changes: 6 additions & 1 deletion netsim/extra/node.clone/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ def update_links(topo_items: str, nodename: str, clones: list, topology: Box) ->
def clone_node(node: Box, topology: Box) -> None:
_p = { 'start': 1, 'step': 1 } + node.pop('clone',{}) # Define cloning parameters
if 'count' not in _p:
log.error("Node {node.name} missing required attribute clone.count", # Not validated by Netlab yet
log.error("Node {node.name} missing required attribute clone.count", # Not validated by Netlab
category=AttributeError, module='node.clone')
return
for attr in _p:
if not data.is_true_int(_p[attr]) or _p[attr]<=0:
log.error(f"Attribute {attr} for node.clone must be a positive int",
category=AttributeError, module='node.clone')
return

if 'include' in node: # Check for components
log.error("Cannot clone component {node.name}, only elementary nodes",
Expand Down
Loading
Loading