def delete(self, request, *args, **kwargs): """ 删除插件 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: plugin_id description: 插件ID required: true type: string paramType: path """ try: code, msg = plugin_service.delete_plugin(self.response_region, self.team, self.plugin.plugin_id) if code != 200: return Response(general_message(code, "delete plugin fail", msg), status=code) else: result = general_message(code, "success", msg) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=result["code"])
def delete(self, request, *args, **kwargs): """ 删除插件 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: plugin_id description: 插件ID required: true type: string paramType: path """ plugin_service.delete_plugin(self.response_region, self.team, self.plugin.plugin_id) result = general_message(200, "success", "删除成功") return Response(result, status=result["code"])
def delete_tenant_on_region(self, enterprise_id, team_name, region_name, user): tenant = team_repo.get_team_by_team_name_and_eid( enterprise_id, team_name) tenant_region = region_repo.get_team_region_by_tenant_and_region( tenant.tenant_id, region_name) if not tenant_region: raise ServiceHandleException( msg="team not open cluster, not need close", msg_show="该团队未开通此集群,无需关闭") # start delete region_config = region_repo.get_enterprise_region_by_region_name( enterprise_id, region_name) ignore_cluster_resource = False if not region_config: # cluster spec info not found, cluster side resources are no longer operated on ignore_cluster_resource = True else: info = region_api.check_region_api(enterprise_id, region_name) # check cluster api health if not info or info["rbd_version"] == "": ignore_cluster_resource = True services = service_repo.get_services_by_team_and_region( tenant.tenant_id, region_name) if not ignore_cluster_resource and services and len(services) > 0: # check component status service_ids = [service.service_id for service in services] status_list = base_service.status_multi_service( region=region_name, tenant_name=tenant.tenant_name, service_ids=service_ids, enterprise_id=tenant.enterprise_id) status_list = filter(lambda x: x not in ["closed", "undeploy"], map(lambda x: x["status"], status_list)) if len(status_list) > 0: raise ServiceHandleException( msg= "There are running components under the current application", msg_show="团队在集群{0}下有运行态的组件,请关闭组件后再卸载当前集群".format( region_config.region_alias)) # Components are the key to resource utilization, # and removing the cluster only ensures that the component's resources are freed up. from console.services.app_actions import app_manage_service from console.services.plugin import plugin_service not_delete_from_cluster = False for service in services: not_delete_from_cluster = app_manage_service.really_delete_service( tenant, service, user, ignore_cluster_resource, not_delete_from_cluster) plugins = plugin_repo.get_tenant_plugins(tenant.tenant_id, region_name) if plugins: for plugin in plugins: plugin_service.delete_plugin(region_name, tenant, plugin.plugin_id, ignore_cluster_resource) # delete tenant if not ignore_cluster_resource: try: region_api.delete_tenant(region_name, team_name) except region_api.CallApiError as e: if e.status != 404: logger.error("delete tenant failure {}".format(e.body)) raise ServiceHandleException( msg="delete tenant from cluster failure", msg_show="从集群删除租户失败") except Exception as e: logger.exception(e) raise ServiceHandleException( msg="delete tenant from cluster failure", msg_show="从集群删除租户失败") tenant_region.delete()