text
stringlengths
81
112k
gets the neighboring devices' extended address to compute the DUT extended address automatically Returns: A list including extended address of neighboring routers, parent as well as children def getNeighbouringDevices(self): """gets the neighboring devices' extended ...
get expected global unicast IPv6 address of Thread device Args: filterByPrefix: a given expected global IPv6 prefix to be matched Returns: a global IPv6 address def getGUA(self, filterByPrefix=None): """get expected global unicast IPv6 address of Thread device ...
set mesh local prefix def setMLPrefix(self, sMeshLocalPrefix): """set mesh local prefix""" print '%s call setMLPrefix' % self.port try: cmd = 'dataset meshlocalprefix %s' % sMeshLocalPrefix self.hasActiveDatasetToCommit = True return self.__sendCommand(cmd)[0...
force to set a slaac IPv6 address to Thread interface Args: slaacAddress: a slaac IPv6 address to be set Returns: True: successful to set slaac address to Thread interface False: fail to set slaac address to Thread interface def forceSetSlaac(self, slaacAddress): ...
start Collapsed Commissioner Returns: True: successful to start Commissioner False: fail to start Commissioner def startCollapsedCommissioner(self): """start Collapsed Commissioner Returns: True: successful to start Commissioner False: fail to s...
scan Joiner Args: xEUI: Joiner's EUI-64 strPSKd: Joiner's PSKd for commissioning Returns: True: successful to add Joiner's steering data False: fail to add Joiner's steering data def scanJoiner(self, xEUI='*', strPSKd='threadjpaketest'): """scan...
start joiner Args: strPSKd: Joiner's PSKd Returns: True: successful to start joiner False: fail to start joiner def joinCommissioned(self, strPSKd='threadjpaketest', waitTime=20): """start joiner Args: strPSKd: Joiner's PSKd Re...
get Commissioning logs Returns: Commissioning logs def getCommissioningLogs(self): """get Commissioning logs Returns: Commissioning logs """ rawLogs = self.logThread.get() ProcessedLogs = [] payload = [] while not rawLogs.empty(): ...
send MGMT_ED_SCAN message to a given destinaition. Args: sAddr: IPv6 destination address for this message xCommissionerSessionId: commissioner session id listChannelMask: a channel array to indicate which channels to be scaned xCount: number of IEEE 802.15.4 ED S...
send MGMT_PANID_QUERY message to a given destination Args: xPanId: a given PAN ID to check the conflicts Returns: True: successful to send MGMT_PANID_QUERY message. False: fail to send MGMT_PANID_QUERY message. def MGMT_PANID_QUERY(self, sAddr, xCommissionerSession...
send MGMT_ACTIVE_SET command Returns: True: successful to send MGMT_ACTIVE_SET False: fail to send MGMT_ACTIVE_SET def MGMT_ACTIVE_SET(self, sAddr='', xCommissioningSessionId=None, listActiveTimestamp=None, listChannelMask=None, xExtendedPanId=None, sNetworkName...
send MGMT_PENDING_SET command Returns: True: successful to send MGMT_PENDING_SET False: fail to send MGMT_PENDING_SET def MGMT_PENDING_SET(self, sAddr='', xCommissionerSessionId=None, listPendingTimestamp=None, listActiveTimestamp=None, xDelayTimer=None, xChann...
send MGMT_COMM_GET command Returns: True: successful to send MGMT_COMM_GET False: fail to send MGMT_COMM_GET def MGMT_COMM_GET(self, Addr='ff02::1', TLVs=[]): """send MGMT_COMM_GET command Returns: True: successful to send MGMT_COMM_GET False: f...
send MGMT_COMM_SET command Returns: True: successful to send MGMT_COMM_SET False: fail to send MGMT_COMM_SET def MGMT_COMM_SET(self, Addr='ff02::1', xCommissionerSessionID=None, xSteeringData=None, xBorderRouterLocator=None, xChannelTlv=None, ExceedMaxPayload=Fals...
set Joiner UDP Port Args: portNumber: Joiner UDP Port number Returns: True: successful to set Joiner UDP Port False: fail to set Joiner UDP Port def setUdpJoinerPort(self, portNumber): """set Joiner UDP Port Args: portNumber: Joiner UDP...
stop commissioner Returns: True: successful to stop commissioner False: fail to stop commissioner def commissionerUnregister(self): """stop commissioner Returns: True: successful to stop commissioner False: fail to stop commissioner """ ...
force update to router as if there is child id request def updateRouterStatus(self): """force update to router as if there is child id request""" print '%s call updateRouterStatus' % self.port cmd = 'state' while True: state = self.__sendCommand(cmd)[0] if state ...
Find the `expected` line within `times` trials. Args: expected str: the expected string times int: number of trials def _expect(self, expected, times=50): """Find the `expected` line within `times` trials. Args: expected str: the expected string...
Read exactly one line from the device, nonblocking. Returns: None on no data def _readline(self): """Read exactly one line from the device, nonblocking. Returns: None on no data """ if len(self.lines) > 1: return self.lines.pop(0) t...
Send exactly one line to the device Args: line str: data send to device def _sendline(self, line): """Send exactly one line to the device Args: line str: data send to device """ self.lines = [] try: self._read() except socket...
Send command and wait for response. The command will be repeated 3 times at most in case data loss of serial port. Args: req (str): Command to send, please do not include new line in the end. Returns: [str]: The output lines def _req(self, req): """Send comman...
Threading callback def run(self): """Threading callback""" self.viewing = True while self.viewing and self._lock.acquire(): try: line = self._readline() except: pass else: logger.info(line) self._lo...
Reset openthread device, not equivalent to stop and start def reset(self): """Reset openthread device, not equivalent to stop and start """ logger.debug('DUT> reset') self._log and self.pause() self._sendline('reset') self._read() self._log and self.resume()
Add network prefix. Args: prefix (str): network prefix. flags (str): network prefix flags, please refer thread documentation for details prf (str): network prf, please refer thread documentation for details def add_prefix(self, prefix, flags, prf): """Add network pr...
Remove network prefix. def remove_prefix(self, prefix): """Remove network prefix. """ self._req('prefix remove %s' % prefix) time.sleep(1) self._req('netdataregister')
Initialize the telnet connection def _init(self): """Initialize the telnet connection """ self.tn = telnetlib.Telnet(self.ip, self.port) self.tn.read_until('User Name') self.tn.write('apc\r\n') self.tn.read_until('Password') self.tn.write('apc\r\n') self....
Open telnet connection Args: params (dict), must contain two parameters "ip" - ip address or hostname and "port" - port number Example: params = {'port': 23, 'ip': 'localhost'} def open(self, **params): """Open telnet connection Args: params (dict)...
Wait until the regex encountered def until(self, regex): """Wait until the regex encountered """ logger.debug('waiting for %s', regex) r = re.compile(regex, re.M) self.tn.expect([r])
Reboot outlet Args: params (dict), must contain parameter "outlet" - outlet number Example: params = {'outlet': 1} def reboot(self, **params): """Reboot outlet Args: params (dict), must contain parameter "outlet" - outlet number Example: ...
send specific command to reference unit over serial port Args: cmd: OpenThread_WpanCtl command string Returns: Fail: Failed to send the command to reference unit and parse it Value: successfully retrieve the desired value from reference unit Error: some ...
strip the special characters in the value Args: value: value string Returns: value string without special characters def __stripValue(self, value): """strip the special characters in the value Args: v...
get specific type of IPv6 address configured on OpenThread_WpanCtl Args: addressType: the specific type of IPv6 address link local: link local unicast IPv6 address that's within one-hop scope global: global unicast IPv6 address rloc: mesh local unicast IPv6 addr...
set thread device mode: Args: mode: thread device mode. 15=rsdn, 13=rsn, 4=s r: rx-on-when-idle s: secure IEEE 802.15.4 data request d: full thread device n: full network data Returns: True: successful to set the device mode ...
set address filter mode Returns: True: successful to set address filter mode. False: fail to set address filter mode. def __setAddressfilterMode(self, mode): """set address filter mode Returns: True: successful to set address filter mode. False:...
start OpenThreadWpan Returns: True: successful to start OpenThreadWpan up False: fail to start OpenThreadWpan def __startOpenThreadWpan(self): """start OpenThreadWpan Returns: True: successful to start OpenThreadWpan up False: fail to start Open...
stop OpenThreadWpan Returns: True: successfully stop OpenThreadWpan False: failed to stop OpenThreadWpan def __stopOpenThreadWpan(self): """stop OpenThreadWpan Returns: True: successfully stop OpenThreadWpan False: failed to stop OpenThreadWpan ...
check whether or not OpenThreadWpan is running Returns: True: OpenThreadWpan is running False: OpenThreadWpan is not running def __isOpenThreadWpanRunning(self): """check whether or not OpenThreadWpan is running Returns: True: OpenThreadWpan is running ...
mapping Rloc16 to router id Args: xRloc16: hex rloc16 short address Returns: actual router id allocated by leader def __convertRlocToRouterId(self, xRloc16): """mapping Rloc16 to router id Args: xRloc16: hex rloc16 short address Returns: ...
convert a channel list to a string Args: channelList: channel list (i.e. [21, 22, 23]) Returns: a comma separated channel string (i.e. '21, 22, 23') def __ChannelMaskListToStr(self, channelList): """convert a channel list to a string Args: channelL...
get joiner state def __getJoinerState(self): """ get joiner state """ maxDuration = 150 # seconds t_end = time.time() + maxDuration while time.time() < t_end: joinerState = self.__stripValue(self.__sendCommand('sudo wpanctl getprop -v NCP:State')[0]) if joinerSt...
initialize the serial port with baudrate, timeout parameters def intialize(self): """initialize the serial port with baudrate, timeout parameters""" print '%s call intialize' % self.port try: # init serial port self.deviceConnected = False self._connect() ...
get Thread Network name def getNetworkName(self): """get Thread Network name""" print '%s call getNetworkname' % self.port networkName = self.__sendCommand(WPANCTL_CMD + 'getprop -v Network:Name')[0] return self.__stripValue(networkName)
set the extended addresss of Thread device Args: xEUI: extended address in hex format Returns: True: successful to set the extended address False: fail to set the extended address def setMAC(self, xEUI): """set the extended addresss of Thread device ...
get one specific type of MAC address currently OpenThreadWpan only supports Random MAC address Args: bType: indicate which kind of MAC address is required Returns: specific type of MAC address def getMAC(self, bType=MacType.RandomMac): """get one specific ty...
get link local unicast IPv6 address def getLL64(self): """get link local unicast IPv6 address""" print '%s call getLL64' % self.port return self.__stripValue(self.__sendCommand(WPANCTL_CMD + 'getprop -v IPv6:LinkLocalAddress')[0])
get router locator unicast IPv6 address def getRloc(self): """get router locator unicast IPv6 address""" print '%s call getRloc' % self.port prefix = self.__stripValue(self.__sendCommand(WPANCTL_CMD + 'getprop -v IPv6:MeshLocalPrefix')[0]) mlprefix = prefix.split('/')[0] rloc16 ...
set Thread Network master key Args: key: Thread Network master key used in secure the MLE/802.15.4 packet Returns: True: successful to set the Thread Network master key False: fail to set the Thread Network master key def setNetworkKey(self, key): """set Th...
add a given extended address to the whitelist addressfilter Args: xEUI: a given extended address in hex format Returns: True: successful to add a given extended address to the whitelist entry False: fail to add a given extended address to the whitelist entry def ad...
clear all entries in whitelist table Returns: True: successful to clear the whitelist False: fail to clear the whitelist def clearAllowList(self): """clear all entries in whitelist table Returns: True: successful to clear the whitelist False: fa...
get current device role in Thread Network def getDeviceRole(self): """get current device role in Thread Network""" print '%s call getDeviceRole' % self.port return self.__stripValue(self.__sendCommand(WPANCTL_CMD + 'getprop -v Network:NodeType')[0])
make device ready to join the Thread Network with a given role Args: eRoleId: a given device role id Returns: True: ready to set Thread Network parameter for joining desired Network def joinNetwork(self, eRoleId): """make device ready to join the Thread Network with a ...
get current partition id of Thread Network Partition from LeaderData Returns: The Thread network Partition Id def getNetworkFragmentID(self): """get current partition id of Thread Network Partition from LeaderData Returns: The Thread network Partition Id """ ...
get Thread device's parent extended address and rloc16 short address Returns: The extended address of parent in hex format def getParentAddress(self): """get Thread device's parent extended address and rloc16 short address Returns: The extended address of parent in hex...
power down the OpenThreadWpan def powerDown(self): """power down the OpenThreadWpan""" print '%s call powerDown' % self.port if self.__sendCommand(WPANCTL_CMD + 'setprop Daemon:AutoAssociateAfterReset false')[0] != 'Fail': time.sleep(0.5) if self.__sendCommand(WPANCTL_CM...
power up the Thread device def powerUp(self): """power up the Thread device""" print '%s call powerUp' % self.port if not self.handle: self._connect() self.isPowerDown = False if self.__sendCommand(WPANCTL_CMD + 'attach')[0] != 'Fail': time.sleep(3) ...
reset and rejoin to Thread Network without any timeout Returns: True: successful to reset and rejoin the Thread Network False: fail to reset and rejoin the Thread Network def reboot(self): """reset and rejoin to Thread Network without any timeout Returns: T...
send ICMPv6 echo request with a given length to a unicast destination address Args: destination: the unicast destination address of ICMPv6 echo request length: the size of ICMPv6 echo request payload def ping(self, destination, length=20): """ send ICMPv6 echo reque...
get OpenThreadWpan stack firmware version number def getVersionNumber(self): """get OpenThreadWpan stack firmware version number""" print '%s call getVersionNumber' % self.port versionStr = self.__sendCommand(WPANCTL_CMD + 'getprop -v NCP:Version')[0] return self.__stripValue(versionSt...
set Thread Network PAN ID Args: xPAN: a given PAN ID in hex format Returns: True: successful to set the Thread Network PAN ID False: fail to set the Thread Network PAN ID def setPANID(self, xPAN): """set Thread Network PAN ID Args: xPAN...
factory reset def reset(self): """factory reset""" print '%s call reset' % self.port try: if self._is_net: self.__sendCommand(WPANCTL_CMD + 'leave') else: self._sendline(WPANCTL_CMD + 'leave') self.__sendCommand(WPANCTL_CMD + ...
kick router with a given router id from the Thread Network Args: xRouterId: a given router id in hex format Returns: True: successful to remove the router from the Thread Network False: fail to remove the router from the Thread Network def removeRouter(self, xRoute...
set default mandatory Thread Network parameter value def setDefaultValues(self): """set default mandatory Thread Network parameter value""" print '%s call setDefaultValues' % self.port # initialize variables self.networkName = ModuleHelper.Default_NwkName self.networkKey = Modu...
set data polling rate for sleepy end device Args: iPollingRate: data poll period of sleepy end device Returns: True: successful to set the data polling rate for sleepy end device False: fail to set the data polling rate for sleepy end device def setPollingRate(self...
reset and join back Thread Network with a given timeout delay Args: timeout: a timeout interval before rejoin Thread Network Returns: True: successful to reset and rejoin Thread Network False: fail to reset and rejoin the Thread Network def resetAndRejoin(self, tim...
configure the border router with a given prefix entry parameters Args: P_Prefix: IPv6 prefix that is available on the Thread Network P_stable: is true if the default router is expected to be stable network data P_default: is true if border router offers the default route for...
set keep alive timeout for device has been deprecated and also set SED polling rate Args: iTimeOut: data poll period for sleepy end device Returns: True: successful to set the data poll period for SED False: fail to set the data poll period for SED def s...
set the Key sequence counter corresponding to Thread Network master key Args: iKeySequenceValue: key sequence value Returns: True: successful to set the key sequence False: fail to set the key sequence def setKeySequenceCounter(self, iKeySequenceValue): """...
get current Thread Network key sequence def getKeySequenceCounter(self): """get current Thread Network key sequence""" print '%s call getKeySequenceCounter' % self.port keySequence = '' keySequence = self.__sendCommand(WPANCTL_CMD + 'getprop -v Network:KeyIndex')[0] return keySe...
increment the key sequence with a given value Args: iIncrementValue: specific increment value to be added Returns: True: successful to increment the key sequence with a given value False: fail to increment the key sequence with a given value def incrementKeySequenc...
set extended PAN ID of Thread Network Args: xPanId: extended PAN ID in hex format Returns: True: successful to set the extended PAN ID False: fail to set the extended PAN ID def setXpanId(self, xPanId): """set extended PAN ID of Thread Network Args...
set Thread Network Partition ID Args: partitionId: partition id to be set by leader Returns: True: successful to set the Partition ID False: fail to set the Partition ID def setPartationId(self, partationId): """set Thread Network Partition ID Args...
get expected global unicast IPv6 address of OpenThreadWpan Args: filterByPrefix: a given expected global IPv6 prefix to be matched Returns: a global IPv6 address def getGUA(self, filterByPrefix=None): """get expected global unicast IPv6 address of OpenThreadWpan ...
get child timeout def getChildTimeoutValue(self): """get child timeout""" print '%s call getChildTimeoutValue' % self.port childTimeout = self.__sendCommand(WPANCTL_CMD + 'getporp -v Thread:ChildTimeout')[0] return int(childTimeout)
start Collapsed Commissioner Returns: True: successful to start Commissioner False: fail to start Commissioner def startCollapsedCommissioner(self): """start Collapsed Commissioner Returns: True: successful to start Commissioner False: fail to s...
scan Joiner Args: xEUI: Joiner's EUI-64 strPSKd: Joiner's PSKd for commissioning Returns: True: successful to add Joiner's steering data False: fail to add Joiner's steering data def scanJoiner(self, xEUI='*', strPSKd='threadjpaketest'): """scan...
set provisioning Url Args: strURL: Provisioning Url string Returns: True: successful to set provisioning Url False: fail to set provisioning Url def setProvisioningUrl(self, strURL='grl.com'): """set provisioning Url Args: strURL: Provi...
start commissioner candidate petition process Returns: True: successful to start commissioner candidate petition process False: fail to start commissioner candidate petition process def allowCommission(self): """start commissioner candidate petition process Returns: ...
start joiner Args: strPSKd: Joiner's PSKd Returns: True: successful to start joiner False: fail to start joiner def joinCommissioned(self, strPSKd='threadjpaketest', waitTime=20): """start joiner Args: strPSKd: Joiner's PSKd Re...
send MGMT_PANID_QUERY message to a given destination Args: xPanId: a given PAN ID to check the conflicts Returns: True: successful to send MGMT_PANID_QUERY message. False: fail to send MGMT_PANID_QUERY message. def MGMT_PANID_QUERY(self, sAddr, xCommissionerSession...
send MGMT_ANNOUNCE_BEGIN message to a given destination Returns: True: successful to send MGMT_ANNOUNCE_BEGIN message. False: fail to send MGMT_ANNOUNCE_BEGIN message. def MGMT_ANNOUNCE_BEGIN(self, sAddr, xCommissionerSessionId, listChannelMask, xCount, xPeriod): """send MGMT_A...
send MGMT_ACTIVE_GET command Returns: True: successful to send MGMT_ACTIVE_GET False: fail to send MGMT_ACTIVE_GET def MGMT_ACTIVE_GET(self, Addr='', TLVs=[]): """send MGMT_ACTIVE_GET command Returns: True: successful to send MGMT_ACTIVE_GET Fal...
send MGMT_ACTIVE_SET command Returns: True: successful to send MGMT_ACTIVE_SET False: fail to send MGMT_ACTIVE_SET def MGMT_ACTIVE_SET(self, sAddr='', xCommissioningSessionId=None, listActiveTimestamp=None, listChannelMask=None, xExtendedPanId=None, sNetworkName...
send MGMT_PENDING_SET command Returns: True: successful to send MGMT_PENDING_SET False: fail to send MGMT_PENDING_SET def MGMT_PENDING_SET(self, sAddr='', xCommissionerSessionId=None, listPendingTimestamp=None, listActiveTimestamp=None, xDelayTimer=None, xChann...
send MGMT_COMM_SET command Returns: True: successful to send MGMT_COMM_SET False: fail to send MGMT_COMM_SET def MGMT_COMM_SET(self, Addr='ff02::1', xCommissionerSessionID=None, xSteeringData=None, xBorderRouterLocator=None, xChannelTlv=None, ExceedMaxPayload=Fals...
stop commissioner Returns: True: successful to stop commissioner False: fail to stop commissioner def commissionerUnregister(self): """stop commissioner Returns: True: successful to stop commissioner False: fail to stop commissioner """ ...
Run the task for the given host. Arguments: host (:obj:`nornir.core.inventory.Host`): Host we are operating with. Populated right before calling the ``task`` nornir(:obj:`nornir.core.Nornir`): Populated right before calling the ``task`` Returns: ...
This is a utility method to call a task from within a task. For instance: def grouped_tasks(task): task.run(my_first_task) task.run(my_second_task) nornir.run(grouped_tasks) This method will ensure the subtask is run only for the host in the current thr...
Returns whether current task is a dry_run or not. def is_dry_run(self, override: bool = None) -> bool: """ Returns whether current task is a dry_run or not. """ return override if override is not None else self.nornir.data.dry_run
Hosts that failed during the execution of the task. def failed_hosts(self): """Hosts that failed during the execution of the task.""" return {h: r for h, r in self.items() if r.failed}
Gather information with napalm and validate it: http://napalm.readthedocs.io/en/develop/validate/index.html Arguments: src: file to use as validation source validation_source (list): data to validate device's state Returns: Result object with the following attributes set: ...
Execute Netmiko save_config method Arguments: cmd(str, optional): Command used to save the configuration. confirm(bool, optional): Does device prompt for confirmation before executing save operation confirm_response(str, optional): Response send to device when it prompts for confirmation ...
Execute Netmiko send_command method (or send_command_timing) Arguments: command_string: Command to execute on the remote network device. use_timing: Set to True to switch to send_command_timing method. enable: Set to True to force Netmiko .enable() call. kwargs: Additional arguments...
Retuns whether the object is a child of the :obj:`Group` ``group`` def has_parent_group(self, group): """Retuns whether the object is a child of the :obj:`Group` ``group``""" if isinstance(group, str): return self._has_parent_group_by_name(group) else: return self._has_...
Returns the value ``item`` from the host or hosts group variables. Arguments: item(``str``): The variable to get default(``any``): Return value if item not found def get(self, item, default=None): """ Returns the value ``item`` from the host or hosts group variables. ...
The function of this method is twofold: 1. If an existing connection is already established for the given type return it 2. If none exists, establish a new connection of that type with default parameters and return it Raises: AttributeError: if it's unknown h...
For an already established connection return its state. def get_connection_state(self, connection: str) -> Dict[str, Any]: """ For an already established connection return its state. """ if connection not in self.connections: raise ConnectionNotOpen(connection) retu...
Open a new connection. If ``default_to_host_attributes`` is set to ``True`` arguments will default to host attributes if not specified. Raises: AttributeError: if it's unknown how to establish a connection for the given type Returns: An already established conn...
Close the connection def close_connection(self, connection: str) -> None: """ Close the connection""" if connection not in self.connections: raise ConnectionNotOpen(connection) self.connections.pop(connection).close()
Returns set of hosts that belongs to a group including those that belong indirectly via inheritance def children_of_group(self, group: Union[str, Group]) -> Set[Host]: """ Returns set of hosts that belongs to a group including those that belong indirectly via inheritance """ ...
Add a host to the inventory after initialization def add_host(self, name: str, **kwargs) -> None: """ Add a host to the inventory after initialization """ host = { name: deserializer.inventory.InventoryElement.deserialize_host( name=name, defaults=self.defaul...