def create(self, req, *args, **kwargs): try: url = req.url if len(args) > 1: raise BadRequest(resource="VRF create", msg=url) context = req.context body_values = json.loads(req.body) valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'name', 'vrfInterface'] values = tools.validat_values(body_values, valid_attributes) # input the staticnat values with dic format LOG.info(_LI("input add_vrf body is %(json)s"), {"json": body_values}) response = self.manager.create_vrf(context, values) return response except Nca47Exception as e: LOG.error(_LE('Nca47Exception! error info: ' + e.message)) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as e: self.response.status = 500 return tools.ret_info(self.response.status, e.value) except Exception as e: LOG.error(_LE('Exception! error info: ' + e.message)) self.response.status = 500 message = "the values of the body format is error" return tools.ret_info(self.response.status, message)
def remove(self, req, *args, **kwargs): try: url = req.url if len(args) > 1: raise BadRequest(resource="SNAT del", msg=url) context = req.context body_values = json.loads(req.body) valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'id'] values = tools.validat_values(body_values, valid_attributes) # input the snat values with dic format LOG.info(_LI("delete Staticnat body is %(json)s"), {"json": body_values}) response = self.manager.del_snat(context, values) return response except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message)
def remove(self, req, *args, **kwargs): context = req.context try: if len(args) != 1: raise BadRequest(resource="delete dnat operation", msg=req.url) body_values = json.loads(req.body) valid_attributes = ['id', 'tenant_id', 'dc_name', 'network_zone'] values = tools.validat_values(body_values, valid_attributes) response = self.manager.delete_dnat(context, values) except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message) return response
def list(self, req, *args, **kwargs): try: url = req.url if len(args) > 1: raise BadRequest(resource="staticnat getAll", msg=url) context = req.context body_values = json.loads(req.body) valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'vfwname'] values = tools.validat_values(body_values, valid_attributes) # input the staticnat values with dic format LOG.info(_LI("get_all the staticnat values with dic format\ is %(json)s"), {"json": body_values}) response = self.manager.get_staticnats(context, values) return response except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except RemoteError as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as e: LOG.exception(e) self.response.status = 500 return tools.ret_info(self.response.status, e.message)
def show(self, req, *args, **kwargs): context = req.context try: if len(args) != 1: raise BadRequest(resource="show dnat operation", msg=req.url) body_values = json.loads(req.body) valid_attributes = ['id'] values = tools.validat_values(body_values, valid_attributes) dnat_info = self.manager.get_dnat(context, values) except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except RemoteError as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as e: LOG.exception(e) self.response.status = 500 return tools.ret_info(self.response.status, e.message) return dnat_info
def list(self, req, *args, **kwargs): context = req.context try: if len(args) != 1: raise BadRequest(resource="list packetfilters operation", msg=req.url) body_values = json.loads(req.body) valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'vfwname'] values = tools.validat_values(body_values, valid_attributes) packetfilter_infos = self.manager.get_all_packetfilters(context, values) except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except RemoteError as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as e: LOG.exception(e) self.response.status = 500 return tools.ret_info(self.response.status, e.message) return packetfilter_infos
def validat_parms(self, values, valid_keys): """check the in value is null and nums""" recom_msg = tools.validat_values(values, valid_keys) for value in recom_msg: if value == "src_logic": if not ((values['src_logic'] == "0") or (values['src_logic'] == "1")): raise ParamValueError(param_name=value) elif value == "dst_logic": if not ((values['dst_logic'] == "0") or (values['dst_logic'] == "1")): raise ParamValueError(param_name=value) elif value == "priority": try: int_priority = int(values['priority']) except Exception: raise ParamFormatError(param_name=value) if (int_priority < 1) or (int_priority > 65535): raise ParamValueError(param_name=value) elif value == "src_type": src_type_array = ['ip_subnet', 'region', 'ISP', 'country', 'province'] if values['src_type'] not in src_type_array: raise ParamValueError(param_name=value) elif value == "dst_type": dst_type_array = ['ip_subnet', 'region', 'ISP', 'country', 'province'] if values['dst_type'] not in dst_type_array: raise ParamValueError(param_name=value) return recom_msg
def list(self, req, *args, **kwargs): try: url = req.url if len(args) > 1: raise BadRequest(resource="SecurityZone getAll", msg=url) context = req.context body_values = json.loads(req.body) valid_attributes = ["tenant_id", "dc_name", "network_zone"] values = tools.validat_values(body_values, valid_attributes) # get_all the SecurityZone values with dic format LOG.info(_LI("get_all SecurityZone body is %(json)s"), {"json": body_values}) response = self.manager.get_securityZones(context, values) return response except Nca47Exception as e: self.response.status = e.code LOG.error(_LE("Error exception! error info: %" + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message)
def remove(self, req, *args, **kwargs): try: url = req.url if len(args) > 1: raise BadRequest(resource="VRF del", msg=url) context = req.context body_values = json.loads(req.body) valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'id'] values = tools.validat_values(body_values, valid_attributes) # input the vrf values with dic format LOG.info(_LI("delete the vrf values with dic format\ is %(json)s"), {"json": body_values}) response = self.manager.del_vrf(context, values) return response except Nca47Exception as e: LOG.error(_LE('Nca47Exception! error info: ' + e.message)) self.response.status = e.code return tools.ret_info(e.code, e.message) except RemoteError as e: self.response.status = 500 return tools.ret_info(self.response.status, e.value) except Exception as e: LOG.error(_LE('Exception! error info: ' + e.message)) self.response.status = 500 return tools.ret_info(self.response.status, e.message)
def validat_parms(self, values, valid_keys): """check the in value is null and nums""" recom_msg = tools.validat_values(values, valid_keys) for value in recom_msg: if value == "name": try: spe_char = '.' char = values[value][-1] if not cmp(spe_char, char): recom_msg[value] = values[value][:-1] if not check_areaname(recom_msg[value]): raise ParamFormatError(param_name=value) except Exception: raise ParamFormatError(param_name=value) elif value == "default_ttl": if not check_ttl(values['default_ttl']): raise ParamFormatError(param_name=value) elif value == "renewal": if not check_renewal(values['renewal']): raise ParamValueError(param_name=value) elif value == "owners": flag = is_not_list(values['owners']) if flag == "0": raise ParamFormatError(param_name=value) elif flag == "1": raise ParamNull(param_name=value) elif value == "slaves": flag = is_not_list(values['slaves']) if flag == "0": raise ParamFormatError(param_name=value) elif flag == "1": raise ParamNull(param_name=value) return recom_msg
def create(self, req, *args, **kwargs): try: url = req.url if len(args) > 1: raise BadRequest(resource="SecurityZone create", msg=url) context = req.context body_values = json.loads(req.body) # ADTEC_COMMENT: 需要加上vfwname 参数 valid_attributes = ["tenant_id", "dc_name", "network_zone", "name", "ifnames", "priority"] values = tools.validat_values(body_values, valid_attributes) # input the SecurityZone values with dic format LOG.info(_LI("input add_SecurityZone body is %(json)s"), {"json": body_values}) values["name"] = values["tenant_id"] + "_" + values["network_zone"] + "_" + values["name"] response = self.manager.create_securityZone(context, values) return response except Nca47Exception as e: self.response.status = e.code LOG.error(_LE("Error exception! error info: %" + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message)
def list(self, req, *args, **kwargs): context = req.context try: if len(args) != 1: raise BadRequest(resource="list vfws operation", msg=req.url) body_values = json.loads(req.body) valid_attributes = ['tenant_id', 'dc_name', 'network_zone'] values = tools.validat_values(body_values, valid_attributes) if 'protection_class' in body_values.keys(): values['protection_class'] = body_values['protection_class'] vfw_info = self.manager.get_all_vfws(context, values) except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message) return vfw_info
def create(self, req, *args, **kwargs): context = req.context valid_attributes = ['name', 'type', 'resource', 'tenant_id', 'dc_name', 'network_zone', 'network_zone_class'] try: if len(args) != 1: raise BadRequest(resource="create vfw operation", msg=req.url) body_values = json.loads(req.body) values = tools.validat_values(body_values, valid_attributes) if 'protection_class' in body_values.keys(): values['protection_class'] = body_values['protection_class'] type_range = (2, 4, 8) if values['type'] not in type_range: raise ParamValueError(param_name='type') vfw_info = self.manager.create_vfw(context, values) except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message) return vfw_info
def show(self, req, *args, **kwargs): context = req.context try: if len(args) != 1: raise BadRequest(resource="show packetfilter operation", msg=req.url) body_values = json.loads(req.body) valid_attributes = ['id'] values = tools.validat_values(body_values, valid_attributes) packetfilter_info = self.manager.get_packetfilter(context, values) except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message) return packetfilter_info
def validat_parms(self, values, valid_keys): """check the in value is null and nums""" recom_msg = tools.validat_values(values, valid_keys) for value in recom_msg: if value == "type": type_array = ['ip_subnet', 'region', 'ISP', 'country', 'province'] if values['type'] not in type_array: raise ParamValueError(param_name=value) return recom_msg
def create(self, req, *args, **kwargs): context = req.context try: if len(args) != 1: raise BadRequest(resource="create packetfilter operation", msg=req.url) body_values = json.loads(req.body) valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'name', 'srczonename', 'dstzonename', 'vfwname'] values = tools.validat_values(body_values, valid_attributes) if 'srcipobjips' in body_values.keys(): for ipinfo in body_values['srcipobjips']: if not tools._is_valid_ipv4_addr(ipinfo): raise ParamValueError(param_name=ipinfo) values['srcipobjips'] = body_values['srcipobjips'] if 'dstipobjips' in body_values.keys(): for ipinfo in body_values['dstipobjips']: if not tools._is_valid_ipv4_addr(ipinfo): raise ParamValueError(param_name=ipinfo) values['dstipobjips'] = body_values['dstipobjips'] if 'servicenames' in body_values.keys(): values['servicenames'] = body_values['servicenames'] valid_range = (0, 1) if 'action' in body_values.keys(): if body_values['action'] not in valid_range: raise ParamValueError(param_name='action') values['action'] = body_values['action'] else: values['action'] = 0 if 'log' in body_values.keys(): if body_values['log'] not in valid_range: raise ParamValueError(param_name='log') values['log'] = body_values['log'] else: values['log'] = 0 packetfilter_info = self.manager.create_packetfilter(context, values) except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message) return packetfilter_info
def create(self, req, *args, **kwargs): context = req.context try: if len(args) != 1: raise BadRequest(resource="create dnat operation", msg=req.url) body_values = json.loads(req.body) valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'name', 'inifname', 'wanip', 'lanipstart', 'lanipend', 'lanport', 'slot', 'vfwname'] values = tools.validat_values(body_values, valid_attributes) keys = body_values.keys() if not tools._is_valid_ipv4_addr(values['wanip']): raise ParamValueError(param_name='wanip') if not tools._is_valid_ipv4_addr(values['lanipstart']): raise ParamValueError(param_name='lanipstart') if not tools._is_valid_ipv4_addr(values['lanipend']): raise ParamValueError(param_name='lanipend') if values['lanport'] != "0": if not tools._is_valid_port(values['lanport']): raise ParamValueError(param_name='lanport') if 'wantcpports' in keys and 'wanudpports' in keys: raise BadRequest(resource="dnat", msg="Only have one" " between wantcpports and wanudpport") if 'wantcpports' in keys: for port_range in body_values['wantcpports']: if not tools._is_valid_port_range(port_range): raise BadRequest(resource="wantcpports", msg=port_range) values['wantcpports'] = body_values['wantcpports'] if 'wanudpports' in keys: for port_range in body_values['wanudpports']: if not tools._is_valid_port_range(port_range): raise BadRequest(resource="wantcpports", msg=port_range) values['wanudpports'] = body_values['wanudpports'] dnat_info = self.manager.create_dnat(context, values) except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message) return dnat_info
def message_regrouping(self, dic, list_imp, list_uni): tool.validat_values(dic, list_imp) values = {} dic_key = dic.keys() for key_imp in list_imp: values[key_imp] = dic[key_imp] uni = {} for k in list_uni: if k not in dic_key: if k == "ttl": uni[k] = "3600" elif k == "klass": uni[k] = "IN" else: continue merge = tool.dict_merge(values, uni) exist_imp = {} for key in dic_key: if key == "ttl": if tool.is_not_nil(dic[key]): exist_imp[key] = dic[key] else: exist_imp[key] = "3600" elif key == "klass": if tool.is_not_nil(dic[key]): exist_imp[key] = dic[key] else: exist_imp[key] = "IN" else: continue new_list = list_imp + list_uni new_dic = tool.dict_merge(merge, exist_imp) return self.validat_parms(new_dic, new_list)
def create(self, req, *args, **kwargs): try: url = req.url if len(args) > 1: raise BadRequest(resource="SNAT create", msg=url) context = req.context body_values = json.loads(req.body) valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'name', 'outIfName', 'vfwname'] values = tools.validat_values(body_values, valid_attributes) values["outifname"] = body_values["outIfName"] if "srcIpObjIP" not in body_values.keys(): values["srcipobjname"] = ["all"] else: values["srcipobjname"] = body_values["srcIpObjIP"] if "dstIpObjIP" not in body_values.keys(): values["dstipobjname"] = ["all"] else: values["dstipobjname"] = body_values["dstIpObjIP"] if "wanIpPoolIP" not in body_values.keys(): values["wanippoolname"] = "" else: values["wanippoolname"] = body_values["wanIpPoolIP"] # input the staticnat values with dic format LOG.info(_LI("input the snat values with dic format\ is %(json)s"), {"json": body_values}) response = self.manager.create_snat(context, values) return response except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except RemoteError as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as e: LOG.exception(e) self.response.status = 500 return tools.ret_info(self.response.status, e.message)
def validat_parms(self, values, valid_keys): """check the in value is null and nums""" recom_msg = validat_values(values, valid_keys) for value in recom_msg: if value == "owners": flag = is_not_list(values['owners']) if flag == "0": raise ParamFormatError(param_name=value) elif flag == "1": raise ParamNull(param_name=value) elif value == "domain_name": if not is_not_nil(values['domain_name']): raise ParamNull(param_name=value) elif value == "view_name": if not is_not_nil(values['view_name']): raise ParamNull(param_name=value) return recom_msg
def update(self, req, id, *args, **kwargs): try: url = req.url # if len(args) > 1: # raise BadRequest(resource="gslb_zone del", msg=url) context = req.context body_values = json.loads(req.body) gslb_zone_id = id valid_attributes = ['enable', 'devices', 'syn_server'] # valid_devices = ["group_name", "device_name"] values = tools.validat_values(body_values, valid_attributes) obj_devices = body_values["devices"] # for key in obj_devices: # tools.validat_values(key, valid_devices) # tools.validat_values(body_values["syn_server"], valid_devices) for key in obj_devices: if body_values["syn_server"] in key: flag = False if flag: raise ParamValueError(param_name=body_values["syn_server"]) # input the gslb_zone values with dic format LOG.info(_LI("update the gslb_zone values with dic format\ is %(json)s"), {"json": body_values}) response = self.manager.update_gslb_zone( context, gslb_zone_id, values) return response except Nca47Exception as e: self.response.status = e.code LOG.error(_LE('Error exception! error info: %' + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except RemoteError as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as e: LOG.exception(e) self.response.status = 500 return tools.ret_info(self.response.status, e.message)
def validat_parms(self, values, valid_keys): """check the in value is null and nums""" recom_msg = tool.validat_values(values, valid_keys) for value in recom_msg: if value == "name": if not tool.check_areaname(values['name']): raise ParamFormatError(param_name=value) elif value == "id": if not tool.is_not_nil(values['id']): raise ParamNull(param_name=value) elif value == "tenant_id": if not tool.is_not_nil(values['tenant_id']): raise ParamNull(param_name=value) elif value == "type": if not tool.is_not_nil(values['type']): raise ParamFormatError(param_name=value) elif value == "ttl": if not tool.check_ttl(values['ttl']): raise ParamFormatError(param_name=value) elif value == "rdata": if not tool.check_rdata(values['rdata']): raise ParamFormatError(param_name=value) return recom_msg
def delif(self, req, *args, **kwargs): try: url = req.url if len(args) > 1: raise BadRequest(resource="SecurityZone del vlan", msg=url) context = req.context body_values = json.loads(req.body) valid_attributes = ["tenant_id", "dc_name", "network_zone", "id", "ifname"] values = tools.validat_values(body_values, valid_attributes) # input the SecurityZone values with dic format LOG.info(_LI("delete SecurityZone body is %(json)s"), {"json": body_values}) response = self.manager.get_securityZone(context, values) if not isinstance(values["ifname"], string): raise ParamFormatError(param_name="ifname") if values["ifname"] not in response.ifnames: message = "securityZone with ifname=" + values["ifname"] + " don't exist!" return tools.ret_info("400", message) response.ifnames.remove(values["ifname"]) values["ifnames"] = response.ifnames response = self.manager.update_securityZone(context, values) return response except Nca47Exception as e: self.response.status = e.code LOG.error(_LE("Error exception! error info: %" + e.message)) LOG.exception(e) self.response.status = e.code return tools.ret_info(e.code, e.message) except MessagingException as exception: self.response.status = 500 message = exception.value return tools.ret_info(self.response.status, message) except Exception as exception: LOG.exception(exception) self.response.status = 500 message = "the values of the body format error" return tools.ret_info(self.response.status, message)
def validat_parms(self, values, valid_keys): """check the in value is null and nums""" recom_msg = tool.validat_values(values, valid_keys) return recom_msg
def message_regrouping(self, dic, list_imp, list_uni): tool.validat_values(dic, list_imp) values = {} dic_key = dic.keys() for key_imp in list_imp: values[key_imp] = dic[key_imp] uni = {} for k in list_uni: if k not in dic_key: if k == "check_interval": uni[k] = "10" elif k == "timeout": uni[k] = "3" elif k == "max_retries": uni[k] = "2" else: continue merge = tool.dict_merge(values, uni) exist_imp = {} for key in dic_key: if key == "check_interval": if tool.is_not_nil(dic[key]): try: val = int(dic[key]) if val < 1 or val > 86400: raise ParamValueError(param_name=val) except Exception: raise ParamValueError(param_name=val) exist_imp[key] = dic[key] else: exist_imp[key] = "10" elif key == "timeout": if tool.is_not_nil(dic[key]): try: val = int(dic[key]) if val < 1 or val > 86400: raise ParamValueError(param_name=val) except Exception: raise ParamValueError(param_name=val) exist_imp[key] = dic[key] else: exist_imp[key] = "3" elif key == "max_retries": if tool.is_not_nil(dic[key]): try: val = int(dic[key]) if val < 1 or val > 10: raise ParamValueError(param_name=val) except Exception: raise ParamValueError(param_name=val) exist_imp[key] = dic[key] else: exist_imp[key] = "2" else: continue new_dic = tool.dict_merge(merge, exist_imp) types = new_dic["types"] if types == "http" or types == "https": if "sendstring" in dic_key: new_dic["sendstring"] = dic["sendstring"] else: new_dic["sendstring"] = "" if "recvstring" in dic_key: new_dic["recvstring"] = dic["recvstring"] else: new_dic["recvstring"] = "" if "username" in dic_key: new_dic["username"] = dic["username"] else: new_dic["username"] = "" if "password" in dic_key: new_dic["password"] = dic["password"] else: new_dic["password"] = "" elif types == "udp": if "sendstring" in dic_key: new_dic["sendstring"] = dic["sendstring"] else: new_dic["sendstring"] = "" elif types == "icmp" or types == "tcp_syn": pass else: raise ParamValueError(param_name=types) return new_dic