示例#1
0
    def killsession_rest_api_handle(self, dInputBody, lschema):

        schemapath = "/".join(lschema)
        logger.debug("killsession_rest_api_handle: XPATH:%s", schemapath)
        for k, v in dInputBody.items():
            logger.debug("killsession_rest_api_handle: dInputBody key:%s Value: %s", k, v)
        srpcsessId = ""
        srpcSource = ""
        shwcontext = ""

        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath, "KILLSESSION")

        if lrpcAndHw == []:
            logger.debug("KILL-SESSION REST API to RPC conversion failed: Return NIL value")
            return ""

        srpcsessId = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]

        if srpcsessId == "":
            logger.debug("KILL-SESSION REST API to RPC conversion failed: Return NIL value")
            return ""

        if shwcontext == "":
            logger.debug("KILL-SESSION REST API hwcontext:not available")

        logger.debug("KILL-SESSION  RPC request generated: %s", srpcsessId)
        logger.debug("KILL-SESSION  hwcontext value: %s", shwcontext)

        srpcreplystring = isdklib.isdk_sendrecv_ncclient(self._m, srpcsessId, shwcontext, "KILLSESSION")
        if srpcreplystring == "":
            logger.debug("KILL-SESSION rpc send request and receive reply  failed")
            return ""
        logger.debug("KILL-SESSION (save) rpc reply: %s", srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath, "KILLSESSION")
示例#2
0
 def getconfig_rest_api_handle(self, dInputBody, schemapath):
     logger.debug('getconfig_rest_api_handle: XPATH:%s JSON_ARRAY: %s',
                  schemapath, dInputBody)
     srpcstring = ''
     shwcontext = ''
     lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath,
                                                  'GETCONFIG')
     if lrpcAndHw == []:
         logger.debug(
             'POST REST API to RPC conversion failed: Return NIL value')
         return ''
     srpcstring = lrpcAndHw[0]
     shwcontext = lrpcAndHw[1]
     if srpcstring == '':
         logger.debug(
             'getconfig_rest_api_handle, REST API TO RPC Request conversion failed: Return NIL value'
         )
         return ''
     if shwcontext == '':
         logger.debug('GETCONFIG, hwcontext: not available')
     logger.debug('GETCONFIG,  RPC request generated: %s', srpcstring)
     logger.debug('GETCONFIG,  hwcontext value: %s', shwcontext)
     srpcreplystring = isdklib.isdk_sendrecv_ncclient(
         self._m, srpcstring, shwcontext, 'GETCONFIG')
     if srpcreplystring == '':
         logger.debug(
             'getconfig_rest_api_handle, GET rpc send request and receive reply  failed'
         )
         return ''
     return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath,
                                             'GETCONFIG')
示例#3
0
    def action_rest_api_handle(self, dInputBody, lschema):

        lschema.pop(1)
        schemapath = "/".join(lschema)
        logger.debug("action_rest_api_handle: XPATH:%s", schemapath)
        for k, v in dInputBody.items():
            logger.debug("action_rest_api_handle: dInputBody key:%s Value: %s", k, v)
        srpcstring = ""
        shwcontext = ""
        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath, "ACTION")

        if lrpcAndHw == []:
            logger.debug("ACTION SCHEMA REST API to RPC conversion failed: Return NIL value")
            return ""

        srpcstring = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]

        if srpcstring == "":
            logger.debug("ACTION SCHEMA REST API to RPC conversion failed: Return NIL value")
            return ""

        if shwcontext == "":
            logger.debug("ACTION SCHEMA REST API hwcontext:not available")

        logger.debug("ACTION SCHEMA  RPC request generated: %s", srpcstring)
        logger.debug("ACTION SCHEMA  hwcontext value: %s", shwcontext)

        srpcreplystring = isdklib.isdk_sendrecv_ncclient(self._m, srpcstring, shwcontext, "ACTION")
        if srpcreplystring == "":
            logger.debug("ACTION SCHEMA rpc send request and receive reply  failed")
            return ""
        logger.debug("ACTION SCHEMA (create) rpc reply: %s", srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath, "ACTION")
示例#4
0
    def deleteconfig_rest_api_handle(self, dInputBody, lschema):
        schemapath = "/".join(lschema)
        logger.debug("deleteconfig_rest_api_handle: XPATH:%s", schemapath)
        for k, v in dInputBody.items():
            logger.debug("deleteconfig_rest_api_handle: dInputBody key:%s Value: %s", k, v)
        srpcTarget = ""
        srpcSource = ""
        shwcontext = ""

        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath, "DELETECONFIG")

        if lrpcAndHw == []:
            logger.debug("DELETE-CONFIG REST API to RPC conversion failed: Return NIL value")
            return ""

        srpcTarget = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]

        if srpcTarget == "":
            logger.debug("DELETE-CONFIG REST API to RPC conversion failed: Return NIL value")
            return ""

        if shwcontext == "":
            logger.debug("DELETE-CONFIG REST API hwcontext:not available")

        logger.debug("DELETE-CONFIG  RPC request generated: %s", srpcTarget)
        logger.debug("DELETE-CONFIG hwcontext value: %s", shwcontext)

        srpcreplystring = isdklib.isdk_sendrecv_ncclient(self._m, srpcTarget, shwcontext, "DELETECONFIG")

        if srpcreplystring == "":
            logger.debug("DELETE-CONFIG rpc send request and receive reply  failed")
            return ""
        logger.debug("DELETE-CONFIG (save) rpc reply: %s", srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath, "DELETECONFIG")
示例#5
0
    def delete_rest_api_handle(self, dInputBody, schemapath):
        logger.debug("delete_rest_api_handle: XPATH:%s JSON_ARRAY: %s", schemapath, dInputBody)
        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath, "DELETE")

        if lrpcAndHw == []:
            logger.debug("POST REST API to RPC conversion failed: Return NIL value")
            return ""

        srpc = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]
        sRollback = lrpcAndHw[2]

        if srpc == "":
            logger.debug("DELETE REST API to RPC conversion failed: Return NIL value")
            return ""

        if shwcontext == "":
            logger.debug("DELETE REST API hwcontext: not available")
        #             return ''

        logger.debug("DELETE RPC request generated: %s", srpc)
        logger.debug("DELETE ,hwcontext : %s", shwcontext)
        srpcstring = "&".join([sRollback, srpc])
        srpcreplystring = isdklib.isdk_sendrecv_ncclient(self._m, srpcstring, shwcontext, "DELETE")
        if srpcreplystring == "":
            logger.debug("Edit-config (delete) rpc send request and receive reply  failed")
            return ""
        logger.debug("Edit-config (delete) rpc reply: %s", srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath, "DELETE")
示例#6
0
    def put_rest_api_handle(self, dInputBody, schemapath):
        logger.debug("put_rest_api_handle: XPATH:%s", schemapath)
        for k, v in dInputBody.items():
            logger.debug("put_rest_api_handle: dInputBody key:%s Value: %s", k, v)

        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath, "PUT")

        if lrpcAndHw == []:
            logger.debug("POST REST API to RPC conversion failed: Return NIL value")
            return ""

        srpc = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]
        sRollback = lrpcAndHw[2]
        if srpc == "":
            logger.debug("PUT REST API to RPC conversion failed: Return NIL value")
            return ""

        if shwcontext == "":
            logger.debug("PUT hwcontext: not available")
        #             return ''

        logger.debug("Edit-config(merge) RPC request generated: %s", srpc)
        logger.debug("Edit-config(merge) hwcontext: %s", shwcontext)
        srpcstring = "&".join([sRollback, srpc])
        srpcreplystring = isdklib.isdk_sendrecv_ncclient(self._m, srpcstring, shwcontext, "PUT")
        if srpcreplystring == "":
            logger.debug("Edit-config (merge) rpc send request and receive reply  failed")
            return ""
        logger.debug("Edit-config (merge) rpc reply: %s", srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath, "PUT")
示例#7
0
    def get_rest_api_handle(self, dInputBody, schemapath):

        if schemapath.find('_restping') != -1:
            logger.debug('get_rest_api_handle : REST PING TEST')
            if not self._m.session_id is None:
                logger.debug('get_rest_api_handle: Session_ID : %s , ',
                             self._m.session_id)
                logger.debug('get_rest_api_handle : REST PING TEST : success')
                return '<restping>pinging success</restping>'
            logger.debug('get_rest_api_handle : REST PING TEST : failed')
            return '<restping>pinging failed</restping>'

        ltemp = schemapath.split('/')
        sdiscoverFlag = ltemp[len(ltemp) - 1]
        if 'discover-enable' == sdiscoverFlag:
            ltemp.pop()
            schemapath = '/'.join(ltemp)
        else:
            schemapath = '/'.join(ltemp)
        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath,
                                                     'GET')

        if lrpcAndHw == []:
            logger.debug(
                'POST REST API to RPC conversion failed: Return NIL value')
            return ''

        srpcstring = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]

        if srpcstring == '':
            logger.debug(
                'get_rest_api_handle, REST API TO RPC Request conversion failed: Return NIL value'
            )
            return ''

        if shwcontext == '':
            logger.debug('GET, hwcontext: not available')

        logger.debug('GET,  RPC request generated: %s', srpcstring)
        logger.debug('GET,  hwcontext value: %s', shwcontext)

        srpcreplystring = isdklib.isdk_sendrecv_ncclient(
            self._m, srpcstring, shwcontext, 'GET')
        if srpcreplystring == '':
            logger.debug(
                'get_rest_api_handle, GET rpc send request and receive reply  failed'
            )
            return ''

        if 'discover-enable' == sdiscoverFlag:
            return selflearn.isdk_process_rpcreply(srpcreplystring, schemapath)
        else:
            return isdklib.isdk_convert_rpc2restapi(srpcreplystring,
                                                    schemapath, 'GET')
示例#8
0
    def post_rest_api_handle(self, dInputBody, schemapath):
        logger.debug('post_rest_api_handle: XPATH:%s', schemapath)

        ##  <device id>/_action/ftpc/ftpcTransferFiles/ftpcTransferFile
        lschema = schemapath.split('/')
        sactionflag = lschema[1]
        if '_action' == sactionflag:
            return self.action_rest_api_handle(dInputBody, lschema)
        elif sactionflag.find('copy-config') != -1:
            return self.copyconfig_rest_api_handle(dInputBody, lschema)
        elif sactionflag.find('delete-config') != -1:
            return self.deleteconfig_rest_api_handle(dInputBody, lschema)
        elif sactionflag.find('kill-session') != -1:
            return self.killsession_rest_api_handle(dInputBody, lschema)

        for k, v in dInputBody.items():
            logger.debug('post_rest_api_handle: dInputBody key:%s Value: %s',
                         k, v)
        sactionflag = ''
        schemapath = '/'.join(lschema)
        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath,
                                                     'POST')

        if lrpcAndHw == []:
            logger.debug(
                'POST REST API to RPC conversion failed: Return NIL value')
            return ''

        srpc = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]
        sRollback = lrpcAndHw[2]
        if srpc == '':
            logger.debug(
                'POST REST API to RPC conversion failed: Return NIL value')
            return ''

        if shwcontext == '':
            logger.debug('POST REST API hwcontext: not available')
#             return ''

        logger.debug('Edit-config(create) RPC request generated: %s', srpc)
        logger.debug('Edit-config(create) hwcontext: %s', shwcontext)
        srpcstring = '&'.join([sRollback, srpc])
        srpcreplystring = isdklib.isdk_sendrecv_ncclient(
            self._m, srpcstring, shwcontext, 'POST')
        if srpcreplystring == '':
            logger.debug(
                'Edit-config (create) rpc send request and receive reply  failed'
            )
            return ''
        logger.debug('Edit-config (create) rpc reply: %s', srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath,
                                                'POST')
示例#9
0
    def copyconfig_rest_api_handle(self, dInputBody, lschema):
        schemapath = '/'.join(lschema)
        logger.debug('copyconfig_rest_api_handle: XPATH:%s', schemapath)
        for k, v in dInputBody.items():
            logger.debug(
                'copyconfig_rest_api_handle: dInputBody key:%s Value: %s', k,
                v)
        srpcTarget = ''
        srpcSource = ''
        shwcontext = ''

        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath,
                                                     'COPYCONFIG')

        if lrpcAndHw == []:
            logger.debug(
                'COPY-CONFIG REST API to RPC conversion failed: Return NIL value'
            )
            return ''

        srpcTarget = lrpcAndHw[0]
        srpcSource = lrpcAndHw[1]
        shwcontext = lrpcAndHw[2]

        if srpcTarget == '' and srpcSource == '':
            logger.debug(
                'COPY-CONFIG REST API to RPC conversion failed: Return NIL value'
            )
            return ''

        if shwcontext == '':
            logger.debug('COPY-CONFIG REST API hwcontext:not available')

        logger.debug('COPY-CONFIG  RPC request generated: %s', srpcTarget)
        logger.debug('COPY-CONFIG  RPC request generated: %s', srpcSource)
        logger.debug('COPY-CONFIG  hwcontext value: %s', shwcontext)

        srpcstring = '&'.join([srpcTarget, srpcSource])
        srpcreplystring = isdklib.isdk_sendrecv_ncclient(
            self._m, srpcstring, shwcontext, 'COPYCONFIG')
        if srpcreplystring == '':
            logger.debug(
                'COPY-CONFIG rpc send request and receive reply  failed')
            return ''
        logger.debug('COPY-CONFIG (save) rpc reply: %s', srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath,
                                                'COPYCONFIG')
示例#10
0
    def get_rest_api_handle(self, dInputBody, schemapath):

        if schemapath.find("_restping") != -1:
            logger.debug("get_rest_api_handle : REST PING TEST")
            if not self._m.session_id is None:
                logger.debug("get_rest_api_handle: Session_ID : %s , ", self._m.session_id)
                logger.debug("get_rest_api_handle : REST PING TEST : success")
                return "<restping>pinging success</restping>"
            logger.debug("get_rest_api_handle : REST PING TEST : failed")
            return "<restping>pinging failed</restping>"

        ltemp = schemapath.split("/")
        sdiscoverFlag = ltemp[len(ltemp) - 1]
        if "discover-enable" == sdiscoverFlag:
            ltemp.pop()
            schemapath = "/".join(ltemp)
        else:
            schemapath = "/".join(ltemp)
        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath, "GET")

        if lrpcAndHw == []:
            logger.debug("POST REST API to RPC conversion failed: Return NIL value")
            return ""

        srpcstring = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]

        if srpcstring == "":
            logger.debug("get_rest_api_handle, REST API TO RPC Request conversion failed: Return NIL value")
            return ""

        if shwcontext == "":
            logger.debug("GET, hwcontext: not available")

        logger.debug("GET,  RPC request generated: %s", srpcstring)
        logger.debug("GET,  hwcontext value: %s", shwcontext)

        srpcreplystring = isdklib.isdk_sendrecv_ncclient(self._m, srpcstring, shwcontext, "GET")
        if srpcreplystring == "":
            logger.debug("get_rest_api_handle, GET rpc send request and receive reply  failed")
            return ""

        if "discover-enable" == sdiscoverFlag:
            return selflearn.isdk_process_rpcreply(srpcreplystring, schemapath)
        else:
            return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath, "GET")
示例#11
0
    def killsession_rest_api_handle(self, dInputBody, lschema):

        schemapath = '/'.join(lschema)
        logger.debug('killsession_rest_api_handle: XPATH:%s', schemapath)
        for k, v in dInputBody.items():
            logger.debug(
                'killsession_rest_api_handle: dInputBody key:%s Value: %s', k,
                v)
        srpcsessId = ''
        srpcSource = ''
        shwcontext = ''

        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath,
                                                     'KILLSESSION')

        if lrpcAndHw == []:
            logger.debug(
                'KILL-SESSION REST API to RPC conversion failed: Return NIL value'
            )
            return ''

        srpcsessId = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]

        if srpcsessId == '':
            logger.debug(
                'KILL-SESSION REST API to RPC conversion failed: Return NIL value'
            )
            return ''

        if shwcontext == '':
            logger.debug('KILL-SESSION REST API hwcontext:not available')

        logger.debug('KILL-SESSION  RPC request generated: %s', srpcsessId)
        logger.debug('KILL-SESSION  hwcontext value: %s', shwcontext)

        srpcreplystring = isdklib.isdk_sendrecv_ncclient(
            self._m, srpcsessId, shwcontext, 'KILLSESSION')
        if srpcreplystring == '':
            logger.debug(
                'KILL-SESSION rpc send request and receive reply  failed')
            return ''
        logger.debug('KILL-SESSION (save) rpc reply: %s', srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath,
                                                'KILLSESSION')
示例#12
0
    def post_rest_api_handle(self, dInputBody, schemapath):
        logger.debug("post_rest_api_handle: XPATH:%s", schemapath)

        ##  <device id>/_action/ftpc/ftpcTransferFiles/ftpcTransferFile
        lschema = schemapath.split("/")
        sactionflag = lschema[1]
        if "_action" == sactionflag:
            return self.action_rest_api_handle(dInputBody, lschema)
        elif sactionflag.find("copy-config") != -1:
            return self.copyconfig_rest_api_handle(dInputBody, lschema)
        elif sactionflag.find("delete-config") != -1:
            return self.deleteconfig_rest_api_handle(dInputBody, lschema)
        elif sactionflag.find("kill-session") != -1:
            return self.killsession_rest_api_handle(dInputBody, lschema)

        for k, v in dInputBody.items():
            logger.debug("post_rest_api_handle: dInputBody key:%s Value: %s", k, v)
        sactionflag = ""
        schemapath = "/".join(lschema)
        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath, "POST")

        if lrpcAndHw == []:
            logger.debug("POST REST API to RPC conversion failed: Return NIL value")
            return ""

        srpc = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]
        sRollback = lrpcAndHw[2]
        if srpc == "":
            logger.debug("POST REST API to RPC conversion failed: Return NIL value")
            return ""

        if shwcontext == "":
            logger.debug("POST REST API hwcontext: not available")
        #             return ''

        logger.debug("Edit-config(create) RPC request generated: %s", srpc)
        logger.debug("Edit-config(create) hwcontext: %s", shwcontext)
        srpcstring = "&".join([sRollback, srpc])
        srpcreplystring = isdklib.isdk_sendrecv_ncclient(self._m, srpcstring, shwcontext, "POST")
        if srpcreplystring == "":
            logger.debug("Edit-config (create) rpc send request and receive reply  failed")
            return ""
        logger.debug("Edit-config (create) rpc reply: %s", srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath, "POST")
示例#13
0
    def action_rest_api_handle(self, dInputBody, lschema):

        lschema.pop(1)
        schemapath = '/'.join(lschema)
        logger.debug('action_rest_api_handle: XPATH:%s', schemapath)
        for k, v in dInputBody.items():
            logger.debug('action_rest_api_handle: dInputBody key:%s Value: %s',
                         k, v)
        srpcstring = ''
        shwcontext = ''
        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath,
                                                     'ACTION')

        if lrpcAndHw == []:
            logger.debug(
                'ACTION SCHEMA REST API to RPC conversion failed: Return NIL value'
            )
            return ''

        srpcstring = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]

        if srpcstring == '':
            logger.debug(
                'ACTION SCHEMA REST API to RPC conversion failed: Return NIL value'
            )
            return ''

        if shwcontext == '':
            logger.debug('ACTION SCHEMA REST API hwcontext:not available')

        logger.debug('ACTION SCHEMA  RPC request generated: %s', srpcstring)
        logger.debug('ACTION SCHEMA  hwcontext value: %s', shwcontext)

        srpcreplystring = isdklib.isdk_sendrecv_ncclient(
            self._m, srpcstring, shwcontext, 'ACTION')
        if srpcreplystring == '':
            logger.debug(
                'ACTION SCHEMA rpc send request and receive reply  failed')
            return ''
        logger.debug('ACTION SCHEMA (create) rpc reply: %s', srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath,
                                                'ACTION')
示例#14
0
    def put_rest_api_handle(self, dInputBody, schemapath):
        logger.debug('put_rest_api_handle: XPATH:%s', schemapath)
        for k, v in dInputBody.items():
            logger.debug('put_rest_api_handle: dInputBody key:%s Value: %s', k,
                         v)

        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath,
                                                     'PUT')

        if lrpcAndHw == []:
            logger.debug(
                'POST REST API to RPC conversion failed: Return NIL value')
            return ''

        srpc = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]
        sRollback = lrpcAndHw[2]
        if srpc == '':
            logger.debug(
                'PUT REST API to RPC conversion failed: Return NIL value')
            return ''

        if shwcontext == '':
            logger.debug('PUT hwcontext: not available')
#             return ''

        logger.debug('Edit-config(merge) RPC request generated: %s', srpc)
        logger.debug('Edit-config(merge) hwcontext: %s', shwcontext)
        srpcstring = '&'.join([sRollback, srpc])
        srpcreplystring = isdklib.isdk_sendrecv_ncclient(
            self._m, srpcstring, shwcontext, 'PUT')
        if srpcreplystring == '':
            logger.debug(
                'Edit-config (merge) rpc send request and receive reply  failed'
            )
            return ''
        logger.debug('Edit-config (merge) rpc reply: %s', srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath,
                                                'PUT')
示例#15
0
 def getconfig_rest_api_handle(self, dInputBody, schemapath):
     logger.debug("getconfig_rest_api_handle: XPATH:%s JSON_ARRAY: %s", schemapath, dInputBody)
     srpcstring = ""
     shwcontext = ""
     lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath, "GETCONFIG")
     if lrpcAndHw == []:
         logger.debug("POST REST API to RPC conversion failed: Return NIL value")
         return ""
     srpcstring = lrpcAndHw[0]
     shwcontext = lrpcAndHw[1]
     if srpcstring == "":
         logger.debug("getconfig_rest_api_handle, REST API TO RPC Request conversion failed: Return NIL value")
         return ""
     if shwcontext == "":
         logger.debug("GETCONFIG, hwcontext: not available")
     logger.debug("GETCONFIG,  RPC request generated: %s", srpcstring)
     logger.debug("GETCONFIG,  hwcontext value: %s", shwcontext)
     srpcreplystring = isdklib.isdk_sendrecv_ncclient(self._m, srpcstring, shwcontext, "GETCONFIG")
     if srpcreplystring == "":
         logger.debug("getconfig_rest_api_handle, GET rpc send request and receive reply  failed")
         return ""
     return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath, "GETCONFIG")
示例#16
0
    def delete_rest_api_handle(self, dInputBody, schemapath):
        logger.debug('delete_rest_api_handle: XPATH:%s JSON_ARRAY: %s',
                     schemapath, dInputBody)
        lrpcAndHw = isdklib.isdk_convert_restapi2rpc(dInputBody, schemapath,
                                                     'DELETE')

        if lrpcAndHw == []:
            logger.debug(
                'POST REST API to RPC conversion failed: Return NIL value')
            return ''

        srpc = lrpcAndHw[0]
        shwcontext = lrpcAndHw[1]
        sRollback = lrpcAndHw[2]

        if srpc == '':
            logger.debug(
                'DELETE REST API to RPC conversion failed: Return NIL value')
            return ''

        if shwcontext == '':
            logger.debug('DELETE REST API hwcontext: not available')
#             return ''

        logger.debug('DELETE RPC request generated: %s', srpc)
        logger.debug('DELETE ,hwcontext : %s', shwcontext)
        srpcstring = '&'.join([sRollback, srpc])
        srpcreplystring = isdklib.isdk_sendrecv_ncclient(
            self._m, srpcstring, shwcontext, 'DELETE')
        if srpcreplystring == '':
            logger.debug(
                'Edit-config (delete) rpc send request and receive reply  failed'
            )
            return ''
        logger.debug('Edit-config (delete) rpc reply: %s', srpcreplystring)
        return isdklib.isdk_convert_rpc2restapi(srpcreplystring, schemapath,
                                                'DELETE')