Implement frozen job serialization/deserialization
This adds (de)serialization to some helper classes in some cases, but in others we simplify the attributes we store on the FrozenJob so that we don't have to deal with objects any more. Notably, the process of serializing playbooks is incorporated into creating the frozen job (rather than creating the executor params) since it uses quite a few helper classes each of which would need to be (de)serialized as well. We could probably turn the rest of these helper classes into dictionaries too (which would be more efficient), but as they are simple and only one level deep, it seemed easier to implement serialization for them right now. Change-Id: I924c94ede1b0b6747b1f5cf92e658a45e6956a93
This commit is contained in:
@@ -98,31 +98,11 @@ def construct_build_params(uuid, sched, job, item, pipeline,
|
||||
params['ansible_version'] = job.ansible_version
|
||||
params['workspace_scheme'] = job.workspace_scheme
|
||||
|
||||
def make_playbook(playbook):
|
||||
d = playbook.toDict(redact_secrets=redact_secrets_and_keys)
|
||||
for role in d['roles']:
|
||||
if role['type'] != 'zuul':
|
||||
continue
|
||||
project_metadata = item.current_build_set.job_graph.\
|
||||
getProjectMetadata(role['project_canonical_name'])
|
||||
if project_metadata:
|
||||
role['project_default_branch'] = \
|
||||
project_metadata.default_branch
|
||||
else:
|
||||
role['project_default_branch'] = 'master'
|
||||
role_trusted, role_project = item.pipeline.tenant.getProject(
|
||||
role['project_canonical_name'])
|
||||
role_connection = role_project.source.connection
|
||||
role['connection'] = role_connection.connection_name
|
||||
role['project'] = role_project.name
|
||||
return d
|
||||
|
||||
if job.name != 'noop':
|
||||
params['playbooks'] = [make_playbook(x) for x in job.run]
|
||||
params['pre_playbooks'] = [make_playbook(x) for x in job.pre_run]
|
||||
params['post_playbooks'] = [make_playbook(x) for x in job.post_run]
|
||||
params['cleanup_playbooks'] = [make_playbook(x)
|
||||
for x in job.cleanup_run]
|
||||
params['playbooks'] = job.run
|
||||
params['pre_playbooks'] = job.pre_run
|
||||
params['post_playbooks'] = job.post_run
|
||||
params['cleanup_playbooks'] = job.cleanup_run
|
||||
|
||||
params["nodeset"] = job.nodeset.toDict()
|
||||
params['ssh_keys'] = []
|
||||
|
||||
Reference in New Issue
Block a user