示例#1
0
 def convert_udp(self, monitor_dict, f5_monitor, skipped):
     udp_attr = ["dest", "send", "recv", "recv disable", "reverse"]
     skipped = [key for key in skipped if key not in udp_attr]
     destination = f5_monitor.get("dest", "*:*")
     dest_str = destination.split(":")
     if len(dest_str) > 1 and isinstance(dest_str[1], numbers.Integral):
         monitor_dict["monitor_port"] = dest_str[1]
     monitor_dict["type"] = "HEALTH_MONITOR_UDP"
     request = f5_monitor.get("send", None)
     request = request.replace('\\\\', '\\')
     request = conv_utils.rreplace(request, '\\r\\n', '', 1)
     response = f5_monitor.get("recv", None)
     udp_monitor = None
     if request or response:
         request = request.replace('\"', '') if request else None
         response = response.replace('\"', '') if response else None
         udp_monitor = {"udp_request": request, "udp_response": response}
         monitor_dict["udp_monitor"] = udp_monitor
     maintenance_resp = self.get_maintenance_response(f5_monitor)
     if udp_monitor:
         udp_monitor["maintenance_response"] = maintenance_resp
     else:
         udp_monitor = {"maintenance_response": maintenance_resp}
         monitor_dict["udp_monitor"] = udp_monitor
     return skipped
示例#2
0
    def convert_tcp(self, monitor_dict, f5_monitor, skipped, type):
        tcp_attr = ["recv-disable", "reverse", "destination", "send", "recv"]
        skipped = [key for key in skipped if key not in tcp_attr]
        destination = f5_monitor.get("destination", "*:*")
        dest_str = destination.split(":")
        if len(dest_str) > 1 and isinstance(dest_str[1], numbers.Integral):
            monitor_dict["monitor_port"] = dest_str[1]
        monitor_dict["type"] = "HEALTH_MONITOR_TCP"
        request = f5_monitor.get("send", None)
        request = request.replace('\\\\', '\\')
        request = conv_utils.rreplace(request, '\\r\\n', '', 1)
        response = f5_monitor.get("recv", None)
        tcp_monitor = None
        if request or response:
            tcp_monitor = {"tcp_request": request, "tcp_response": response}
            monitor_dict["tcp_monitor"] = tcp_monitor

        maintenance_resp = self.get_maintenance_response(f5_monitor)
        if tcp_monitor:
            tcp_monitor["maintenance_response"] = maintenance_resp
        else:
            tcp_monitor = {"maintenance_response": maintenance_resp}
            monitor_dict["tcp_monitor"] = tcp_monitor
        if type == 'tcp-half-open':
            if tcp_monitor:
                tcp_monitor["tcp_half_open"] = True
            else:
                tcp_monitor = {"tcp_half_open": True}
                monitor_dict["tcp_monitor"] = tcp_monitor

        return skipped
示例#3
0
 def convert_https(self, monitor_dict, f5_monitor, skipped):
     https_attr = ["recv", "recv disable", "reverse", "send"]
     ignore_list = ['compatibility']
     https_attr = ignore_list + https_attr
     skipped = [key for key in skipped if key not in https_attr]
     send = f5_monitor.get('send', None)
     send = send.replace('\\\\', '\\')
     send = conv_utils.rreplace(send, '\\r\\n', '', 1)
     monitor_dict["type"] = "HEALTH_MONITOR_HTTPS"
     monitor_dict["https_monitor"] = {
         "http_request": send,
         "http_response_code": ["HTTP_2XX", "HTTP_3XX"]
     }
     maintenance_resp = self.get_maintenance_response(f5_monitor)
     monitor_dict["https_monitor"][
         "maintenance_response"] = maintenance_resp
     return skipped
示例#4
0
    def convert_http(self, monitor_dict, f5_monitor, skipped):
        http_attr = ["recv", "recv-disable", "reverse", "send"]
        skipped = [key for key in skipped if key not in http_attr]
        send = f5_monitor.get('send', 'HEAD / HTTP/1.0')
        send = send.replace('\\\\', '\\')
        send = conv_utils.rreplace(send, '\\r\\n', '', 1)
        monitor_dict["type"] = "HEALTH_MONITOR_HTTP"
        monitor_dict["http_monitor"] = {
            "http_request": send,
            "http_response_code": [{
                "code": "HTTP_2XX"
            }, {
                "code": "HTTP_3XX"
            }]
        }

        maintenance_resp = self.get_maintenance_response(f5_monitor)
        monitor_dict["http_monitor"]["maintenance_response"] = maintenance_resp

        return skipped