Permalink
Browse files

Merge branch 'openstack-os-build' into release/essex-hack/openstack-o…

…s-build
  • Loading branch information...
2 parents 49cbb07 + 0d109a7 commit 4c7aca0766db32d1d006b44cd7edb0cbfdd12dad @VictorLowther VictorLowther committed Apr 23, 2012
Showing with 363 additions and 182 deletions.
  1. +15 −15 dev
  2. +69 −6 extra/barclamp_install.rb
  3. +117 −71 extra/barclamp_mgmt_lib.rb
  4. +4 −3 redhat-common/build_lib.sh
  5. +57 −0 run-installer.sh
  6. +9 −9 test_framework/network-team.json
  7. +23 −12 test_lib.sh
  8. +69 −66 ubuntu-common/build_lib.sh
View
@@ -80,9 +80,9 @@ trap - 0 INT QUIT TERM
if [[ $DEV_GITHUB_PASSWD ]]; then
debug "Migrating Github password information to $HOME/.netrc"
for mach in github.com api.github.com; do
- grep -q "^$mach" "$HOME/.netrc" &>/dev/null && continue
- printf "\nmachine %s login %s password %s\n" \
- "$mach" "$DEV_GITHUB_ID" "$DEV_GITHUB_PASSWD" >> "$HOME/.netrc"
+ grep -q "^$mach" "$HOME/.netrc" &>/dev/null && continue
+ printf "\nmachine %s login %s password %s\n" \
+ "$mach" "$DEV_GITHUB_ID" "$DEV_GITHUB_PASSWD" >> "$HOME/.netrc"
done
chmod 600 "$HOME/.netrc"
sed -ie 's/DEV_GITHUB_PASSWD=.*//' "$HOME/.build-crowbar.conf"
@@ -489,7 +489,7 @@ scrub_merged_pull_requests() {
git_config_has remote.personal.url || return
while read ref br; do
case $br in
- refs/heads/*)
+ refs/heads/*)
ref=${br#refs/heads/}
heads[${ref//\//-}]+="$br ";;
refs/remotes/personal/pull-req-*)
@@ -707,7 +707,7 @@ setup() {
die "Crowbar repo must be clean before trying to set things up!"
# Make sure we have Github login credentials as the very first thing.
[[ $DEV_GITHUB_ID ]] || {
- local DEV_GITHUB_PASSWD
+ local DEV_GITHUB_PASSWD
read -p "Enter your Github username: " DEV_GITHUB_ID
curl_and_res -f \
"https://api.github.com/users/$DEV_GITHUB_ID" &>/dev/null || \
@@ -724,12 +724,12 @@ setup() {
echo "Unable to authenticate as Github user $DEV_GITHUB_ID." >&2
die "Please try again when you have Github access."
}
- for mach in github.com api.github.com; do
- grep -q "^$mach" "$HOME/.netrc" &>/dev/null && continue
- printf "\nmachine %s login %s password %s\n" \
- "$mach" "$DEV_GITHUB_ID" "$DEV_GITHUB_PASSWD" >> "$HOME/.netrc"
- done
- chmod 600 "$HOME/.netrc"
+ for mach in github.com api.github.com; do
+ grep -q "^$mach" "$HOME/.netrc" &>/dev/null && continue
+ printf "\nmachine %s login %s password %s\n" \
+ "$mach" "$DEV_GITHUB_ID" "$DEV_GITHUB_PASSWD" >> "$HOME/.netrc"
+ done
+ chmod 600 "$HOME/.netrc"
printf "DEV_GITHUB_ID=%q\n" "$DEV_GITHUB_ID" >> "$HOME/.build-crowbar.conf"
}
# We have a baked-in assumption that Github is our origin, and that
@@ -1294,7 +1294,7 @@ ripple_changes_out() {
# repository, and then update the branches for the current release according
# to the branch structure defined in DEV_BRANCHES.
sync_everything() {
- local unsynced_barclamps=()
+ local unsynced_barclamps=()
local b u head res=0 ref branch rel allow_remote_rebase=true
crowbar_is_clean || exit 1
# Do barclamps first.
@@ -1385,13 +1385,13 @@ Command line options:
You can run a fetch at any time without disturbing your working
code, provided you have network connectivity.
If you pass the name of a remote, fetch will try to fetch changes
- from that remote in the main Crowbar repository and in each of the
+ from that remote in the main Crowbar repository and in each of the
barclamps
remote -- Manage remotes across all dellcloudedge repositories. It has the
following subcommands:
add <remote> <urlbase> : The add subcommand adds a new remote to
- the Crowbar repositories.
+ the Crowbar repositories.
rm <remote> : The rm subcommand removes an already-existing remote
from the Crowbar repositories.
set-url <remote> <urlbase> : The set-url subcommands allows you to
@@ -1746,7 +1746,7 @@ pull_requests_gen() {
[[ ${br_pulls["$br"]} ]] || continue
in_repo git_push personal "${br}:${br_pulls[$br]}"
local br_head="$DEV_GITHUB_ID:${br_pulls[$br]}"
- if [[ $br = feature/* ]]; then
+ if [[ $br = feature/* ]]; then
br="$(best_parent_prefix)${br##*/}" || exit 1
fi
do_pull_request \
@@ -19,15 +19,47 @@
# the 1st choice is to use the code from the framework since it is most up to date
# however, that code is not always available when installing
require '/opt/dell/bin/barclamp_mgmt_lib.rb'
+require 'getoptlong'
+require 'pp'
-tmpdir="/tmp/bc_install-#{Process.pid}-#{Kernel.rand(65535)}"
-Dir.mkdir(tmpdir)
+opts = GetoptLong.new(
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
+ [ '--debug', '-d', GetoptLong::NO_ARGUMENT ],
+ [ '--force', '-f', GetoptLong::NO_ARGUMENT ]
+)
+
+def usage()
+ puts "Usage:"
+ puts "#{__FILE__} [--help] [--debug] /path/to/new/barclamp"
+ exit
+end
+
+debug = false
force_install = false
+
+opts.each do |opt, arg|
+ case opt
+ when "--help"
+ usage
+ when "--debug"
+ puts "DEBUG: debug mode is enabled"
+ debug = true
+ when "--force"
+ force_install = true
+ end
+end
+
+usage if ARGV.length < 1
+
+tmpdir = "/tmp/bc_install-#{Process.pid}-#{Kernel.rand(65535)}"
+puts "DEBUG: tarball tmpdir: #{tmpdir}" if debug
+Dir.mkdir(tmpdir)
candidates = Array.new
ARGV.each do |src|
+ puts "DEBUG: src: #{src}" if debug
case
- when /tar\.gz$/ =~ src
+ when /tar\.gz|tgz$/ =~ src
# This might be a barclamp tarball. Expand it into a temporary location.
src=File.expand_path(src)
system "tar xzf \"#{src}\" -C \"#{tmpdir}\""
@@ -42,16 +74,24 @@
candidates << File.expand_path(src)
when File.exists?(File.join("/opt","dell","barclamps",src,"crowbar.yml"))
candidates << File.join("/opt","dell","barclamps",src)
- when src == "--force" then force_install = true
else
puts "#{src} is not a barclamp, ignoring."
end
end
+puts "DEBUG: checking candidates: #{candidates.to_s}" if debug
+
barclamps = Hash.new
candidates.each do |bc|
# We have already verified that each of the candidates has crowbar.yml
- barclamp = YAML.load_file File.join(bc,"crowbar.yml")
+ begin
+ puts "DEBUG: trying to parse crowbar.yml" if debug
+ barclamp = YAML.load_file File.join(bc,"crowbar.yml")
+ rescue
+ puts "Exception occured while parsing crowbar.yml in #{bc}, skiping"
+ next
+ end
+
if barclamp["barclamp"] and barclamp["barclamp"]["name"]
name = barclamp["barclamp"]["name"]
else
@@ -64,61 +104,84 @@
order = barclamp["crowbar"]["order"].to_i
end
barclamps[name] = { :src => bc, :name => name, :order => order, :yaml => barclamp }
+ puts "DEBUG: barclamp[#{name}] = #{barclamps[name].pretty_inspect}" if debug
end
+puts "DEBUG: installing barclamps:" if debug
barclamps.values.sort_by{|v| v[:order]}.each do |bc|
+ puts "DEBUG: bc = #{bc.pretty_inspect}" if debug
begin
unless /^\/opt\/dell\/barclamps\// =~ bc[:src]
target="/opt/dell/barclamps/#{bc[:src].split("/")[-1]}"
if File.directory? target
+ puts "DEBUG: target directory #{target} exists" if debug
if File.exists? "#{target}/crowbar.yml"
+ puts "DEBUG: #{target}/crowbar.yml file exists" if debug
if File.exists? "#{target}/sha1sums"
+ puts "DEBUG: #{target}/sha1sums file exists" if debug
unless force_install or system "cd \"#{target}\"; sha1sum --status -c sha1sums"
+ puts "DEBUG: force_install mode is disabled and not all file checksums do match" if debug
puts "Refusing to install over non-pristine target #{target}"
puts "Please back up the following files:"
system "cd \"#{target}\"; sha1sum -c sha1sums |grep -v OK"
puts "and rerun the install after recreating the checksum file with:"
puts " cd \"#{target}\"; find -type f -not -name sha1sums -print0 | \\"
puts" xargs -0 sha1sum -b >sha1sums"
puts "(or use the --force switch)"
+ puts "DEBUG: temporary directory #{tmpdir} will be removed if it exists" if debug
system "rm -rf #{tmpdir}" if File.directory?(tmpdir)
exit -1
end
elsif not force_install
+ puts "DEBUG: force_install mode is disabled and #{target}/sha1sums file does not exist" if debug
puts "#{target} already exists, but it does not have checksums."
puts "Please back up any local changes you may have made, and then"
puts "create a checksums file with:"
puts " cd \"#{target}\"; find -type f -not -name sha1sums -print0 | \\"
puts" xargs -0 sha1sum -b >sha1sums"
puts "(or use the --force switch)"
+ puts "DEBUG: temporary directory #{tmpdir} will be removed if it exists" if debug
system "rm -rf #{tmpdir}" if File.directory?(tmpdir)
exit -1
end
else
+ puts "DEBUG: #{target}/crowbar.yml does not exist" if debug
puts "#{target} exists, but it is not a barclamp."
puts "Cowardly refusing to overwrite it."
+ puts "DEBUG: temporary directory #{tmpdir} will be removed if it exists" if debug
system "rm -rf #{tmpdir}" if File.directory?(tmpdir)
exit -1
end
else
+ puts "DEBUG: target directory \"#{target}\" does not exist" if debug
+ puts "DEBUG: creating directory \"#{target}\"" if debug
system "mkdir -p \"#{target}\""
end
# Only rsync over the changes if this is a different install
# from the POV of the sha1sums files
unless File.exists?("#{bc[:src]}/sha1sums") and \
File.exists?("#{target}/sha1sums") and \
system "/bin/bash -c 'diff -q <(sort \"#{bc[:src]}/sha1sums\") <(sort \"#{target}/sha1sums\")'"
+ puts "DEBUG: syncing \"#{bc[:src]}\" directory and \"#{target}\" directory" if debug
system "rsync -r \"#{bc[:src]}/\" \"#{target}\""
end
bc[:src] = target
end
- bc_install bc[:name],bc[:src],bc[:yaml]
+ puts "DEBUG: installing barclamp" if debug
+ begin
+ bc_install bc[:name], bc[:src], bc[:yaml], :debug => debug
+ rescue Exception => e
+ puts "DEBUG: exception occured while installing barclamp" if debug
+ raise e
+ end
rescue
puts "Install of #{bc[:name]} failed."
+ puts "DEBUG: temporary directory #{tmpdir} will be removed if it exists" if debug
system "rm -rf #{tmpdir}" if File.directory?(tmpdir)
exit -3
end
end
+puts "DEBUG: temporary directory #{tmpdir} will be removed if it exists" if debug
system "rm -rf #{tmpdir}" if File.directory?(tmpdir)
exit 0
Oops, something went wrong.

0 comments on commit 4c7aca0

Please sign in to comment.