Merge lp:~julian-edwards/gwacl/vhd-define into lp:gwacl
Status: | Merged |
---|---|
Approved by: | Julian Edwards |
Approved revision: | 128 |
Merged at revision: | 133 |
Proposed branch: | lp:~julian-edwards/gwacl/vhd-define |
Merge into: | lp:gwacl |
Diff against target: |
202 lines (+151/-1) 4 files modified
Makefile (+1/-1) storage.go (+80/-0) storage_test.go (+69/-0) vhd_footer.go (+1/-0) |
To merge this branch: | bzr merge lp:~julian-edwards/gwacl/vhd-define |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella | Approve | ||
Review via email: mp+170746@code.launchpad.net |
Commit message
Add a convenience function CreateVHD to create a VHD based on a filesystem image.
Description of the change
Add a convenience function to create a VHD based on a filesystem image. It works by making a page blob of a fixed 20Mb size and uploading a fixed VHD footer of 512 bytes to the last page. The supplied filesystem image is then uploaded from the start of the blob. The resulting blob is then able to be mounted as an Azure disk on an instance.
The point of all this is to enable a callsite to make arbitrary data available to the new instance, since Azure does not provide any other way.
This branch probably (read: definitely) needs more error testing, but quite frankly I find writing test code in Go to be utter drudgery and have lost the will to live. If you have any specific and useful ideas to help me out, go for it.
Looks good, but I'm concerned about [3]. I'm not 100% sure that's a
bug, so Needs Information.
[1]
+ Size int // How many bytes from the Filesystem data to
+ // upload. *Must* be a modulo of 512.
I'm not sure modulo is the right word here (and I don't think it's a
noun either). How about s/modulo/multiple/?
[2]
+ if err != nil {
+ // This really shouldn't ever happen since there's a test to make sure
+ // it can be decoded.
+ panic("Unable to base64 decode VHD_FOOTER")
+ }
We lose the original error here. How about panic(err) instead?
[3]
+ err = context. PutPage( &PutPageRequest {
+ Container: req.Container,
+ Filename: req.Filename,
+ StartRange: VHD_SIZE-513,
+ EndRange: VHD_SIZE-1,
+ Data: dataReader,
+ })
This should probably use len(data) instead of literals.
Also, this means that the maximum size of the filesystem data is
VHD_SIZE - len(data), not VHD_SIZE.
[4]
+func (context *StorageContext) CreateVHD(req *CreateVHDRequest) error {
This isn't a general purpose function for creating a VHD, so I think rData or something like
it ought to be renamed to, say, CreateVHDForUse
that.