Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nokia/moler/llms.txt

Use this file to discover all available pages before exploring further.

Moler provides command support for two Juniper device families:
  • moler.cmd.juniper — Junos CLI and configuration mode commands for Juniper routers.
  • moler.cmd.juniper_ex — Commands for Juniper EX-series switches (extends the router module).
All commands inherit from GenericJuniperCommand (moler.cmd.juniper.genericjuniper), which itself extends CommandTextualGeneric.
Juniper commands are typically connection-changing: they transition between the CLI (> prompt) and configuration (# prompt) modes. They signal completion by detecting the target prompt rather than returning parsed data.

Command list

Juniper (router) — moler.cmd.juniper

ClassModuleShell commandMode
Configuremoler.cmd.juniper.cli.configureconfigureCLI → configure
ExitConfiguremoler.cmd.juniper.configure.exit_configureexitconfigure → CLI
GenericJuniperCommandmoler.cmd.juniper.genericjuniper(abstract base)

Juniper EX (switch) — moler.cmd.juniper_ex

ClassModuleShell commandMode
GenericJuniperExCommandmoler.cmd.juniper_ex.genericjuniperex(abstract base)

Detailed reference

Configuremoler.cmd.juniper.cli.configure

Switches the Juniper device from CLI mode to configuration mode by sending the configure command and waiting for the configuration-mode prompt.
connection
object
required
Moler connection to the Juniper device.
prompt
str
Regex for the starting CLI prompt. Defaults to generic detection.
expected_prompt
str
Regex for the target configuration-mode prompt. Default r'^admin@switch#'.
newline_chars
list
Characters used to split output lines.
target_newline
str
Newline characters for the remote system. Default "\r\n".
runner
object
Runner used to execute the command.
Return value Returns {} when the expected configuration-mode prompt is detected. ret_required is False.
from moler.cmd.juniper.cli.configure import Configure

cmd = Configure(
    connection=conn,
    expected_prompt=r'^admin@switch#',
)
cmd()
# Device is now in: [edit] admin@switch#

ExitConfiguremoler.cmd.juniper.configure.exit_configure

Exits Juniper configuration mode by sending exit and waiting for the CLI-mode prompt.
connection
object
required
Moler connection to the Juniper device.
prompt
str
Regex for the starting configuration-mode prompt.
expected_prompt
str
Regex for the target CLI-mode prompt. Default r'^admin@switch>'.
target_newline
str
Newline characters for the remote system. Default "\r\n".
Return value Returns {} when the expected CLI-mode prompt is detected.
from moler.cmd.juniper.configure.exit_configure import ExitConfigure

cmd = ExitConfigure(
    connection=conn,
    expected_prompt=r'^admin@switch>',
)
cmd()
# Device is now in CLI mode: admin@switch>

Typical Juniper workflow

A typical test sequence enters configuration mode, applies changes, then returns to CLI mode:
from moler.cmd.juniper.cli.configure import Configure
from moler.cmd.juniper.configure.exit_configure import ExitConfigure
from moler.cmd.unix.enter import Enter  # to send raw commands

# 1. Enter configuration mode
enter_cfg = Configure(
    connection=conn,
    expected_prompt=r'^admin@switch#',
)
enter_cfg()

# 2. Apply a configuration change (send raw command lines)
raw = Enter(connection=conn)
raw(command_string="set interfaces ge-0/0/0 description 'uplink'")
raw(command_string="commit")

# 3. Exit configuration mode
exit_cfg = ExitConfigure(
    connection=conn,
    expected_prompt=r'^admin@switch>',
)
exit_cfg()

Base classes

GenericJuniperCommandmoler.cmd.juniper.genericjuniper

Abstract base for all Juniper router commands. Accepts connection, prompt, newline_chars, and runner. Inherits all textual parsing infrastructure from CommandTextualGeneric.

GenericJuniperExCommandmoler.cmd.juniper_ex.genericjuniperex

Abstract base for Juniper EX-series switch commands. Extends GenericJuniperCommand with EX-specific defaults.
Juniper EX commands reuse the same prompt-detection mechanism as standard Juniper commands. Instantiate with the appropriate expected_prompt for your switch’s configured prompt.