Commit 1af9e401 authored by Federico Sismondi's avatar Federico Sismondi

timestamps changed to json numbers and not json strings

parent b999dc50
......@@ -26,7 +26,7 @@ Usage:
------
>>> m = MsgTestCaseSkip(testcase_id = 'some_testcase_id')
>>> m
MsgTestCaseSkip(_api_version = 1.0.10, description = Skip testcase, node = someNode, testcase_id = some_testcase_id, )
MsgTestCaseSkip(_api_version = 1.0.11, description = Skip testcase, node = someNode, testcase_id = some_testcase_id, )
>>> m.routing_key
'testsuite.testcase.skip'
>>> m.message_id # doctest: +SKIP
......@@ -37,24 +37,24 @@ MsgTestCaseSkip(_api_version = 1.0.10, description = Skip testcase, node = someN
# also we can modify some of the fields (rewrite the default ones)
>>> m = MsgTestCaseSkip(testcase_id = 'TD_COAP_CORE_03')
>>> m
MsgTestCaseSkip(_api_version = 1.0.10, description = Skip testcase, node = someNode, testcase_id = TD_COAP_CORE_03, )
MsgTestCaseSkip(_api_version = 1.0.11, description = Skip testcase, node = someNode, testcase_id = TD_COAP_CORE_03, )
>>> m.testcase_id
'TD_COAP_CORE_03'
# and even export the message in json format (for example for sending the message though the amqp event bus)
>>> m.to_json()
'{"_api_version": "1.0.10", "description": "Skip testcase", "node": "someNode", "testcase_id": "TD_COAP_CORE_03"}'
'{"_api_version": "1.0.11", "description": "Skip testcase", "node": "someNode", "testcase_id": "TD_COAP_CORE_03"}'
# We can use the Message class to import json into Message objects:
>>> m=MsgTestSuiteStart()
>>> m.routing_key
'testsuite.start'
>>> m.to_json()
'{"_api_version": "1.0.10", "description": "Test suite START command"}'
'{"_api_version": "1.0.11", "description": "Test suite START command"}'
>>> json_message = m.to_json()
>>> obj=Message.load(json_message,'testsuite.start', None )
>>> obj
MsgTestSuiteStart(_api_version = 1.0.10, description = Test suite START command, )
MsgTestSuiteStart(_api_version = 1.0.11, description = Test suite START command, )
>>> type(obj) # doctest: +SKIP
<class 'messages.MsgTestSuiteStart'>
......@@ -66,7 +66,7 @@ MsgTestSuiteStart(_api_version = 1.0.10, description = Test suite START command,
# the error reply (note that we pass the message of the request to build the reply):
>>> err = MsgErrorReply(m)
>>> err
MsgErrorReply(_api_version = 1.0.10, error_code = None, error_message = None, ok = False, )
MsgErrorReply(_api_version = 1.0.11, error_code = None, error_message = None, ok = False, )
# properties of the message are auto-generated:
>>> m.reply_to
......@@ -91,7 +91,7 @@ import time
import json
import uuid
API_VERSION = '1.0.10'
API_VERSION = '1.0.11'
class NonCompliantMessageFormatError(Exception):
......@@ -117,7 +117,7 @@ class Message(object):
self._properties = dict(
content_type="application/json",
message_id=str(uuid.uuid4()),
timestamp=int(time.time())
timestamp=time.time()
)
try:
......@@ -201,10 +201,10 @@ class Message(object):
>>> m.routing_key
'sniffing.getcapture.request'
>>> m.to_json()
'{"_api_version": "1.0.10", "capture_id": "TD_COAP_CORE_01"}'
'{"_api_version": "1.0.11", "capture_id": "TD_COAP_CORE_01"}'
>>> json_message = m.to_json()
>>> json_message
'{"_api_version": "1.0.10", "capture_id": "TD_COAP_CORE_01"}'
'{"_api_version": "1.0.11", "capture_id": "TD_COAP_CORE_01"}'
>>> obj=Message.load(json_message,'testsuite.start', None )
>>> type(obj) # doctest
<class 'messages.MsgTestSuiteStart'>
......@@ -1071,7 +1071,7 @@ class MsgPacketInjectRaw(Message):
routing_key = "toAgent.*.ip.tun.packet.raw"
_msg_data_template = {
"timestamp": "1488586183.45",
"timestamp": 1488586183.45,
"interface_name": "tun0",
"data": [96, 0, 0, 0, 0, 36, 0, 1, 254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 255, 2, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 22, 58, 0, 5, 2, 0, 0, 1, 0, 143, 0, 112, 7, 0, 0, 0, 1, 4, 0, 0, 0, 255, 2, 0, 0,
......@@ -1094,7 +1094,7 @@ class MsgPacketSniffedRaw(Message):
routing_key = "fromAgent.*.ip.tun.packet.raw"
_msg_data_template = {
"timestamp": "1488586183.45",
"timestamp": 1488586183.45,
"interface_name": "tun0",
"data": [96, 0, 0, 0, 0, 36, 0, 1, 254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 255, 2, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 22, 58, 0, 5, 2, 0, 0, 1, 0, 143, 0, 112, 7, 0, 0, 0, 1, 4, 0, 0, 0, 255, 2, 0, 0,
......
......@@ -368,13 +368,7 @@ class OpenTunLinux(object):
ipv4_netmask = [255, 255, 0, 0]
self.ipv4_netmask = ipv4_netmask
log.debug("IP info")
log.debug(self.ipv6_prefix)
log.debug(self.ipv6_host)
log.debug(self.ipv6_no_forwarding)
log.debug(self.ipv4_host)
log.debug(self.ipv4_network)
log.debug(self.ipv4_netmask)
log.debug("IP info: \n {}".format(self.get_tun_configuration()))
# local variables
self.tunIf = self._createTunIf()
......@@ -519,7 +513,7 @@ class OpenTunLinux(object):
# dispatch to EventBus
m = MsgPacketSniffedRaw(
interface_name=self.ifname,
timestamp=str(time.time()),
timestamp=time.time(),
data=data
)
print(arrow_up)
......@@ -734,7 +728,7 @@ class OpenTunMACOS(object):
# dispatch to EventBus
m = MsgPacketSniffedRaw(
interface_name=self.ifname,
timestamp=str(time.time()),
timestamp=time.time(),
data=data
)
print(arrow_up)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment