Skip to content

FakeNOS Service Restart Task¤

task api name: restart

The FakeNOS service restart task stops a running virtual network and immediately starts it again using the same inventory. This allows you to refresh a network's simulated devices without having to re-supply the inventory configuration.

FakeNOS Restart Task Overview¤

The restart task provides the following features:

  • Inventory Preservation: Reuses the inventory that was provided when the network was originally started — no need to re-fetch or re-specify it.
  • Seamless Re-initialisation: Stops the existing child process cleanly, then spawns a new one with the same configuration.
  • Immediate Feedback: Returns the same detailed host and process information as the start task.

FakeNOS Restart Task Arguments¤

Argument Type Default Description
network str required Name of the FakeNOS network to restart. The network must already be running.

FakeNOS Restart Command Shell Reference¤

NorFab shell supports these command options for Netbox create_prefix task:

nf#man tree fakenos.start

R - required field, M - supports multiline input, D - dynamic key

root
└── fakenos:    FakeNOS service
    └── start:    FakeNOS start command
        ├── network (R):    FakeNOS network name to start
        ├── inventory:    Inventory content (dict) or path/URL to an inventory file
        ├── timeout:    Job timeout
        ├── workers:    Filter workers to target, default 'all'
        ├── verbose-result:    Control output details, default 'False'
        ├── progress:    Display progress events, default 'True'
        └── nowait:    Do not wait for job to complete, default 'False'
nf#

Python API Reference¤

Stop and restart an existing FakeNOS network.

Retrieves the previously resolved inventory from self.networks, stops the running process, then starts a fresh child process using the same inventory. Progress events are forwarded to the caller via job.

Parameters:

Name Type Description Default
job Job

NorFab job context injected by the @Task decorator.

required
network str

Name of the FakeNOS network to restart. Must already exist in self.networks.

required
Source code in norfab\workers\fakenos_worker\fakenos_worker.py
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
@Task(
    input=FakeNOSRestartInput,
    output=FakeNOSNetworkActionResult,
    fastapi={"methods": ["POST"]},
    mcp={
        "annotations": {
            "title": "Restart FakeNOS Network",
            "readOnlyHint": False,
            "destructiveHint": True,
            "idempotentHint": False,
            "openWorldHint": False,
        }
    },
)
def restart(self, job: Job, network: str) -> Result:
    """
    Stop and restart an existing FakeNOS network.

    Retrieves the previously resolved inventory from ``self.networks``,
    stops the running process, then starts a fresh child process using the
    same inventory.  Progress events are forwarded to the caller via *job*.

    Args:
        job: NorFab job context injected by the ``@Task`` decorator.
        network: Name of the FakeNOS network to restart.  Must already
            exist in ``self.networks``.
    """
    ret = Result()
    log.info(f"{self.name} - Restart: Restarting '{network}' FakeNOS network")
    inventory = self.networks[network]["inventory"]
    self.stop(job, network)
    self.start(job, network, inventory)
    ret.result = self.inspect_networks(
        job=job, network=network, details=True
    ).result
    return ret