Skip to content

Commit

Permalink
feat: MAC OS安装脚本适配 (closed TencentBlueKing#2084)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyyalt authored and ZhuoZhuoCrayon committed Mar 8, 2024
1 parent 3879585 commit c0ce29c
Show file tree
Hide file tree
Showing 15 changed files with 2,509 additions and 4 deletions.
3 changes: 3 additions & 0 deletions apps/backend/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class OS(object):
LINUX = "linux"
AIX = "aix"
SOLARIS = "solaris"
DARWIN = "darwin"


# 操作系统->系统账户映射表
Expand All @@ -31,6 +32,7 @@ class OS(object):
OS.LINUX: "root",
OS.AIX: "root",
OS.SOLARIS: "root",
OS.DARWIN: "root",
}

# 操作系统->后缀映射表
Expand All @@ -39,6 +41,7 @@ class OS(object):
OS.LINUX: "sh",
OS.AIX: "ksh",
OS.SOLARIS: "sh",
OS.DARWIN: "zsh",
}


Expand Down
13 changes: 9 additions & 4 deletions apps/node_man/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ def get_optional_items(cls) -> List[str]:
AUTH_CHOICES = tuple_choices(AUTH_TUPLE)
AuthType = choices_to_namedtuple(AUTH_CHOICES)

OS_TUPLE = ("LINUX", "WINDOWS", "AIX", "SOLARIS")
OS_TUPLE = ("LINUX", "WINDOWS", "AIX", "SOLARIS", "DARWIN")
OS_CHOICES = tuple_choices(OS_TUPLE)
OsType = choices_to_namedtuple(OS_CHOICES)
OS_CHN = {os_type: os_type if os_type == OsType.AIX else os_type.capitalize() for os_type in OS_TUPLE}
BK_OS_TYPE = {"LINUX": "1", "WINDOWS": "2", "AIX": "3", "SOLARIS": "5"}
BK_OS_TYPE = {"LINUX": "1", "WINDOWS": "2", "AIX": "3", "SOLARIS": "5", "DARWIN": "8"}
# 操作系统匹配关键词
OS_KEYWORDS = {
OsType.LINUX: ["linux", "ubuntu", "centos", "redhat", "suse", "debian", "fedora"],
Expand All @@ -132,13 +132,15 @@ def get_optional_items(cls) -> List[str]:
OsType.LINUX: settings.BACKEND_UNIX_ACCOUNT,
OsType.AIX: settings.BACKEND_UNIX_ACCOUNT,
OsType.SOLARIS: settings.BACKEND_UNIX_ACCOUNT,
OsType.DARWIN: settings.BACKEND_UNIX_ACCOUNT,
OsType.WINDOWS.lower(): settings.BACKEND_WINDOWS_ACCOUNT,
OsType.LINUX.lower(): settings.BACKEND_UNIX_ACCOUNT,
OsType.AIX.lower(): settings.BACKEND_UNIX_ACCOUNT,
OsType.SOLARIS.lower(): settings.BACKEND_UNIX_ACCOUNT,
OsType.DARWIN.lower(): settings.BACKEND_UNIX_ACCOUNT,
}

OS_TYPE = {"1": "LINUX", "2": "WINDOWS", "3": "AIX", "5": "SOLARIS"}
OS_TYPE = {"1": "LINUX", "2": "WINDOWS", "3": "AIX", "5": "SOLARIS", "8": "DARWIN"}

NODE_TUPLE = ("AGENT", "PROXY", "PAGENT")
NODE_CHOICES = tuple_choices(NODE_TUPLE)
Expand Down Expand Up @@ -488,7 +490,7 @@ def _get_member__alias_map(cls) -> Dict[Enum, str]:
CONFIG_FILE_FORMAT_TUPLE = ("json", "yaml", "", None)
CONFIG_FILE_FORMAT_CHOICES = tuple_choices(CONFIG_FILE_FORMAT_TUPLE)

PLUGIN_OS_TUPLE = ("windows", "linux", "aix", "solaris")
PLUGIN_OS_TUPLE = ("windows", "linux", "aix", "solaris", "darwin")
PLUGIN_OS_CHOICES = tuple_choices(PLUGIN_OS_TUPLE)
PluginOsType = choices_to_namedtuple(PLUGIN_OS_CHOICES)

Expand All @@ -500,6 +502,7 @@ def _get_member__alias_map(cls) -> Dict[Enum, str]:
OsType.WINDOWS: CpuType.x86_64,
OsType.AIX: CpuType.powerpc,
OsType.SOLARIS: CpuType.sparc,
OsType.DARWIN: CpuType.x86_64,
}
CMDB_CPU_MAP = {"x86": CpuType.x86, "arm": CpuType.aarch64}

Expand Down Expand Up @@ -686,6 +689,7 @@ class SetupScriptFileName(Enum):
SETUP_PROXY_SH = "setup_proxy.sh"
SETUP_AGENT_SH = "setup_agent.sh"
SETUP_AGENT_KSH = "setup_agent.ksh"
SETUP_AGENT_ZSH = "setup_agent.zsh"
SETUP_AGENT_BAT = "setup_agent.bat"
SETUP_PAGENT_PY = "setup_pagent.py"
GSECTL_BAT = "gsectl.bat"
Expand All @@ -697,6 +701,7 @@ class SetupScriptFileName(Enum):
OsType.WINDOWS: SetupScriptFileName.SETUP_AGENT_BAT.value,
OsType.AIX: SetupScriptFileName.SETUP_AGENT_KSH.value,
OsType.SOLARIS: SetupScriptFileName.SETUP_AGENT_SOLARIS_SH.value,
OsType.DARWIN: SetupScriptFileName.SETUP_AGENT_ZSH.value,
}


Expand Down
113 changes: 113 additions & 0 deletions apps/node_man/migrations/0081_auto_20240307_1656.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Generated by Django 3.2.4 on 2024-03-07 08:56

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("node_man", "0080_auto_20231122_1552"),
]

operations = [
migrations.AlterField(
model_name="gseconfigenv",
name="os",
field=models.CharField(
choices=[
("windows", "windows"),
("linux", "linux"),
("aix", "aix"),
("solaris", "solaris"),
("darwin", "darwin"),
],
db_index=True,
default="linux",
max_length=32,
verbose_name="系统类型",
),
),
migrations.AlterField(
model_name="gseconfigtemplate",
name="os",
field=models.CharField(
choices=[
("windows", "windows"),
("linux", "linux"),
("aix", "aix"),
("solaris", "solaris"),
("darwin", "darwin"),
],
db_index=True,
default="linux",
max_length=32,
verbose_name="系统类型",
),
),
migrations.AlterField(
model_name="host",
name="os_type",
field=models.CharField(
choices=[
("LINUX", "LINUX"),
("WINDOWS", "WINDOWS"),
("AIX", "AIX"),
("SOLARIS", "SOLARIS"),
("DARWIN", "DARWIN"),
],
db_index=True,
default="LINUX",
max_length=16,
verbose_name="操作系统",
),
),
migrations.AlterField(
model_name="packages",
name="os",
field=models.CharField(
choices=[
("windows", "windows"),
("linux", "linux"),
("aix", "aix"),
("solaris", "solaris"),
("darwin", "darwin"),
],
db_index=True,
default="linux",
max_length=32,
verbose_name="系统类型",
),
),
migrations.AlterField(
model_name="pluginconfigtemplate",
name="os",
field=models.CharField(
choices=[
("windows", "windows"),
("linux", "linux"),
("aix", "aix"),
("solaris", "solaris"),
("darwin", "darwin"),
],
default="linux",
max_length=16,
verbose_name="操作系统",
),
),
migrations.AlterField(
model_name="proccontrol",
name="os",
field=models.CharField(
choices=[
("windows", "windows"),
("linux", "linux"),
("aix", "aix"),
("solaris", "solaris"),
("darwin", "darwin"),
],
default="linux",
max_length=32,
verbose_name="系统类型",
),
),
]
1 change: 1 addition & 0 deletions apps/node_man/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ def get_agent_config(self, os_type: str) -> Dict[str, Any]:
if os_type in [
constants.OsType.AIX.lower(),
constants.OsType.SOLARIS.lower(),
constants.OsType.DARWIN.lower(),
]:
os_type = constants.OsType.LINUX.lower()
return self.agent_config[os_type]
Expand Down
Loading

0 comments on commit c0ce29c

Please sign in to comment.