Skip to content

NFCLI Client API

PICLE Shell CLient¤

Client that implements interactive shell to work with NorFab.

FileServiceCommands ¤

Bases: BaseModel

Sample Usage¤

copy¤

Copy to client's fetched files directory:

file copy_ url nf://cli/commands.txt

Copy file to destination relative to current directory

file copy_ url nf://cli/commands.txt destination commands.txt

list¤

List files at broker root directory:

file list file list url nf://

List files details:

file details
file details url nf://

NorFabShell ¤

Bases: BaseModel

cmd_preloop_override() -> None classmethod ¤

This method called before CMD loop starts

Source code in norfab\clients\nfcli_shell\nfcli_shell_client.py
474
475
476
477
@classmethod
def cmd_preloop_override(self) -> None:
    """This method called before CMD loop starts"""
    pass

mount_shell_plugins(shell: App, inventory: object) -> None ¤

Mounts shell plugins to the given shell application.

This function iterates over the plugins in the inventory and mounts those that have an "nfcli" configuration to the shell application.

Parameters:

Name Type Description Default
shell App

The shell application to which the plugins will be mounted.

required
inventory object

An object containing the plugins to be mounted. It should have an attribute plugins which is a dictionary where keys are service names and values are service data dictionaries.

required

Returns:

Type Description
None

None

Source code in norfab\clients\nfcli_shell\nfcli_shell_client.py
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
def mount_shell_plugins(shell: App, inventory: object) -> None:
    """
    Mounts shell plugins to the given shell application.

    This function iterates over the plugins in the inventory and mounts
    those that have an "nfcli" configuration to the shell application.

    Args:
        shell (App): The shell application to which the plugins will be mounted.
        inventory (object): An object containing the plugins to be mounted.
                            It should have an attribute `plugins` which is a dictionary
                            where keys are service names and values are service data dictionaries.

    Returns:
        None
    """
    for service_name, service_data in inventory.plugins.items():
        if service_data.get("nfcli"):
            plugin = inventory.load_plugin(service_name)
            shell.model_mount(
                path=plugin[service_name]["nfcli"]["mount_path"],
                model=plugin[service_name]["nfcli"]["shell_model"],
            )

    # mount MAN commands
    shell.model_mount(
        path=["man", "tasks"],
        model=ManTasks,
        description="SHow NorFab services tasks documentation",
    )