feat: 支持DB2数据库

pull/11767/head
halo 2023-10-08 20:03:15 +08:00 committed by 老广
parent e71e8cd595
commit b42014d58e
4 changed files with 45 additions and 1 deletions

View File

@ -7,6 +7,7 @@ class DatabaseTypes(BaseType):
POSTGRESQL = 'postgresql', 'PostgreSQL'
ORACLE = 'oracle', 'Oracle'
SQLSERVER = 'sqlserver', 'SQLServer'
DB2 = 'db2', 'DB2'
CLICKHOUSE = 'clickhouse', 'ClickHouse'
MONGODB = 'mongodb', 'MongoDB'
REDIS = 'redis', 'Redis'
@ -45,6 +46,15 @@ class DatabaseTypes(BaseType):
'change_secret_enabled': False,
'push_account_enabled': False,
},
cls.DB2: {
'ansible_enabled': False,
'ping_enabled': False,
'gather_facts_enabled': False,
'gather_accounts_enabled': False,
'verify_account_enabled': False,
'change_secret_enabled': False,
'push_account_enabled': False,
},
cls.CLICKHOUSE: {
'ansible_enabled': False,
'ping_enabled': False,
@ -73,6 +83,7 @@ class DatabaseTypes(BaseType):
cls.POSTGRESQL: [{'name': 'PostgreSQL'}],
cls.ORACLE: [{'name': 'Oracle'}],
cls.SQLSERVER: [{'name': 'SQLServer'}],
cls.DB2: [{'name': 'DB2'}],
cls.CLICKHOUSE: [{'name': 'ClickHouse'}],
cls.MONGODB: [{'name': 'MongoDB'}],
cls.REDIS: [

View File

@ -22,6 +22,7 @@ class Protocol(ChoicesMixin, models.TextChoices):
oracle = 'oracle', 'Oracle'
postgresql = 'postgresql', 'PostgreSQL'
sqlserver = 'sqlserver', 'SQLServer'
db2 = 'db2', 'DB2'
clickhouse = 'clickhouse', 'ClickHouse'
redis = 'redis', 'Redis'
mongodb = 'mongodb', 'MongoDB'
@ -170,6 +171,12 @@ class Protocol(ChoicesMixin, models.TextChoices):
}
}
},
cls.db2: {
'port': 5000,
'required': True,
'secret_types': ['password'],
'xpack': True,
},
cls.clickhouse: {
'port': 9000,
'required': True,

View File

@ -0,0 +1,26 @@
# Generated by Django 4.1.10 on 2023-10-07 06:37
from django.db import migrations
def add_db2_platform(apps, schema_editor):
platform_cls = apps.get_model('assets', 'Platform')
automation_cls = apps.get_model('assets', 'PlatformAutomation')
platform = platform_cls.objects.create(
name='DB2', internal=True, category='database', type='db2',
domain_enabled=True, su_enabled=False, comment='DB2',
created_by='System', updated_by='System',
)
platform.protocols.create(name='db2', port=5000, primary=True, setting={})
automation_cls.objects.create(ansible_enabled=False, platform=platform)
class Migration(migrations.Migration):
dependencies = [
('assets', '0123_device_automation_ansible_enabled'),
]
operations = [
migrations.RunPython(add_db2_platform)
]

View File

@ -144,7 +144,7 @@ class ConnectMethodUtil:
'support': [
Protocol.mysql, Protocol.postgresql,
Protocol.oracle, Protocol.sqlserver,
Protocol.mariadb
Protocol.mariadb, Protocol.db2
],
'match': 'm2m'
},