bosh-cloudfoundry 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. data/.gitignore +18 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +6 -0
  5. data/Guardfile +10 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +242 -0
  8. data/Rakefile +33 -0
  9. data/bosh-cloudfoundry.gemspec +29 -0
  10. data/config/defaults.yml +6 -0
  11. data/lib/bosh-cloudfoundry.rb +34 -0
  12. data/lib/bosh-cloudfoundry/bosh_release_manager.rb +141 -0
  13. data/lib/bosh-cloudfoundry/config.rb +6 -0
  14. data/lib/bosh-cloudfoundry/config/common_config.rb +27 -0
  15. data/lib/bosh-cloudfoundry/config/dea_config.rb +150 -0
  16. data/lib/bosh-cloudfoundry/config/microbosh_config.rb +106 -0
  17. data/lib/bosh-cloudfoundry/config/postgresql_service_config.rb +185 -0
  18. data/lib/bosh-cloudfoundry/config/redis_service_config.rb +179 -0
  19. data/lib/bosh-cloudfoundry/config/system_config.rb +60 -0
  20. data/lib/bosh-cloudfoundry/config_options.rb +362 -0
  21. data/lib/bosh-cloudfoundry/gerrit_patches_helper.rb +47 -0
  22. data/lib/bosh-cloudfoundry/providers.rb +19 -0
  23. data/lib/bosh-cloudfoundry/providers/aws.rb +75 -0
  24. data/lib/bosh-cloudfoundry/system_deployment_manifest_renderer.rb +286 -0
  25. data/lib/bosh-cloudfoundry/version.rb +5 -0
  26. data/lib/bosh/cli/commands/cf.rb +668 -0
  27. data/spec/assets/.gitkeep +0 -0
  28. data/spec/assets/cf-release/jobs/cloud_controller/templates/runtimes.yml +150 -0
  29. data/spec/assets/deployments/aws-core-1-m1.small-free-redis.yml +221 -0
  30. data/spec/assets/deployments/aws-core-1-m1.xlarge-free-postgresql-2-m1.small-free-postgresql.yml +248 -0
  31. data/spec/assets/deployments/aws-core-2-m1.xlarge-dea.yml +195 -0
  32. data/spec/assets/deployments/aws-core-only.yml +178 -0
  33. data/spec/assets/deployments/aws-core-with-nfs.yml +192 -0
  34. data/spec/functional/.gitkeep +0 -0
  35. data/spec/spec_helper.rb +41 -0
  36. data/spec/unit/.gitkeep +0 -0
  37. data/spec/unit/bosh_release_manager_spec.rb +36 -0
  38. data/spec/unit/cf_command_spec.rb +280 -0
  39. data/spec/unit/config/common_config_spec.rb +21 -0
  40. data/spec/unit/config/dea_config_spec.rb +92 -0
  41. data/spec/unit/config/microbosh_config_spec.rb +11 -0
  42. data/spec/unit/config/postgresql_service_config_spec.rb +103 -0
  43. data/spec/unit/config/redis_service_config_spec.rb +103 -0
  44. data/spec/unit/config/system_config_spec.rb +29 -0
  45. data/spec/unit/config_options_spec.rb +64 -0
  46. data/spec/unit/system_deployment_manifest_renderer_spec.rb +93 -0
  47. metadata +246 -0
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format progress
2
+ --color
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-19mode # JRuby in 1.9 mode
5
+ - rbx-19mode
6
+ - ruby-head
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bosh-cloudfoundry.gemspec
4
+ gemspec
5
+
6
+ gem "awesome_print"
@@ -0,0 +1,10 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/bosh/cli/commands/cf.rb$}) { |m| "spec/unit/cf_command_spec.rb" }
7
+ watch(%r{^lib/bosh-cloudfoundry/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
8
+ watch('spec/spec_helper.rb') { "spec" }
9
+ end
10
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Dr Nic Williams
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,242 @@
1
+ # Bosh::CloudFoundry
2
+
3
+ You want CloudFoundry? You can now create, scale, upgrade and patch one or more Cloud Foundry deployments using very simple, easy to learn and remember CLI commands.
4
+
5
+ Currently supports AWS only. OpenStack support is coming. vSphere and vCloud support will require someone to tell me that they really want it.
6
+
7
+ ## NOTE - currently requires latest edge of nearly everything
8
+
9
+ This tool currently requires the latest merged patches. The readme below, from "Usage" onward, is written for when there are public stemcells and final releases.
10
+
11
+ Today, to get everything running:
12
+
13
+ ```
14
+ # on your laptop
15
+ git clone git://github.com/StarkAndWayne/bosh-bootstrap.git
16
+ cd bosh-bootstrap
17
+ bundle
18
+ rake install
19
+
20
+ bosh-bootstrap deploy --latest-stemcell
21
+ bosh-bootstrap ssh
22
+
23
+ # now on the inception VM
24
+ cd /var/vcap/store/repos
25
+ git clone git://github.com/StarkAndWayne/bosh-cloudfoundry.git
26
+ cd bosh-cloudfoundry
27
+ bundle
28
+ gem build *.gemspec && mv *.gem pkg/
29
+ sudo gem install pkg/*.gem --no-ri --no-rdoc
30
+
31
+ export TMPDIR=/var/vcap/store/tmp
32
+ bosh cf upload release --dev
33
+
34
+ bosh cf prepare system production --release-name appcloud-dev
35
+ # prompts for a DNS host for your CloudFoundry, such as mycompany.com
36
+ # will generate a new IP address
37
+ # now setup your DNS for *.mycompany.com => new IP address
38
+ # the re-run:
39
+ bosh cf prepare system production
40
+
41
+ bosh cf upload stemcell --latest
42
+ bosh cf merge gerrit 37/13137/4 84/13084/4 83/13583/1
43
+ bosh deploy
44
+
45
+ # now we can grow our single VM deployment
46
+
47
+ bosh cf change deas 1
48
+ bosh cf add service postgresql
49
+ bosh deploy
50
+ ```
51
+
52
+ Overtime, as you add more DEAs and other service nodes, your set of VMs might look like:
53
+
54
+ ```
55
+ $ bosh vms
56
+ +-----------------------------+---------+---------------------------+-----------------------------+
57
+ | Job/index | State | Resource Pool | IPs |
58
+ +-----------------------------+---------+---------------------------+-----------------------------+
59
+ | core/0 | running | core | 10.4.70.116, 54.235.200.165 |
60
+ | dea/0 | running | dea | 10.4.49.7 |
61
+ | dea/1 | running | dea | 10.111.39.12 |
62
+ | postgresql_m1_medium_free/0 | running | postgresql_m1_medium_free | 10.4.71.164 |
63
+ | postgresql_m1_small_free/0 | running | postgresql_m1_small_free | 10.110.83.128 |
64
+ | postgresql_m1_small_free/1 | running | postgresql_m1_small_free | 10.189.103.26 |
65
+ +-----------------------------+---------+---------------------------+-----------------------------+
66
+ ```
67
+
68
+ ## Requirements
69
+
70
+ * Ruby 1.9
71
+ * BOSH running on AWS (other CPIs coming)
72
+
73
+ ## Usage
74
+
75
+ The tool is very simple to use and to get CloudFoundry deployed on a small set of initial servers.
76
+
77
+ ```
78
+ gem install bosh-cloudfoundry
79
+ bosh cf prepare system demo
80
+ bosh cf deploy
81
+ ```
82
+
83
+ The above can be run the following from your local laptop or a server, such as an `bosh-bootstrap` inception server.
84
+
85
+ The latter is preferred. As the Cloud Foundry BOSH release (`cf-release`) is 1.5 Gb, it may be preferable to manage your Cloud Foundry deployments from your inception server, as created/prepared via `bosh-bootstrap`.
86
+
87
+ ```
88
+ bosh-bootstrap deploy --latest-stemcell
89
+ bosh-bootstrap ssh
90
+
91
+ # now on the inception VM
92
+ gem install bosh-cloudfoundry
93
+ export TMPDIR=/var/vcap/store/tmp
94
+ bosh cf prepare system production
95
+ # prompts for a DNS host for your CloudFoundry, such as mycompany.com
96
+ bosh cf change deas 1
97
+ bosh cf add service postgresql 1
98
+ bosh deploy
99
+ ```
100
+
101
+ During `bosh cf prepare system production`, it will automatically upload the latest release of CloudFoundry (the latest final [BOSH release](http://github.com/cloudfoundry/cf-release)) and the latest stable stemcell (becomes the base AMI for AWS, for example).
102
+
103
+ NOTE: `export TMPDIR=/var/vcap/store/tmp` tells the upload process to use the larger mounted volume at `/var/vcap/store`.
104
+
105
+ You can upload a more recent stemcell or create a new one from source, respectively:
106
+
107
+ ```
108
+ bosh cf upload stemcell --latest
109
+ bosh cf upload stemcell --custom
110
+ ```
111
+
112
+ You can upload a more recent final BOSH release of CloudFoundry, or create a non-final version from the very latest commits to the CloudFoundry BOSH release, respectively:
113
+
114
+ ```
115
+ bosh cf upload release
116
+ bosh cf upload release --dev
117
+ ```
118
+
119
+ ### All available commands
120
+
121
+ Prefix each with `bosh`:
122
+
123
+ ```
124
+ cf prepare system [<name>] [--core-ip ip] [--root-dns dns]
125
+ [--core-server-flavor flavor] [--release-name name] [--release-version
126
+ version] [--stemcell-name name] [--stemcell-version version]
127
+ [--admin-emails email1,email2] [--skip-validations]
128
+ create CloudFoundry system
129
+ --core-ip ip Static IP for CloudController/router, e.g. 1.2.3.4
130
+ --root-dns dns Base DNS for CloudFoundry applications, e.g. vcap.me
131
+ --core-server-flavor flavor Flavor of the CloudFoundry Core server. Default: 'm1.large'
132
+ --release-name name Name of BOSH release within target BOSH. Default: 'appcloud'
133
+ --release-version version Version of target BOSH release within target BOSH. Default: 'latest'
134
+ --stemcell-name name Name of BOSH stemcell within target BOSH. Default: 'bosh-stemcell'
135
+ --stemcell-version version Version of BOSH stemcell within target BOSH. Default: determines latest for stemcell
136
+ --admin-emails email1,email2 Admin email accounts in created CloudFoundry
137
+ --skip-validations Skip all validations
138
+
139
+ cf change deas [<server_count>] [--flavor flavor]
140
+ change the number/flavor of DEA servers (servers that run CF apps)
141
+ --flavor flavor Change flavor of all DEA servers
142
+
143
+ cf add service <service_name> [<additional_count>] [--flavor flavor]
144
+ add additional CloudFoundry service node
145
+ --flavor flavor Server flavor for additional service nodes
146
+
147
+ cf upload stemcell [--latest] [--custom]
148
+ download/create stemcell & upload to BOSH
149
+ --latest Use latest stemcell; possibly not tagged stable
150
+ --custom Create custom stemcell from BOSH git source
151
+
152
+ cf upload release [--dev]
153
+ fetch & upload public cloudfoundry release to BOSH
154
+ --dev Create development release from very latest cf-release commits
155
+
156
+ cf deploy
157
+ deploy CloudFoundry system or apply any changes
158
+
159
+ cf watch nats
160
+ subscribe to all nats messages within CloudFoundry
161
+ ```
162
+
163
+ ## Services
164
+
165
+ By default your CloudFoundry deployment comes with no built-in services. Instead, you easily enable each one and allocate it resources using the `bosh cf add service NAME` command; then deploy again.
166
+
167
+ ```
168
+ $ bosh cf add service postgresql
169
+ $ bosh cf add service redis
170
+ $ bosh deploy
171
+ ```
172
+
173
+ Eventually the new service node servers will be up and running, and then the VMC client will be able to create/bind/delete these services with your CloudFoundry applications.
174
+
175
+ For example:
176
+
177
+ ```
178
+ ============== System Services ==============
179
+
180
+ +------------+---------+---------------------------------------+
181
+ | Service | Version | Description |
182
+ +------------+---------+---------------------------------------+
183
+ | postgresql | 9.0 | PostgreSQL database service (vFabric) |
184
+ | redis | 2.2 | Redis key-value store service |
185
+ +------------+---------+---------------------------------------+
186
+
187
+ =========== Provisioned Services ============
188
+
189
+ +------------------+------------+
190
+ | Name | Service |
191
+ +------------------+------------+
192
+ | postgresql-6d01e | postgresql |
193
+ | postgresql-ff0c1 | postgresql |
194
+ | redis-d0d3d | redis |
195
+ +------------------+------------+g
196
+ ```
197
+
198
+ ## Orders of easiness vs powerfulness
199
+
200
+ ```
201
+
202
+ +--------------+ +-----------------+ +---------------------+
203
+ | | | | | |
204
+ | CLI | | | | |
205
+ | commands +---->| | | |
206
+ | | | system | | deployment |
207
+ | | | config | | manifest |
208
+ +--------------+ | (yaml) | | (yaml) |
209
+ | +------>| |
210
+ | | | |
211
+ | | | |
212
+ | | | |
213
+ | | | |
214
+ +-----------------+ | |
215
+ | |
216
+ | |
217
+ | |
218
+ | |
219
+ | |
220
+ | |
221
+ | |
222
+ | |
223
+ | |
224
+ | |
225
+ +---------------------+
226
+ ```
227
+
228
+ ## Development
229
+
230
+ ```
231
+ bundle
232
+ bundle exec rake spec
233
+ bundle exec rake install
234
+ ```
235
+
236
+ ## Contributing
237
+
238
+ 1. Fork it
239
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
240
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
241
+ 4. Push to the branch (`git push origin my-new-feature`)
242
+ 5. Create new Pull Request
@@ -0,0 +1,33 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
4
+
5
+ require "rubygems"
6
+ require "bundler"
7
+ Bundler.setup(:default, :test, :development)
8
+
9
+ require "bundler/gem_tasks"
10
+
11
+ require "rake/dsl_definition"
12
+ require "rake"
13
+ require "rspec/core/rake_task"
14
+
15
+
16
+ if defined?(RSpec)
17
+ namespace :spec do
18
+ desc "Run Unit Tests"
19
+ unit_rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
20
+ t.pattern = "spec/unit/**/*_spec.rb"
21
+ t.rspec_opts = %w(--format progress --color -d)
22
+ end
23
+
24
+ desc "Run Integration Tests"
25
+ functional_rspec_task = RSpec::Core::RakeTask.new(:functional) do |t|
26
+ t.pattern = "spec/functional/**/*_spec.rb"
27
+ t.rspec_opts = %w(--format progress --color)
28
+ end
29
+ end
30
+
31
+ desc "Install dependencies and run tests"
32
+ task :spec => %w(spec:unit spec:functional)
33
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bosh-cloudfoundry/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "bosh-cloudfoundry"
8
+ gem.version = Bosh::Cloudfoundry::VERSION
9
+ gem.authors = ["Dr Nic Williams"]
10
+ gem.email = ["drnicwilliams@gmail.com"]
11
+ gem.description = %q{Create and manage your Cloud Foundry deployments}
12
+ gem.summary = %q{Create and manage your Cloud Foundry deployments via the BOSH CLI}
13
+ gem.homepage = "https://github.com/StarkAndWayne/bosh-cloudfoundry"
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency "bosh_cli", ">=1.0.3"
22
+ gem.add_dependency "rake" # file_utils sh helper
23
+ gem.add_dependency "net-dns"
24
+ gem.add_dependency "fog", ">= 1.8.0"
25
+ gem.add_development_dependency "rspec"
26
+ gem.add_development_dependency "ci_reporter"
27
+ gem.add_development_dependency "debugger"
28
+ gem.add_development_dependency "guard-rspec"
29
+ end
@@ -0,0 +1,6 @@
1
+ ---
2
+
3
+ logging:
4
+ level: INFO
5
+
6
+ base_systems_dir: /var/vcap/store/systems
@@ -0,0 +1,34 @@
1
+ require "bosh-cloudfoundry/version"
2
+
3
+ module Bosh; module CloudFoundry; end; end
4
+
5
+ require "logger"
6
+ require "common/common"
7
+ require "common/thread_formatter"
8
+ require "cli"
9
+
10
+ # for generating password
11
+ require 'openssl'
12
+
13
+ # for the #sh helper
14
+ require "rake"
15
+ require "rake/file_utils"
16
+
17
+ # for validating DNS -> IP setups
18
+ require 'net/dns'
19
+
20
+ # for:
21
+ # * validating compute flavors
22
+ # * provisioning IP addresses
23
+ require "fog"
24
+ require 'fog/aws/models/compute/flavors'
25
+
26
+ # CLI mixins
27
+ require "bosh-cloudfoundry/config_options"
28
+ require "bosh-cloudfoundry/bosh_release_manager"
29
+ require "bosh-cloudfoundry/gerrit_patches_helper"
30
+
31
+ require "bosh-cloudfoundry/config"
32
+ require "bosh-cloudfoundry/providers"
33
+
34
+ require "bosh-cloudfoundry/system_deployment_manifest_renderer"
@@ -0,0 +1,141 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ module Bosh; module CloudFoundry; end; end
4
+
5
+ # There are two concepts of "latest".
6
+ # * for upload: "latest" is the highest release in cf-release
7
+ # * for manifest creation: "latest" is the highest release already uploaded to the BOSH
8
+ module Bosh::CloudFoundry::BoshReleaseManager
9
+
10
+ # @return [Array] BOSH releases available in target BOSH
11
+ # [{"name"=>"appcloud", "versions"=>["124", "126"], "in_use"=>[]}]
12
+ def bosh_releases
13
+ @bosh_releases ||= releases = director.list_releases
14
+ end
15
+
16
+ # @return [Array] BOSH release names available in target BOSH
17
+ def bosh_release_names
18
+ @bosh_release_names ||= bosh_releases.map { |rel| rel["name"] }
19
+ end
20
+
21
+ # @return [Array] BOSH release versions for specific release name in target BOSH
22
+ def bosh_release_versions(release_name)
23
+ if release = bosh_releases.find { |rel| rel["name"] == release_name }
24
+ release["versions"]
25
+ else
26
+ []
27
+ end
28
+ end
29
+
30
+ def release_name_version
31
+ "#{release_name}/#{release_version}"
32
+ end
33
+
34
+ # @return [Version String] BOSH version number; converts 'latest' into actual version
35
+ # TODO implement this; map "latest" to highest uploaded release in BOSH
36
+ # return "unknown" if BOSH has no releases of this name yet
37
+ def effective_release_version
38
+ release_version.to_s
39
+ end
40
+
41
+ # for upload, "latest" is the newest release in cf-release
42
+ def upload_final_release
43
+ release_number = use_latest_release? ?
44
+ latest_uploadable_final_release_number :
45
+ release_version
46
+ chdir(cf_release_dir) do
47
+ bosh_cmd "upload release releases/appcloud-#{release_number}.yml"
48
+ end
49
+ @bosh_releases = nil # reset cache
50
+ end
51
+
52
+ # Looks at the last line of releases/index.yml in cf-release
53
+ # for the latest release number that could be uploaded
54
+ # @returns [String] a number such as "126"
55
+ def latest_uploadable_final_release_number
56
+ chdir(cf_release_dir) do
57
+ return `tail -n 1 releases/index.yml | awk '{print $2}'`.strip
58
+ end
59
+ end
60
+
61
+ # Looks at the last line of releases/index.yml in cf-release
62
+ # for the latest release number that could be uploaded
63
+ # @returns [String] a dev release code such as "126.8-dev"
64
+ def latest_uploadable_dev_release_number
65
+ chdir(cf_release_dir) do
66
+ return `tail -n 1 dev_releases/index.yml | awk '{print $2}'`.strip
67
+ end
68
+ end
69
+
70
+ # @returns [String] absolute path to latest release to be uploaded
71
+ def latest_dev_release_filename
72
+ dev_release_number = latest_uploadable_dev_release_number
73
+ return nil unless dev_release_number.size > 0
74
+ File.join(cf_release_dir, "#{release_name}-#{dev_release_number}.yml")
75
+ end
76
+
77
+ def create_and_upload_dev_release(release_name=default_dev_release_name)
78
+ chdir(cf_release_dir) do
79
+ write_dev_config_file(release_name)
80
+ sh "bosh create release --with-tarball --force"
81
+ sh "bosh -n --color upload release"
82
+ end
83
+ @bosh_releases = nil # reset cache
84
+ end
85
+
86
+ def write_dev_config_file(release_name)
87
+ dev_config_file = "config/dev.yml"
88
+ if File.exist?(dev_config_file)
89
+ dev_config = YAML.load_file(dev_config_file)
90
+ else
91
+ dev_config = {}
92
+ end
93
+ dev_config["dev_name"] = release_name
94
+ File.open(dev_config_file, "w") { |file| file << dev_config.to_yaml }
95
+ end
96
+
97
+ # assume unchanged config/final.yml
98
+ def clone_or_update_cf_release
99
+ cf_release_dirname = File.basename(cf_release_dir)
100
+ if File.directory?(cf_release_dir)
101
+ chdir(cf_release_dir) do
102
+ sh "git pull origin master"
103
+ end
104
+ else
105
+ chdir(releases_dir) do
106
+ sh "git clone #{cf_release_git_repo} #{cf_release_dirname}"
107
+ chdir(cf_release_dirname) do
108
+ sh "git update-index --assume-unchanged config/final.yml 2>/dev/null"
109
+ end
110
+ end
111
+ end
112
+ chdir(cf_release_dir) do
113
+ say "Rewriting all git:// & git@ to https:// ..."
114
+ # Snippet written by Mike Reeves <swampfoxmr@gmail.com> on bosh-users mailing list
115
+ # Date 2012-12-06
116
+ sh "sed -i 's#git@github.com:#https://github.com/#g' .gitmodules"
117
+ sh "sed -i 's#git://github.com#https://github.com#g' .gitmodules"
118
+ sh "git submodule update --init --recursive"
119
+ end
120
+ end
121
+
122
+ def default_release_name
123
+ "appcloud"
124
+ end
125
+
126
+ def default_dev_release_name
127
+ default_release_name + "-dev"
128
+ end
129
+
130
+ def switch_to_development_release
131
+ system_config.release_name = default_dev_release_name
132
+ system_config.release_version = "latest"
133
+ system_config.save
134
+ end
135
+
136
+ def switch_to_final_release
137
+ system_config.release_name = default_release_name
138
+ system_config.release_version = "latest"
139
+ system_config.save
140
+ end
141
+ end