Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Commit

Permalink
Ignore stemcells with pre in their name
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Feb 26, 2013
1 parent aac91f4 commit de6c638
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
15 changes: 5 additions & 10 deletions lib/bosh/cli/commands/cf.rb
Expand Up @@ -319,12 +319,12 @@ def confirm_or_upload_stemcell
end
end
unless stemcell_version && stemcell_version.size
system_config.stemcell_version = best_bosh_stemcell_version
system_config.stemcell_version = latest_bosh_stemcell_version
system_config.save
end
unless bosh_stemcell_versions.include?(stemcell_version)
say "Requested stemcell version #{stemcell_version} is not available.".yellow
system_config.stemcell_version = best_bosh_stemcell_version
system_config.stemcell_version = latest_bosh_stemcell_version
system_config.save
end
say "Using stemcell #{stemcell_name} #{stemcell_version}".green
Expand All @@ -343,13 +343,6 @@ def confirm_release_name
end
end

# An attempt to choose the best base stemcell for the current
# BOSH. Currently it hardcodes a guess on the assumption that
# the BOSH is from 0.8.1; rather than current edge (1.5.0.preX)
def best_bosh_stemcell_version
"0.7.0"
end

# Largest version number BOSH stemcell ("bosh-stemcell") uploaded to BOSH
# @return [String] version number, e.g. "0.6.7"
def latest_bosh_stemcell_version
Expand Down Expand Up @@ -436,12 +429,14 @@ def clone_or_update_repository(name, repo_uri)
# | bosh-stemcell-0.5.2.tgz | vsphere |
# | bosh-stemcell-aws-0.6.4.tgz | aws, stable |
# | bosh-stemcell-aws-0.6.7.tgz | aws |
#
# Ignores any stemcells with "pre" in their name
def bosh_stemcell_name(stemcell_type)
tags = [bosh_provider]
tags << "stable" if stemcell_type == "stable" unless openstack?
bosh_stemcells_cmd = "bosh public stemcells --tags #{tags.join(',')}"
say "Locating bosh stemcell, running '#{bosh_stemcells_cmd}'..."
`#{bosh_stemcells_cmd} | grep ' bosh-stemcell-' | awk '{ print $2 }' | sort -r | head -n 1`.strip
`#{bosh_stemcells_cmd} | grep ' bosh-stemcell-' | grep -V pre | awk '{ print $2 }' | sort -r | head -n 1`.strip
end

def download_stemcell(stemcell_name)
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/cf_command_spec.rb
Expand Up @@ -43,11 +43,11 @@
@cmd.stub!(:bosh_target_uuid).and_return("DIRECTOR_UUID")
@cmd.stub!(:bosh_cpi).and_return("aws")
@cmd.should_receive(:`).
with("bosh public stemcells --tags aws | grep ' bosh-stemcell-' | awk '{ print $2 }' | sort -r | head -n 1").
with("bosh public stemcells --tags aws | grep ' bosh-stemcell-' | grep -V pre | awk '{ print $2 }' | sort -r | head -n 1").
and_return("bosh-stemcell-aws-0.6.7.tgz")
# FIXME default to stable stemcells when 0.8.1 is marked stable
# @cmd.should_receive(:`).
# with("bosh public stemcells --tags aws,stable | grep ' bosh-stemcell-' | awk '{ print $2 }' | sort -r | head -n 1").
# with("bosh public stemcells --tags aws,stable | grep ' bosh-stemcell-' | grep -V pre | awk '{ print $2 }' | sort -r | head -n 1").
# and_return("bosh-stemcell-aws-0.6.7.tgz")
@cmd.should_receive(:sh).
with("bosh -n --color download public stemcell bosh-stemcell-aws-0.6.7.tgz")
Expand Down

0 comments on commit de6c638

Please sign in to comment.