def get(self):
        # * Funcion para obtener todos los datos de un Call Pickup Group
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug('Ha accedido a la funcion get de la clase CiscoAXL_CallPickupGroup' )
        varFORM = request.form
        if 'name' in varFORM:
            infoLogger.debug('Esta buscando el Call PickUp Group %s' % (varFORM['name']))
            CustomSoap_Data = {
                    'name': varFORM['name'],
            }
        else:
            infoLogger.error('No estan todas los parametros requeridos: %s' % (varFORM))
            return {'Class': 'CallPickupGroup','AXL': 'get','Method': 'GET', 'Status': 'ERROR', 'Detail': 'Faltan parametros'},400

        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        CustomService = CustomSoap.ClientSoap (infoLogger,varFORM['mmpHost'],varFORM['mmpUser'],varFORM['mmpPass'],varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient ()

        try:
            CustomUser_Resp = CustomService.getCallPickupGroup(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            infoLogger.error(type(zeep.helpers.serialize_object(sys.exc_info()[1])))
            return {'Class': 'CallPickupGroup','AXL': 'get','Method': 'GET', 'Status': 'ERROR', 'Detail': str(sys.exc_info()[1]),'name':varFORM['name']},400
        else:
            infoLogger.info('Se ha encontrado el Call Pickup Group %s' % (varFORM['name']))
            return json.loads(json.dumps(zeep.helpers.serialize_object(CustomUser_Resp['return'])))
    def patch(self):
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug('Ha accedido a la funcion post de la clase CiscoAXL_Change' )
        infoLogger.debug('Esta utilizando el metodo PATCH' )
        varFORM = request.form
        infoLogger.debug('Los datos del formulario son: %s' % (varFORM))
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))

        CustomService = CustomSoap.ClientSoap (infoLogger,varFORM['mmpHost'],varFORM['mmpUser'],varFORM['mmpPass'],varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient ()

        try:
            CustomUser_Resp = CustomService.listChange()
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            CustomSoap_Data = {
                'Method': 'PATCH',
                'Status': 'Error',
                'Detail': sys.exc_info()[1]
            }
            return jsonify(CustomSoap_Data)
        else:
            #infoLogger.debug('Los datos devueltos son: %s' % (CustomUser_Resp))
            return json.loads(json.dumps(zeep.helpers.serialize_object(CustomUser_Resp)))
Пример #3
0
    def get(self):
        # * Funcion para obtener todos los datos de un Directory Number
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion get de la clase CiscoAXL_Line')
        varFORM = request.form
        if all(k in varFORM for k in ('pattern', 'routePartitionName')):
            infoLogger.debug(
                'Esta buscando el Directory Number %s en la Particion %s' %
                (varFORM['pattern'], varFORM['routePartitionName']))
            CustomSoap_Data = {
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }
        else:
            infoLogger.error('No estan todas los parametros requeridos: %s' %
                             (varFORM))
            return {
                'Class': 'line',
                'AXL': 'get',
                'Method': 'GET',
                'Status': 'ERROR',
                'Detail': 'Faltan parametros'
            }, 400

        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        try:
            CustomUser_Resp = CustomService.getLine(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            infoLogger.error(
                type(zeep.helpers.serialize_object(sys.exc_info()[1])))
            return {
                'Class': 'line',
                'AXL': 'get',
                'Method': 'GET',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }, 400
        else:
            infoLogger.info(
                'Se ha encontrado el Translation Pattern %s en la Particion %s'
                % (varFORM['pattern'], varFORM['routePartitionName']))
            return json.loads(
                json.dumps(
                    zeep.helpers.serialize_object(CustomUser_Resp['return'])))
    def patch(self):
        # * Funcion para buscar todos los elementos que coincidan con el criterio listProcessNode
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion PATCH de la clase CiscoAXL_ServiceParameter'
        )
        infoLogger.debug('Esta utilizando el metodo PATCH')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        infoLogger.debug(
            'Esta buscando los ServiceParameter con el siguiente criterio: %s - %s'
            % (varFORM['processNodeName'], varFORM['service']))
        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        searchCriteria = {
            'processNodeName': varFORM['processNodeName'],
            'service': varFORM['service']
        }
        returnedTags = {
            'processNodeName': '',
            'name': '',
            'service': '',
            'value': '',
            'valueType': '',
            'uuid': ''
        }

        CustomSoap_Data = {
            'searchCriteria': searchCriteria,
            'returnedTags': returnedTags,
        }

        try:
            CustomUser_Resp = CustomService.listServiceParameter(
                **CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'ServiceParameter',
                'AXL': 'list',
                'Method': 'PATCH',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'searchCriteria': varFORM['searchCriteria']
            }, 400
        else:
            return json.loads(
                json.dumps(
                    zeep.helpers.serialize_object(CustomUser_Resp['return'])))
Пример #5
0
    def delete(self):
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion delete de la clase CiscoAXL_User')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))

        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {}

        # Comprobamos si existe la Key userid
        if 'userid' in varFORM:
            infoLogger.debug('Vamos a eliminar el Userid: %s' %
                             (varFORM['userid']))
            CustomSoap_Data = {'userid': varFORM['userid']}
        else:
            return {
                'Class': 'userid',
                'AXL': 'remove',
                'Method': 'DELETE',
                'Status': 'ERROR',
                'Detail': 'No tenemos el campo userid'
            }, 400

        try:
            CustomUser_Resp = CustomService.removeUser(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return jsonify({
                'Class': 'userid',
                'AXL': 'remove',
                'Method': 'DELETE',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'userid': varFORM['userid']
            })
        else:
            infoLogger.info('Se ha configurado el User ID %s' %
                            (varFORM['userid']))
            return {
                'Class': 'userid',
                'AXL': 'remove',
                'Method': 'DELETE',
                'Status': 'OK',
                'Detail': str(CustomUser_Resp['return']),
                'userid': varFORM['userid']
            }
    def post(self):
        # * Funcion para crear un Call Pickup Group
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug('Ha accedido a la funcion post de la clase CiscoAXL_CallPickupGroup' )
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        if all (k in varFORM for k in ('pattern', 'name', 'routePartitionName')):
            infoLogger.debug('Se quiere dar de alta el Call Pickup Group %s en la Particion %s' % (varFORM['pattern'],varFORM['routePartitionName']))
            CustomSoap_Data = {
                    'pattern': varFORM['pattern'],
                    'name': varFORM['name'],
                    'routePartitionName': varFORM['routePartitionName']
            }
        else:
            infoLogger.error('No estan todas los parametros requeridos: %s' % (varFORM))
            return {'Class': 'CallPickupGroup','AXL': 'add','Method': 'POST', 'Status': 'ERROR', 'Detail': 'Faltan parametros'},400

        CustomService = CustomSoap.ClientSoap (infoLogger,varFORM['mmpHost'],varFORM['mmpUser'],varFORM['mmpPass'],varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient ()

        # Comprobamos si existe la Key description
        if 'description' in varFORM:
            CustomSoap_Data['description'] = varFORM['description']

        # Comprobamos si existe la Key pickupNotification
        if 'pickupNotification' in varFORM:
            CustomSoap_Data['pickupNotification'] = varFORM['pickupNotification']
            # Comprobamos si existe la Key callInfoForPickupNotification
            if 'callInfoForPickupNotification' in varFORM:
                CustomSoap_Data['callInfoForPickupNotification'] = {
                    'callingPartyInfo': varFORM['callInfoForPickupNotification'],
                    'calledPartyInfo': varFORM['callInfoForPickupNotification'],
                }

        # Comprobamos si existe la Key pickupNotificationTimer
        if 'pickupNotificationTimer' in varFORM:
            CustomSoap_Data['pickupNotificationTimer'] = varFORM['pickupNotificationTimer']

        # Replicando el bucle anterior puedo añadir todas las variables que tiene un Call Pickup Group
        try:
            # Damos de alta el Call Pickup Group y no verificamos si existe el mismo Call Pickup Group
            CustomUser_Resp = CustomService.addCallPickupGroup(CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {'Class': 'CallPickupGroup','AXL': 'add','Method': 'POST', 'Status': 'ERROR', 'Detail': str(sys.exc_info()[1]),'pattern':varFORM['pattern'],'routePartitionName':varFORM['routePartitionName'],'name':varFORM['name']},400
        else:
            infoLogger.info('Se ha configurado el Call Pickup Group %s en la Particion %s' % (varFORM['pattern'],varFORM['routePartitionName']))
            return {'Class': 'CallPickupGroup','AXL': 'add','Method': 'POST', 'Status': 'OK', 'Detail': str(sys.exc_info()[1]),'pattern':varFORM['pattern'],'routePartitionName':varFORM['routePartitionName'],'name':varFORM['name']},400
Пример #7
0
    def get(self):
        # * Funcion para obtener todos los parametros de un elemento
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion get de la clase CiscoAXL_Phone')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        infoLogger.debug('Esta buscando el Phone con el nombre: %s' %
                         (varFORM['name']))
        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {'name': varFORM['name']}

        try:
            CustomUser_Resp = CustomService.getPhone(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'Phone',
                'AXL': 'get',
                'Method': 'GET',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'name': varFORM['name']
            }, 400
        else:
            # *------------------------------------------------------------------
            # * Tenemos que convertir la variable vendorConfig que es una lista
            # * en un dictionary de tipo string para poder añadirlo a la variable
            # * JSON que tiene que devolver la funcion
            # *------------------------------------------------------------------
            CustomUser_Resp_temp = {}
            for i in range(
                    len(CustomUser_Resp['return']['phone']['vendorConfig']
                        ['_value_1'])):
                CustomUser_Resp_temp['_value_' + str(i)] = str(
                    CustomUser_Resp['return']['phone']['vendorConfig']
                    ['_value_1'][i])
            CustomUser_Resp['return']['phone']['vendorConfig'][
                '_value_1'] = CustomUser_Resp_temp
            return json.loads(
                json.dumps(
                    zeep.helpers.serialize_object(CustomUser_Resp['return'])))
    def put(self):
        # * Funcion para obtener todos los parametros de un elemento
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion PUT de la clase CiscoAXL_ServiceParameter'
        )
        infoLogger.debug('Esta utilizando el metodo PUT')
        varFORM = request.form
        infoLogger.debug('Los datos del formulario son: %s' % (varFORM))
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        infoLogger.debug('Esta buscando el ProcessNode: %s' %
                         (varFORM['name']))
        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {
            'processNodeName': varFORM['processNodeName'],
            'name': varFORM['name'],
            'service': varFORM['service'],
            'value': varFORM['value']
        }

        try:
            CustomUser_Resp = CustomService.updateServiceParameter(
                **CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'ServiceParameter',
                'AXL': 'update',
                'Method': 'PUT',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'name:': varFORM['name']
            }, 400
        else:
            return {
                'Class': 'ServiceParameter',
                'AXL': 'update',
                'Method': 'PUT',
                'Status': 'OK',
                'Detail': CustomUser_Resp['return']
            }, 201
Пример #9
0
    def get(self):
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion get de la clase CiscoAXL_User')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        infoLogger.debug('Esta buscando el Userid: %s' % (varFORM['userid']))
        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {}

        # Comprobamos si existe la Key userid
        if 'userid' in varFORM:
            CustomSoap_Data['userid'] = varFORM['userid']
        else:
            return {
                'Class': 'userid',
                'AXL': 'get',
                'Method': 'GET',
                'Status': 'ERROR',
                'Detail': 'No tenemos el campo userid'
            }, 400

        CustomSoap_Data = {'userid': varFORM['userid']}

        try:
            CustomUser_Resp = CustomService.getUser(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'userid',
                'AXL': 'get',
                'Method': 'GET',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'userid': varFORM['userid']
            }, 400
        else:
            return json.loads(
                json.dumps(
                    zeep.helpers.serialize_object(CustomUser_Resp['return'])))
Пример #10
0
    def delete(self):
        # * Funcion para borrar un telefono
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion delete de la clase CiscoAXL_Phone')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        infoLogger.debug('Vamos a borrar el Phone con el nombre: %s' %
                         (varFORM['name']))
        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {'name': varFORM['name']}

        try:
            CustomUser_Resp = CustomService.removePhone(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'Phone',
                'AXL': 'remove',
                'Method': 'DELETE',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'name': varFORM['name']
            }, 400
        else:
            # *------------------------------------------------------------------
            # * Tenemos que convertir la variable vendorConfig que es una lista
            # * en un dictionary de tipo string para poder añadirlo a la variable
            # * JSON que tiene que devolver la funcion
            # *------------------------------------------------------------------
            return {
                'Class': 'Phone',
                'AXL': 'remove',
                'Method': 'DELETE',
                'Status': 'OK',
                'Detail': str(CustomUser_Resp['return']),
                'name': varFORM['name']
            }
    def get(self):
        # * Funcion para obtener todos los parametros de un elemento
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion get de la clase CiscoAXL_ProcessNode')
        infoLogger.debug('Esta utilizando el metodo GET')
        varFORM = request.form
        infoLogger.debug('Los datos del formulario son: %s' % (varFORM))
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        infoLogger.debug('Esta buscando el ProcessNode: %s' %
                         (varFORM['name']))
        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {'name': varFORM['name']}

        try:
            CustomUser_Resp = CustomService.getProcessNode(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'ProcessNode',
                'AXL': 'get',
                'Method': 'GET',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'name:': varFORM['name']
            }, 400
        else:
            return json.loads(
                json.dumps(
                    zeep.helpers.serialize_object(CustomUser_Resp['return'])))
Пример #12
0
    def post(self):
        # * Funcion para crear un phone
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion post de la clase CiscoAXL_Phone')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))

        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {}

        # Configuramos los parámetros por defecto
        CustomSoap_Data['class'] = 'Phone'
        CustomSoap_Data['protocolSide'] = 'User'

        # Comprobamos si existe la Key certificateOperation
        if 'certificateOperation' in varFORM:
            CustomSoap_Data['certificateOperation'] = varFORM[
                'certificateOperation']
        else:
            CustomSoap_Data['certificateOperation'] = 'No Pending Operation'
        CustomSoap_Data['useTrustedRelayPoint'] = 'Default'
        CustomSoap_Data['builtInBridgeStatus'] = 'Default'
        CustomSoap_Data['packetCaptureMode'] = 'None'
        CustomSoap_Data['deviceMobilityMode'] = 'Default'

        # Comprobamos si existe las siguientes Key's name, product, class, protocol, protocolSide, devicePoolName, commonPhoneConfigName, locationName, useTrustedRelayPoint and phoneTemplateName
        if all(k in varFORM
               for k in ('name', 'product', 'protocol', 'devicePoolName',
                         'commonPhoneConfigName', 'locationName',
                         'phoneTemplateName')):
            infoLogger.debug(
                'Se quiere dar de alta un telefono con el nombre %s modelo %s'
                % (varFORM['name'], varFORM['product']))
            CustomSoap_Data['name'] = varFORM['name'][0:15]
            CustomSoap_Data['product'] = varFORM['product']
            CustomSoap_Data['protocol'] = varFORM['protocol']
            CustomSoap_Data['devicePoolName'] = varFORM['devicePoolName']
            CustomSoap_Data['commonPhoneConfigName'] = varFORM[
                'commonPhoneConfigName']
            CustomSoap_Data['locationName'] = varFORM['locationName']
            CustomSoap_Data['phoneTemplateName'] = varFORM['phoneTemplateName']
        else:
            infoLogger.error('No estan todas los parametros requeridos: %s' %
                             (varFORM))
            return {
                'Class': 'Phone',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': 'Faltan parametros'
            }, 400

        # Comprobamos si existe la Key description
        if 'description' in varFORM:
            CustomSoap_Data['description'] = varFORM[
                'lines'] + ' - ' + varFORM['description'][0:40]
        # Comprobamos si existe la Key description
        if 'commonDeviceConfigName' in varFORM:
            CustomSoap_Data['commonDeviceConfigName'] = varFORM[
                'commonDeviceConfigName']
        # Comprobamos si existe la Key ownerUserName
        if 'ownerUserName' in varFORM:
            CustomSoap_Data['ownerUserName'] = varFORM['ownerUserName']
            # Comprobamos si existe la Key digestUser
            if 'digestUser' in varFORM:
                if 'digestUser' == '':
                    CustomSoap_Data['digestUser'] = varFORM['ownerUserName']
                else:
                    CustomSoap_Data['digestUser'] = varFORM['digestUser']
        # Comprobamos si existe la Key subscribeCallingSearchSpaceName
        if 'callingSearchSpaceName' in varFORM:
            CustomSoap_Data['callingSearchSpaceName'] = varFORM[
                'callingSearchSpaceName']
        # Comprobamos si existe la Key subscribeCallingSearchSpaceName
        if 'subscribeCallingSearchSpaceName' in varFORM:
            CustomSoap_Data['subscribeCallingSearchSpaceName'] = varFORM[
                'subscribeCallingSearchSpaceName']
        # Comprobamos si existe la Key maxNumCalls
        if 'maxNumCalls' in varFORM:
            CustomSoap_Data['maxNumCalls'] = varFORM['maxNumCalls']
        else:
            CustomSoap_Data['maxNumCalls'] = '2'
        # Comprobamos si existe la Key busyTrigger
        if 'busyTrigger' in varFORM:
            CustomSoap_Data['busyTrigger'] = varFORM['busyTrigger']
        else:
            CustomSoap_Data['busyTrigger'] = '1'

        # Comprobamos si existe la Key lines
        if all(k in varFORM for k in ('lines', 'routePartitionName')):
            if 'ownerUserName' in varFORM:
                if 'e164Mask' in varFORM:
                    CustomSoap_Data['lines'] = {
                        'line': {
                            'index':
                            1,
                            'display':
                            varFORM['description'][0:50],
                            'label':
                            varFORM['lines'] + ' - ' +
                            varFORM['description'][0:20],
                            'e164Mask':
                            varFORM['e164Mask'],
                            'dirn': {
                                'pattern':
                                varFORM['lines'],
                                'routePartitionName':
                                varFORM['routePartitionName'],
                            },
                            'associatedEndusers': {
                                'enduser': {
                                    'userId': varFORM['ownerUserName'],
                                },
                            },
                            'recordingFlag':
                            'Call Recording Disabled',
                            'recordingMediaSource':
                            'Gateway Preferred',
                            'maxNumCalls':
                            CustomSoap_Data['maxNumCalls'],
                            'busyTrigger':
                            CustomSoap_Data['busyTrigger'],
                        },
                    }
                else:
                    CustomSoap_Data['lines'] = {
                        'line': {
                            'index':
                            1,
                            'display':
                            varFORM['description'][0:50],
                            'label':
                            varFORM['lines'] + ' - ' +
                            varFORM['description'][0:20],
                            'dirn': {
                                'pattern':
                                varFORM['lines'],
                                'routePartitionName':
                                varFORM['routePartitionName'],
                            },
                            'associatedEndusers': {
                                'enduser': {
                                    'userId': varFORM['ownerUserName'],
                                },
                            },
                            'recordingFlag':
                            'Call Recording Disabled',
                            'recordingMediaSource':
                            'Gateway Preferred',
                            'maxNumCalls':
                            CustomSoap_Data['maxNumCalls'],
                            'busyTrigger':
                            CustomSoap_Data['busyTrigger'],
                        },
                    }
            else:
                if 'e164Mask' in varFORM:
                    CustomSoap_Data['lines'] = {
                        'line': {
                            'index':
                            1,
                            'display':
                            varFORM['description'][0:50],
                            'label':
                            varFORM['lines'] + ' - ' +
                            varFORM['description'][0:20],
                            'e164Mask':
                            varFORM['e164Mask'],
                            'dirn': {
                                'pattern':
                                varFORM['lines'],
                                'routePartitionName':
                                varFORM['routePartitionName'],
                            },
                            'recordingFlag':
                            'Call Recording Disabled',
                            'recordingMediaSource':
                            'Gateway Preferred',
                            'maxNumCalls':
                            CustomSoap_Data['maxNumCalls'],
                            'busyTrigger':
                            CustomSoap_Data['busyTrigger'],
                        },
                    }
                else:
                    CustomSoap_Data['lines'] = {
                        'line': {
                            'index':
                            1,
                            'display':
                            varFORM['description'][0:50],
                            'label':
                            varFORM['lines'] + ' - ' +
                            varFORM['description'][0:20],
                            'dirn': {
                                'pattern':
                                varFORM['lines'],
                                'routePartitionName':
                                varFORM['routePartitionName'],
                            },
                            'recordingFlag':
                            'Call Recording Disabled',
                            'recordingMediaSource':
                            'Gateway Preferred',
                            'maxNumCalls':
                            CustomSoap_Data['maxNumCalls'],
                            'busyTrigger':
                            CustomSoap_Data['busyTrigger'],
                        },
                    }
        else:
            infoLogger.error('No estan todas los parametros requeridos: %s' %
                             (varFORM))
            return {
                'Class': 'Phone',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': 'Faltan parametros'
            }, 400
        # Comprobamos si existe la Key e164Mask
        if 'e164Mask' in varFORM:
            CustomSoap_Data['e164Mask'] = varFORM['e164Mask']

        infoLogger.debug('CustomSoap_Data: %s' % (CustomSoap_Data))
        try:
            # Damos de alta el telefono y no verificamos si existe el mismo telefono
            CustomUser_Resp = CustomService.addPhone(CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'Phone',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'name': varFORM['name'],
                'product': varFORM['product']
            }, 400
        else:
            infoLogger.info('Se ha configurado el telefono %s' %
                            (varFORM['name']))
            return {
                'Class': 'Phone',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'OK',
                'Detail': str(CustomUser_Resp['return']),
                'name': varFORM['name'],
                'product': varFORM['product']
            }, 201
    def post(self):
        # * Funcion para crear un Translation Pattern
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion post de la clase CiscoAXL_TransPattern')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        infoLogger.debug(
            'Se quiere dar de alta el Translation Pattern %s en la Particion %s'
            % (varFORM['pattern'], varFORM['routePartitionName']))

        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {}

        # Comprobamos si el Pattern tiene el caracter +
        if varFORM['pattern'][0] == '+':
            CustomSoap_Data['pattern'] = '\\' + varFORM['pattern']
        else:
            CustomSoap_Data['pattern'] = varFORM['pattern']
        CustomSoap_Data['usage'] = 'Translation'
        CustomSoap_Data['routePartitionName'] = varFORM['routePartitionName']
        # Comprobamos si existe la Key description
        if 'description' in varFORM:
            CustomSoap_Data['description'] = varFORM['description']
        else:
            # Comprobamos si existe la Key CalledPartyTransformMask
            if 'calledPartyTransformationMask' in varFORM:
                CustomSoap_Data[
                    'description'] = varFORM['pattern'] + ' - ' + varFORM[
                        'calledPartyTransformationMask']
                CustomSoap_Data['calledPartyTransformationMask'] = varFORM[
                    'calledPartyTransformationMask']
            else:
                CustomSoap_Data['description'] = varFORM['pattern']
        # Comprobamos si existe la Key callingSearchSpaceName
        if 'callingSearchSpaceName' in varFORM:
            CustomSoap_Data['callingSearchSpaceName'] = varFORM[
                'callingSearchSpaceName']
        # Comprobamos si existe la Key patternUrgency
        if 'patternUrgency' in varFORM:
            CustomSoap_Data['patternUrgency'] = varFORM['patternUrgency']
        else:
            CustomSoap_Data['patternUrgency'] = 'true'
        # Comprobamos si existe la Key provideOutsideDialtone
        if 'provideOutsideDialtone' in varFORM:
            CustomSoap_Data['provideOutsideDialtone'] = varFORM[
                'provideOutsideDialtone']
        else:
            CustomSoap_Data['provideOutsideDialtone'] = 'false'
        # Replicando el bucle anterior puedo añadir todas las variables que tiene el Translation Pattern
        try:
            # Damos de alta el translation Pattern y no verificamos si existe el mismo translation Pattern
            CustomUser_Resp = CustomService.addTransPattern(CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'TransPattern',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }, 400
        else:
            infoLogger.debug('CustomUser_Resp %s' % (CustomUser_Resp))
            infoLogger.info(
                'Se ha configurado el Translation Pattern %s en la Particion %s'
                % (varFORM['pattern'], varFORM['routePartitionName']))
            return {
                'Class': 'TransPattern',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'OK',
                'Detail': CustomUser_Resp['return'],
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }
Пример #14
0
    def post(self):
        # * Funcion para crear un Directory Number
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion post de la clase CiscoAXL_Line')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        if all(k in varFORM for k in ('pattern', 'routePartitionName')):
            infoLogger.info(
                'Se quiere dar de alta el Directory Number %s en la Particion %s'
                % (varFORM['pattern'], varFORM['routePartitionName']))
            CustomSoap_Data = {
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }
        else:
            infoLogger.error('No estan todas los parametros requeridos: %s' %
                             (varFORM))
            return {
                'Class': 'line',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': 'Faltan parametros'
            }, 400

        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        # Comprobamos si existe la Key usage
        if 'usage' in varFORM:
            CustomSoap_Data['usage'] = varFORM['usage']
        else:
            CustomSoap_Data['usage'] = 'Device'

        # Comprobamos si existe la Key description
        if 'description' in varFORM:
            CustomSoap_Data['description'] = varFORM['description']

        # Comprobamos si existe la Key alertingName
        if 'alertingName' in varFORM:
            CustomSoap_Data['alertingName'] = varFORM['alertingName']

        # Comprobamos si existe la Key voiceMailProfileName
        if 'voiceMailProfileName' in varFORM:
            CustomSoap_Data['voiceMailProfileName'] = varFORM[
                'voiceMailProfileName']

        # Comprobamos si existe la Key allowCtiControlFlag
        if 'allowCtiControlFlag' in varFORM:
            CustomSoap_Data['allowCtiControlFlag'] = varFORM[
                'allowCtiControlFlag']
        else:
            CustomSoap_Data['allowCtiControlFlag'] = 'true'

        # Comprobamos si existe la Key shareLineAppearanceCssName
        if 'shareLineAppearanceCssName' in varFORM:
            CustomSoap_Data['shareLineAppearanceCssName'] = varFORM[
                'shareLineAppearanceCssName']

        # Comprobamos si existe la Key callPickupGroupName
        if 'callPickupGroupName' in varFORM:
            CustomSoap_Data['callPickupGroupName'] = varFORM[
                'callPickupGroupName']

        # Comprobamos si existe la Key callForwardAll callingSearchSpaceName
        if 'callForwardAll' in varFORM:
            if 'callingSearchSpaceName' in varFORM:
                CustomSoap_Data['callForwardAll'] = {
                    'destination':
                    '',
                    'forwardToVoiceMail':
                    'false',
                    'callingSearchSpaceName':
                    varFORM['callingSearchSpaceName'],
                    'secondaryCallingSearchSpaceName':
                    varFORM['callingSearchSpaceName'],
                }
                CustomSoap_Data['callForwardBusy'] = {
                    'destination': '',
                    'forwardToVoiceMail': 'false',
                    'callingSearchSpaceName':
                    varFORM['callingSearchSpaceName'],
                }
            else:
                CustomSoap_Data['callForwardAll'] = {
                    'destination':
                    '',
                    'forwardToVoiceMail':
                    'false',
                    'callingSearchSpaceName':
                    varFORM['shareLineAppearanceCssName'],
                    'secondaryCallingSearchSpaceName':
                    varFORM['shareLineAppearanceCssName'],
                }
                CustomSoap_Data['callForwardBusy'] = {
                    'destination':
                    '',
                    'forwardToVoiceMail':
                    'false',
                    'callingSearchSpaceName':
                    varFORM['shareLineAppearanceCssName'],
                }
            CustomSoap_Data['callForwardBusyInt'] = CustomSoap_Data[
                'callForwardBusy']
            CustomSoap_Data['callForwardNoAnswer'] = CustomSoap_Data[
                'callForwardBusy']
            CustomSoap_Data['callForwardNoAnswerInt'] = CustomSoap_Data[
                'callForwardBusy']
            CustomSoap_Data['callForwardNoCoverage'] = CustomSoap_Data[
                'callForwardBusy']
            CustomSoap_Data['callForwardNoCoverageInt'] = CustomSoap_Data[
                'callForwardBusy']
            CustomSoap_Data['callForwardOnFailure'] = CustomSoap_Data[
                'callForwardBusy']
            CustomSoap_Data['callForwardNotRegistered'] = CustomSoap_Data[
                'callForwardBusy']
            CustomSoap_Data['callForwardNotRegisteredInt'] = CustomSoap_Data[
                'callForwardBusy']

        # Replicando el bucle anterior puedo añadir todas las variables que tiene un Directory Number
        try:
            # Damos de alta el Directory Number y no verificamos si existe el mismo Directory Number
            CustomUser_Resp = CustomService.addLine(CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'line',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }, 400
        else:
            infoLogger.info(
                'Se ha configurado el Directory Number %s en la Particion %s' %
                (varFORM['pattern'], varFORM['routePartitionName']))
            return {
                'Class': 'line',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'OK',
                'Detail': CustomUser_Resp['return'],
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }, 201
Пример #15
0
    def put(self):
        # * Funcion para actualizar un User
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion put de la clase CiscoAXL_userid')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))

        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {}

        # Comprobamos si existe la Key associatedDevices
        if 'userid' in varFORM:
            CustomSoap_Data = {
                'userid': varFORM['userid'],
            }
        else:
            return {
                'Class': 'userid',
                'AXL': 'update',
                'Method': 'PUT',
                'Status': 'ERROR',
                'Detail': 'No esta el campo userid'
            }, 400

        try:
            CustomUser_Resp = CustomService.getUser(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'userid',
                'AXL': 'get',
                'Method': 'GET',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'userid': varFORM['userid']
            }, 400
        else:
            # Comprobamos si existe la Key associatedDevices
            if 'associatedDevices' in varFORM:
                if CustomUser_Resp['return']['user'][
                        'associatedDevices'] == None:
                    CustomSoap_Data['associatedDevices'] = {
                        'device': varFORM['associatedDevices']
                    }
                    infoLogger.debug('CustomSoap_Data: %s' % (CustomSoap_Data))
                else:
                    CustomSoap_Data['associatedDevices'] = CustomUser_Resp[
                        'return']['user']['associatedDevices']
                    CustomSoap_Data['associatedDevices']['device'].append(
                        varFORM['associatedDevices'][0:15])
                    infoLogger.debug('CustomSoap_Data: %s' % (CustomSoap_Data))
            else:
                return {
                    'Class': 'userid',
                    'AXL': 'update',
                    'Method': 'PUT',
                    'Status': 'ERROR',
                    'Detail': 'No esta definida la funcion'
                }, 400

            # Comprobamos si existe la Key pattern y routePartitionName
            if all(k in varFORM for k in ('pattern', 'routePartitionName')):
                CustomSoap_Data['primaryExtension'] = {
                    'pattern': varFORM['pattern'],
                    'routePartitionName': varFORM['routePartitionName'],
                }
            try:
                CustomUser_Resp = CustomService.updateUser(**CustomSoap_Data)
            except:
                infoLogger.error(
                    'Se ha producido un error en la consulta SOAP')
                infoLogger.debug(sys.exc_info())
                infoLogger.error(sys.exc_info()[1])
                return {
                    'Class': 'User',
                    'AXL': 'update',
                    'Method': 'POST',
                    'Status': 'ERROR',
                    'Detail': str(sys.exc_info()[1]),
                    'userid': varFORM['userid']
                }
            else:
                infoLogger.info('Se ha actualizado el usuario %s' %
                                (varFORM['userid']))
                return {
                    'Class': 'User',
                    'AXL': 'update',
                    'Method': 'POST',
                    'Status': 'OK',
                    'Detail': str(CustomUser_Resp['return']),
                    'userid': varFORM['userid']
                }, 201
    def patch(self):
        # * Funcion para list un Translation Pattern
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion post de la clase CiscoAXL_TransPattern')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        infoLogger.debug(
            'Esta buscando los Translation Pattern con el siguiente criterio: %s'
            % (varFORM['searchCriteria']))
        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        searchCriteria = {'pattern': '%' + varFORM['searchCriteria'] + '%'}
        returnedTags = {
            'pattern': '',
            'description': '',
            'usage': '',
            'routePartitionName': '',
            'blockEnable': '',
            'calledPartyTransformationMask': '',
            'callingPartyTransformationMask': '',
            'useCallingPartyPhoneMask': '',
            'callingPartyPrefixDigits': '',
            'dialPlanName': '',
            'digitDiscardInstructionName': '',
            'patternUrgency': '',
            'prefixDigitsOut': '',
            'routeFilterName': '',
            'callingLinePresentationBit': '',
            'callingNamePresentationBit': '',
            'connectedLinePresentationBit': '',
            'connectedNamePresentationBit': '',
            'patternPrecedence': '',
            'provideOutsideDialtone': '',
            'callingPartyNumberingPlan': '',
            'callingPartyNumberType': '',
            'calledPartyNumberingPlan': '',
            'calledPartyNumberType': '',
            'callingSearchSpaceName': '',
            'resourcePriorityNamespaceName': '',
            'routeNextHopByCgpn': '',
            'routeClass': '',
            'callInterceptProfileName': '',
            'releaseClause': '',
            'useOriginatorCss': '',
            'dontWaitForIDTOnSubsequentHops': '',
            'isEmergencyServiceNumber': ''
        }

        CustomSoap_Data = {
            'searchCriteria': searchCriteria,
            'returnedTags': returnedTags,
        }

        try:
            CustomUser_Resp = CustomService.listTransPattern(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'TransPattern',
                'AXL': 'update',
                'Method': 'PUT',
                'Status': 'ERROR',
                'Detail': 'No esta definida la funcion'
            }, 400
            sys.exit()
        else:
            return json.loads(
                json.dumps(
                    zeep.helpers.serialize_object(CustomUser_Resp['return'])))
Пример #17
0
    def post(self):
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion post de la clase CiscoAXL_User')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        infoLogger.debug('Vamos a dar de alta el Userid: %s' %
                         (varFORM['userid']))

        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {}

        # Comprobamos si existe la Key lastName
        if 'lastName' in varFORM:
            CustomSoap_Data['lastName'] = varFORM['lastName']
        else:
            return {
                'Class': 'userid',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': 'No tenemos el campo lastName'
            }, 400

        # Comprobamos si existe la Key userid
        if 'userid' in varFORM:
            CustomSoap_Data['userid'] = varFORM['userid']
        else:
            return {
                'Class': 'userid',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': 'No tenemos el campo userid'
            }, 400

        # Comprobamos si existe la Key presenceGroupName
        if 'presenceGroupName' in varFORM:
            CustomSoap_Data['presenceGroupName'] = varFORM['presenceGroupName']
        else:
            CustomSoap_Data['presenceGroupName'] = 'Standard Presence group'
        if 'pin' in varFORM:
            CustomSoap_Data['pin'] = varFORM['pin']
        else:
            CustomSoap_Data['pin'] = '123456'
        if 'password' in varFORM:
            CustomSoap_Data['password'] = varFORM['password']
        if 'digestCredentials' in varFORM:
            CustomSoap_Data['digestCredentials'] = varFORM['digestCredentials']
        if 'telephoneNumber' in varFORM:
            CustomSoap_Data['telephoneNumber'] = varFORM['telephoneNumber']
            CustomSoap_Data['selfService'] = varFORM['telephoneNumber']
            CustomSoap_Data['enableUserToHostConferenceNow'] = 'true'
            CustomSoap_Data['attendeesAccessCode'] = varFORM['telephoneNumber']

        try:
            # Damos de alta el User ID y no verificamos si existe el mismo User ID
            CustomUser_Resp = CustomService.addUser(CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'userid',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'userid': varFORM['userid']
            }, 400
        else:
            infoLogger.info('Se ha configurado el User ID %s' %
                            (varFORM['userid']))
            return {
                'Class': 'userid',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'OK',
                'Detail': CustomUser_Resp['return'],
                'userid': varFORM['userid']
            }, 201
    def delete(self):
        # * Funcion para borrar un Translation Pattern
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion delete de la clase CiscoAXL_TransPattern'
        )
        varFORM = request.form
        if all(k in varFORM for k in ('pattern', 'routePartitionName')):
            infoLogger.debug(
                'Esta borrando el Translation Pattern %s en la Particion %s' %
                (varFORM['pattern'], varFORM['routePartitionName']))
            CustomSoap_Data = {
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }
        else:
            infoLogger.error('No estan todas los parametros requeridos: %s' %
                             (varFORM))
            return {
                'Class': 'TransPattern',
                'AXL': 'remove',
                'Method': 'DELETE',
                'Status': 'ERROR',
                'Detail': 'Faltan parametros'
            }, 400

        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))
        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        try:
            CustomUser_Resp = CustomService.removeTransPattern(
                **CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            infoLogger.error(
                type(zeep.helpers.serialize_object(sys.exc_info()[1])))
            return {
                'Class': 'TransPattern',
                'AXL': 'remove',
                'Method': 'DELETE',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }, 400
        else:
            infoLogger.info(
                'Se ha encontrado el Translation Pattern %s en la Particion %s'
                % (varFORM['pattern'], varFORM['routePartitionName']))
            return {
                'Class': 'TransPattern',
                'AXL': 'remove',
                'Method': 'DELETE',
                'Status': 'OK',
                'Detail': str(CustomUser_Resp['return']),
                'pattern': varFORM['pattern'],
                'routePartitionName': varFORM['routePartitionName']
            }
Пример #19
0
    def put(self):
        # * Funcion para actualizar un elemento
        infoLogger = logging.getLogger('FlaskCiscoCollab')
        infoLogger.debug(
            'Ha accedido a la funcion put de la clase CiscoAXL_Phone')
        varFORM = request.form
        infoLogger.debug('La direccion IP es: %s' % (varFORM['mmpHost']))

        CustomService = CustomSoap.ClientSoap(infoLogger, varFORM['mmpHost'],
                                              varFORM['mmpUser'],
                                              varFORM['mmpPass'],
                                              varFORM['mmpVersion'])
        CustomService = CustomService.CustomSoapClient()

        CustomSoap_Data = {}

        # Comprobamos si existe las siguientes Key's name
        if 'name' in varFORM:
            CustomSoap_Data['name'] = varFORM['name']
            if 'newName' in varFORM:
                CustomSoap_Data['newName'] = varFORM['newName']
            else:
                CustomSoap_Data['newName'] = varFORM['name']
        else:
            infoLogger.error('No estan todas los parametros requeridos: %s' %
                             (varFORM))
            return {
                'Class': 'Phone',
                'AXL': 'add',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': 'Faltan parametros'
            }, 400

        # Comprobamos si existe la Key ownerUserName
        if 'ownerUserName' in varFORM:
            CustomSoap_Data['ownerUserName'] = varFORM['ownerUserName']

        try:
            CustomUser_Resp = CustomService.updatePhone(**CustomSoap_Data)
        except:
            infoLogger.error('Se ha producido un error en la consulta SOAP')
            infoLogger.debug(sys.exc_info())
            infoLogger.error(sys.exc_info()[1])
            return {
                'Class': 'Phone',
                'AXL': 'update',
                'Method': 'POST',
                'Status': 'ERROR',
                'Detail': str(sys.exc_info()[1]),
                'name': varFORM['name']
            }
        else:
            infoLogger.info('Se ha configurado el telefono %s' %
                            (varFORM['name']))
            return {
                'Class': 'Phone',
                'AXL': 'update',
                'Method': 'POST',
                'Status': 'OK',
                'Detail': str(CustomUser_Resp['return']),
                'name': varFORM['name']
            }