iotcs.diagnostics module¶
-
class
iotcs.diagnostics.DiagnosticCounters¶ Bases:
object
-
class
iotcs.diagnostics.Diagnostics¶ Bases:
iotcs.messaging.client.device.util.RequestHandlerThe diagnostics
RequestHandler.The
iotcs.client.impl.Diagnosticsprocesses diagnosticiotcs.shared.message.RequestMessage`s. Diagnostics information includes total and free disk space, IP address, MAC address, diagnostics start time and client version. See `iotcs.config.config.pysection diagnostics and properties client_paths, client_version, client_ip_address, and client_mac_address.Create a
iotcs.client.impl.Diagnosticsinstance.-
CONFIG_CLIENT_IP_ADDRESS_PROPERTY= 'client_ip_address'¶
-
CONFIG_CLIENT_MAC_ADDRESS_PROPERTY= 'client_mac_address'¶
-
CONFIG_CLIENT_PATHS_PROPERTY= 'client_paths'¶
-
CONFIG_CLIENT_VERSION_PROPERTY= 'client_version'¶
-
CONFIG_DIAGNOSTICS_SECTION= 'diagnostics'¶
-
DIAGNOSTICS_URL= 'urn:oracle:iot:dcd:capability:diagnostics:diagnostics/info'¶
-
DIAGNOSTICS_URN= 'urn:oracle:iot:dcd:capability:diagnostics'¶
-
getDiskUsage(paths)¶ Return total disk usage.
Parameters: paths – collect disk information from this list of paths Returns: a list of namedtuple ‘Diskusage’ [ ‘path’, ‘free’, ‘total’, ‘used’ ]
-
getFreeDiskSpace()¶ Return the amount of free disk space.
See iotcs.config.config.py section diagnostics property client_paths. If this property is not set, the total disk space of . is returned. :return: list of namedtuple Freespace, [ ‘path’, ‘free’ ] or empty list if free space cannot be determined
-
getIpAddress()¶ Return a network interface and IP address.
Return a tuple containing (<network interface>, <ipaddress>). This first global IPv4 address is returned in the AF_INET family. If there are no IPv4 addresses, then the first IPv6 address. In no IP address can be determined, the tuple ( ‘Unknown’, ‘Unknown’ ) is returned. :return: ( <network interface>, <ipaddress> ) or ( ‘Unknown’, ‘Unknown’ ) :raises:
-
getLogger()¶ Return logger for
iotcs.client.impl.Diagnostics.Returns: logger for iotcs.client.impl.Diagnostics
-
getMacAddress(networkInterface, ipAddress)¶ Return the MAC address of ipAddress’s networkInterface.
The MAC address of the first global ipAddress`s `networkInterface is returned. On a device that has multiple network interfaces, it is not defined which MAC address is returned. :param networkInterface: a netork interface :return: the MAC address for ipAddress on networkInterface
-
getStartTimeMs()¶ Return the diagnostics start time in milliseconds.
Returns: Return the diagnostics start time in milliseconds.
-
getTotalDiskSpace()¶ Return the total disk space.
See iotcs.config.config.py section diagnostics property client_paths. If this property is not set, the total disk space of . is returned. :return: list of namedtuple Totalspace, [ ‘path’, ‘total’ ] or empty list if total space cannot be determined
-
handleRequest(request)¶ Handle a diagnostics
iotcs.shared.message.RequestMessage.The total and free disk space, IP address, MAC address, diagnostics start time and client version are returned.
See
iotcs.client.device.util.RequestHandlerReturns: iotcs.shared.message.ResponseMessagewith the free disksapce, total diskspace, IP address, MAC address, the diagnostics start time, and client version.
-
-
class
iotcs.diagnostics.TestConnectivity(endpointId, messageDispatcher)¶ Bases:
objectHandle diagnostics test connectivity messages.
It is assumed there will only be one instance of this class constructed.
Create a
TestConnectivityinstance.Parameters: - endpointId – the endpoint ID of the device.
- messageDispatcher – a reference to a
iotcs.client.device.MessageDispatcher.
-
TEST_CONNECTIVITY_URL= 'deviceModels/urn:oracle:iot:dcd:capability:diagnostics/testConnectivity'¶
-
class
TestConnectivityHandler(testConnectivity)¶ Bases:
iotcs.messaging.client.device.util.RequestHandlerThe test connectivity
RequestHandlerclass.The
iotcs.client.impl.TestConnectivityHandlerprocesses test connectivityiotcs.shared.message.RequestMessage`s. The :class:`iotcs.client.impl.TestConnectivityHandlerhandles GET and PUTiotcs.shared.message.RequestMessage`s. *GET* returns information about the state of the :class:.TestConnectivityThread` including * active - whether the test connectivity thread is running * count - the number of pings to send to the IoT server * currentCount - the number pings sent * interval - the ping frequency in milliseconds * size - the size in bytes of the message to ping the server withPUT start a test connectivity thread if one is not in progress providing the count, interval and size parameters.
Create a
TestConnectivityHandler.-
getTestConnectivity(request)¶ Return the test connectivity parameters.
Returns: a RepsonseMessage
-
handleRequest(request)¶ Handle a test connectivity
RequestMessage.Support a GET and PUT
-
putTestConnectivity(request)¶ Start a
TestConnectivityThreadthread.Start a test connectivity thread if a thread is not currently active and initialize with the given parameters. :param request: :return: a
ResponseMessage
-
testConnectivity¶
-
-
class
TestConnectivityThread(testConnectivity)¶ Bases:
threading.ThreadA Thread to test connectivity with IoT server.
Test the IoT server connevtivity.
-
getLogger()¶ Returen a logger for :class:’.TestConnectivityThread`.
Returns: the looger for TestConnectivityThread
-
payload¶
-
run()¶ Test connectivity with the IoT server.
-
running¶
-
testConnectivity¶
-
testConnectivityMessage¶
-
-
count¶
-
currentCount¶
-
endpointId¶
-
classmethod
getAlreadyRunningResponse(requestMessage)¶ Return
StatusCode.CONFLICTresponse.Return a
iotcs.shared.message.ResponseMessagewithStatusCode.CONFLICT:param requestMessage: the request message :return: aiotcs.shared.message.ResponseMessagewithStatusCode.CONFLICT
-
classmethod
getBadRequestResponse(requestMessage, message)¶ Return a
StatusCode.BAD_REQUESTresponse.Return a
iotcs.shared.message.ResponseMessagewithStatusCode.BAD_REQUESTParameters: - requestMessage – the request message
- message – the reason for the BAD_REQUEST
Returns: a
iotcs.shared.message.ResponseMessagewithStatusCode.BAD_REQUEST
-
classmethod
getMethodNotAllowedResponse(requestMessage)¶ Return
StatusCode.METHOD_NOT_ALLOWEDresponse.Return a
iotcs.shared.message.ResponseMessagewithStatusCode.METHOD_NOT_ALLOWEDParameters: requestMessage – the request message Returns: a iotcs.shared.message.ResponseMessagewithStatusCode.METHOD_NOT_ALLOWED
-
classmethod
getNullRequestResponse(requestMessage)¶ Return
StatusCode.METHOD_NOT_ALLOWEDresponse.Return a
iotcs.shared.message.ResponseMessagewithStatusCode.METHOD_NOT_ALLOWED:param requestMessage: the request message :return: aiotcs.shared.message.ResponseMessagewithStatusCode.METHOD_NOT_ALLOWED
-
classmethod
getParam(jsonObject, paramName, errors)¶ Return the value of paramName and accumulated errors.
Return a tuple (parmavalue, errors). The errors member is a concatenated string of accumulated errors. :param jsonObject: the json object containing paramName :param paramName: the json object attribute key :param errors: the error to include in the response if paramName is invvalid :return: a tuple (paramvalue, errors)
-
classmethod
getResponseMessage(requestMessage, body, statusCode)¶ Return a
ResponseMessagewith the given parameters.Parameters: - requestMessage – the request message
- body – the body of the response.
- statusCode – the status code of the response.
Returns: a
iotcs.shared.message.ResponseMessagewith the given parameters
-
getTestConnectivityHandler()¶ Return an instance of
TestConnectivityHandler.
-
interval¶
-
messageDispatcher¶
-
resetParameters()¶ Reset all parameters to 0.
-
size¶
-
testConnectivityHandler¶
-
testConnectivityThread¶
-
testConnectivityThreadLock¶