Skip to content

Instantly share code, notes, and snippets.

@amitsaha
Created March 25, 2012 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitsaha/2193179 to your computer and use it in GitHub Desktop.
Save amitsaha/2193179 to your computer and use it in GitHub Desktop.
Web based front-end for BoxGrinder Build
# Demo of BoxGrinder build using a web-based interface
# Uses Sinatra
# Amit Saha (amitksaha@fedoraproject.org)
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
@goldmann
Copy link

We added a nice feature to BoxGrinder in version 0.8.0 where you don't need to store the appliance definition in a file at all, you can directly execute the plugin chain. Take a look.

@amitsaha
Copy link
Author

Very cool. Will check it out. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment