Closed jamesdobson closed 9 years ago
@jamesdobson thank you for your submission! I will try to find the time to review it soon.
Unfortunately running vagrant with the VirtualBox provider didn't work for me. I will try to debug it and will submit a fix.
@jamesdobson Thank you again for your contribution. I am available to help you merge this PR, let me know if you need any help!
Regarding the Vagrantfile not working with VirtualBox: I've only tested with OS X and Windows 7--let me know if I should test on another platform.
The only piece that didn't work out as I'd hoped was doHttpRequest
. I was hoping the return type could be []map[string]interface{}
, but It isn't possible to do a conversion from []interface{}
to []map[string]interface{}
, so I had to put the return type of doHttpRequest
as []interface{}
. Callers have to take result[0].(map[string]interface{})
, which isn't super.
According to http://golang.org/doc/faq#convert_slice_of_interface, one can do an array copy to make the conversion, but it seems like a big hammer to have to pull out...
I can confirm that the Vagrant file works with the VirtualBox provider.
The only thing that is missing is to register the new builder with packer. I added the following lines to the SCRIPT heredoc end:
# Setup packer to use recognize the softlayer builder
cat <<EOF >$HOME/.packerconfig
{
"builders": {
"softlayer": "$GOPATH/bin/packer-builder-softlayer"
}
}
EOF
I think it can be a good idea to add this change. What do you think ?
@jamesdobson I think that when decoding variable-schema JSON we can get a cleaner code by using go-simplejson library. A good example of how it can be used can be found here Switching to working with that library will require additional work, therefore I don't think that we should do it as part of this PR.
I am ok with merging this code in it's current state, and to work on improving the doHttpRequest
readability later on.
On my system it works without adding the ".packerconfig" file: "go install" puts packer-builder-softlayer in the same directory as the other packer binaries ($GOPATH/bin), so packer finds the softlayer plugin automatically. I'm running as the user "vagrant".
I tried the code you supplied that adds the ".packerconfig" file: packer continues to find the softlayer plugin. The .packerconfig file certainly doesn't break anything in my workflow, so if it is needed to get things working on other systems, I think it's a great addition. Shall I add it to the PR?
go-simplejson looks like it may clean things up; we will have to try it out!
Yeah, let's get the PR merged as it currently stands (with the exception of the code to add .packerconfig that I'm happy to add)--I'm eager to see how well it works for other users.
Just want to give a :+1: for your work here.
I've been testing this today and so far it's looking good. Images are being created (using Ubuntu Precise x64) although I've yet to launch anything from one. The Vagrantfile
was a really nice touch.
These changesets add support for creating standard images. The approach is:
1) Find all non-swap block devices 2) Execute createArchiveTransaction with these block device ids 3) Find the image by name in the list of images associated with the account and return the image GUID.
Also, the following changes were made:
I'm still wrapping my head around both Go and SoftLayer. Let me know if there's anything you'd like me to improve, or any change you'd like me to undo, before approving the pull request.