mirror of https://github.com/jumpserver/jumpserver
perf: 添加生成 platform
parent
dd0b8e988c
commit
f0c9c2b1ad
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue