Skip to content

Commit

Permalink
feat(backend): 增加平台管理权限 #8774
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud authored and zhangzhw8 committed Dec 23, 2024
1 parent 1397b04 commit c511191
Show file tree
Hide file tree
Showing 5 changed files with 533 additions and 47 deletions.
2 changes: 2 additions & 0 deletions dbm-ui/backend/configuration/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ def get_profile(self, request, *args, **kwargs):
client = Permission()
resource_manage = client.is_allowed(action=ActionEnum.RESOURCE_MANAGE, resources=[])
global_manage = client.is_allowed(action=ActionEnum.GLOBAL_MANAGE, resources=[])
platform_manage = client.is_allowed(action=ActionEnum.PLATFORM_MANAGE, resources=[])
return Response(
{
"resource_manage": resource_manage,
"global_manage": global_manage,
"platform_manage": platform_manage,
"username": username,
"profile": list(Profile.objects.filter(username=username).values("label", "values")),
"is_superuser": request.user.is_superuser,
Expand Down
23 changes: 14 additions & 9 deletions dbm-ui/backend/db_meta/models/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ def _get_apply_params_detail(
apply_params = {
"group_mark": group_mark,
"bk_cloud_id": bk_cloud_id,
"device_class": self.device_class,
"spec": {
"cpu": self.cpu,
# 内存GB-->MB,只偏移左边
"ram": {
"min": max(int(self.mem["min"] * 1024 - spec_offset["mem"]), 0),
"max": int(self.mem["max"] * 1024),
},
},
"storage_spec": [
{
"mount_point": storage_spec["mount_point"],
Expand All @@ -112,6 +103,20 @@ def _get_apply_params_detail(
"count": count,
"affinity": affinity,
}
# 对于机型和规格,优先以机型为准,机型不存在则用规格申请
if self.device_class:
apply_params.update(device_class=self.device_class)
else:
spec = {
"cpu": self.cpu,
# 内存GB-->MB,只偏移左边
"ram": {
"min": max(int(self.mem["min"] * 1024 - spec_offset["mem"]), 0),
"max": int(self.mem["max"] * 1024),
},
}
apply_params.update(spec=spec)

if location_spec:
# 将bk_sub_zone_id转成str,本身为空也不影响
location_spec["sub_zone_ids"] = list(map(str, location_spec.get("sub_zone_ids", [])))
Expand Down
36 changes: 36 additions & 0 deletions dbm-ui/backend/iam_app/dataclass/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,42 @@ class ActionEnum:
common_labels=[CommonActionLabel.BIZ_MAINTAIN],
)

PLATFORM_MANAGE = ActionMeta(
id="platform_manage",
name=_("平台管理"),
name_en="platform_manage",
type="manage",
related_actions=[],
related_resource_types=[],
group=_("平台管理"),
subgroup="",
common_labels=[],
)

PLATFORM_TICKET_VIEW = ActionMeta(
id="platform_ticket_view",
name=_("全局单据查看"),
name_en="platform_ticket_view",
type="manage",
related_actions=[],
related_resource_types=[],
group=_("平台管理"),
subgroup="",
common_labels=[],
)

PLATFORM_TASKFLOW_VIEW = ActionMeta(
id="platform_taskflow_view",
name=_("全局任务查看"),
name_en="platform_taskflow_view",
type="manage",
related_actions=[],
related_resource_types=[],
group=_("平台管理"),
subgroup="",
common_labels=[],
)

DBCONFIG_VIEW = ActionMeta(
id="dbconfig_view",
name=_("数据库配置查看"),
Expand Down
Loading

0 comments on commit c511191

Please sign in to comment.