def create(name, cartridges)
check_config!
check_name!(name)
cartridges = check_cartridges(cartridges, &require_one_web_cart)
options.default \
:dns => true,
:git => true
raise ArgumentError, "You have named both your main application and your Jenkins application '#{name}'. In order to continue you'll need to specify a different name with --enable-jenkins or choose a different application name." if jenkins_app_name == name && enable_jenkins?
rest_domain = check_domain!
rest_app = nil
cart_names = cartridges.collect do |c|
c.usage_rate? ? "#{c.short_name} (addtl. costs may apply)" : c.short_name
end.join(', ')
paragraph do
header "Application Options"
table([["Namespace:", options.namespace],
["Cartridges:", cart_names],
(["Source Code:", options.from_code] if options.from_code),
["Gear Size:", options.gear_size || "default"],
["Scaling:", options.scaling ? "yes" : "no"],
].compact
).each { |s| say " #{s}" }
end
messages = []
paragraph do
say "Creating application '#{name}' ... "
rest_app = create_app(name, cartridges, rest_domain, options.gear_size, options.scaling, options.from_code)
messages.concat(rest_app.messages)
success "done"
end
build_app_exists = rest_app.building_app
if enable_jenkins?
unless build_app_exists
paragraph do
say "Setting up a Jenkins application ... "
begin
build_app_exists = add_jenkins_app(rest_domain)
success "done"
messages.concat(build_app_exists.messages)
rescue Exception => e
warn "not complete"
add_issue("Jenkins failed to install - #{e}",
"Installing jenkins and jenkins-client",
"rhc create-app jenkins",
"rhc add-cartridge jenkins-client -a #{rest_app.name}")
end
end
end
paragraph do
add_jenkins_client_to(rest_app, messages)
end if build_app_exists
end
debug "Checking SSH keys through the wizard"
check_sshkeys! unless options.no_keys
if options.dns
paragraph do
say "Waiting for your DNS name to be available ... "
if dns_propagated? rest_app.host
success "done"
else
warn "failure"
add_issue("We were unable to lookup your hostname (#{rest_app.host}) in a reasonable amount of time and can not clone your application.",
"Clone your git repo",
"rhc git-clone #{rest_app.name}")
output_issues(rest_app)
return 0
end
end
if options.git
paragraph do
say "Downloading the application Git repository ..."
paragraph do
begin
git_clone_application(rest_app)
rescue RHC::GitException => e
warn "#{e}"
unless RHC::Helpers.windows? and windows_nslookup_bug?(rest_app)
add_issue("We were unable to clone your application's git repo - #{e}",
"Clone your git repo",
"rhc git-clone #{rest_app.name}")
end
end
end
end
end
end
display_app(rest_app, rest_app.cartridges)
if issues?
output_issues(rest_app)
else
results{ messages.each { |msg| success msg } }.blank? and "Application created"
end
0
end