Skip to content

Functions

Kim Knight edited this page Apr 2, 2025 · 7 revisions

addDevice

( deviceName, deviceModel, x, y )

Adds a device to the logical workspace.

Example:

addDevice("R1","2911",100,100)

addModule

( deviceName, slot, model )

Adds a module to a device.

  • slot should be a string, typically be something like 0/0, 2/0, or 0/0/1
  • model should be a string from this list of module models

Examples:

addModule("R1","0/0","HWIC-1GE-SFP")

addModule("R1","0/0/0","GLC-TE")

addLink

( device1Name, device1Interface, device2Name, device2Interface, linkType )

Creates a link between two devices.

Example:

addLink("R1","GigabitEthernet0/0","S1","GigabitEthernet0/1", "straight")

configureIosDevice

( deviceName, commands )

Sends configuration commands to a Cisco IOS device.

Example:

configureIosDevice("R2", "hostname R1\ninterface GigabitEthernet0/1\nno shutdown")

configurePcIp

( deviceName, [dhcpEnabled], [ipAddress], [subnetMask], [defaultGateway], [dnsServer] )

Configures the IP address settings on a PC or Server.

  • All parameters except deviceName are optional, however, if an ipAddress is specified, a subnetMask should also be specified

Example:

configurePcIp("PC1", false, "192.168.0.10", "255.255.255.0", "192.168.0.1")

getDevices

( [filter], [startsWith] )

Returns the names of devices in the current network as an array of strings.

  • filter optionally specifies the type(s) of device you want returned
  • filter can be specified as a string, a number (ID), an array of strings, or an array of numbers
  • If filter is not specified, all devices will be returned
  • Device type can be specified from this list of device types
  • startsWith optionally specifies a string that the device name must start with
    • For example: Return devices from HQ by specifying "HQ-" (only works if devices are named accordingly)

Examples:

getDevices("router")

getDevices(0)

getDevices(["switch", "router", "multilayerswitch"])

getDevices([0, 1, 16])

getDevices("switch", "HQ-")

for (var device of getDevices(["router","switch","multilayerswitch"])) {
    configureIosDevice(device, "enable secret class");
}
Clone this wiki locally