def delete(self,firewall): logger.debug('handler.config.delete()') 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.rules(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 'name' not in request.args: logger.warning("No rule name given.") return {'error' : 'No rule name given.'}, 400 else: return c.delete(request.args['name']) elif fw['brand'] == "juniper": return Cisco.configuration(firewall) elif fw['brand'] == "cisco": return Cisco.configuration(firewall) elif fw['brand'] == "aws": 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: #That Firewall Brand does not exists. logger.error("{0}: Firewall brand not found.".format(request.remote_addr)) return {'error' : 'URL not found.'}, 404
def patch(self, firewall): logger.debug('handler.config.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.rules(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 elif 'name' not in request.args: return {'error': 'No rule name supplied.'}, 400 else: return c.patch(request.args['name'], request.json) elif fw['brand'] == "juniper": c = Juniper.rules(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 elif 'name' not in request.json: return {'error': 'No rule name supplied.'}, 400 else: return c.patch(request.json['name'], request.json, comment=request.args['comment']) elif fw['brand'] == "cisco": return Cisco.configuration(firewall) elif fw['brand'] == "aws": 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: #That Firewall Brand does not exists. logger.error("{0}: Firewall brand not found.".format( request.remote_addr)) return {'error': 'URL not found.'}, 404