diff --git a/console/services/app_actions/app_manage.py b/console/services/app_actions/app_manage.py index 05aaabc6ca..01a8eeec67 100644 --- a/console/services/app_actions/app_manage.py +++ b/console/services/app_actions/app_manage.py @@ -328,6 +328,7 @@ def deploy(self, tenant, service, user, oauth_instance=None, service_copy_path=N else: logger.warning("service_source is not exist for service {0}".format(service.service_id)) try: + body['operator'] = user.nick_name re = region_api.build_service(service.service_region, tenant.tenant_name, service.service_alias, body) if re and re.get("bean") and re.get("bean").get("status") != "success": logger.error("deploy component failure {}".format(re)) @@ -600,6 +601,7 @@ def batch_operations(self, tenant, region_name, user, action, service_ids, oauth if code != 200: raise AbortRequest(415, "failed to get component", "组件信息获取失败") # 获取数据中心信息 + data['operator'] = user.nick_name try: _, body = region_api.batch_operation_service(region_name, tenant.tenant_name, data) events = body["bean"]["batch_result"] diff --git a/console/services/group_service.py b/console/services/group_service.py index eccb4a0367..737dadc86b 100644 --- a/console/services/group_service.py +++ b/console/services/group_service.py @@ -415,7 +415,7 @@ def batch_delete_app_services(self, user, tenant_id, region_name, app_id): if service.create_status == "complete": service_dict["service_id"] = service.service_id stop_infos_list.append(service_dict) - body = {"operation": "stop", "stop_infos": stop_infos_list} + body = {"operation": "stop", "stop_infos": stop_infos_list,"operator":user.nick_name} try: region_api.batch_operation_service(region_name, tenant.tenant_name, body) except region_api.CallApiError as e: diff --git a/console/services/k8s_attribute.py b/console/services/k8s_attribute.py index 58ce42d2b9..4db3c13fc5 100644 --- a/console/services/k8s_attribute.py +++ b/console/services/k8s_attribute.py @@ -49,9 +49,10 @@ def update_k8s_attribute(self, tenant, component, region_name, attribute): region_api.update_component_k8s_attribute(tenant.tenant_name, region_name, component.service_alias, attribute) @transaction.atomic - def delete_k8s_attribute(self, tenant, component, region_name, name): + def delete_k8s_attribute(self, tenant, component, region_name, name, operator): k8s_attribute_repo.delete(component.service_id, name) - region_api.delete_component_k8s_attribute(tenant.tenant_name, region_name, component.service_alias, {"name": name}) + region_api.delete_component_k8s_attribute(tenant.tenant_name, region_name, component.service_alias, + {"name": name, "operator": operator}) k8s_attribute_service = ComponentK8sAttributeService() diff --git a/console/services/market_app/app_restore.py b/console/services/market_app/app_restore.py index 6c52cc04c7..b87bfdcf69 100644 --- a/console/services/market_app/app_restore.py +++ b/console/services/market_app/app_restore.py @@ -72,7 +72,7 @@ def __init__(self, tenant, region: RegionConfig, user, app: ServiceGroup, compon self.original_app = OriginalApp(tenant, region, app, component_group.ID, self.support_labels) self.snapshot = self._get_snapshot() self.new_app = self._create_new_app() - super(AppRestore, self).__init__(self.original_app, self.new_app) + super(AppRestore, self).__init__(self.original_app, self.new_app,self.user) def restore(self): # Sync the new application to the data center first diff --git a/console/services/market_app/app_upgrade.py b/console/services/market_app/app_upgrade.py index 48205bdafc..98077fb5ac 100644 --- a/console/services/market_app/app_upgrade.py +++ b/console/services/market_app/app_upgrade.py @@ -115,7 +115,7 @@ def __init__(self, self.property_changes.ensure_dep_changes(self.new_app, self.original_app) self.app_property_changes = self._get_app_property_changes() - super(AppUpgrade, self).__init__(self.original_app, self.new_app) + super(AppUpgrade, self).__init__(self.original_app, self.new_app,self.user) def preinstall(self): self.pre_install_plugins() @@ -264,6 +264,7 @@ def _sync_plugins(self, plugins: [Plugin]): region_api.sync_plugins(self.tenant_name, self.region_name, body) def _install_predeploy(self): + try: helm_chart_parameter = dict() helm_chart_parameter["app_name"] = self.app_template["group_name"] diff --git a/console/services/market_app/market_app.py b/console/services/market_app/market_app.py index 7c5f607452..cc97db9972 100644 --- a/console/services/market_app/market_app.py +++ b/console/services/market_app/market_app.py @@ -33,10 +33,12 @@ class MarketApp(object): - def __init__(self, original_app: OriginalApp, new_app: NewApp): + def __init__(self, original_app: OriginalApp, new_app: NewApp,user): self.original_app = original_app self.new_app = new_app + self.user = user + self.tenant_name = self.new_app.tenant.tenant_name self.region_name = self.new_app.region_name @@ -73,6 +75,7 @@ def predeploy(self, helm_chart_parameter): builds = self._generate_builds("export_helm_chart") res = [] body = { + "operator": self.user.nick_name, "operation": "export", "build_infos": builds, "helm_chart": { @@ -90,6 +93,7 @@ def predeploy(self, helm_chart_parameter): return res def deploy(self): + builds = self._generate_builds() upgrades = self._generate_upgrades() @@ -98,6 +102,7 @@ def deploy(self): res = [] if builds: body = { + "operator": self.user.nick_name, "operation": "build", "build_infos": builds, } @@ -106,6 +111,7 @@ def deploy(self): if upgrades: body = { + "operator": self.user.nick_name, "operation": "upgrade", "upgrade_infos": upgrades, } diff --git a/console/services/market_app_service.py b/console/services/market_app_service.py index 16063ed126..b956e0d379 100644 --- a/console/services/market_app_service.py +++ b/console/services/market_app_service.py @@ -715,6 +715,7 @@ def __deploy_services(self, tenant, user, service_list, app_templates): body = dict() code, data = app_manage_service.deploy_services_info( body, service_list, tenant, user, oauth_instance=None, template_apps=app_templates, upgrade=False) + data['operator'] = user.nick_name if code == 200: # 获取数据中心信息 one_service = service_list[0] diff --git a/console/views/k8s_attribute.py b/console/views/k8s_attribute.py index 5c003370fb..ded4edf8a7 100644 --- a/console/views/k8s_attribute.py +++ b/console/views/k8s_attribute.py @@ -17,11 +17,12 @@ def put(self, request, name, *args, **kwargs): attribute = request.data.get("attribute", {}) if name != attribute.get("name", ""): raise AbortRequest(400, "参数错误") + attribute['operator'] = self.user.nick_name k8s_attribute_service.update_k8s_attribute(self.tenant, self.service, self.region_name, attribute) return Response(general_message(200, "success", "修改成功")) def delete(self, request, name, *args, **kwargs): - k8s_attribute_service.delete_k8s_attribute(self.tenant, self.service, self.region_name, name) + k8s_attribute_service.delete_k8s_attribute(self.tenant, self.service, self.region_name, name,self.user.nick_name) return Response(general_message(200, "success", "删除成功")) @@ -32,5 +33,6 @@ def get(self, request, *args, **kwargs): def post(self, request, *args, **kwargs): attribute = request.data.get("attribute", {}) + attribute['operator'] = self.user.nick_name k8s_attribute_service.create_k8s_attribute(self.tenant, self.service, self.region_name, attribute) return Response(general_message(200, "success", "创建成功"))