Skip to content

Commit 2b1b2f9

Browse files
author
Thomas Boerger
committed
Improved development environment setup and guard sync
1 parent a174ded commit 2b1b2f9

File tree

3 files changed

+60
-83
lines changed

3 files changed

+60
-83
lines changed

Guardfile

+41-56
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,16 @@ group :tree do
9696
file.write "- /*\n"
9797
end
9898

99-
guard_options = {
100-
:source => "#{barclamp.to_s}/",
101-
:destination => target,
102-
:user => user,
103-
:remote_address => host,
104-
:remote_port => port,
105-
:exclude_from => exclude_tree,
106-
:sync_on_start => true,
107-
:ssh => true,
108-
:cvs_exclude => true,
109-
:delete => false
110-
}
111-
112-
guard("remote-sync", guard_options) do
99+
guard_params = [
100+
"-ar --stats --cvs-exclude",
101+
"--chown 'crowbar:crowbar'",
102+
"--exclude-from '#{exclude_tree}'",
103+
"-e 'ssh -p #{port}'",
104+
"#{barclamp.to_s}/",
105+
"#{user}@#{host}:#{target}"
106+
]
107+
108+
guard "remote-sync", sync_on_start: true, source: "#{barclamp.to_s}/", cli_options: guard_params.join(" ") do
113109
watch(/\A#{barclamp.to_s}\/.+/)
114110
end
115111

@@ -119,7 +115,7 @@ group :tree do
119115
)
120116

121117
File.open(exclude_barclamp, "w") do |file|
122-
file.write "+ /crowbar.yml\n"
118+
file.write "+ /*.yml\n"
123119
file.write "+ /Gemfile\n"
124120
file.write "+ /Rakefile\n"
125121
file.write "+ /README.md\n"
@@ -131,21 +127,16 @@ group :tree do
131127
file.write "- /*\n"
132128
end
133129

134-
config_options = {
135-
:source => "#{barclamp.to_s}/",
136-
:destination => File.join(target, barclamp.to_s),
137-
:user => user,
138-
:remote_address => host,
139-
:remote_port => port,
140-
:exclude_from => exclude_barclamp,
141-
:exclude_from => nil,
142-
:include_from => nil,
143-
:sync_on_start => true,
144-
:ssh => true,
145-
:cvs_exclude => true
146-
}
147-
148-
guard("remote-sync", config_options) do
130+
config_params = [
131+
"-ar --stats --cvs-exclude --delete",
132+
"--chown 'crowbar:crowbar'",
133+
"--exclude-from '#{exclude_barclamp}'",
134+
"-e 'ssh -p #{port}'",
135+
"#{barclamp.to_s}/",
136+
"#{user}@#{host}:#{File.join(target, barclamp.to_s)}"
137+
]
138+
139+
guard "remote-sync", sync_on_start: true, source: "#{barclamp.to_s}/", cli_options: config_params.join(" ") do
149140
watch(/\A#{barclamp.to_s}\/.+/)
150141
end
151142
end
@@ -171,19 +162,16 @@ group :script do
171162
file.write "- /*\n"
172163
end
173164

174-
script_options = {
175-
:source => "scripts/",
176-
:destination => target,
177-
:user => user,
178-
:remote_address => host,
179-
:remote_port => port,
180-
:exclude_from => exclude_script,
181-
:sync_on_start => true,
182-
:ssh => true,
183-
:cvs_exclude => true
184-
}
185-
186-
guard("remote-sync", script_options) do
165+
script_params = [
166+
"-ar --stats --cvs-exclude --delete",
167+
"--chown 'crowbar:crowbar'",
168+
"--exclude-from '#{exclude_script}'",
169+
"-e 'ssh -p #{port}'",
170+
"scripts/",
171+
"#{user}@#{host}:#{target}"
172+
]
173+
174+
guard "remote-sync", sync_on_start: true, source: "scripts/", cli_options: script_params.join(" ") do
187175
watch(/\Ascripts\/barclamp_.+\z/)
188176
watch(/\Ascripts\/json\-.+\z/)
189177
watch(/\Ascripts\/install\-.+\z/)
@@ -208,19 +196,16 @@ group :mirror do
208196
file.write "- *.swp\n"
209197
end
210198

211-
mirror_options = {
212-
:source => "barclamps/",
213-
:destination => target,
214-
:user => user,
215-
:remote_address => host,
216-
:remote_port => port,
217-
:exclude_from => exclude_mirror,
218-
:sync_on_start => true,
219-
:ssh => true,
220-
:cvs_exclude => true
221-
}
222-
223-
guard("remote-sync", mirror_options) do
199+
mirror_params = [
200+
"-ar --stats --cvs-exclude --delete",
201+
"--chown 'crowbar:crowbar'",
202+
"--exclude-from '#{exclude_mirror}'",
203+
"-e 'ssh -p #{port}'",
204+
"barclamps/",
205+
"#{user}@#{host}:#{target}"
206+
]
207+
208+
guard "remote-sync", sync_on_start: true, source: "barclamps/", cli_options: mirror_params.join(" ") do
224209
watch(/\Abarclamps\/.+/)
225210
end
226211
end

doc/development.md

+18-25
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ compare the differences:
2828
1. __Regular SUSE OpenStack Cloud install__. Runs on standard http port
2929
(http://HOSTNAME) and from the `/opt/dell` directory.
3030
2. __From Git upstream branding__. Runs on [port 5000]
31-
(http://HOSTNAME:5100) and from the `/opt/crowbar` directory.
31+
(http://HOSTNAME:5000) and from the `/opt/crowbar` directory.
3232

3333
All are using the same default username and password, both ```crowbar```. The
3434
following sections will describe in detail how each of these are setup and
@@ -49,16 +49,16 @@ Before we can start you need to match some prerequirements on your host machine.
4949
zypper ar -f http://dist.suse.de/install/SLP/SLE-12-SP1-SDK-LATEST/x86_64/DVD1/ sle12-sp1-sdk
5050
zypper -n in -l gcc ruby2.1-devel sqlite3-devel libxml2-devel;
5151
52-
mkdir -p /opt/crowbar/crowbar_framework/db;
53-
mkdir -p /opt/crowbar/barclamps;
52+
mkdir -p /opt/crowbar/crowbar_framework/db /opt/crowbar/barclamps;
5453
55-
cp /opt/dell/crowbar_framework/db/production.sqlite3 /opt/crowbar/crowbar_framework/db/development.sqlite3;
54+
ln -sf /opt/dell/crowbar_framework/db/production.sqlite3 /opt/crowbar/crowbar_framework/db/development.sqlite3;
5655
EOS
5756
)
5857
58+
export SHAREDVG=1
5959
export TESTHEAD=1
6060
export cloudsource=develcloud6
61-
export virtualcloud=wiggy
61+
export virtualcloud=l6
6262
export cloud=cloud6
6363
export net_fixed=192.168.116
6464
export net_public=192.168.96
@@ -67,18 +67,21 @@ Before we can start you need to match some prerequirements on your host machine.
6767
export nodenumber=2
6868
export vcpus=4
6969
export cloudvg=system
70+
export user_keyfile=~${SUDO_USER}/.ssh/id_rsa.pub
71+
export adminvcpus=2
72+
export want_sles12=1
7073
7174
/usr/local/bin/mkcloud $@
7275
```
7376
74-
1. At first you need a running mkcloud setup. For more information about this
77+
2. At first you need a running mkcloud setup. For more information about this
7578
read the [mkcloud](http://git.io/vYO2E) documentation. Please use the
76-
wrapper script created above to install Crowbar.
79+
wrapper script created above to install Crowbar, e.g. `sudo mkcloud6 plain`.
7780
78-
2. You need some ruby environment on you workstation in order to execute some
81+
3. You need some ruby environment on you workstation in order to execute some
7982
rake tasks, so please install ```ruby``` and ```bundler``` first.
8083
81-
3. You need to clone all repositories from GitHub. There are rake tasks for
84+
4. You need to clone all repositories from GitHub. There are rake tasks for
8285
cloning, forking and updating all required repositories. Make sure to get
8386
all the dependencies with ```bundle install``` and use ```rake -T``` to get
8487
an overview about the rake tasks.
@@ -89,17 +92,11 @@ Before we can start you need to match some prerequirements on your host machine.
8992
2. ```rake crowbar:update``` will update the clones, this should be performed from time
9093
to time to get the latest changes into your cloned repositories.
9194
92-
4. After this copy your ssh-key to the machine using ```ssh-copy-id```.
93-
94-
5. Change within ```barclamps/crowbar/crowbar_framework/Gemfile``` the
95-
rubygems source from ```https``` to ```http``` as there is some known issue
96-
in SLE 11 for bundle install..
97-
98-
6. Now run Guard to sync you local git clones with the server, please execute
95+
5. Now run Guard to sync your local git repos with the server, please execute
9996
```GUARD_SYNC_HOST=192.168.106.10 bundle exec guard``` in a seperate
10097
terminal window as this process will stay in the foreground.
10198
102-
7. Now ssh to the admin node and follow the steps below:
99+
6. Now ssh to the admin node and follow the steps below:
103100
104101
1. Change to ```/opt/crowbar/crowbar_framework```.
105102
@@ -108,15 +105,11 @@ Before we can start you need to match some prerequirements on your host machine.
108105
3. Install all barclamps with this snippet
109106
110107
```bash
111-
components=$(find /opt/crowbar/barclamps -mindepth 1 -maxdepth 1 -type d)
112-
CROWBAR_DIR=/opt/crowbar /opt/crowbar/bin/barclamp_install.rb $components
108+
COMPONENTS=$(find /opt/crowbar/barclamps -mindepth 1 -maxdepth 1 -type d)
109+
CROWBAR_DIR=/opt/crowbar RAILS_ENV=development /opt/crowbar/bin/barclamp_install.rb $COMPONENTS
113110
```
114111
115-
4. shutdown the production server `systemctl stop crowbar && systemctl disable crowbar`
116-
as it currently causes confusion with the crowbar database. It gets out of sync when
117-
you e.g. change proposals.
118-
119-
5. Run the Rails server ```bin/rails s -b 0.0.0.0 -p 5000```
112+
4. Run the Rails server ```bin/rails s -b 0.0.0.0 -p 5000```
120113
121114
122-
8. Now you can access you crowbar development setup via ```http://192.168.106.10:5000```
115+
7. Now you can access you crowbar development setup via ```http://192.168.106.10:5000```

scripts/barclamp_mgmt_lib.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ def merge_tree(key, value, target)
369369
def bc_remove_layout_1(from_rpm, bc, bc_path, yaml)
370370
filelist = File.join BARCLAMP_PATH, "#{bc}-filelist.txt"
371371
if File.exist? filelist
372-
files = [ filelist ]
373372
File.open(filelist, 'r') do |f|
374373
f.each_line { |line| FileUtils.rm line.chomp rescue nil }
375374
end
@@ -533,7 +532,7 @@ def bc_install_layout_1_chef(from_rpm, component_paths, log)
533532
def bc_install_layout_1_chef_migrate(bc, log)
534533
debug "Migrating schema to new revision..."
535534
File.open(log, "a") { |f| f.puts("======== Migrating #{bc} barclamp -- #{Time.now.strftime('%c')} ========") }
536-
migrate_cmd = "cd #{CROWBAR_PATH} && RAILS_ENV=production ./bin/rake --silent crowbar:schema_migrate_prod[#{bc}] 2>&1"
535+
migrate_cmd = "cd #{CROWBAR_PATH} && RAILS_ENV=#{ENV["RAILS_ENV"] || "production"} bin/rake --silent crowbar:schema_migrate_prod[#{bc}] 2>&1"
537536
migrate_cmd_su = "su -s /bin/sh - crowbar sh -c \"#{migrate_cmd}\" >> #{log}"
538537
debug "running #{migrate_cmd_su}"
539538
unless system migrate_cmd_su

0 commit comments

Comments
 (0)