Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
from pydd import GoalDb, DeviceDetectionProtocol, Device

# The local IP address
localip = "192.168.0.200"
# Default timeout in ms
timeout = 2000

...

idx = 1
ip_start = "192.168.0."
ip_end = 101
netmask = "255.255.255.0"
gw = "192.168.0.1"
dns0 = "0.0.0.0"
dns1 = "0.0.0.0"
dhcp_enabled = False
activate = True
permanent = True
for device in devices:
    ip = ip_start + str(ip_end)
    ipdata = (ip, netmask, gw, dns0, dns1, dhcp_enabled)
    print("============ Network Params Device {id} ============".format(id = idx))
    
    res = proto.writenetworkparams(device, localip, timeout, ipdata, activate, permanent)
    
    print("Result: " + ("Success" if res else "Failed"))
    print()
    idx += 1
    ip_end += 1

As shown in the code example above, writenetworkparams expects the following parameters:

  • device: The Device instance where the IP data shall be set

  • localip: The local IP to use as the source address

  • timeout: The timeout in ms

  • ipdata: A touple containing the IP address, the net mask, the gw, dns0, dns1 and whether DHCP shall be enabled. IP addresses are provided as a dotted string notation (e.g.”192.168.0.1”), dhcp_enabled is a boolean value.

  • activate: Set to True if the IP address settings shall be coming effective immediately. Otherwise, the settings are applied after the next reboot.

  • permanent: Set To True if the IP address settings shall be stored in flash. If False, the settings are lost after a reboot.