perf: 添加生成 platform

pull/8873/head
ibuler 2022-08-22 15:23:28 +08:00
parent dd0b8e988c
commit f0c9c2b1ad
2 changed files with 6 additions and 2 deletions

View File

@ -12,7 +12,7 @@ sys.path.insert(0, APPS_DIR)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jumpserver.settings")
django.setup()
from resources.assets import AssetsGenerator, NodesGenerator
from resources.assets import AssetsGenerator, NodesGenerator, PlatformGenerator
from resources.users import UserGroupGenerator, UserGenerator
from resources.perms import AssetPermissionGenerator
from resources.terminal import CommandGenerator, SessionGenerator
@ -20,6 +20,7 @@ from resources.terminal import CommandGenerator, SessionGenerator
resource_generator_mapper = {
'asset': AssetsGenerator,
'platform': PlatformGenerator,
'node': NodesGenerator,
'user': UserGenerator,
'user_group': UserGroupGenerator,

View File

@ -30,9 +30,12 @@ class PlatformGenerator(FakeDataGenerator):
def do_generate(self, batch, batch_size):
platforms = []
for i in batch:
category = choice(self.categories)
tp = choice(self.category_type[category].choices)
data = {
'name': forgery_py.name.company_name(),
'category': ''
'category': choice(self.categories),
'type': tp
}
platforms.append(Platform(**data))
Platform.objects.bulk_create(platforms, ignore_conflicts=True)