def unbind_domain(self, tenant, service, container_port, domain_name, is_tcp=False): if not is_tcp: servicerDomain = domain_repo.get_domain_by_name_and_port(service.service_id, container_port, domain_name) if not servicerDomain: return 404, u"域名不存在" for servicer_domain in servicerDomain: data = dict() data["service_id"] = servicer_domain.service_id data["domain"] = servicer_domain.domain_name data["container_port"] = int(container_port) data["http_rule_id"] = servicer_domain.http_rule_id try: region_api.delete_http_domain(service.service_region, tenant.tenant_name, data) servicer_domain.delete() return 200, u"success" except region_api.CallApiError as e: if e.status != 404: raise e else: servicer_tcp_domain = tcp_domain.get_service_tcp_domain_by_service_id_and_port( service.service_id, container_port, domain_name) if not servicer_tcp_domain: return 404, u"域名不存在" data = dict() data["tcp_rule_id"] = servicer_tcp_domain.tcp_rule_id try: region_api.unbindTcpDomain(service.service_region, tenant.tenant_name, data) servicer_tcp_domain.delete() return 200, u"success" except region_api.CallApiError as e: if e.status != 404: raise e
def unbind_domain(self, tenant, service, container_port, domain_name): servicerDomain = domain_repo.get_domain_by_name_and_port(service.service_id, container_port, domain_name) if not servicerDomain: return 404, u"域名不存在" data = {} data["service_id"] = servicerDomain.service_id data["domain"] = servicerDomain.domain_name data["pool_name"] = tenant.tenant_name + "@" + service.service_alias + ".Pool" data["container_port"] = int(container_port) data["enterprise_id"] = tenant.enterprise_id try: region_api.unbindDomain(service.service_region, tenant.tenant_name, service.service_alias, data) except region_api.CallApiError as e: if e.status != 404: raise e servicerDomain.delete() return 200, u"success"