def build build_options = {}
verify_status
force = build_options[:force]
version = nil
begin
params = {
:appliance_id => @options.appliance_id,
:image_type => "oem"
}
params[:force] = force if force
params[:version] = version if version
build = StudioApi::RunningBuild.create(params)
rescue StudioApi::ImageAlreadyExists
@shell.say 'An image with the same version already exists'
if @shell.yes? 'Do you want to overwrite it? (y/n)'
force = true
retry
else
begin
version = @shell.ask 'Enter new version number:'
end until !version.blank?
retry
end
end
build.reload
if build.state == "queued"
puts "Your build is queued. It will be automatically processed by "\
"SUSE Studio. You can keep waiting or you can exit from dister."
puts "Exiting from dister won't remove your build from the queue."
if @shell.no?('Do you want to keep waiting (y/n)')
exit 0
end
Utils::execute_printing_progress "Build queued..." do
while build.state == 'queued' do
sleep 5
build.reload
end
end
end
pbar = ProgressBar.new "Building", 100
while not ['finished', 'error', 'failed', 'cancelled'].include?(build.state)
pbar.set build.percent.to_i
sleep 5
build.reload
end
pbar.finish
build.state == 'finished'
end