示例#1
0
    def delete_port_by_container_port(self, tenant, service, container_port):
        service_domain = domain_repo.get_service_domain_by_container_port(
            service.service_id, container_port)
        if service_domain:
            return 412, u"请先解绑该端口绑定的域名", None
        port_info = port_repo.get_service_port_by_port(tenant.tenant_id,
                                                       service.service_id,
                                                       container_port)
        if not port_info:
            return 404, u"端口{0}不存在".format(container_port), None
        if port_info.is_inner_service:
            return 409, u"请关闭对外服务", None
        if port_info.is_outer_service:
            return 409, u"请关闭外部服务", None
        if service.create_status == "complete":
            # 删除数据中心端口
            region_api.delete_service_port(service.service_region,
                                           tenant.tenant_name,
                                           service.service_alias,
                                           container_port,
                                           tenant.enterprise_id)

        # 删除env
        env_var_service.delete_env_by_container_port(tenant, service,
                                                     container_port)
        # 删除端口
        port_repo.delete_serivce_port_by_port(tenant.tenant_id,
                                              service.service_id,
                                              container_port)
        # 删除端口绑定的域名
        domain_repo.delete_service_domain_by_port(service.service_id,
                                                  container_port)
        return 200, u"删除成功", port_info
示例#2
0
    def delete_port_by_container_port(self, tenant, service, container_port):
        service_domain = domain_repo.get_service_domain_by_container_port(service.service_id, container_port)

        if len(service_domain) > 1 or len(service_domain) == 1 and service_domain[0].type != 0:
            return 412, u"该端口有自定义域名,请先解绑域名", None

        port_info = port_repo.get_service_port_by_port(tenant.tenant_id, service.service_id, container_port)
        if not port_info:
            return 404, u"端口{0}不存在".format(container_port), None
        if port_info.is_inner_service:
            return 409, u"请关闭对内服务", None
        if port_info.is_outer_service:
            return 409, u"请关闭外部服务", None
        if service.create_status == "complete":
            # 删除数据中心端口
            region_api.delete_service_port(service.service_region, tenant.tenant_name, service.service_alias, container_port,
                                           tenant.enterprise_id)

        # 删除端口时禁用相关服务
        self.disable_service_when_delete_port(tenant, service, container_port)

        # 删除env
        env_var_service.delete_env_by_container_port(tenant, service, container_port)
        # 删除端口
        port_repo.delete_serivce_port_by_port(tenant.tenant_id, service.service_id, container_port)
        # 删除端口绑定的域名
        domain_repo.delete_service_domain_by_port(service.service_id, container_port)
        return 200, u"删除成功", port_info
示例#3
0
 def delete_by_port(component_id, port):
     http_rules = domain_repo.list_service_domain_by_port(
         component_id, port)
     http_rule_ids = [rule.http_rule_id for rule in http_rules]
     # delete rule extensions
     configuration_repo.delete_by_rule_ids(http_rule_ids)
     # delete http rules
     domain_repo.delete_service_domain_by_port(component_id, port)
     # delete tcp rules
     tcp_domain.delete_by_component_port(component_id, port)