def test_TD_M2M_NH_02_Create_RemoteCSE(self): remoteCSE = csr() remoteCSE.set_csi("CSE3219") remoteCSE.set_rr(True) remoteCSE.set_rn("RemoteCSE") payload = remoteCSE.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse", 16, payload, origin="CSE3219", requestID="12345")
def test_TD_M2M_NH_06_Create_AE(self): AE = ae() AE.set_api("Nk836-t071-fc022") AE.set_rr(True) AE.set_rn("TestAE") payload = AE.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse", 2, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_31_Create_Group(self): group = grp() group.set_mt(2) group.set_mnm(10) group.set_mid(["a"]) group.set_rn("TestGroup") payload = group.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse", 9, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_10_Create_Container(self): container = cnt() container.set_rn("TestContainer") payload = container.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", 3, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_35_Create_Node(self): node = nod() node.set_ni("a") node.set_rn("TestNode") payload = node.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse", 14, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_SH_05_Create_MgmtObj(self): firmware = fwr() firmware.set_mgd("1001") firmware.set_ud(True) firmware.set_vr("1") firmware.set_url("localhost") firmware.set_fwnnam("TestFirmware") firmware.set_rn("TestFirmware") payload = firmware.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestNode", 13, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_22_Create_Subscription(self): subscription = sub() subscription.set_nu(["http://localhost"]) subscription.set_rn("TestSubscription") payload = subscription.to_JSON() iotdm_api.create( "coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", 23, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_14_Create_ContentInstance(self): con_instance = cin() con_instance.set_con("some data") con_instance.set_rn("TestContentInstance") payload = con_instance.to_JSON() iotdm_api.create( "coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", 4, payload, origin="CSE3219/C9886", requestID="12345")
def test_TD_M2M_NH_26_Create_AccessControlPolicy(self): accessControlRule1 = acr() accessControlRule1.set_acor(["*"]) accessControlRule1.set_acop(63) pv_payload = accessControlRule1.to_JSON() accessControlRule2 = acr() accessControlRule2.set_acor(["admin"]) accessControlRule2.set_acop(63) pvs_payload = accessControlRule2.to_JSON() accessControlPolicy = acp() accessControlPolicy.set_pv(pv_payload) accessControlPolicy.set_pvs(pvs_payload) accessControlPolicy.set_rn("TestACP") payload = accessControlPolicy.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", 1, payload, origin="CSE3219/C9886", requestID="12345")
def __main__(): parser = argparse.ArgumentParser(description="Command-line Interface for IoTDM Python Client") parser.add_argument('protocol', help='Protocol for Requests', choices=['http', 'coap'], type=str) parser.add_argument('--from', '-fr', dest='from', help='From Which IP Address', type=str) parser.add_argument('--to', '-t', dest='host', help='To Which IP Address', type=str) parser.add_argument('--path', '-pa', dest='path', help='path', type=str, default='') parser.add_argument('--name', '-nm', dest='name', help='Resource Name', type=str) parser.add_argument('--op', '-o', dest='operation', help='Operation', choices=['restconf', 'kill', 'create', 'retrieve', 'update', 'delete'], type=str, required=True) parser.add_argument('--port', '-p', dest='port', help='Port Number', type=str) parser.add_argument('--primitiveContent', '-pc', dest='payload', help='payload', type=str) parser.add_argument('--requestIdentifier', '-rqi', dest='rqi', help='Request ID', type=str) parser.add_argument('--resourceType', '-ty', dest='ty', help='Resource Type', type=str) args = parser.parse_args() url = '%s://%s' %(args.protocol, args.host) if args.operation == 'restconf': iotdm_api.restConf(url, args.name, 'admin', 'admin') if args.operation == 'kill': iotdm_api.cleanup(url, 'admin', 'admin') if args.operation == 'create': url = url + ':%s/%s' %(args.port, args.path) iotdm_api.create(url, args.ty, args.name, args.payload) if args.operation == 'retrieve': url = url + ':%s/%s' %(args.port, args.path) iotdm_api.retrieve(url) if args.operation == 'update': url = url + ':%s/%s' %(args.port, args.path) iotdm_api.update(url, args.ty, args.payload) if args.operation == 'delete': url = url + ':%s/%s' %(args.port, args.path) iotdm_api.delete(url)
# payload = AE.to_JSON() # iotdm_api.create("http://localhost:8282/ODL-oneM2M-Cse", 2, payload, origin="//www.m2mprovider.com/CSE3219/C9886", requestID="12345") '''Container Creation''' # container = cnt() # container.set_mbs(30) # container.set_or("http://hey/you") # container.set_lbl(["key1"]) # container.set_rn("TestContainer") # payload = container.to_JSON() # iotdm_api.create("http://localhost:8282/ODL-oneM2M-Cse/TestAE", 3, payload) '''Content-instance Creation''' subscription = sub() subscription.set_nu(["http://localhost"]) subscription.set_rn("TestSubscription") payload = subscription.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", 23, payload) '''Subscription creation''' # subscription = sub() # subscription.set_nu(["10.195.131.12"]) # payload = subscription.to_JSON() # iotdm_api.create("coap://127.0.0.1:5683/ODL-oneM2M-Cse/AE/Container", 23, "sub1", payload) '''Get''' # iotdm_api.retrieve("http://localhost:8282/ODL-oneM2M-Cse?fu=1") '''Delete''' # iotdm_api.delete("http://127.0.0.1:8282/ODL-oneM2M-Cse/AE4") '''Update''' # AE = ae() # AE.set_acpi(["ODL-oneM2M-Cse/TestAE/TestACP"]) # payload = AE.to_JSON() # iotdm_api.update("coap://localhost:5683/ODL-oneM2M-Cse/TestAE", payload)
def test_TD_M2M_NH_14_Create_ContentInstance(self): con_instance = cin() con_instance.set_con("some data") con_instance.set_rn("TestContentInstance") payload = con_instance.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", 4, payload, origin="CSE3219/C9886", requestID="12345")
# RestConf calls require admin access iotdm_api.restConf('http://localhost', 'InCSE1', 'admin', 'admin') # Clean-up of resource tree iotdm_api.cleanup('http://localhost', 'admin', 'admin') # CoAP Creation of an AE named "myAE" under the CSE base "InCSE1". AE = ae() AE.set_api("Nk836-t071-fc022") AE.set_rr(True) AE.set_rn("myAE") payload = AE.to_JSON() iotdm_api.create("coap://localhost:5683/InCSE1", 2, payload, origin="AE-ID", requestID="12345") # Creation of a Container named "mySubContainer" with a maximum number of instances of 5, under "myContainer". container = cnt() container.set_rn("mySubContainer") container.set_mni(5) payload = container.to_JSON() iotdm_api.create("http://localhost:8282/InCSE1/myAE/myContainer", 3, payload, origin="AE-ID", requestID="12345") # Creation of a Content Instance named "myOtherContentInstance" under "mySubContainer", with "world" as its content. con_instance = cin() con_instance.set_con("world") con_instance.set_rn("myOtherContentInstance") payload = con_instance.to_JSON()
'''Container Creation''' # container = cnt() # container.set_mbs(30) # container.set_or("http://hey/you") # container.set_lbl(["key1"]) # container.set_rn("TestContainer") # payload = container.to_JSON() # iotdm_api.create("http://localhost:8282/ODL-oneM2M-Cse/TestAE", 3, payload) '''Content-instance Creation''' subscription = sub() subscription.set_nu(["http://localhost"]) subscription.set_rn("TestSubscription") payload = subscription.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", 23, payload) '''Subscription creation''' # subscription = sub() # subscription.set_nu(["10.195.131.12"]) # payload = subscription.to_JSON() # iotdm_api.create("coap://127.0.0.1:5683/ODL-oneM2M-Cse/AE/Container", 23, "sub1", payload) '''Get''' # iotdm_api.retrieve("http://localhost:8282/ODL-oneM2M-Cse?fu=1") '''Delete''' # iotdm_api.delete("http://127.0.0.1:8282/ODL-oneM2M-Cse/AE4")
from onem2m_xml_protocols.ae import * from onem2m_xml_protocols.container import * from onem2m_xml_protocols.contentinstance import * # Build the root CSE base of a tree by Restconf: iotdm_api.restConf('http://localhost', 'InCSE1', 'admin', 'admin') # Creation of an AE named "myAE" under the CSE base "InCSE1". AE = ae() AE.set_api("Nk836-t071-fc022") AE.set_rr(True) AE.set_rn("myAE") payload = AE.to_JSON() iotdm_api.create("http://localhost:8282/InCSE1", 2, payload, origin="AE-ID", requestID="12345") # Creation of a Container named "myContainer" with a maximum number of bytes of 32, under "myAE". container = cnt() container.set_rn("myContainer") container.set_mbs(32) payload = container.to_JSON() iotdm_api.create("http://localhost:8282/InCSE1/myAE", 3, payload, origin="AE-ID", requestID="12345") # Creation of a Container named "mySubContainer" with a maximum number of instances of 5, under "myContainer".
def test_TD_M2M_NH_22_Create_Subscription(self): subscription = sub() subscription.set_nu(["http://localhost"]) subscription.set_rn("TestSubscription") payload = subscription.to_JSON() iotdm_api.create("coap://localhost:5683/ODL-oneM2M-Cse/TestAE/TestContainer", 23, payload, origin="CSE3219/C9886", requestID="12345")