Created
March 25, 2012 12:05
-
-
Save amitsaha/2193179 to your computer and use it in GitHub Desktop.
Web based front-end for BoxGrinder Build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Demo of BoxGrinder build using a web-based interface | |
# Uses Sinatra | |
# Amit Saha ([email protected]) | |
require 'rubygems' | |
require 'sinatra' | |
require 'dm-core' | |
require 'yaml' | |
# Home, sweet home | |
get '/' do | |
'<html> | |
<body> | |
<center> <h1>BoxGrinder Not-so-Studio</h1> </center> | |
<center><img src="http://boxgrinder.org/images/banner.png"></img> | |
<p> Your appliance definition: | |
<form action="/build" method="post"> | |
<div><textarea name="appliance" rows="23" cols="100"></textarea></div> | |
<div>Your E-mail address to recieve a download link:: <input type="text" name="email" ></div> | |
<div><input type="submit" value="Build Image"></div> | |
</form> | |
</body> | |
</html>' | |
end | |
# Process Build Request | |
post '/build' do | |
# Generate a unique request ID | |
jobID=123 | |
# Get the email address of the request | |
email = "#{params[:email]}" | |
# Get the appliance defintion | |
definition = "#{params[:appliance]}" | |
# save the appliance definition to a file | |
# filename:jobid.appl | |
fname="#{jobID}.appl" | |
File.open("appliances/"+fname, 'w') { |f| f.write("#{definition}")} | |
# Add build job to the build queue | |
# Job: JobID,email,appliance definition file name | |
# simple text file | |
File.open('jobs','a') {|f| f.write("#{jobID}" + "\t" + email + "\t" + fname + "\n")}; | |
# system "dos2unix foo.appl" | |
# puts "Starting Build Process" | |
# system "sudo boxgrinder-build foo.appl -p virtualbox" | |
'<html> | |
<body>Recieved Build Request</body> | |
</html>' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very cool. Will check it out. Thanks!