def __check_params(self, action, container_port, protocol, port_alias, service_id): standard_actions = ("open_outer", "only_open_outer", "close_outer", "open_inner", "close_inner", "change_protocol", "change_port_alias") if not action: return 400, "操作类型不能为空" if action not in standard_actions: return 400, "不允许的操作类型" if action == "change_port_alias": if not port_alias: return 400, "端口别名不能为空" try: port = port_repo.get_service_port_by_alias( service_id, port_alias) if port.container_port != container_port: return 400, "别名已存在" except TenantServicesPort.DoesNotExist: pass if action == "change_protocol": if not protocol: return 400, "端口协议不能为空" if port_alias: code, msg = self.check_port_alias(port_alias) if code != 200: return code, msg return 200, "检测成功"
def __check_params(self, action, protocol, port_alias, service_id): standard_actions = ("open_outer", "only_open_outer", "close_outer", "open_inner", "close_inner", "change_protocol", "change_port_alias") if not action: return 400, u"操作类型不能为空" if action not in standard_actions: return 400, u"不允许的操作类型" if action == "change_port_alias": if not port_alias: return 400, u"端口别名不能为空" if port_repo.get_service_port_by_alias(service_id, port_alias): return 400, u"别名已存在" if action == "change_protocol": if not protocol: return 400, u"端口协议不能为空" if port_alias: code, msg = self.check_port_alias(port_alias) if code != 200: return code, msg return 200, u"检测成功"