コード例 #1
0
ファイル: monitor_converter.py プロジェクト: ypraveen/sdk
 def convert_udp(self, monitor_dict, f5_monitor, skipped):
     skipped = [key for key in skipped if key not in self.udp_attr]
     # F5 version 10 have dest as port added code.
     # if * is there then ignore it else add to port.
     destination = f5_monitor.get(self.dest_key, "*:*")
     dest_str = destination.split(":")
     # some config . appear with port. ex '*.80'
     if '.' in destination:
         dest_str = destination.split('.')
     if dest_str[0] != '*':
         skipped.append(self.dest_key)
     if dest_str[1].isdigit():
         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
     # Added mapping for http_response.
     maintenance_resp, http_resp = self.get_maintenance_response(f5_monitor)
     if udp_monitor:
         udp_monitor["maintenance_response"] = maintenance_resp
         udp_monitor["http_response"] = http_resp
     else:
         udp_monitor = {"maintenance_response": maintenance_resp,
                        "http_response": http_resp}
         monitor_dict["udp_monitor"] = udp_monitor
     return skipped
コード例 #2
0
ファイル: monitor_converter.py プロジェクト: ypraveen/sdk
 def convert_http(self, monitor_dict, f5_monitor, skipped):
     ignore_list = ['adaptive']
     http_attr = self.http_attr + ignore_list
     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": ["HTTP_2XX", "HTTP_3XX"]
     }
     # F5 version 10 have dest as port added code.
     # if * is there then ignore it else add to port.
     destination = f5_monitor.get(self.dest_key, "*:*")
     dest_str = destination.split(":")
     # some config . is appear with port ex: *.80
     if '.' in destination:
         dest_str = destination.split('.')
     if dest_str[0] != '*':
         skipped.append(self.dest_key)
     if dest_str[1].isdigit():
         monitor_dict["monitor_port"] = dest_str[1]
     # Added mapping for http_response.
     maintenance_resp, http_resp = self.get_maintenance_response(f5_monitor)
     monitor_dict["http_monitor"]["maintenance_response"] = maintenance_resp
     monitor_dict["http_monitor"]["http_response"] = http_resp
     return skipped
コード例 #3
0
ファイル: monitor_converter.py プロジェクト: ypraveen/sdk
    def convert_https(self, monitor_dict, f5_monitor, skipped,
                      avi_config, tenant, input_dir, cloud_name, controller_version):

        ignore_list = ['compatibility']
        https_attr = ignore_list + self.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"]
        }
        # Added code to handel ssl attribute and certificate.
        monitor_dict["https_monitor"]['ssl_attributes'] = dict()
        if f5_monitor.get('cipherlist', None) \
                and parse_version(controller_version) >= parse_version('17.1'):
            self.create_sslprofile(monitor_dict, f5_monitor, avi_config,
                           tenant, cloud_name)
        # Added code create ssl  key and cert
        if f5_monitor.get('key', None) != 'none' \
                and f5_monitor.get('cert', None) != 'none' \
                and parse_version(controller_version) >= parse_version('17.1'):
            self.create_sslkeyandcert(
                monitor_dict, f5_monitor, avi_config, tenant,
                input_dir, cloud_name)
        # F5 version 10 have dest as port added code.
        # if * is there then ignore it else add to port.
        destination = f5_monitor.get(self.dest_key, "*:*")
        dest_str = destination.split(":")
        # some config . appear with port. ex '*.80'
        if '.' in destination:
            dest_str = destination.split('.')
        if dest_str[0] != '*':
            skipped.append(self.dest_key)
        if dest_str[1].isdigit():
            monitor_dict["monitor_port"] = dest_str[1]
        # Added mapping for http_response.
        maintenance_resp, http_resp = self.get_maintenance_response(f5_monitor)
        monitor_dict["https_monitor"]["maintenance_response"] = maintenance_resp
        monitor_dict["https_monitor"]["http_response"] = http_resp
        return skipped
コード例 #4
0
ファイル: monitor_converter.py プロジェクト: ypraveen/sdk
    def convert_tcp(self, monitor_dict, f5_monitor, skipped, type):
        skipped = [key for key in skipped if key not in self.tcp_attr]
        # F5 version 11 have destination as port added code.
        # if * is there then ignore it else add to port.
        destination = f5_monitor.get(self.dest_key, "*:*")
        dest_str = destination.split(":")
        # some config . appear with port. ex '*.80'
        if '.' in destination:
            dest_str = destination.split('.')
        if dest_str[0] != '*':
            skipped.append(self.dest_key)
        if dest_str[1].isdigit():
            monitor_dict["monitor_port"] = dest_str[1]
        monitor_dict["type"] = "HEALTH_MONITOR_TCP"
        request = f5_monitor.get("send", None)
        if request:
            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
        # Added mapping for http_response.
        maintenance_resp, http_rsp = self.get_maintenance_response(f5_monitor)
        if tcp_monitor:
            tcp_monitor["maintenance_response"] = maintenance_resp
            tcp_monitor["http_response"] = http_rsp
        else:
            tcp_monitor = {"maintenance_response": maintenance_resp,
                           "http_response": http_rsp}
            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