Skip to content

Commit

Permalink
fix: third component stop start (#1463)
Browse files Browse the repository at this point in the history
* fix: third component stop start

Signed-off-by: 逆流而上 <1666888816@qq.com>

* fix: third component stop start

Signed-off-by: 逆流而上 <1666888816@qq.com>

---------

Signed-off-by: 逆流而上 <1666888816@qq.com>
  • Loading branch information
DokiDoki1103 authored May 13, 2024
1 parent 8f24f6c commit 477f301
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 140 deletions.
1 change: 0 additions & 1 deletion console/models/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ class Meta:
app_id = models.IntegerField(help_text="application ID", default=-1)



class RoleInfo(BaseModel):
class Meta:
db_table = 'role_info'
Expand Down
5 changes: 2 additions & 3 deletions console/services/app_actions/app_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,9 @@ def batch_action(self, region_name, tenant, user, action, service_ids, move_grou
fail_service_name = []
for service in services:
try:
# 第三方组件不具备启动,停止,重启操作
if action == "start" and service.service_source != "third_party":
if action == "start":
self.start(tenant, service, user, oauth_instance=oauth_instance)
elif action == "stop" and service.service_source != "third_party":
elif action == "stop":
self.stop(tenant, service, user)
elif action == "restart" and service.service_source != "third_party":
self.restart(tenant, service, user, oauth_instance=oauth_instance)
Expand Down
3 changes: 2 additions & 1 deletion console/services/perm_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ def __unpack_to_build_perms_list(self, perms_model, role_id, perms_name_code_kv,
perm_key, perms_value = perm_items
if perms_value:
role_perms_list.append(
RolePerms(role_id=role_id, perm_code=perms_name_code_kv["_".join([kind_name, perm_key])], app_id=app_id))
RolePerms(
role_id=role_id, perm_code=perms_name_code_kv["_".join([kind_name, perm_key])], app_id=app_id))
return role_perms_list

# 角色的权限树降维
Expand Down
117 changes: 72 additions & 45 deletions console/urls.py

Large diffs are not rendered by default.

137 changes: 74 additions & 63 deletions console/utils/perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from console.enum.enterprise_enum import EnterpriseRolesEnum
from www.models.main import ServiceGroup

"""
- enterprise 100
sub1 -- 101
Expand Down Expand Up @@ -83,12 +82,7 @@
]
},
"app_release": {
"perms": [
["describe", "查看", 310004],
["share", "发布", 310001],
["export", "导出", 310002],
["delete", "删除", 310003]
]
"perms": [["describe", "查看", 310004], ["share", "发布", 310001], ["export", "导出", 310002], ["delete", "删除", 310003]]
},
"app_gateway_manage": {
"perms": [],
Expand Down Expand Up @@ -123,12 +117,8 @@
},
},
"app_upgrade": {
"perms": [
["app_model_list", "应用模型列表", 330001],
["upgrade_record", "升级记录", 330002],
["upgrade", "升级", 330003],
["rollback", "回滚", 330004]
]
"perms": [["app_model_list", "应用模型列表", 330001], ["upgrade_record", "升级记录", 330002], ["upgrade", "升级", 330003],
["rollback", "回滚", 330004]]
},
"app_resources": {
"perms": [
Expand Down Expand Up @@ -157,7 +147,6 @@
]
}
}

'''
注意:以下注释部分是企业版功能,新增权限的时候需要避免冲突!
'''
Expand Down Expand Up @@ -242,12 +231,8 @@
},
},
"app_upgrade": {
"perms": [
["app_model_list", "应用模型列表", 330001],
["upgrade_record", "升级记录", 330002],
["upgrade", "升级", 330003],
["rollback", "回滚", 330004]
]
"perms": [["app_model_list", "应用模型列表", 330001], ["upgrade_record", "升级记录", 330002], ["upgrade", "升级", 330003],
["rollback", "回滚", 330004]]
},
"app_resources": {
"perms": [
Expand Down Expand Up @@ -332,10 +317,7 @@
]
},
"team_region": {
"perms": [
["describe", "查看", 620001],
["install", "开通", 620002],
["uninstall", "卸载", 620003]]
"perms": [["describe", "查看", 620001], ["install", "开通", 620002], ["uninstall", "卸载", 620003]]
},
"team_role": {
"perms": [
Expand Down Expand Up @@ -377,48 +359,77 @@

DEFAULT_TEAM_ROLE_PERMS = {
"管理员": [
200001, 200002,
300001, 300002, 300003, 300004, 300005, 300006, 300007, 300008, 300009, 300010, 300011, 300012, 300013, 300014,
300015, 300016, 300017, 300018, 300019, 300020, 300021, 300022, 300023, 300024, 300025, 300026,
310001, 310002, 310003,
320001,
321001, 321002, 321003, 321004,
322001, 322002, 322003, 322004,
323001, 323002, 323003, 323004,
330001, 330002, 330003, 330004,
340001, 340002, 340003, 340004,
350001, 350002, 350003, 350004, 350005, 350006,
360001, 360002, 360003, 360004,
400001,
410001, 410002, 410003, 410004,
420001, 420002, 420003, 420004,
430001, 430002, 430003, 430004,
500001, 500002, 500003, 500004,
600001,
610001, 610002, 610003, 610004,
620001, 620002, 620003, 620004,
630001, 630002, 630003, 630004,
640001, 640002, 640003, 640004,
700001, 700002, 700003, 700004,
800001
200001, 200002, 300001, 300002, 300003, 300004, 300005, 300006, 300007, 300008, 300009, 300010, 300011, 300012, 300013,
300014, 300015, 300016, 300017, 300018, 300019, 300020, 300021, 300022, 300023, 300024, 300025, 300026, 310001, 310002,
310003, 320001, 321001, 321002, 321003, 321004, 322001, 322002, 322003, 322004, 323001, 323002, 323003, 323004, 330001,
330002, 330003, 330004, 340001, 340002, 340003, 340004, 350001, 350002, 350003, 350004, 350005, 350006, 360001, 360002,
360003, 360004, 400001, 410001, 410002, 410003, 410004, 420001, 420002, 420003, 420004, 430001, 430002, 430003, 430004,
500001, 500002, 500003, 500004, 600001, 610001, 610002, 610003, 610004, 620001, 620002, 620003, 620004, 630001, 630002,
630003, 630004, 640001, 640002, 640003, 640004, 700001, 700002, 700003, 700004, 800001
],

"开发者": [
300001, 300002, 300003, 300004, 300005, 300006, 300007, 300008, 300009, 300010, 300011, 300012, 300013, 300014,
300015, 300016, 300017, 300018, 300019, 300020, 300021, 300022, 300023, 300024, 300025, 300026,
310001, 310002, 310003,
300001,
300002,
300003,
300004,
300005,
300006,
300007,
300008,
300009,
300010,
300011,
300012,
300013,
300014,
300015,
300016,
300017,
300018,
300019,
300020,
300021,
300022,
300023,
300024,
300025,
300026,
310001,
310002,
310003,
320001,
321001, 321002, 321003, 321004,
322001, 322002, 322003, 322004,
323001, 323002, 323003, 323004,
330001, 330002, 330003, 330004,
340001, 340002, 340003, 340004,
350001, 350002, 350003, 350004, 350005, 350006,
360001, 360002, 360003, 360004,
],
"观察者": [

321001,
321002,
321003,
321004,
322001,
322002,
322003,
322004,
323001,
323002,
323003,
323004,
330001,
330002,
330003,
330004,
340001,
340002,
340003,
340004,
350001,
350002,
350003,
350004,
350005,
350006,
360001,
360002,
360003,
360004,
],
"观察者": [],
}


Expand Down Expand Up @@ -487,7 +498,7 @@ def get_perms_structure(tenant_id):
removed_value = team.get("team_app_manage")
app_perms = dict()
for app_id in app_ids:
key = "app_"+str(app_id)
key = "app_" + str(app_id)
app_perms[key] = removed_value
team = get_structure(team, "team")
enterprise = get_structure(copy.deepcopy(ENTERPRISE), "enterprise")
Expand Down
14 changes: 14 additions & 0 deletions console/views/app_config/app_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,17 @@ def post(self, request, *args, **kwargs):
return Response(general_message(code, "add probe error", msg))
result = general_message(200, "success", "添加成功", bean=(probe.to_dict() if probe else probe))
return Response(result, status=result["code"])

@never_cache
def put(self, request, *args, **kwargs):
"""
修改组件探针,包括启用停用 mode参数必填
---
serializer: ProbeSerilizer
"""
data = request.data

probe = probe_service.update_service_probea(
tenant=self.tenant, service=self.service, data=data, user_name=self.user.nick_name)
result = general_message(200, "success", "修改成功", bean=(probe.to_dict() if probe else probe))
return Response(result, status=result["code"])
12 changes: 0 additions & 12 deletions console/views/app_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,18 +414,6 @@ def post(self, request, *args, **kwargs):
move_group_id = request.data.get("move_group_id", None)
if action not in ("stop", "start", "restart", "move", "upgrade", "deploy"):
return Response(general_message(400, "param error", "操作类型错误"), status=400)
if action == "stop":
self.has_perms([400008])
if action == "start":
self.has_perms([400006])
if action == "restart":
self.has_perms([400007])
if action == "move":
self.has_perms([400003])
if action == "upgrade":
self.has_perms([400009])
if action == "deploy":
self.has_perms([400010])
service_id_list = service_ids.split(",")
code, msg = app_manage_service.batch_action(self.region_name, self.tenant, self.user, action, service_id_list,
move_group_id, self.oauth_instance)
Expand Down
15 changes: 0 additions & 15 deletions console/views/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,6 @@ def post(self, request, *args, **kwargs):
service_ids = [service.service_id for service in services]
if action not in ("stop", "start", "upgrade", "deploy"):
return Response(general_message(400, "param error", "操作类型错误"), status=400)
# 去除掉第三方组件
for service_id in service_ids:
service_obj = service_repo.get_service_by_service_id(service_id)
if service_obj and service_obj.service_source == "third_party":
service_ids.remove(service_id)

if action == "stop":
self.has_perms([300006, 400008])
if action == "start":
self.has_perms([300005, 400006])
if action == "upgrade":
self.has_perms([300007, 400009])
if action == "deploy":
self.has_perms([300008, 400010])
# 批量操作
app_manage_service.batch_operations(self.tenant, self.region_name, self.user, action, service_ids, self.oauth_instance)
result = general_message(200, "success", "操作成功")
return Response(result, status=result["code"])
Expand Down

0 comments on commit 477f301

Please sign in to comment.