Use digidevice.config for device configuration

Use the config Python module to access and modify the device configuration.

Read the device configuration

  1. Select a device in Remote Manager that is configured to allow shell access to the admin user, and click Actions > Open Console. Alternatively, log into the IX15 local command line as a user with shell access.

    Depending on your device configuration, you may be presented with an Access selection menu. Type shell to access the device shell.

  2. At the shell prompt, use the python command with no parameters to enter an interactive Python session:

    # python
    Python 3.10.1 (main, Mar 30 2023, 23:47:13) [GCC 11.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    

  3. Import the config submodule:
    >>> from digidevice import config
    >>>
  4. Use config.load() and the get() method to return the device's configuration:
    1. Return the entire configuration:

      >>> from pprint import pprint # use pprint vs. print to make the output easier to read
      >>> cfg = config.load()
      >>> pprint(cfg.dump().splitlines())

      This returns the device configuration:

      ...
      network.interface.lan1.device=/network/bridge/lan1
      network.interface.lan1.enable=true
      network.interface.lan1.ipv4.address=192.168.2.1/24
      network.interface.lan1.ipv4.connection_monitor.attempts=3
      ...
    2. Print a list of available interfaces:

      >>> cfg = config.load() 
      >>> interfaces = cfg.get("network.interface")
      >>> print(interfaces.keys())

      This returns the following:

      ['setupip', 'setuplinklocal', 'lan1', 'loopback', 'wan1', 'wwan1', 'wwan2']
      
    3. Print the IPv4 address of the LAN interface:

      >>> cfg = config.load()
      >>> interfaces = cfg.get(“network.interfaces”)
      >>> print(interfaces.get("lan.ipv4.address"))

      Which returns:

      192.168.2.1/24
      

Modify the device configuration

Use the set() and commit() methods to modify the device configuration:

  1. Select a device in Remote Manager that is configured to allow shell access to the admin user, and click Actions > Open Console. Alternatively, log into the IX15 local command line as a user with shell access.

    Depending on your device configuration, you may be presented with an Access selection menu. Type shell to access the device shell.

  2. At the shell prompt, use the python command with no parameters to enter an interactive Python session:

    # python
    Python 3.10.1 (main, Mar 30 2023, 23:47:13) [GCC 11.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    

  3. Import the config submodule:
    >>> from digidevice import config
    >>>
  4. Use config.load(writable=True) to enable write mode for the configuration:
    >>> cfg = config.load(writable=True)
    >>>
  5. Use the set() method to make changes to the configuration:
    >>> cfg.set("system.name", "New-Name")
    >>>
  6. Use the commit() method to save the changes:
    >>> cfg.commit()
    True
    >>>
  7. Use the get() method to verify the change:
    >>> print(cfg.get("system.name"))
    New-Name
    >>>