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)
Example #2
0
# File to demonstate operation of Python API using HTTP protocol to talk to host
# To operate run IoTDM server on localhost as described at:
# https://wiki.opendaylight.org/view/IoTDM:Main#Getting_started_for_users
# Contents of this file is based on:
# https://wiki.opendaylight.org/view/IoTDM:PythonAPI

# December 2016
# Author: Iain Sharp

import iotdm_api
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()
Example #3
0
 def test_0_CSE_Provisioning(self):
     iotdm_api.restConf('http://localhost', 'ODL-oneM2M-Cse', 'admin',
                        'admin')
Example #4
0
import iotdm_api
from onem2m_xml_protocols.ae import ae
from onem2m_xml_protocols.container import cnt
from onem2m_xml_protocols.contentinstance import cin
from onem2m_xml_protocols.subscription import sub
from onem2m_xml_protocols.remotecse import csr
from onem2m_xml_protocols.acp import acp
from onem2m_xml_protocols.acp import acr
from onem2m_xml_protocols.group import grp
from onem2m_xml_protocols.node import nod
from onem2m_xml_protocols.firmware import fwr


# 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()
 def test_0_CSE_Provisioning(self):
     iotdm_api.restConf('http://localhost', 'ODL-oneM2M-Cse', 'admin', 'admin')