Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[dev_setup] Work with broken out repos

  This change adapts dev_setup to the repo split.
  - Cookbooks and bootstrapping scripts are updated.
  - bin/{cc,hm,dea,router,vcap} are removed

  Test plan:
  - Run dev_setup on an existing installation, pass BVT's
  - Run dev_setup on a pristine VM, pass BVt's

  Next step:
  - remove the component / gem sub dirs from vcap repo

Change-Id: If24e2e113075cf0d9135d59b594b3a2517c401fa
  • Loading branch information...
commit 9bc7403d4a8d4f72980fd35ef83a223be0a50170 1 parent 0d6ec9a
@d d authored
View
83 bin/cloud_controller
@@ -1,83 +0,0 @@
-#!/usr/bin/env ruby
-# Copyright (c) 2009-2011 VMware, Inc.
-
-require 'optparse'
-opts_parser = OptionParser.new do |opts|
- opts.on('-p PORT') { |port| $cc_port = port.to_i }
- opts.on('-c CONFIG_FILE') { |cfg| $cc_config_file = cfg.to_s }
-end
-opts_parser.parse!(ARGV.dup)
-
-if $cc_config_file.nil? && ENV["CLOUD_FOUNDRY_CONFIG_PATH"]
- $cc_config_file = File.join(ENV["CLOUD_FOUNDRY_CONFIG_PATH"], "cloud_controller.yml")
- puts "Using config file #{$cc_config_file}"
-end
-
-if $cc_config_file
- if File.exists?($cc_config_file)
- ENV['CLOUD_CONTROLLER_CONFIG'] = $cc_config_file
- else
- $stderr.puts "Could not find specified config file at #{$cc_config_file.inspect}"
- exit 1
- end
-end
-
-cc_root = File.expand_path('../../cloud_controller', __FILE__)
-cc_boot = File.join(cc_root, 'config', 'boot')
-require cc_boot
-
-# Sets TCP/IP environment for sub-processes as well.
-if $cc_port && $cc_port.nonzero?
- CloudController.external_port = $cc_port
-end
-
-begin
- pid_file = CloudController.pid
- FileUtils.mkdir_p(File.dirname(pid_file)) # ensure pidfile directory exists
- File.open(pid_file, 'wb') do |handle|
- handle.print(Process.pid)
- at_exit { File.unlink(pid_file) rescue nil }
- end
-rescue
- $stderr.puts "Unable to write to pidfile at: #{pid_file}"
- exit 1
-end
-
-begin
- tmp_dir = CloudController.tmp_dir
- uploads_dir = CloudController.uploads_dir
- if CloudController.nuke_tmp
- FileUtils.rm_rf(tmp_dir)
- end
- FileUtils.mkdir_p(tmp_dir)
- FileUtils.mkdir_p(uploads_dir)
-rescue
- $stderr.puts "Unable to setup clean tmp dir #{tmp_dir}"
- exit 1
-end
-
-require 'thin'
-
-if not CloudController.use_nginx
- server = Thin::Server.new(CloudController.bind_address, CloudController.external_port)
-else
- socket = CloudController.instance_socket
- port = CloudController.instance_port
- if socket and port
- $stderr.puts "only one of instance_socket or insecure_instance_port should be enabled in config file...quiting..."
- exit 1
- end
- if socket
- server = Thin::Server.new(socket)
- else
- $stderr.puts "Warning!!! starting up in a known insecure configuration."
- server = Thin::Server.new('127.0.0.1', port)
- end
-end
-
-cc_rack = File.join(cc_root, 'config.ru')
-server.app = Rack::Adapter.load(cc_rack)
-# The routers proxying to us handle killing inactive connections. Set an upper limit
-# just to be safe.
-server.timeout = 15 * 60 # 15 min
-server.start
View
4 bin/dea
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-# Copyright (c) 2009-2011 VMware, Inc.
-
-exec(File.expand_path("../../dea/bin/dea", __FILE__), *ARGV)
View
4 bin/health_manager
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-# Copyright (c) 2009-2011 VMware, Inc.
-
-exec(File.expand_path("../../health_manager/bin/health_manager", __FILE__), *ARGV)
View
4 bin/router
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-# Copyright (c) 2009-2011 VMware, Inc.
-
-exec(File.expand_path("../../router/bin/router", __FILE__), *ARGV)
View
617 bin/vcap
@@ -1,617 +0,0 @@
-#!/usr/bin/env ruby
-# Copyright (c) 2009-2011 VMware, Inc.
-#
-# Usage: bin/vcap_system [start|stop|restart|tail|status] [component ...]
-#
-# Omit component name to apply the operation to these components:
-#
-# core
-# - router
-# - cloud_controller
-# - health_manager
-# - stager
-# - package_cache
-# - dea
-# - uaa
-# - acm
-#
-# services
-# - redis
-# - mysql
-# - mongo
-# - neo4j
-
-require 'yaml'
-require 'fileutils'
-require 'optparse'
-
-require 'rubygems'
-require 'eventmachine'
-require 'nats/client'
-
-DIR = File.dirname(__FILE__)
-SERVICE_DIR = File.join(DIR, '/services')
-TMP = "/tmp/vcap-run"
-FileUtils.mkdir_p(TMP)
-
-class Component
- attr :name
- attr :path
-
- def initialize(name, configuration_path = nil)
- @name = name
- @configuration_path = configuration_path
-
- if core?
- @path = File.join(DIR, name)
- # Sane default for location of configuration file
- @configuration_path ||= File.expand_path(File.join(DIR, "..", name, "config", "#{name}.yml"))
- else
- @path = File.join(SERVICE_DIR, name)
- # Sane default for location of service configuration file
- pre = name.sub(/_node|_gateway/,'')
- @configuration_path ||= File.expand_path(File.join(DIR, "../services", pre, "config", "#{name}.yml"))
- end
- end
-
- def is_cloud_controller?
- @name =~ /cloud_controller/i
- end
-
- def is_router?
- @name =~ /router/i
- end
-
- def to_s
- name
- end
-
- def core?
- Run.core.include? name
- end
-
- def service?
- Run.services.include? name
- end
-
- def exists?
- File.exists? @path
- end
-
- def configuration
- @configuration ||= YAML.load(File.read(@configuration_path))
- end
-
- def pid_file
- configuration["pid"] || configuration['pid_filename'] || raise("#{@configuration_path} does not specify location of pid file")
- end
-
- def log_file?
- !configuration["log_file"].nil?
- end
-
- def log_file
- log_file = configuration["log_file"]
- log_file || File.join(TMP, "#{name}.log")
- end
-
- def pid
- if File.exists?(pid_file)
- body = File.read(pid_file)
- body.to_i if body
- end
- end
-
- def running?
- running = false
- # Only evaluate 'pid' once per call to 'running?'
- if procid = pid
- running = `ps -o rss= -p #{procid}`.length > 0
- end
- running
- end
-
- def component_start_path
- exec_path = path.dup
- if $configdir
- config_file = File.join($configdir, "#{name}.yml")
- if File.exists?(config_file)
- exec_path << " -c #{config_file}"
- end
- end
- if is_router? && $port
- exec_path << " -p #{$port}"
- end
- exec_path
- end
-
- def start
- if !running?
-
- pid = fork do
- # Capture STDOUT when no log file is configured
- if !log_file?
- stdout = File.open(log_file, 'a')
- stdout.truncate(0)
- STDOUT.reopen(stdout)
- stderr = File.open(log_file, 'a')
- STDERR.reopen(stderr)
- end
- # Make sure db is setup, this is slow and we should make it faster, but
- # should help for now.
- if is_cloud_controller?
- Dir.chdir("#{File.dirname(__FILE__)}/../cloud_controller") { `bundle exec rake db:migrate CLOUD_CONTROLLER_CONFIG=#{@configuration_path}` }
- end
- exec("#{component_start_path}")
- end
-
- Process.detach(pid)
-
- start = Time.now
- while ((Time.now - start) < 10)
- break if running?
- sleep (0.25)
- end
- end
-
- status
-
- if !running?
- if File.exists?(log_file)
- log = File.read(log_file)
- STDERR.puts "LOG:\n #{log}" if !log.empty?
- end
- end
- end
-
- def stop
- return status unless running?
-
- kill = "kill -TERM #{pid}"
- `#{kill} 2> /dev/null`
-
- if $? != 0
- STDERR.puts "#{'Failed'.red} to stop #{name}, possible permission problem\?"
- return
- end
-
- # Return status if we succeeded in stopping
- return status unless running?
-
- if running?
- sleep(0.25)
- if running?
- kill = "kill -9 #{pid}"
- `#{kill} 2> /dev/null`
- end
- end
- status
- end
-
- def status
- status = running? ? 'RUNNING'.green : 'STOPPED'.red
- puts "#{name.ljust(20)}:\t #{status}"
- end
-
-end
-
-# This is used to bring up and down the NATS messaging server.
-class NatsServer
-
- attr_reader :was_running
- alias :was_running? :was_running
-
- class << self
- def kill_autostart_server
- pid ||= File.read(NATS::AUTOSTART_PID_FILE).chomp.to_i
- %x[kill -9 #{pid}] if pid
- %x[rm #{NATS::AUTOSTART_PID_FILE}]
- %x[rm #{NATS::AUTOSTART_LOG_FILE}]
- end
- end
-
- def initialize(uri=NATS::DEFAULT_URI, pid_file=NATS::AUTOSTART_PID_FILE)
- @uri = URI.parse(uri)
- @pid_file = pid_file
- end
-
- def server_pid
- @pid ||= File.read(@pid_file).chomp.to_i
- end
-
- def start_server
- if NATS.server_running? @uri
- @was_running = true
- return
- end
-
- nats_server = `which nats-server`
- unless $? == 0 && nats_server
- STDERR.puts "Could not locate a nats-server, exiting.".red
- exit 1
- end
- nats_server.chomp!
- `#{nats_server} -p #{@uri.port} -P #{@pid_file} -d 2> /dev/null`
- NATS.wait_for_server(@uri, 5)
- end
-
- def is_running?
- NATS.server_running? @uri
- end
-
- def kill_server
- if File.exists? @pid_file
- %x[kill -9 #{server_pid} 2> /dev/null]
- %x[rm #{@pid_file} 2> /dev/null]
- %x[rm #{NATS::AUTOSTART_LOG_FILE} 2> /dev/null]
- end
- end
-end
-
-class RedisServer
- DEFAULT_CONFIG_PATH = File.expand_path('../config/redis-server.conf', __FILE__)
-
- def initialize(pid_filename, config_path=DEFAULT_CONFIG_PATH)
- @config_path = config_path
- @pid_filename = pid_filename
- @redis_path = `which redis-server`.chomp
- unless $? == 0
- STDERR.puts "Could not find redis-server, exiting.".red
- exit 1
- end
- @pid = read_pidfile
- end
-
- def start
- return if running?
- @pid = fork do
- log_file = File.join(TMP, 'redis-server.log')
- stdout = File.open(log_file, 'a')
- STDOUT.reopen(stdout)
- stderr = File.open(log_file, 'a')
- STDERR.reopen(stderr)
- exec("#{@redis_path} #{@config_path}")
- end
- Process.detach(@pid)
- File.open(@pid_filename, 'w+') {|f| f.write(@pid) }
- end
-
- def stop
- return unless running?
- Process.kill('TERM', @pid)
- @pid = nil
- end
-
- private
-
- def read_pidfile
- if File.exist?(@pid_filename)
- File.read(@pid_filename).chomp.to_i
- else
- nil
- end
- end
-
- def running?
- return false unless @pid
- File.exist?(File.join('/proc', @pid.to_s))
- end
-end
-
-
-module Run
- DEFAULT_REDIS_PIDFILE = File.join(TMP, 'redis-server.pid')
-
- def self.start_init
- nats_server = NatsServer.new
- nats_server.start_server
- RedisServer.new(DEFAULT_REDIS_PIDFILE).start
- end
-
- def self.start(args)
- self.start_init
- components(args).each(&:start)
- end
-
- def self.stop_cleanup
- # Only process this if no one else running..
- running_components = components([]).select {|c| c.running?}.map{|c| c.name }
- return unless running_components.empty?
- RedisServer.new(DEFAULT_REDIS_PIDFILE).stop
- nats_server = NatsServer.new
- return unless nats_server.is_running?
- nats_server.kill_server
- end
-
- def self.stop(args)
- components(args).each(&:stop)
- self.stop_cleanup
- end
-
- def self.restart(args)
- stop(args)
- start(args)
- end
-
- def self.reset(args)
- unless $noprompt
- exit unless ask_to_continue "#{'CAUTION'.red}: All data will be lost. Continue?"
- end
-
- # Try not to shoot ourselves in the foot..
- running_components = components([]).select {|c| c.running?}.map{|c| c.name }
- unless running_components.empty?
- puts "It looks like the following components are already running: #{running_components.join(', ')}"
- puts "Resetting VCAP now may produce unintended results."
- exit unless ask_to_continue
- puts
- end
-
- cc_dir = File.expand_path(File.join(DIR, '..', 'cloud_controller'))
- run_command("Resetting the CloudController database", "cd #{cc_dir} 2>&1 && bundle exec rake db:drop 2>&1")
- puts
-
- cc_log_dir = File.join(cc_dir, 'log')
- run_command("Clearing the CloudController logs", "cd #{cc_log_dir} 2>&1 && rm -f *.log 2>&1")
- puts
-
- # TODO - Need to connect to mysql and unprovision any orphaned DBs
- kill_service_instances('redis', /redis-server/)
- puts
- kill_service_instances('mongodb', /mongod/)
- puts
- kill_service_instances('neo4j', /neo4j/ )
- puts
-
- puts "Cleaning shared directories:"
- dirs = %w[/var/vcap/services /var/vcap/shared /var/vcap/sys /var/vcap.local/* /tmp/vcap-run]
- max_len = dirs.reduce(0) {|cur_max, dir| dir.length > cur_max ? dir.length : cur_max}
- dirs.each do |dir|
- run_command(" %-#{max_len}s" % [dir], "rm -rf #{dir}")
- end
- end
-
- # Make tail exits fast and clean
- def self.exit_tails
- unless @tpids.empty?
- kill = "kill -9 #{@tpids.join(' ')}"
- `#{kill} 2> /dev/null`
- end
- exit!
- end
-
- def self.tail(args)
- tail = 'tail'
-
- # Annoying when CTRL-C takes forever
- trap('TERM') { Run.exit_tails }
- trap('INT') { Run.exit_tails }
-
- if RUBY_PLATFORM =~ /linux/i
- # tail in coreutils 7.5 uses inotify
- tail_version = `tail --version | grep coreutils | head -n1`.slice(/\d+.\d+/)
- if tail_version < '7.5'
- path = `which inotail`
- tail = path.strip if $?.success?
- end
- end
-
- @tpids = []
- EM.run do
- components(args).map do |component|
- next unless component.running?
- args = [tail, '-f', component.log_file]
- tpid = EM.get_subprocess_pid( EM.popen(args.join(' '), Tail, component).signature )
- @tpids << tpid
- end
- if @tpids.empty?
- puts 'No tailable components currently running.'
- EM.stop
- end
- end
- end
-
- module Tail
- include EM::Protocols::LineText2
-
- def initialize(component)
- @component = component
- end
-
- def prefix
- "%s --> " % @component.name.rjust(15)
- end
-
- def receive_line(line)
- puts prefix + line
- if line.start_with?('F') # FATAL
- puts prefix + "fatal error, closing tail"
- close_connection_after_writing
- end
- end
-
- end
-
- def self.status(args)
- components(args).each(&:status)
- end
-
- private
-
- def self.core
- %w(router cloud_controller dea health_manager stager uaa acm package_cache)
- end
-
- def self.services
- %w(redis mysql mongodb neo4j)
- end
-
- def self.alias_args(args)
- aliased = []
- args.each do |arg|
- case arg
- when 'all'
- aliased.concat(Run.core + Run.services)
- when 'core'
- aliased.concat Run.core
- when 'services'
- aliased.concat Run.services
- when 'mongo'
- aliased << 'mongodb'
- else
- aliased << arg
- end
- end
- aliased
- end
-
- def self.expand_args(args)
- args = Run.alias_args(args)
- new_args = []
- args.each do |arg|
- if Run.core.include? arg
- new_args << arg
- else # This is a service, expand in place here..
- new_args << "#{arg}_gateway"
- new_args << "#{arg}_node"
- end
- end
- new_args
- end
-
- def self.components(args)
- args = (Run.core + Run.services) if args.empty?
- args = Run.expand_args(args)
- components = args.map do |arg|
- if $configdir
- config_file = File.join($configdir, "#{arg}.yml")
- if ! File.exists?(config_file)
- config_file = nil
- end
- end
- component = Component.new(arg, config_file)
- component if component.exists?
- end.compact
- STDERR.puts "Don't know how to process '#{args.inspect}' \?\?" if components.empty?
- components
- end
-
- def self.pad_left(str, padlen=2)
- pad_str = " " * padlen
- str.split("\n") \
- .map {|line| pad_str + line } \
- .join("\n")
- end
-
- def self.run_command(desc, command)
- print desc
- output = `#{command}`
- if $? == 0
- puts " Ok".green
- else
- puts " Failed".red
- puts " '#{command}' exited with status '#{$?}', output:"
- puts pad_left(output, 2)
- end
- [$?, output]
- end
-
- def self.ask_to_continue(prompt="Would you like to continue?")
- should_continue = nil
- while should_continue == nil
- print prompt + " (y/N) "
- choice = STDIN.gets.chomp
- if choice.empty? || /^n/i.match(choice)
- should_continue = false
- elsif /^y/i.match(choice)
- should_continue = true
- end
- end
- should_continue
- end
-
- def self.find_processes(cmd_re)
- output = `ps ax -o pid= -o command=`
- ret = []
- output.split("\n").each do |line|
- pid, cmd = line.split(' ', 2)
- ret << {:pid => pid, :command => cmd} if cmd_re.match(cmd)
- end
- ret
- end
-
- def self.kill_service_instances(name, cmd_re)
- print "Checking for stray #{name} instances"
- instances = find_processes(cmd_re)
- puts " Ok".green
-
- return if instances.empty?
-
- puts "The following #{name} instances are running:"
- puts " PID COMMAND"
- instances.each do |instance|
- puts " %-6d %s" % [instance[:pid], instance[:command]]
- end
-
- if ask_to_continue("Would you like to kill them?")
- run_command("Killing instances", "kill -9 #{instances.map{|i| i[:pid]}.join(' ')}")
- end
- end
-
-end
-
-module VcapStringExtensions
-
- def red
- colorize("\e[0m\e[31m")
- end
-
- def green
- colorize("\e[0m\e[32m")
- end
-
- def yellow
- colorize("\e[0m\e[33m")
- end
-
- def bold
- colorize("\e[0m\e[1m")
- end
-
- def colorize(color_code)
- unless $nocolor
- "#{color_code}#{self}\e[0m"
- else
- self
- end
- end
-end
-
-class String
- include VcapStringExtensions
-end
-
-args = ARGV.dup
-opts_parser = OptionParser.new do |opts|
- opts.on('--port PORT') { |port| $port = port.to_i }
- opts.on('--configdir CONFIGDIR', '-c CONFIGDIR') { |dir| $configdir = File.expand_path(dir.to_s) }
- opts.on('--config CONFIGDIR') { |dir| $configdir = File.expand_path(dir.to_s) }
- opts.on('--no-color', '--nocolor', '--nc') { $nocolor = true }
- opts.on('--noprompt', '-n') { $noprompt = true }
-
-end
-$configdir ||= ENV['CLOUD_FOUNDRY_CONFIG_PATH']
-args = opts_parser.parse!(args)
-
-$nocolor = true unless STDOUT.tty?
-
-if args.empty?
- STDERR.puts "Usage: #{$0} [start|stop|restart|tail|status] [COMPONENT] [--no-color] [--config CONFIGDIR]"
-else
- command = args.shift.downcase
- if Run.respond_to?(command)
- Run.send(command, args)
- else
- STDERR.puts "Don't know what to do with #{command.inspect}"
- end
-end
View
4 dev_setup/bin/vcap
@@ -334,7 +334,7 @@ opts_parser = OptionParser.new do |opts|
opts.on('--port PORT') { |port| $port = port.to_i }
opts.on('--configdir CONFIGDIR', '-c CONFIGDIR') { |dir| $config_dir = File.expand_path(dir.to_s) }
opts.on('--config CONFIGDIR') { |dir| $config_dir = File.expand_path(dir.to_s) }
- opts.on('--vcapdir VCAP_DIR', '-v VCAP_DIR') { |dir| $vcap_dir = File.expand_path(dir.to_s) }
+ opts.on('--vcapdir VCAP_DIR', '-v VCAP_DIR') { |dir| $vcap_home = File.expand_path(dir.to_s) }
opts.on('--logdir LOG_DIR', '-l LOG_DIR') { |dir| $log_dir = File.expand_path(dir.to_s) }
opts.on('--no-color', '--nocolor', '--nc') { $nocolor = true }
opts.on('--noprompt', '-n') { $noprompt = true }
@@ -346,7 +346,7 @@ puts "- Excluded components: #{excluded}.\n See dev_setup/README for details" i
args = opts_parser.parse!(args)
ENV['CLOUD_FOUNDRY_CONFIG_PATH'] = $config_dir
-DIR = $vcap_dir || File.expand_path("../../../bin", __FILE__)
+DIR = File.join($vcap_home, "vcap", "bin")
SERVICE_DIR = File.join(DIR, '/services')
unless $log_dir
View
6 dev_setup/bin/vcap_dev
@@ -56,7 +56,7 @@ if !ARGV.empty? and (vcap_components["components"] & ARGV).empty?
end
vcap_components["components"] &= ARGV unless ARGV.empty?
-unless File.exists?(File.join(deployment_info["cloudfoundry_path"], "bin", "vcap"))
+unless File.exists?(File.join(deployment_info["cloudfoundry_path"], "dev_setup", "bin", "vcap"))
puts "Cannot find vcap repo. Please specify the deployment name or the deployment home directory where to find the config file"
exit 1
end
@@ -103,8 +103,8 @@ def exec_cmd(cmd)
end
ruby_binary = File.join(ruby_bin_dir, "ruby")
-vcap_path = File.join(deployment_info["cloudfoundry_path"], "bin")
+vcap_home = File.join(deployment_info["cloudfoundry_home"])
vcap_launch = File.join(script_dir, "vcap")
puts "Using cloudfoundry config from #{deployment_config_path}"
-exec_cmd("#{ruby_binary} #{vcap_launch} #{command} #{vcap_components["components"].join(" ")} -c #{deployment_config_path} -v #{vcap_path} -l #{deployment_info["deployment_log_path"]}")
+exec_cmd("#{ruby_binary} #{vcap_launch} #{command} #{vcap_components["components"].join(" ")} -c #{deployment_config_path} -v #{vcap_home} -l #{deployment_info["deployment_log_path"]}")
View
47 dev_setup/bin/vcap_dev_setup
@@ -15,7 +15,7 @@ OPTIONS:
-c deployment config
-d cloudfoundry home
-D cloudfoundry domain (default: vcap.me)
- -r cloud foundry repo
+ -r cloud foundry repo base
-b cloud foundry repo branch/tag/SHA
EOF
}
@@ -29,13 +29,15 @@ function run_cmd () {
}
function clear_bundler_settings () {
+ [ $# -ge 1 ] || return 1
+ local DIR=$1
# Do we have a Bundler problem?
- find $CLOUDFOUNDRY_HOME/vcap -type d -name .bundle | grep -Fq .bundle || return 0
+ find $DIR -type d -name .bundle | grep -Fq .bundle || return 0
if [ "$ALL" != true ]; then
read -p "Remembered Bundler options could cause you troubles, do you want me to clear them for you? [Y/n]"
[[ $REPLY =~ ^[nN] ]] && return 0
fi
- (cd $CLOUDFOUNDRY_HOME/vcap && find -type d -name .bundle -prune -exec rm -r {} \; )
+ (cd $DIR && find -type d -name .bundle -prune -exec rm -r {} \; )
}
RUBY="/usr/bin/ruby"
@@ -70,7 +72,7 @@ do
CLOUDFOUNDRY_DOMAIN=$OPTARG
;;
r)
- VCAP_REPO=$OPTARG
+ VCAP_REPO_BASE=$OPTARG
;;
b)
VCAP_REPO_BRANCH=$OPTARG
@@ -90,8 +92,8 @@ if [ -z "$CLOUDFOUNDRY_DOMAIN" ]; then
CLOUDFOUNDRY_DOMAIN=vcap.me
fi
-if [ -z "$VCAP_REPO" ]; then
- VCAP_REPO=https://github.com/cloudfoundry/vcap.git
+if [ -z "$VCAP_REPO_BASE" ]; then
+ VCAP_REPO_BASE=https://github.com/cloudfoundry
fi
if [ -z "$VCAP_REPO_BRANCH" ]; then
@@ -144,19 +146,30 @@ ${GEM} list -i rake -i || sudo ${GEM} install rake -q --no-ri --no-rdoc > /dev/n
echo "Installing git..."
run_cmd apt-get $APT_CONFIG install -qym git-core
+readonly CORE_REPOS=(cloud_controller dea router stager)
+
[ -d $CLOUDFOUNDRY_HOME ] || mkdir $CLOUDFOUNDRY_HOME
-if [ ! -d $CLOUDFOUNDRY_HOME/vcap ]; then
- if ! (cd $CLOUDFOUNDRY_HOME
- git clone $VCAP_REPO
- cd vcap
- git submodule update --init
- git checkout $VCAP_REPO_BRANCH
- ); then
- echo "Unable to clone cloudfoundry repo."
- exit 1
+for REPO in vcap "${CORE_REPOS[@]}"; do
+ if [ ! -d $CLOUDFOUNDRY_HOME/$REPO ]; then
+ if ! (cd $CLOUDFOUNDRY_HOME
+ git clone --no-checkout $VCAP_REPO_BASE/$REPO
+ cd $REPO
+ git checkout $VCAP_REPO_BRANCH
+ git submodule update --recursive --init
+ ); then
+ echo "Unable to clone cloudfoundry $REPO repo."
+ exit 1
+ fi
+ else
+ clear_bundler_settings $CLOUDFOUNDRY_HOME/$REPO
fi
-else
- clear_bundler_settings
+done
+
+
+# Our deployment code needs this gem. Using bundler seems like an overkill for
+# the deployment code. So for now just manually install the required gem.
+if ! gem list rake -i > /dev/null; then
+ gem install rake -q --no-ri --no-rdoc > /dev/null 2>&1
fi
# Launch chef
View
2  dev_setup/cookbooks/acm/recipes/default.rb
@@ -25,4 +25,4 @@
mode 0644
end
-cf_bundle_install(File.expand_path(File.join(node["cloudfoundry"]["path"], "acm")))
+cf_bundle_install(File.expand_path("acm", node["cloudfoundry"]["path"]))
View
2  dev_setup/cookbooks/cloud_controller/recipes/default.rb
@@ -28,7 +28,7 @@
:builtin_services => builtin_services
})
end
-cf_bundle_install(File.expand_path(File.join(node["cloudfoundry"]["path"], "cloud_controller")))
+cf_bundle_install(File.expand_path(File.join("cloud_controller", "cloud_controller"), node[:cloudfoundry][:home]))
staging_dir = File.join(node[:deployment][:config_path], "staging")
View
2  dev_setup/cookbooks/cloudfoundry/definitions/cloudfoundry_service.rb
@@ -16,5 +16,5 @@
service_name = params[:name]
# Work around for RabbitMQ service since its directory name is "rabbit"
service_name = "rabbit" if service_name == "rabbitmq"
- cf_bundle_install(File.expand_path(File.join(node[:cloudfoundry][:path], "services", service_name)))
+ cf_bundle_install(File.join(node[:cloudfoundry][:path], "services", service_name))
end
View
2  dev_setup/cookbooks/dea/recipes/default.rb
@@ -33,4 +33,4 @@
mode 0644
end
-cf_bundle_install(File.expand_path(File.join(node["cloudfoundry"]["path"], "dea")))
+cf_bundle_install(File.join(node[:cloudfoundry][:home], "dea"))
View
1  dev_setup/cookbooks/deployment/recipes/default.rb
@@ -52,6 +52,7 @@
:name => node[:deployment][:name],
:ruby_bin_dir => File.join(node[:ruby][:path], "bin"),
:maven_bin_dir => File.join(node[:maven][:path], "bin"),
+ :cloudfoundry_home => node[:cloudfoundry][:home],
:cloudfoundry_path => node[:cloudfoundry][:path],
:deployment_log_path => node[:deployment][:log_path]
})
View
1  dev_setup/cookbooks/deployment/templates/default/deployment_info.json.erb
@@ -2,6 +2,7 @@
"name": "<%= @name %>",
"ruby_bin_dir": "<%= @ruby_bin_dir %>",
"maven_bin_dir": "<%= @maven_bin_dir %>",
+ "cloudfoundry_home": "<%= @cloudfoundry_home %>",
"cloudfoundry_path": "<%= @cloudfoundry_path %>",
"deployment_log_path": "<%= @deployment_log_path %>"
}
View
2  dev_setup/cookbooks/health_manager/recipes/default.rb
@@ -11,4 +11,4 @@
mode 0644
end
-cf_bundle_install(File.expand_path(File.join(node["cloudfoundry"]["path"], "health_manager")))
+cf_bundle_install(File.expand_path(File.join("cloud_controller", "health_manager"), node[:cloudfoundry][:home]))
View
2  dev_setup/cookbooks/nginx/attributes/default.rb
@@ -24,7 +24,7 @@
default[:lua][:path] = File.join(node[:deployment][:home], "deploy", "lua", "lua-#{lua[:version]}")
default[:lua][:cjson_id] = "eyJvaWQiOiI0ZTRlNzhiY2E2MWUxMjEwMDRlNGU3ZDUxZDk1MGUwNGYzMDY4%0AMzE5YzBiYiIsInNpZyI6IkpGUW01bnRxWWllTUxFM0FteGExaG5FamFQOD0i%0AfQ==%0A"
default[:lua][:module_path] = File.join(lua[:path], 'lib', 'lua', lua[:simple_version])
-default[:lua][:plugin_source_path] = File.join(node["cloudfoundry"]["path"], "router", "ext", "nginx")
+default[:lua][:plugin_source_path] = File.join(node["cloudfoundry"]["home"], "router", "ext", "nginx")
default[:lua][:checksums][:source] = "b038e225eaf2a5b57c9bcc35cd13aa8c6c8288ef493d52970c9545074098af3a"
default[:lua][:checksums][:cjson_source] = "9659fef3d4d3bc08b3fbd7827636dad6fb236c83d277b632879cb354f1b2e942"
View
2  dev_setup/cookbooks/router/recipes/default.rb
@@ -11,4 +11,4 @@
mode 0644
end
-cf_bundle_install(File.expand_path(File.join(node["cloudfoundry"]["path"], "router")))
+cf_bundle_install(File.expand_path("router", node[:cloudfoundry][:home]))
View
2  dev_setup/cookbooks/uaa/recipes/default.rb
@@ -26,4 +26,4 @@
EOH
end
-cf_bundle_install(File.expand_path(File.join(node["cloudfoundry"]["path"], "uaa")))
+cf_bundle_install(File.expand_path("uaa", node["cloudfoundry"]["path"]))
View
27 dev_setup/lib/vcap_components.rb
@@ -78,7 +78,7 @@ def vcap_bin
end
def get_path
- @path = File.join(vcap_bin, name)
+ @path ||= File.join(vcap_bin, name)
end
def configuration_file_in
@@ -154,7 +154,7 @@ def start
# Make sure db is setup, this is slow and we should make it faster, but
# should help for now.
if is_cloud_controller?
- cc_dir = File.expand_path(File.join(vcap_bin, '..', 'cloud_controller'))
+ cc_dir = File.expand_path(File.join($vcap_home, 'cloud_controller', 'cloud_controller'))
Dir.chdir(cc_dir) { `bundle exec rake db:migrate` }
end
exec("#{component_start_path}")
@@ -214,6 +214,25 @@ class CoreComponent < Component
def core?
true
end
+
+ def initialize(name, configuration_file = nil)
+ @path ||= File.join($vcap_home, name, "bin", name)
+ super
+ end
+end
+
+class CCComponent < CoreComponent
+ def initialize(*args)
+ @path = File.join($vcap_home, "cloud_controller", "cloud_controller", "bin", "cloud_controller")
+ super
+ end
+end
+
+class HMComponent < CoreComponent
+ def initialize(*args)
+ @path = File.join($vcap_home, "cloud_controller", "health_manager", "bin", "health_manager")
+ super
+ end
end
class VcapRedisComponent < Component
@@ -366,9 +385,11 @@ def get_configuration_path
# register valid named components
## core
-%w(router cloud_controller dea health_manager uaa acm).each do |core|
+%w(router dea uaa acm).each do |core|
CoreComponent.register(core)
end
+CCComponent.register("cloud_controller")
+HMComponent.register("health_manager")
## standalone
%w(vcap_redis).each do |redis|
Please sign in to comment.
Something went wrong with that request. Please try again.