packages = saved_info.get('packages') or []
images = saved_info.get('images') or []
submitter = saved_info.get('submitter') or []
-
+ download_num = saved_info.get('download_num') or int(0)
saved_info.update(info)
if 'projects' in info:
saved_info['projects'] = list(set(projects + info['projects']))
saved_info['snapshot'] = info['snapshot']
if 'chksnap' in info:
saved_info['chksnap'] = info['chksnap']
+ if 'download_num' in info:
+ saved_info['download_num'] = int(download_num) + int(info['download_num'])
+
self.set_description(json.dumps(saved_info), prj, pkg)
def get_info(self, prj, pkg=None):
fields = trigger_info(os.getenv('TRIGGER_INFO'))
# Check if we've got required fields in TRIGGER_INFO
- for field in ('kickstart', 'name', 'buildid', 'repo_path'):
+ for field in ('kickstart', 'name', 'buildid', 'repo_path', 'download_num'):
if field not in fields:
print 'Error: TRIGGER_INFO doesn\'t contain %s'
return 1
"name": fields['name'],
"project": fields.get('project', ''),
"status": "failed",
- "url": url
+ "url": url,
+ "download_num": int(fields['download_num'])
}
trigger_next("POST-IMAGE-CREATION", data)
"name": fields['name'],
"project": fields.get('project', ''),
"status": status,
- "url": url
+ "url": url,
+ "download_num": int(fields['download_num'])
}
trigger_next("POST-IMAGE-CREATION", data)
if is_prerelease_project(project):
build = BuildService(obs_api, obs_user, obs_passwd)
+ saveinfo = build.get_info(project)
+ if saveinfo.get('download_num', 0) != content.get('download_num', 1):
+ print 'EXCEPTION* mismatch download_num current:%s, obs:%s' \
+ % (content.get('download_num'), saveinfo.get('download_num'))
+ print 'SKIP UPDATING BUILD INFO'
+ return
+
info = {"images":
[{"name": name,
"status": status,
if buildmonitor_enabled:
saveinfo = build.get_info(project)
- if len(saveinfo['images']) == saveinfo['images_count']:
+ if len(saveinfo['images']) == int(saveinfo['images_count']):
print '[%s] last image(%s)\n' \
% (__file__, len(saveinfo['images']))
#buildmonitor.end_create_image_for_sr_stage(bm_start_datetime,
return images_ks
def trigger_image_creation(images_ks, build_id, path_repo,
- project, url_pub_base, repo_name):
+ project, url_pub_base, repo_name, download_num=1):
"""
trigger_image_creation:
Prepare the data and trigger the image_creation jobs
'project': project,
'repo_path': path_repo,
'repo': repo_name,
- 'url_pub_base': url_pub_base
+ 'url_pub_base': url_pub_base,
+ 'download_num': download_num
}
# add image_building for iris
pub_enabled = os.getenv("IRIS_PUB_ENABLED", "0") != "0"
"""
images_count = 0
+ current_download_num = build.get_info(project).get('download_num') or int(1)
+ print 'Current download_num = %d' % current_download_num
+
# Make build id from latest snapshot + project suffix
target_project, tstamp = get_info_from_prerelease_name(project)
images_count += trigger_image_creation(images_ks, prerelease.build_id,
os.path.join(prerelease.dir,
prerelease.build_id),
- project, base_url, repo['Name'])
+ project, base_url, repo['Name'], download_num=current_download_num)
# reset 'images' and add download_url meta info
build.update_info({'images_count': images_count,
'images': [],