mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 23:17:32 -02:30
finish implementation of data generator presets, fix flake8
This commit is contained in:
3
Makefile
3
Makefile
@@ -507,11 +507,12 @@ test_tox:
|
|||||||
test_jenkins : test_coverage
|
test_jenkins : test_coverage
|
||||||
|
|
||||||
# Make fake data
|
# Make fake data
|
||||||
|
DATA_GEN_PRESET = ""
|
||||||
bulk_data:
|
bulk_data:
|
||||||
@if [ "$(VENV_BASE)" ]; then \
|
@if [ "$(VENV_BASE)" ]; then \
|
||||||
. $(VENV_BASE)/tower/bin/activate; \
|
. $(VENV_BASE)/tower/bin/activate; \
|
||||||
fi; \
|
fi; \
|
||||||
$(PYTHON) tools/data_generators/rbac_dummy_data_generator.py
|
$(PYTHON) tools/data_generators/rbac_dummy_data_generator.py --preset=$(DATA_GEN_PRESET)
|
||||||
|
|
||||||
# l10n TASKS
|
# l10n TASKS
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
preset = 'medium'
|
|
||||||
|
|
||||||
presets_filename = os.path.abspath(os.path.join(
|
|
||||||
os.path.dirname(os.path.abspath(__file__)),
|
|
||||||
'presets.tsv'))
|
|
||||||
|
|
||||||
with open(presets_filename) as f:
|
|
||||||
text = f.read()
|
|
||||||
|
|
||||||
split_lines = [line.split('\t') for line in text.split('\n')]
|
|
||||||
keys = split_lines[0][1:]
|
|
||||||
|
|
||||||
try:
|
|
||||||
col = keys.index(preset)
|
|
||||||
except ValueError:
|
|
||||||
raise Exception('Preset %s data set not found, options are %s' % (preset, keys))
|
|
||||||
|
|
||||||
options = {cols[0]: cols[col+1] for cols in split_lines}
|
|
||||||
|
|
||||||
print ' text '
|
|
||||||
print text
|
|
||||||
|
|
||||||
print ' options '
|
|
||||||
print options
|
|
||||||
@@ -84,7 +84,22 @@ options = vars(options)
|
|||||||
|
|
||||||
|
|
||||||
if options['preset']:
|
if options['preset']:
|
||||||
pass
|
# Read the numbers of resources from presets file, if provided
|
||||||
|
presets_filename = os.path.abspath(os.path.join(
|
||||||
|
os.path.dirname(os.path.abspath(__file__)), 'presets.tsv'))
|
||||||
|
|
||||||
|
with open(presets_filename) as f:
|
||||||
|
text = f.read()
|
||||||
|
|
||||||
|
split_lines = [line.split('\t') for line in text.split('\n')]
|
||||||
|
keys = split_lines[0][1:]
|
||||||
|
|
||||||
|
try:
|
||||||
|
col = keys.index(options['preset'])
|
||||||
|
except ValueError:
|
||||||
|
raise Exception('Preset "%s" dataset not found, options are %s' % (options['preset'], keys))
|
||||||
|
|
||||||
|
options.update({cols[0]: cols[col + 1] for cols in split_lines})
|
||||||
|
|
||||||
|
|
||||||
n_organizations = int(options['organizations'])
|
n_organizations = int(options['organizations'])
|
||||||
@@ -163,6 +178,7 @@ class Rollback(Exception):
|
|||||||
def mock_save(self, *args, **kwargs):
|
def mock_save(self, *args, **kwargs):
|
||||||
return super(PrimordialModel, self).save(*args, **kwargs)
|
return super(PrimordialModel, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
PrimordialModel.save = mock_save
|
PrimordialModel.save = mock_save
|
||||||
|
|
||||||
|
|
||||||
@@ -334,17 +350,17 @@ try:
|
|||||||
project, _ = Project.objects.get_or_create(
|
project, _ = Project.objects.get_or_create(
|
||||||
name='%s Project %d Org %d' % (prefix, project_id, org_idx),
|
name='%s Project %d Org %d' % (prefix, project_id, org_idx),
|
||||||
organization=org,
|
organization=org,
|
||||||
defaults=dict(created_by=next(creator_gen),
|
defaults=dict(
|
||||||
modified_by=next(modifier_gen),
|
created_by=next(creator_gen), modified_by=next(modifier_gen),
|
||||||
scm_url='https://github.com/jlaska/ansible-playbooks.git',
|
scm_url='https://github.com/jlaska/ansible-playbooks.git',
|
||||||
scm_type='git',
|
scm_type='git',
|
||||||
playbook_files=[
|
playbook_files=[
|
||||||
"check.yml", "debug-50.yml", "debug.yml", "debug2.yml",
|
"check.yml", "debug-50.yml", "debug.yml", "debug2.yml",
|
||||||
"debug_extra_vars.yml", "dynamic_inventory.yml",
|
"debug_extra_vars.yml", "dynamic_inventory.yml",
|
||||||
"environ_test.yml", "fail_unless.yml", "pass_unless.yml",
|
"environ_test.yml", "fail_unless.yml", "pass_unless.yml",
|
||||||
"pause.yml", "ping-20.yml", "ping.yml",
|
"pause.yml", "ping-20.yml", "ping.yml",
|
||||||
"setfact_50.yml", "vault.yml"
|
"setfact_50.yml", "vault.yml"
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
projects.append(project)
|
projects.append(project)
|
||||||
if org_idx == 0 and i == 0:
|
if org_idx == 0 and i == 0:
|
||||||
@@ -567,7 +583,7 @@ try:
|
|||||||
|
|
||||||
print('# Adding labels to job templates')
|
print('# Adding labels to job templates')
|
||||||
jt_idx = 0
|
jt_idx = 0
|
||||||
for n in spread(n_labels*7, n_job_templates):
|
for n in spread(n_labels * 7, n_job_templates):
|
||||||
jt = job_templates[jt_idx]
|
jt = job_templates[jt_idx]
|
||||||
if not jt._is_new:
|
if not jt._is_new:
|
||||||
continue
|
continue
|
||||||
@@ -578,7 +594,7 @@ try:
|
|||||||
|
|
||||||
print('# Adding labels to workflow job templates')
|
print('# Adding labels to workflow job templates')
|
||||||
wfjt_idx = 0
|
wfjt_idx = 0
|
||||||
for n in spread(n_labels*3, n_wfjts):
|
for n in spread(n_labels * 3, n_wfjts):
|
||||||
wfjt = wfjts[wfjt_idx]
|
wfjt = wfjts[wfjt_idx]
|
||||||
if not jt._is_new:
|
if not jt._is_new:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user