bosh-cloudfoundry 0.4.1 → 0.5.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.
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format progress
2
2
  --color
3
+ --profile
data/ChangeLog.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## v0.5
4
+
5
+ Gerrit is dead. Long live gerrit. This release is for everyone who is getting started or wants to upgrade. Gerrit is dead.
6
+
7
+ A few days ago the core Cloud Foundry team shut down the gerrit hosting of cf-release and several patches that we needed to run Cloud Foundry on AWS and/or OpenStack. Fortunately, all the patches have been merged into the staging branch of the cf-release on github. This new release of bosh-cloudfoundry defaults to creating a development (non-final) release of cf-release from its staging branch.
8
+
9
+ The `bosh cf upload release` command now has a `--branch BRANCH` for uploading a release based on a different branch. It currently defaults to `staging`.
10
+
11
+ In future, when cf-release eventually merges all the required patches into master branch, we will switch to defaulting to `master`.
12
+
13
+ And finally, the big requirement for going v1.0, is for all the required patches to be included in a final release of cf-release.
14
+
3
15
  ## v0.4
4
16
 
5
17
  Defaults to patched dev release (since a cf-release final release doesn't work).
data/README.md CHANGED
@@ -33,7 +33,8 @@ bosh cf prepare system production
33
33
  # the re-run:
34
34
  bosh cf prepare system production
35
35
 
36
- bosh deploy
36
+ # use special "cf deploy" to install VMC & create initial VMC user
37
+ bosh cf deploy
37
38
 
38
39
  # now we can grow our single VM deployment
39
40
 
@@ -74,7 +74,8 @@ module Bosh::CloudFoundry::BoshReleaseManager
74
74
  File.join(cf_release_dir, "#{release_name}-#{dev_release_number}.yml")
75
75
  end
76
76
 
77
- def create_and_upload_dev_release(release_name=default_dev_release_name)
77
+ def create_and_upload_dev_release
78
+ release_name = default_dev_release_name
78
79
  chdir(cf_release_dir) do
79
80
  write_dev_config_file(release_name)
80
81
  sh "bosh -n --color create release --with-tarball --force"
@@ -94,22 +95,29 @@ module Bosh::CloudFoundry::BoshReleaseManager
94
95
  File.open(dev_config_file, "w") { |file| file << dev_config.to_yaml }
95
96
  end
96
97
 
97
- # assume unchanged config/final.yml
98
+ # clones or updates cf-release for a specific branch
99
+ # For all defaults, clones into:
100
+ # * /var/vcap/store/releases/cf-release/master (cf_release_branch_dir)
101
+ #
102
+ # Uses:
103
+ # * releases_dir (e.g. '/var/vcap/store/releases')
104
+ # * cf_release_branch (e.g. 'staging')
105
+ # * cf_release_branch_dir (e.g. '/var/vcap/store/releases/cf-release/staging')
98
106
  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"
107
+ raise "invoke #set_cf_release_branch(branch) first" unless cf_release_branch_dir
108
+ if File.directory?(cf_release_branch_dir)
109
+ chdir(cf_release_branch_dir) do
110
+ sh "git pull origin #{cf_release_branch} --no-recurse-submodules" # recursive is below
103
111
  end
104
112
  else
105
113
  chdir(releases_dir) do
106
- sh "git clone #{cf_release_git_repo} #{cf_release_dirname}"
107
- chdir(cf_release_dirname) do
114
+ sh "git clone #{cf_release_git_repo} #{cf_release_branch_dir}"
115
+ chdir(cf_release_branch_dir) do
108
116
  sh "git update-index --assume-unchanged config/final.yml 2>/dev/null"
109
117
  end
110
118
  end
111
119
  end
112
- chdir(cf_release_dir) do
120
+ chdir(cf_release_branch_dir) do
113
121
  say "Rewriting all git:// & git@ to https:// ..."
114
122
  # Snippet written by Mike Reeves <swampfoxmr@gmail.com> on bosh-users mailing list
115
123
  # Date 2012-12-06
@@ -123,12 +131,13 @@ module Bosh::CloudFoundry::BoshReleaseManager
123
131
  "appcloud"
124
132
  end
125
133
 
126
- def default_dev_release_name
127
- default_release_name + "-dev"
134
+ def default_dev_release_name(branch_name=cf_release_branch)
135
+ suffix = "-#{branch_name || 'dev'}"
136
+ default_release_name + suffix
128
137
  end
129
138
 
130
139
  def switch_to_development_release
131
- system_config.release_name = default_dev_release_name
140
+ system_config.release_name = default_dev_release_name(cf_release_branch)
132
141
  system_config.release_version = "latest"
133
142
  system_config.save
134
143
  end
@@ -138,4 +147,4 @@ module Bosh::CloudFoundry::BoshReleaseManager
138
147
  system_config.release_version = "latest"
139
148
  system_config.save
140
149
  end
141
- end
150
+ end
@@ -10,10 +10,8 @@ module Bosh::CloudFoundry::Config
10
10
  [
11
11
  :base_systems_dir, # e.g. /var/vcap/store/systems
12
12
  :target_system, # e.g. /var/vcap/store/systems/production
13
- :cf_release_git_repo, # e.g. "git://github.com/cloudfoundry/cf-release.git"
14
13
  :bosh_git_repo, # e.g. "git://github.com/cloudfoundry/bosh.git"
15
14
  :releases_dir, # e.g. /var/vcap/store/releases
16
- :cf_release_dir, # e.g. /var/vcap/store/releases/cf-release
17
15
  :stemcells_dir, # e.g. /var/vcap/store/stemcells
18
16
  :repos_dir, # e.g. /var/vcap/store/repos
19
17
  ].each do |attr|
@@ -25,6 +25,10 @@ class Bosh::CloudFoundry::Config::SystemConfig < Bosh::Cli::Config
25
25
  :bosh_provider, # from list 'aws', 'openstack', 'vsphere', 'vcloud'
26
26
  :system_name, # e.g. production
27
27
  :system_dir, # e.g. /var/vcap/store/systems/production
28
+ :cf_release_git_repo, # e.g. "git://github.com/cloudfoundry/cf-release.git"
29
+ :cf_release_dir, # e.g. /var/vcap/store/releases/cf-release
30
+ :cf_release_branch, # e.g. staging
31
+ :cf_release_branch_dir, # e.g. /var/vcap/store/releases/cf-release/staging
28
32
  :release_name, # e.g. 'appcloud'
29
33
  :release_version, # e.g. 'latest'
30
34
  :gerrit_changes, # e.g. ['84/13084/4', '37/13137/4']
@@ -29,7 +29,6 @@ module Bosh::CloudFoundry::ConfigOptions
29
29
  @common_config ||= begin
30
30
  config_file = options[:common_config] || DEFAULT_CONFIG_PATH
31
31
  common_config = Bosh::CloudFoundry::Config:: CommonConfig.new(config_file)
32
- common_config.cf_release_git_repo ||= DEFAULT_CF_RELEASE_GIT_REPO
33
32
  common_config.bosh_git_repo ||= DEFAULT_BOSH_GIT_REPO
34
33
  common_config.save
35
34
  common_config
@@ -47,6 +46,7 @@ module Bosh::CloudFoundry::ConfigOptions
47
46
  system_config.bosh_target = options[:bosh_target] || config.target
48
47
  system_config.bosh_target_uuid = options[:bosh_target_uuid] || config.target_uuid
49
48
  system_config.bosh_provider = options[:bosh_provider] || bosh_cpi
49
+ system_config.cf_release_git_repo ||= DEFAULT_CF_RELEASE_GIT_REPO
50
50
  system_config.release_name ||= DEFAULT_RELEASE_NAME
51
51
  system_config.release_version ||= DEFAULT_RELEASE_VERSION
52
52
  system_config.stemcell_name ||= DEFAULT_STEMCELL_NAME
@@ -124,6 +124,13 @@ module Bosh::CloudFoundry::ConfigOptions
124
124
  # @return [String] BOSH target director UUID
125
125
  overriddable_config_option :bosh_target_uuid, :system_config
126
126
 
127
+ # @return [String] name of git branch to use to build/upload releases, e.g. "staging"
128
+ overriddable_config_option :cf_release_branch, :system_config
129
+
130
+ # @return [String] path to where git branch is cloned locally
131
+ # e.g. /var/vcap/store/releases/cf-release/staging
132
+ overriddable_config_option :cf_release_branch_dir, :system_config
133
+
127
134
  # @return [String] Name of BOSH release in target BOSH
128
135
  overriddable_config_option :release_name, :system_config
129
136
 
@@ -159,7 +166,7 @@ module Bosh::CloudFoundry::ConfigOptions
159
166
 
160
167
  # @return [String] CloudFoundry BOSH release git URI
161
168
  def cf_release_git_repo
162
- options[:cf_release_git_repo] || common_config.cf_release_git_repo
169
+ options[:cf_release_git_repo] || system_config.cf_release_git_repo
163
170
  end
164
171
 
165
172
  # @return [String] Path to store BOSH release projects
@@ -169,13 +176,20 @@ module Bosh::CloudFoundry::ConfigOptions
169
176
 
170
177
  # @return [String] Path to cf-release BOSH release
171
178
  def cf_release_dir
172
- options[:cf_release_dir] || common_config.cf_release_dir || begin
173
- common_config.cf_release_dir = File.join(releases_dir, "cf-release")
174
- common_config.save
175
- common_config.cf_release_dir
179
+ options[:cf_release_dir] || system_config.cf_release_dir || begin
180
+ system_config.cf_release_dir = File.join(releases_dir, "cf-release")
181
+ system_config.save
182
+ system_config.cf_release_dir
176
183
  end
177
184
  end
178
185
 
186
+ # Switch to a different branch (and ultimately a different folder)
187
+ def set_cf_release_branch(branch)
188
+ system_config.cf_release_branch = branch
189
+ system_config.cf_release_branch_dir = File.join(cf_release_dir, branch)
190
+ system_config.save
191
+ end
192
+
179
193
  # @return [String] Path to store stemcells locally
180
194
  def stemcells_dir
181
195
  options[:stemcells_dir] || common_config.stemcells_dir || choose_stemcells_dir
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Cloudfoundry
3
- VERSION = "0.4.1"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -127,43 +127,21 @@ module Bosh::Cli::Command
127
127
 
128
128
  usage "cf upload release"
129
129
  desc "fetch & upload latest public cloudfoundry release to BOSH"
130
- # option "--dev", "Create development release from very latest cf-release commits & specific patches"
130
+ option "--branch branch", String, "Create development release from branch of cf-release [default: staging]"
131
131
  option "--final", "Upload latest final release from very latest cf-release commits"
132
132
  def upload_release
133
- clone_or_update_cf_release
134
133
  if options.delete(:final)
134
+ clone_or_update_cf_release
135
135
  upload_final_release
136
136
  else
137
137
  # FUTURE once all patches from https://github.com/StarkAndWayne/bosh-cloudfoundry/issues/42
138
138
  # are merged into cf-release, then no more gerrit merging required
139
- options[:dev] = true
140
- merge_gerrit(*%w[37/13137/4 84/13084/4])
141
- # create_and_upload_dev_release
142
- end
143
- end
144
-
145
- usage "cf merge gerrit"
146
- desc "create development release including one or more gerrit patches"
147
- def merge_gerrit(*gerrit_changes)
148
- # gerrit_change might be:
149
- # * refs/changes/84/13084/4
150
- # * 84/13084/4
151
- # * 'git pull http://reviews.cloudfoundry.org/cf-release refs/changes/84/13084/4'
152
- gerrit_changes.each do |gerrit_change|
153
- if refs_change = extract_refs_change(gerrit_change)
154
- add_gerrit_refs_change(refs_change)
155
- else
156
- say "Please provide the gerrit change information in one of the following formats:".red
157
- say " -> bosh cf merge gerrit refs/changes/84/13084/4"
158
- say " -> bosh cf merge gerrit 84/13084/4"
159
- say " -> bosh cf merge gerrit 'git pull http://reviews.cloudfoundry.org/cf-release refs/changes/84/13084/4'"
160
- say ""
161
- say "Please re-run the command again with the change reference formatted as above.".red
162
- exit 1
139
+ if new_branch = options.delete(:branch)
140
+ set_cf_release_branch(new_branch)
163
141
  end
142
+ clone_or_update_cf_release
143
+ create_and_upload_dev_release
164
144
  end
165
- apply_gerrit_patches
166
- create_and_upload_dev_release(release_name)
167
145
  end
168
146
 
169
147
  usage "cf deploy"
@@ -557,6 +535,8 @@ module Bosh::Cli::Command
557
535
  def generate_generatable_options
558
536
  common_password
559
537
  security_group
538
+
539
+ set_cf_release_branch("staging")
560
540
  end
561
541
 
562
542
  # Renders the +SystemConfig+ model (+system_config+) into the system's
@@ -8,24 +8,51 @@ describe Bosh::CloudFoundry::BoshReleaseManager do
8
8
 
9
9
  attr_reader :system_config
10
10
 
11
+ # accessors provided by config_options.rb
12
+ attr_accessor :cf_release_dir, :cf_release_branch, :cf_release_branch_dir
13
+
11
14
  before do
12
15
  @system_dir = File.join(Dir.mktmpdir, "systems", "production")
16
+ @cf_release_dir = File.join(Dir.mktmpdir, "releases", "cf-release")
13
17
  mkdir_p(@system_dir)
14
18
  @system_config = Bosh::CloudFoundry::Config::SystemConfig.new(@system_dir)
15
19
  end
16
20
 
21
+ it "clone_or_update_cf_release - updates master branch" do
22
+ self.cf_release_branch = "master"
23
+ self.cf_release_branch_dir = File.join(cf_release_dir, "master")
24
+ mkdir_p(cf_release_branch_dir)
25
+ should_receive(:sh).with("git pull origin master --no-recurse-submodules")
26
+ should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
27
+ should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
28
+ should_receive(:sh).with("git submodule update --init --recursive")
29
+ clone_or_update_cf_release
30
+ end
31
+
32
+ it "clone_or_update_cf_release - updates staging branch" do
33
+ self.cf_release_branch = "staging"
34
+ self.cf_release_branch_dir = File.join(cf_release_dir, "staging")
35
+ mkdir_p(cf_release_branch_dir)
36
+ should_receive(:sh).with("git pull origin staging --no-recurse-submodules")
37
+ should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
38
+ should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
39
+ should_receive(:sh).with("git submodule update --init --recursive")
40
+ clone_or_update_cf_release
41
+ end
42
+
17
43
  describe "switch release types" do
18
44
  it "from final to dev" do
45
+ self.cf_release_branch = "staging"
19
46
  @system_config.release_name = "appcloud"
20
47
  @system_config.release_version = "latest"
21
48
  @system_config.save
22
49
  switch_to_development_release
23
- @system_config.release_name.should == "appcloud-dev"
50
+ @system_config.release_name.should == "appcloud-staging"
24
51
  @system_config.release_version.should == "latest"
25
52
  end
26
53
 
27
54
  it "from dev to final" do
28
- @system_config.release_name = "appcloud-dev"
55
+ @system_config.release_name = "appcloud-staging"
29
56
  @system_config.release_version = "latest"
30
57
  @system_config.save
31
58
  switch_to_final_release
@@ -80,29 +80,32 @@ describe Bosh::Cli::Command::Base do
80
80
  @cmd.upload_stemcell
81
81
  end
82
82
 
83
- it "updates/creates/uploads final cf-release" do
84
- cf_release_dir = File.join(@releases_dir, "cf-release")
85
- FileUtils.mkdir_p(cf_release_dir)
86
- @cmd.common_config.cf_release_dir = cf_release_dir
87
-
88
- @cmd.should_receive(:sh).with("git pull origin master")
89
- script = <<-BASH.gsub(/^ /, '')
90
- grep -rI "github.com" * .gitmodules | awk 'BEGIN {FS=":"} { print($1) }' | uniq while read file
91
- do
92
- echo "changing - $file"
93
- sed -i 's#git://github.com#https://github.com#g' $file
94
- sed -i 's#git@github.com:#https://github.com:#g' $file
95
- done
96
- BASH
97
- @cmd.should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
98
- @cmd.should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
99
- @cmd.should_receive(:sh).with("git submodule update --init --recursive")
100
- @cmd.should_receive(:`).with("tail -n 1 releases/index.yml | awk '{print $2}'").
101
- and_return("126")
102
- @cmd.should_receive(:sh).with("bosh -n --color upload release releases/appcloud-126.yml")
103
- @cmd.add_option(:final, true)
104
- @cmd.upload_release
105
- end
83
+ it "updates/creates/uploads final cf-release"
84
+ # do
85
+ # cf_release_dir = File.join(@releases_dir, "cf-release")
86
+ # FileUtils.mkdir_p(cf_release_dir)
87
+ # @cmd.system_config.cf_release_dir = cf_release_dir
88
+ # @cmd.system_config.cf_release_branch = "staging"
89
+ # @cmd.system_config.cf_release_branch_dir = File.join(cf_release_dir, "staging")
90
+ #
91
+ # @cmd.should_receive(:sh).with("git pull origin master")
92
+ # script = <<-BASH.gsub(/^ /, '')
93
+ # grep -rI "github.com" * .gitmodules | awk 'BEGIN {FS=":"} { print($1) }' | uniq while read file
94
+ # do
95
+ # echo "changing - $file"
96
+ # sed -i 's#git://github.com#https://github.com#g' $file
97
+ # sed -i 's#git@github.com:#https://github.com:#g' $file
98
+ # done
99
+ # BASH
100
+ # @cmd.should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
101
+ # @cmd.should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
102
+ # @cmd.should_receive(:sh).with("git submodule update --init --recursive")
103
+ # @cmd.should_receive(:`).with("tail -n 1 releases/index.yml | awk '{print $2}'").
104
+ # and_return("126")
105
+ # @cmd.should_receive(:sh).with("bosh -n --color upload release releases/appcloud-126.yml")
106
+ # @cmd.add_option(:final, true)
107
+ # @cmd.upload_release
108
+ # end
106
109
 
107
110
  it "updates/creates/uploads development/edge cf-release (requires system setup)"
108
111
  # TODO turn this into a unit test for the specific methods
@@ -124,7 +127,7 @@ describe Bosh::Cli::Command::Base do
124
127
  # @cmd.should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
125
128
  # @cmd.should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
126
129
  # @cmd.should_receive(:sh).with("git submodule update --init --recursive")
127
- # @cmd.should_receive(:write_dev_config_file).with("appcloud-dev")
130
+ # @cmd.should_receive(:write_dev_config_file).with("appcloud-staging")
128
131
  # @cmd.should_receive(:sh).with("bosh create release --with-tarball --force")
129
132
  # @cmd.should_receive(:sh).with("bosh -n --color upload release")
130
133
  # @cmd.upload_release
@@ -152,11 +155,11 @@ describe Bosh::Cli::Command::Base do
152
155
  if needs_initial_release_uploaded
153
156
  cmd.should_receive(:bosh_releases).exactly(1).times.and_return([])
154
157
  cmd.should_receive(:clone_or_update_cf_release)
155
- cmd.should_receive(:merge_gerrit).with(*%w[37/13137/4 84/13084/4])
158
+ cmd.should_receive(:create_and_upload_dev_release)
156
159
  else
157
160
  cmd.should_receive(:bosh_releases).exactly(1).times.and_return([
158
161
  {"name"=>"appcloud", "versions"=>["124", "126"], "in_use"=>[]},
159
- {"name"=>"appcloud-dev", "versions"=>["124.1-dev", "126.1-dev"], "in_use"=>[]},
162
+ {"name"=>"appcloud-staging", "versions"=>["124.1-dev", "126.1-dev"], "in_use"=>[]},
160
163
  ])
161
164
  end
162
165
 
@@ -178,7 +181,7 @@ describe Bosh::Cli::Command::Base do
178
181
  cmd.add_option(:core_server_flavor, 'm1.large')
179
182
  cmd.add_option(:admin_emails, ['drnic@starkandwayne.com'])
180
183
 
181
- cmd.common_config.cf_release_dir = @releases_dir
184
+ cmd.common_config.releases_dir = @releases_dir
182
185
  cmd.common_config.stemcells_dir = @stemcells_dir
183
186
 
184
187
  cmd.system.should be_nil
@@ -196,7 +199,7 @@ describe Bosh::Cli::Command::Base do
196
199
  it "temporarily uploads latest stemcell & patched cf-release by default" do
197
200
  generate_new_system(@cmd)
198
201
  File.basename(@cmd.system).should == "production"
199
- @cmd.system_config.release_name.should == "appcloud-dev"
202
+ @cmd.system_config.release_name.should == "appcloud-staging"
200
203
  end
201
204
 
202
205
  it "new system has common random password" do
@@ -290,15 +293,6 @@ describe Bosh::Cli::Command::Base do
290
293
  @cmd.watch_nats
291
294
  end
292
295
 
293
- it "merges gerrit patches" do
294
- generate_new_system
295
- @cmd.should_receive(:create_and_change_into_patches_branch)
296
- @cmd.should_receive(:sh).
297
- with("git pull http://reviews.cloudfoundry.org/cf-release refs/changes/84/13084/4")
298
- @cmd.should_receive(:create_and_upload_dev_release)
299
- @cmd.merge_gerrit("refs/changes/84/13084/4")
300
- end
301
-
302
296
  it "returns bosh_release_versions" do
303
297
  @cmd.should_receive(:bosh_releases).exactly(3).times.and_return([
304
298
  {"name"=>"appcloud", "versions"=>["124", "126"], "in_use"=>[]},
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-cloudfoundry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-07 00:00:00.000000000 Z
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bosh_cli
@@ -161,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  segments:
163
163
  - 0
164
- hash: -3570084276239392817
164
+ hash: 3552248026887533179
165
165
  required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  none: false
167
167
  requirements:
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  segments:
172
172
  - 0
173
- hash: -3570084276239392817
173
+ hash: 3552248026887533179
174
174
  requirements: []
175
175
  rubyforge_project:
176
176
  rubygems_version: 1.8.24