#===============================================================================
# [job_imager.py]
-def update_fail_create_image_for_sr_stage(fields, bm_start_datetime):
+def update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot_name):
print '[%s] enter update_fail_create_image_for_sr_stage\n' % (__file__)
bm_prj_name = fields["project"]
pre_build_snapshot_id, bm_repo, bm_device_name)
buildmonitor_db.do_query(query, query_data)
else:
- # get post_info_project_id -> get post_build_project_id
- query = "SELECT id FROM info_project WHERE project_name = %s"
- query_data = (bm_prj_name,)
- post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (post_info_project_id,)
+ # get post_build_project_id by using bm_snapshot_name
+ query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s"
+ query_data = (bm_snapshot_name,)
post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id)
# get curr_sr_status_id
query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s"
buildmonitor_db.do_query(query, query_data)
def create_image_for_build_image(fields, bm_start_datetime,
- bm_end_datetime, build_id, bm_img_size):
+ bm_end_datetime, bm_snapshot_name, bm_img_size):
print '[%s] enter create_image_for_build_image\n' % (__file__)
bm_repository = fields['repo']
# get curr_build_snapshot_id
query = "SELECT id FROM build_snapshot WHERE snapshot_name = %s"
- query_data = (build_id,)
+ query_data = (bm_snapshot_name,)
curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data)
#print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id)
#===============================================================================
# [job_post_image.py]
-def end_create_image_for_sr_stage(bm_start_datetime, project):
+def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name):
print '[%s] enter end_create_image_for_sr_stage project(%s)\n' % (__file__, project)
bm_end_datetime = datetime.datetime.now()
curr_sr_status_id, info_stage_id, curr_build_project_id)
buildmonitor_db.do_query(query, query_data)
else:
- # get curr_info_project_id -> get curr_build_project_id for multi profile
- query = "SELECT id FROM info_project WHERE project_name = %s"
- query_data = (project,)
- curr_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (curr_info_project_id,)
- curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ # get post_build_project_id by using bm_snapshot_name
+ query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s"
+ query_data = (bm_snapshot_name,)
+ post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id)
# get curr_build_snapshot_id
query = "SELECT id FROM build_snapshot WHERE build_project_id = %s"
- query_data = (curr_build_project_id,)
+ query_data = (post_build_project_id,)
curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data)
# get multi_build_image_status
query = "SELECT status FROM build_image WHERE build_snapshot_id = %s"
if isFailed == 0:
# get multi_sr_status_id
query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s"
- query_data = (curr_build_project_id,)
+ query_data = (post_build_project_id,)
multi_sr_status_id = buildmonitor_db.get_multi_values_from_query_data(query, query_data)
- #print '[%s] curr_info_project_id(%s), curr_build_project_id(%d), multi_sr_status_id(%s)\n' \
- # % (__file__, curr_info_project_id, curr_build_project_id, multi_sr_status_id)
+ #print '[%s] curr_info_project_id(%s), post_build_project_id(%d), multi_sr_status_id(%s)\n' \
+ # % (__file__, curr_info_project_id, post_build_project_id, multi_sr_status_id)
### [POST_SNAP/POST_IMAGE] stage end : [POST] snapshot & image creation
for each_sr_status_id in multi_sr_status_id:
query = "UPDATE sr_stage SET stage_end_time = %s, stage_status = %s " \
"WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s"
query_data = (bm_end_datetime, 'S',
- each_sr_status_id[0], info_stage_id, curr_build_project_id)
+ each_sr_status_id[0], info_stage_id, post_build_project_id)
buildmonitor_db.do_query(query, query_data)
info_stage_id = POST_IMAGE
query = "UPDATE sr_stage SET stage_end_time = %s, stage_status = %s " \
"WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s"
query_data = (bm_end_datetime, 'S',
- each_sr_status_id[0], info_stage_id, curr_build_project_id)
+ each_sr_status_id[0], info_stage_id, post_build_project_id)
buildmonitor_db.do_query(query, query_data)
#===============================================================================
# [job_request.py]
query = "SELECT id FROM info_project WHERE project_name = %s"
query_data = (bm_target_prj_name,)
curr_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (curr_info_project_id,)
+
+ # get last_bpid_of_build_snapshot
+ query = "SELECT bp.id " \
+ "FROM build_project bp, info_project ip, build_snapshot bs " \
+ "WHERE ip.project_name = %s " \
+ "AND ip.id = bp.info_project_id " \
+ "AND bp.id = bs.build_project_id " \
+ "ORDER BY id desc LIMIT 1"
+ query_data = (bm_target_prj_name,)
+ last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] last_bpid_of_build_snapshot(%s)\n' \
+ % (__file__, last_bpid_of_build_snapshot)
+
+ # get post_build_project_id
+ query = "SELECT bp.id " \
+ "FROM build_project bp " \
+ "WHERE bp.info_project_id = %s " \
+ "AND bp.id > %s " \
+ "ORDER BY id LIMIT 1"
+ query_data = (curr_info_project_id, last_bpid_of_build_snapshot)
post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] post_build_project_id(%s)\n' \
+ % (__file__, post_build_project_id)
+
+ # use the prev last_bpid if there is no post_build_project_id
+ if post_build_project_id == 0:
+ print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \
+ (__file__, post_build_project_id, last_bpid_of_build_snapshot)
+ post_build_project_id = last_bpid_of_build_snapshot
### [POST_BUILD] stage start : [post] package build
info_stage_id = POST_BUILD
#print '[%s] pre_info_project_id(%d), pre_build_project_id(%s)\n' \
# % (__file__, pre_info_project_id, pre_build_project_id)
- # get post_info_project_id -> get post_build_project_id
+ # get post_info_project_id
query = "SELECT id FROM info_project WHERE project_name = %s"
query_data = (bm_target_prj_name,)
post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (post_info_project_id,)
+
+ # get last_bpid_of_build_snapshot
+ query = "SELECT bp.id " \
+ "FROM build_project bp, info_project ip, build_snapshot bs " \
+ "WHERE ip.project_name = %s " \
+ "AND ip.id = bp.info_project_id " \
+ "AND bp.id = bs.build_project_id " \
+ "ORDER BY id desc LIMIT 1"
+ query_data = (bm_target_prj_name,)
+ last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] last_bpid_of_build_snapshot(%s)\n' \
+ % (__file__, last_bpid_of_build_snapshot)
+
+ # get post_build_project_id
+ query = "SELECT bp.id " \
+ "FROM build_project bp " \
+ "WHERE bp.info_project_id = %s " \
+ "AND bp.id > %s " \
+ "ORDER BY id LIMIT 1"
+ query_data = (post_info_project_id, last_bpid_of_build_snapshot)
post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- #print '[%s] post_info_project_id(%s), post_build_project_id(%s)\n' \
- # % (__file__, post_info_project_id, post_build_project_id)
+ print '[%s] post_build_project_id(%s)\n' \
+ % (__file__, post_build_project_id)
+
+ # use the prev last_bpid if there is no post_build_project_id
+ if post_build_project_id == 0:
+ print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \
+ (__file__, post_build_project_id, last_bpid_of_build_snapshot)
+ post_build_project_id = last_bpid_of_build_snapshot
### for sr_status_detail
query = "UPDATE sr_status_detail SET post_build_project_id = %s, obs_request_no = %s, " \
#===============================================================================
# [job_create_snapshot.py]
-def update_fail_create_snapshot_for_sr_stage(project):
+def update_fail_create_snapshot_for_sr_stage(bm_snapshot_name):
print '[%s] enter update_fail_create_snapshot_for_sr_stage\n' % (__file__)
- # get post_info_project_id
- query = "SELECT id FROM info_project WHERE project_name = %s"
- query_data = (project,) # Tizen:Mobile
- post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
-
- # get post_build_project_id
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (post_info_project_id,)
+ # get post_build_project_id by using bm_snapshot_name
+ query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s"
+ query_data = (bm_snapshot_name,)
post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id)
# get curr_sr_status_id
query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s"
query_data = (post_build_project_id,)
curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- #print '[%s] post_info_project_id(%s), post_build_project_id(%d), curr_sr_status_id(%s)\n' \
- # % (__file__, post_info_project_id, post_build_project_id, curr_sr_status_id)
+ #print '[%s] curr_sr_status_id(%s)\n' \
+ # % (__file__, curr_sr_status_id)
### [7] stage : update fail status when failed
bm_start_datetime = bm_end_datetime = datetime.datetime.now()
# get post_info_project_id
query = "SELECT id FROM info_project WHERE project_name = %s"
- query_data = (project,) # Tizen:Mobile
+ query_data = (project,)
post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ # get last_bpid_of_build_snapshot
+ query = "SELECT bp.id " \
+ "FROM build_project bp, info_project ip, build_snapshot bs " \
+ "WHERE ip.project_name = %s " \
+ "AND ip.id = bp.info_project_id " \
+ "AND bp.id = bs.build_project_id " \
+ "ORDER BY id desc LIMIT 1"
+ query_data = (project,)
+ last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] last_bpid_of_build_snapshot(%s)\n' \
+ % (__file__, last_bpid_of_build_snapshot)
+
# get post_build_project_id
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (post_info_project_id,)
+ query = "SELECT bp.id " \
+ "FROM build_project bp " \
+ "WHERE bp.info_project_id = %s " \
+ "AND bp.id > %s " \
+ "ORDER BY id LIMIT 1"
+ query_data = (post_info_project_id, last_bpid_of_build_snapshot)
post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] post_build_project_id(%s)\n' \
+ % (__file__, post_build_project_id)
+
+ # use the prev last_bpid if there is no post_build_project_id
+ if post_build_project_id == 0:
+ print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \
+ (__file__, post_build_project_id, last_bpid_of_build_snapshot)
+ post_build_project_id = last_bpid_of_build_snapshot
# get multi_sr_status_id
query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s"
query_data = (project,)
post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ # get last_bpid_of_build_snapshot
+ query = "SELECT bp.id " \
+ "FROM build_project bp, info_project ip, build_snapshot bs " \
+ "WHERE ip.project_name = %s " \
+ "AND ip.id = bp.info_project_id " \
+ "AND bp.id = bs.build_project_id " \
+ "ORDER BY id desc LIMIT 1"
+ query_data = (project,)
+ last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] last_bpid_of_build_snapshot(%s)\n' \
+ % (__file__, last_bpid_of_build_snapshot)
+
# get post_build_project_id
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (post_info_project_id,)
+ query = "SELECT bp.id " \
+ "FROM build_project bp " \
+ "WHERE bp.info_project_id = %s " \
+ "AND bp.id > %s " \
+ "ORDER BY id LIMIT 1"
+ query_data = (post_info_project_id, last_bpid_of_build_snapshot)
post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- #print '[%s] post_info_project_id(%s), post_build_project_id(%d)\n' \
- # % (__file__, post_info_project_id, post_build_project_id)
+ print '[%s] post_build_project_id(%s)\n' \
+ % (__file__, post_build_project_id)
+
+ # use the prev last_bpid if there is no post_build_project_id
+ if post_build_project_id == 0:
+ print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \
+ (__file__, post_build_project_id, last_bpid_of_build_snapshot)
+ post_build_project_id = last_bpid_of_build_snapshot
# insert new post_build_project_id
query = "INSERT INTO build_snapshot (build_project_id, snapshot_name, " \
query_data = (post_build_project_id, bm_snapshot_name, bm_start_datetime, 'R')
buildmonitor_db.do_query(query, query_data)
-def create_snapshot_packages_for_post_build_snapshot_package(project, bm_repo, bm_arch,
+def create_snapshot_packages_for_post_build_snapshot_package(bm_snapshot_name,
+ bm_repo, bm_arch,
bm_pkg_url,
bm_pkg_name_lst,
bm_pkg_mdate_lst,
bm_pkg_size_lst):
print '[%s] enter create_snapshot_packages_for_post_build_snapshot_package\n' % (__file__)
- # get post_info_project_id
- query = "SELECT id FROM info_project WHERE project_name = %s"
- query_data = (project,)
- post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- #print '[%s] post_info_project_id (%s)\n' % (__file__, post_info_project_id)
-
- # get post_build_project_id
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (post_info_project_id,)
- build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
-
# get curr_build_snapshot_id
- query = "SELECT id FROM build_snapshot WHERE build_project_id = %s"
- query_data = (build_project_id,)
+ query = "SELECT id FROM build_snapshot WHERE snapshot_name = %s"
+ query_data = (bm_snapshot_name,)
curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id)
for each_pkg_name, each_pkg_mdate, each_pkg_size in zip(bm_pkg_name_lst, bm_pkg_mdate_lst, bm_pkg_size_lst):
timestamp = datetime.datetime.fromtimestamp(each_pkg_mdate)
each_pkg_name, timestamp, each_pkg_size, bm_pkg_url)
buildmonitor_db.do_query(query, query_data)
-def end_create_snapshot_create_images_for_sr_stage(project, bm_start_datetime,
+def end_create_snapshot_create_images_for_sr_stage(bm_snapshot_name,
+ bm_start_datetime,
bm_end_datetime):
print '[%s] enter end_create_snapshot_create_images_for_sr_stage\n' % (__file__)
### [POST_SNAP/POST_IMAGE] end : [post] snapshot creation / [post] image creation
- # get post_info_project_id
- query = "SELECT id FROM info_project WHERE project_name = %s"
- query_data = (project,) # Tizen:Mobile
- post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- # get post_build_project_id
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (post_info_project_id,)
+ # get post_build_project_id by using bm_snapshot_name
+ query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s"
+ query_data = (bm_snapshot_name,)
post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id)
# get multi_sr_status_id
query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s"
query_data = (post_build_project_id,)
multi_sr_status_id = buildmonitor_db.get_multi_values_from_query_data(query, query_data)
- #print '[%s] post_info_project_id(%s), post_build_project_id(%d), multi_sr_status_id(%s)\n' \
- # % (__file__, post_info_project_id, post_build_project_id, multi_sr_status_id)
+ #print '[%s] multi_sr_status_id(%s)\n' \
+ # % (__file__, multi_sr_status_id)
for each_sr_status_id in multi_sr_status_id:
print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
each_sr_status_id[0], info_stage_id, post_build_project_id)
buildmonitor_db.do_query(query, query_data)
-def end_create_snapshot_for_post_build_snapshot(project, bm_start_datetime,
- bm_end_datetime, bm_snapshot_url,
+def end_create_snapshot_for_post_build_snapshot(bm_end_datetime,
+ bm_snapshot_url,
bm_snapshot_name):
print '[%s] enter end_create_snapshot_for_post_build_snapshot\n' % (__file__)
- # get post_info_project_id
- query = "SELECT id FROM info_project WHERE project_name = %s"
- query_data = (project,)
- post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
-
- # get post_build_project_id
- query = "SELECT id FROM build_project " \
- "WHERE info_project_id = %s ORDER BY id desc LIMIT 1"
- query_data = (post_info_project_id,)
- post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- #print '[%s] post_info_project_id(%s), post_build_project_id(%d)\n' \
- # % (__file__, post_info_project_id, post_build_project_id)
-
- # insert new post_build_project_id
+ # update the build_snapshot data
query = "UPDATE build_snapshot SET snapshot_url = %s, " \
"end_time = %s, status = %s WHERE snapshot_name = %s"
query_data = (bm_snapshot_url, bm_end_datetime, 'S', bm_snapshot_name)
fields = content.get("fields")
bm_start_datetime = content.get("bm_start_datetime")
bm_end_datetime = content.get("bm_end_datetime")
- build_id = content.get("build_id")
+ bm_snapshot_name = content.get("build_id")
bm_img_size = content.get("bm_img_size")
- #print '[%s] fields(%s), bm_start_datetime(%s), build_id(%s)\n' \
- # % (__file__, fields, bm_start_datetime, build_id)
+ #print '[%s] fields(%s), bm_start_datetime(%s), bm_snapshot_name(%s)\n' \
+ # % (__file__, fields, bm_start_datetime, bm_snapshot_name)
create_image_for_build_image(fields, bm_start_datetime,
- bm_end_datetime, build_id, bm_img_size)
+ bm_end_datetime, bm_snapshot_name, bm_img_size)
if image_status == 'failed':
if bm_stage == 'Image':
print '[%s][Image]\n' % (__file__)
- update_fail_create_image_for_sr_stage(fields, bm_start_datetime)
+ update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot_name)
# [17_0110] TRBS]
if bm_stage == '[TRBS]_Image':
# func call
if bm_stage == 'Post_Image':
print '[%s][Post_Image]\n' % (__file__)
- end_create_image_for_sr_stage(bm_start_datetime, project)
+ bm_snapshot_name = content.get("bm_snapshot_name")
+ end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name)
# [17_0110] TRBS
if bm_stage == '[TRBS]_Post_Image':
print '[%s][Post_Snap_packages]\n' % (__file__)
# get vars
- repo = content.get("repo")
- project = content.get("project")
+ bm_snapshot_name = content.get("bm_snapshot_name")
bm_repo = content.get("bm_repo")
bm_arch = content.get("bm_arch")
bm_pkg_url = content.get("bm_pkg_url")
bm_pkg_size_lst = content.get("bm_pkg_size_lst")
# func call
- create_snapshot_packages_for_post_build_snapshot_package(project,
+ create_snapshot_packages_for_post_build_snapshot_package(bm_snapshot_name,
bm_repo,
bm_arch,
bm_pkg_url,
print '[%s][Post_Snap_End]\n' % (__file__)
# get vars
- project = content.get("project")
bm_start_datetime = content.get("bm_start_datetime")
bm_end_datetime = content.get("bm_end_datetime")
bm_snapshot_url = content.get("bm_snapshot_url")
- repo_data_build_id = content.get("repo_data_build_id")
+ bm_snapshot_name = content.get("bm_snapshot_name")
# func call
# for sr_stage & build_snapshot
- end_create_snapshot_create_images_for_sr_stage(project,
+ end_create_snapshot_create_images_for_sr_stage(bm_snapshot_name,
bm_start_datetime,
bm_end_datetime)
- end_create_snapshot_for_post_build_snapshot(project,
- bm_start_datetime,
- bm_end_datetime,
+ end_create_snapshot_for_post_build_snapshot(bm_end_datetime,
bm_snapshot_url,
- repo_data_build_id)
+ bm_snapshot_name)
elif bm_stage == 'Post_Snap_Fail':
print '[%s][Post_Snap_Fail]\n' % (__file__)
- bm_project = content.get("bm_project")
- update_fail_create_snapshot_for_sr_stage(bm_project)
+ bm_snapshot_name = content.get("bm_snapshot_name")
+ update_fail_create_snapshot_for_sr_stage(bm_snapshot_name)
elif bm_stage == 'REPA':
print '[%s][REPA]\n' % (__file__)