def create(name, cartridges)
check_config!
check_name!(name)
arg_envs, cartridges = cartridges.partition{|item| item.match(env_var_regex_pattern)}
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
repo_dir = nil
cart_names = cartridges.collect do |c|
c.usage_rate? ? "#{c.short_name} (addtl. costs may apply)" : c.short_name
end.join(', ')
if rest_domain.supports_add_application_with_env_vars?
environment_variables = collect_env_vars(arg_envs.concat(Array(options.env)))
else
warn "Server does not support environment variables."
end
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"],
(["Environment Variables:", environment_variables.map{|item| "#{item.name}=#{item.value}"}.join(', ')] if environment_variables.present?),
].compact
).each { |s| say " #{s}" }
end
paragraph do
say "Creating application '#{name}' ... "
rest_app = create_app(name, cartridges, rest_domain, options.gear_size, options.scaling, options.from_code, environment_variables)
success "done"
paragraph{ indent{ success rest_app.messages.map(&:strip) } }
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"
paragraph{ indent{ success build_app_exists.messages.map(&:strip) } }
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
messages = []
add_jenkins_client_to(rest_app, messages)
paragraph{ indent{ success messages.map(&:strip) } }
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
section(:now => true, :top => 1, :bottom => 1) do
begin
repo_dir = 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
output_issues(rest_app) if issues?
paragraph do
say "Your application '#{rest_app.name}' is now available."
paragraph do
indent do
say table [
['URL:', rest_app.app_url],
['SSH to:', rest_app.ssh_string],
['Git remote:', rest_app.git_url],
(['Cloned to:', repo_dir] if repo_dir)
].compact
end
end
end
paragraph{ say "Run 'rhc show-app #{name}' for more details about your app." }
0
end