Пример #1
0
	def get(self,firewall,object):
		logger.debug('handler.config.get()')
		fw = Firewall(firewall=firewall).getConfig()
		if not fw:
			logger.error('Firewall not found.')
			return {'error' : 'Firewall not found.'}, 404
		if fw['brand'] == "paloalto":
			c = PaloAlto.objects(firewall_config=fw)
			if not c.primary:
				logger.error("Could not get {0} active ip.".format(firewall))
				return {'error' : 'Could not get firewall active IP.'}, 502
			else:
				logger.info("{0} active ip {1}".format(firewall, c.primary))
				return c.get(request.args,object)
		elif fw['brand'] == "juniper":
			c = Juniper.objects(firewall_config=fw)
			if not c.primary:
				logger.error("Could not get {0} active ip.".format(firewall))
				return {'error' : 'Could not get firewall active IP.'}, 502
			else:
				logger.info("{0} active ip {1}".format(firewall, c.primary))
				return c.get(request.args,object)
		elif fw['brand'] == "cisco":
			return Cisco.configuration(firewall)
		elif fw['brand'] == "checkpoint":
			return Checkpoint.configuration(firewall)
		elif fw['brand'] == "fortinet":
			return Fortinet.configuration(firewall)
		elif fw['brand'] == "pfsense":
			return PfSense.configuration(firewall)
		else:
			logger.error("{0}: Firewall brand not found.".format(request.remote_addr))
			return {'error' : 'URL not found.'}, 404
Пример #2
0
 def patch(self, firewall, object):
     logger.debug('handler.objects.patch()')
     fw = Firewall(firewall=firewall).getConfig()
     if not fw:
         logger.error('Firewall not found.')
         return {'error': 'Firewall not found.'}, 404
     if fw['brand'] == "paloalto":
         c = PaloAlto.objects(firewall_config=fw)
         if not c.primary:
             logger.error("Could not get {0} active ip.".format(firewall))
             return {'error': 'Could not get firewall active IP.'}, 502
         else:
             logger.info("{0} active ip {1}".format(firewall, c.primary))
             if not request.json:
                 return {
                     'error': 'Content type needs to be application/json.'
                 }, 400
             else:
                 return c.patch(request.json, object)
     elif fw['brand'] == "juniper":
         c = Juniper.objects(firewall_config=fw)
         if not c.primary:
             logger.error("Could not get {0} active ip.".format(firewall))
             return {'error': 'Could not get firewall active IP.'}, 502
         else:
             logger.info("{0} active ip {1}".format(firewall, c.primary))
             if not request.json:
                 return {
                     'error': 'Content type needs to be application/json.'
                 }, 400
             else:
                 return c.patch(data=request.json,
                                object=object,
                                comment=request.args['comment'])
     elif fw['brand'] == "cisco":
         return Cisco.configuration(firewall)
     elif fw['brand'] == "checkpoint":
         return Checkpoint.configuration(firewall)
     elif fw['brand'] == "fortinet":
         return Fortinet.configuration(firewall)
     elif fw['brand'] == "pfsense":
         return PfSense.configuration(firewall)
     else:
         logger.error("{0}: Firewall brand not found.".format(
             request.remote_addr))
         return {'error': 'URL not found.'}, 404