Merge lp:~rcj/simplestreams/lxd into lp:simplestreams

Proposed by Robert C Jennings
Status: Merged
Merged at revision: 437
Proposed branch: lp:~rcj/simplestreams/lxd
Merge into: lp:simplestreams
Diff against target: 96 lines (+43/-22)
2 files modified
tools/make-test-data (+41/-21)
tools/toolutil.py (+2/-1)
To merge this branch: bzr merge lp:~rcj/simplestreams/lxd
Reviewer Review Type Date Requested Status
Dan Watkins (community) Approve
simplestreams-dev Pending
Review via email: mp+297798@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Dan Watkins (oddbloke) wrote :

Overall approach looks good; comments inline.

review: Needs Fixing
Revision history for this message
Dan Watkins (oddbloke) wrote :

Looks much better; one remaining question.

review: Needs Information
Revision history for this message
Robert C Jennings (rcj) wrote :

fixed.

Revision history for this message
Dan Watkins (oddbloke) wrote :

SHIP IT

review: Approve
lp:~rcj/simplestreams/lxd updated
437. By Robert C Jennings

Create chksum for LXD metadata+root for squashfs (LP: #1577922)

This adds a 'combined_sqashfs_sha256' element to items that have
both a LXD metadata tar and a squashfs root. Additionally, we
have 'combined_rootxz_sha256' which wil have the same value as
'combined_sha256' and allow for sunsetting that ambiguous name.

Revision history for this message
Robert C Jennings (rcj) wrote :

I combined the revisions for a clean upstream merge with a good commit message. No code changes. Merging now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tools/make-test-data'
--- tools/make-test-data 2016-05-17 13:48:54 +0000
+++ tools/make-test-data 2016-06-22 19:05:52 +0000
@@ -288,23 +288,34 @@
288 del fdata['content']288 del fdata['content']
289 FAKE_DATA[item['ftype']].update(fdata)289 FAKE_DATA[item['ftype']].update(fdata)
290290
291 # create a combined_sha256 for lxd.tar.xz from the -root.tar.gz also291 # create a combined sha256 for lxd.tar.xz (metadata) and the root fs
292 # - combined_sha256 and combined_rootxz_sha256 for the -root.tar.gz
293 # - combined_squashfs_sha256 for the squashfs
292 ftype = item['ftype']294 ftype = item['ftype']
293 if ftype == "lxd.tar.xz" and 'combined_sha256' not in FAKE_DATA[ftype]:295 for name, extension in (('rootxz', '-root.tar.xz'),
294 rootpath = item['path'].replace("-lxd.tar.xz", "-root.tar.xz")296 ('squashfs', '.squashfs')):
295 # make sure the root.tar.xz exists297 if (ftype == "lxd.tar.xz" and
296 if not os.path.exists(os.path.join(prefix, rootpath)):298 'combined_{}_sha256'.format(name) not in FAKE_DATA[ftype]):
297 rootitem = item.copy()299 rootpath = item['path'].replace("-lxd.tar.xz", extension)
298 rootitem['ftype'] = "root.tar.xz"300 if not os.path.exists(os.path.join(prefix, rootpath)):
299 rootitem['path'] = rootpath301 rootitem = item.copy()
300 create_fake_file(prefix, rootitem)302 rootitem['ftype'] = extension.lstrip('-.')
301303 rootitem['path'] = rootpath
302 # and sha256 hash the combined file, .xz first304 create_fake_file(prefix, rootitem)
303 chash = hashlib.new('sha256')305
304 for member in [fpath, os.path.join(prefix, rootpath)]:306 # and sha256 hash the combined file
305 with open(member, "rb") as fp:307 chash = hashlib.new('sha256')
306 chash.update(fp.read())308 for member in [fpath, os.path.join(prefix, rootpath)]:
307 data.update({'combined_sha256': chash.hexdigest()})309 with open(member, "rb") as fp:
310 chash.update(fp.read())
311 data.update(
312 {'combined_{}_sha256'.format(name): chash.hexdigest()})
313
314 # Add legacy combined_sha256 if combined_rootxz_sha256 exists
315 if (ftype == "lxd.tar.xz" and 'combined_sha256' not in FAKE_DATA[ftype]
316 and 'combined_rootxz_sha256' in FAKE_DATA[ftype]):
317 data.update({'combined_sha256':
318 FAKE_DATA[ftype]['combined_rootxz_sha256']})
308319
309 item.update(data)320 item.update(data)
310321
@@ -545,13 +556,22 @@
545 path = item['path']556 path = item['path']
546 item.update(get_cloud_images_file_info(path))557 item.update(get_cloud_images_file_info(path))
547 if path.endswith('-lxd.tar.xz'):558 if path.endswith('-lxd.tar.xz'):
548 # find calculated combined checksum
549 dirname = os.path.dirname(path)559 dirname = os.path.dirname(path)
550 lxd = os.path.basename(path)560 lxd = os.path.basename(path)
551 root = lxd.replace('-lxd', '-root')561
552 combined = os.path.join(dirname, ','.join([lxd, root]))562 # find calculated combined checksums
553 item.update({'combined_sha256':563 for name, extension in (('rootxz', '-root.tar.xz'),
554 get_cache_data(combined, 'sha256')})564 ('squashfs', '.squashfs')):
565 root = lxd.replace('-lxd.tar.xz', extension)
566 combined = os.path.join(dirname, ','.join([lxd, root]))
567 value = get_cache_data(combined, 'sha256')
568 if value:
569 item.update({'combined_{}_sha256'.format(name): value})
570
571 # Add legacy combined_sha256 if combined_rootxz_sha256 exists
572 if 'combined_rootxz_sha256' in item:
573 value = item['combined_rootxz_sha256']
574 item.update({'combined_sha256': value})
555575
556 cid_fmt = "com.ubuntu.cloud:%s:download"576 cid_fmt = "com.ubuntu.cloud:%s:download"
557 for stream in tree:577 for stream in tree:
558578
=== modified file 'tools/toolutil.py'
--- tools/toolutil.py 2016-05-20 19:39:13 +0000
+++ tools/toolutil.py 2016-06-22 19:05:52 +0000
@@ -101,7 +101,8 @@
101 return False101 return False
102 if codename_cmp(rel, "<", "precise"):102 if codename_cmp(rel, "<", "precise"):
103 return False103 return False
104 if codename_cmp(rel, ">=", "yakkety"):104 # -root.tar.xz is replaced by squashfs for yakkety
105 if codename_cmp(rel, ">=", "yakkety") and suffix == '-root.tar.xz':
105 return False106 return False
106107
107 if suffix == '.squashfs' or suffix == '.squashfs.manifest':108 if suffix == '.squashfs' or suffix == '.squashfs.manifest':

Subscribers

People subscribed via source and target branches