summaryrefslogtreecommitdiffstats
path: root/genome-bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'genome-bootstrap')
-rw-r--r--genome-bootstrap/LICENSE305
-rw-r--r--genome-bootstrap/Makefile35
-rw-r--r--genome-bootstrap/README4
-rw-r--r--genome-bootstrap/Rakefile45
-rw-r--r--genome-bootstrap/bin/genome-bootstrap193
-rw-r--r--genome-bootstrap/extra/genome-bootstrap.spec57
-rw-r--r--genome-bootstrap/lib/genome-bootstrap.rb22
-rw-r--r--genome-bootstrap/lib/genome-bootstrap/core.rb188
-rw-r--r--genome-bootstrap/lib/genome-bootstrap/ddns.rb75
-rw-r--r--genome-bootstrap/spec/genomed_spec.rb27
-rw-r--r--genome-bootstrap/spec/spec.opts1
-rw-r--r--genome-bootstrap/spec/spec_helper.rb26
-rw-r--r--genome-bootstrap/test/data/test_main_page.html56
-rw-r--r--genome-bootstrap/test/test_genome-bootstrap.rb53
14 files changed, 1087 insertions, 0 deletions
diff --git a/genome-bootstrap/LICENSE b/genome-bootstrap/LICENSE
new file mode 100644
index 0000000..8764452
--- /dev/null
+++ b/genome-bootstrap/LICENSE
@@ -0,0 +1,305 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executablt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this sectioclaims; this section has the sole purpose of
+protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for thM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT
+WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any lils.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/genome-bootstrap/Makefile b/genome-bootstrap/Makefile
new file mode 100644
index 0000000..b1859f9
--- /dev/null
+++ b/genome-bootstrap/Makefile
@@ -0,0 +1,35 @@
+NAME := genome-bootstrap
+SPECFILE = extra/$(NAME).spec
+VERSION := $(shell rpm -q --qf "%{VERSION}\n" --specfile $(SPECFILE)| head -1)
+RELEASE := $(shell rpm -q --qf "%{RELEASE}\n" --specfile $(SPECFILE)| head -1)
+UPSTREAM_NAME = $(PROJECT)
+
+TAG = $(subst .,_,$(NAME)-$(VERSION)-$(RELEASE))
+
+CVS = cvs
+RPMBUILD = rpmbuild
+INSTALL = /usr/bin/install
+INSTALL_DIR = $(INSTALL) --verbose -d -m 755
+
+RPM_TOPDIR = /tmp/$(NAME)-$(VERSION)-$(RELEASE)-build
+_RPM_OPTS = --define "_topdir $(RPM_TOPDIR)" \
+ --define "_builddir %{_topdir}" \
+ --define "_sourcedir $(shell pwd)/pkg" \
+ --define "_specdir $(shell pwd)" \
+ --define "_rpmdir $(shell pwd)" \
+ --define "_srcrpmdir $(shell pwd)" \
+ --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
+RPM_OPTS = $(strip $(_RPM_OPTS))
+
+rpm: clean gem $(RPM_TOPDIR) $(SPECFILE)
+ $(RPMBUILD) --clean $(RPM_OPTS) -bb $(SPECFILE)
+
+gem:
+ rake package
+
+clean:
+ @rm -rfv *~ *.rpm $(RPM_TOPDIR) $(ARCHIVE)
+ rake clobber_package
+
+$(RPM_TOPDIR):
+ @$(INSTALL_DIR) $@
diff --git a/genome-bootstrap/README b/genome-bootstrap/README
new file mode 100644
index 0000000..358969d
--- /dev/null
+++ b/genome-bootstrap/README
@@ -0,0 +1,4 @@
+genome-bootstrap
+============
+
+A gem that provides...
diff --git a/genome-bootstrap/Rakefile b/genome-bootstrap/Rakefile
new file mode 100644
index 0000000..51c5cbe
--- /dev/null
+++ b/genome-bootstrap/Rakefile
@@ -0,0 +1,45 @@
+require 'rubygems'
+require 'rake/gempackagetask'
+require 'rake/clean'
+require 'rubygems/specification'
+require 'date'
+
+GEM = "genome-bootstrap"
+GEM_VERSION = "1.0.0"
+AUTHOR = "Red HAT IT"
+EMAIL = "genome-project-list@redhat.com"
+HOMEPAGE = "http://fedorahosted.org/genome"
+SUMMARY = "Tool for provisioning virtual machines"
+
+spec = Gem::Specification.new do |s|
+ s.name = GEM
+ s.version = GEM_VERSION
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README", "LICENSE"]
+ s.executables = ["genome-bootstrap"]
+ s.summary = SUMMARY
+ s.description = s.summary
+ s.author = AUTHOR
+ s.email = EMAIL
+ s.homepage = HOMEPAGE
+ s.require_path = 'lib'
+ s.autorequire = GEM
+ s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,extra,lib,specs,test}/**/*")
+end
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
+
+desc "install the gem locally"
+task :install => [:package] do
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
+end
+
+desc "create a gemspec file"
+task :make_spec do
+ File.open("#{GEM}.gemspec", "w") do |file|
+ file.puts spec.to_ruby
+ end
+end
diff --git a/genome-bootstrap/bin/genome-bootstrap b/genome-bootstrap/bin/genome-bootstrap
new file mode 100644
index 0000000..54e590f
--- /dev/null
+++ b/genome-bootstrap/bin/genome-bootstrap
@@ -0,0 +1,193 @@
+#!/usr/bin/env ruby
+require 'ostruct'
+require 'genome-bootstrap'
+require 'main'
+require 'net/http'
+require 'uri'
+require "highline/import"
+#http://www.mail-archive.com/capistrano@googlegroups.com/msg01822.html
+HighLine.track_eof = false
+
+include GenomeBootstrap
+
+Main {
+
+ def handle_exception e
+ puts e.message
+ end unless $DEBUG
+
+ def say_red(text)
+ say("<%= color(\"#{text}\", :red) %>")
+ end
+
+ def get_input
+ @facts = Hash.new
+
+ say_red("\nYour genome repo server is the system that serves as the")
+ say_red("puppet master, git server, and cobbler server all in one.")
+ @repo = ask("Enter your Genome repo machine name (leave off the '-repo'): ")
+
+ say_red("\nYour cloud master is the server that determines where the")
+ say_red("machine you're trying to create will be provisioned. Typically")
+ say_red("cloud masters control several machines in a cloud. However,")
+ say_red("cloud masters can be configured to simply manage their own disk space.")
+ @cloudmaster = ask("Enter your cloud master: ")
+ @email = ask("Enter your email address for cloud notifications: ")
+
+ say_red("\nYour cobbler system name consists of two parts")
+ say_red("\t* a system prefix")
+ say_red("\t* a machine type")
+ say_red("The system prefix can be used to help group common systems")
+ say_red("together using some canonical name. For instance, this can be")
+ say_red("helpful when configuring clustered JBoss servers")
+ @system_prefix = ask("Enter your system prefix: ")
+
+ # Once we know the repo we can fetch the supported machines
+ @genome_repo = GenomeRepo.new(@repo)
+ say_red("\nNow, you can select your machine type.")
+ say_red("To see a description of these machine types visit: " +
+ "#{@genome_repo.machine_types_url}")
+
+ @machine_type = choose do |menu|
+ menu.prompt = "Select your machine type: "
+ menu.choices(*@genome_repo.machines.map{|m| m.name})
+ end
+
+ # This might be useful is we stop using DDNS
+ @facts["genome_machine_type"] = @machine_type
+
+ say_red("\nYour cobbler profile determines the OS, the disk space, and")
+ say_red("the amount of memory that should be allocated to the system")
+ say_red("that you are provisioning.")
+ @facts["cobbler_profile"] = choose do |menu|
+ menu.prompt = "Select your cobbler profile (This determines the OS): "
+ menu.choices(*@genome_repo.cobbler_profiles)
+ end
+
+ say_red("\nNow you need to enter some parameters what will be used to configure this machine.")
+ say_red("Most of the defaults will work out fine for development.")
+
+ @genome_repo.facts_for(@machine_type, @machine_name).each do |f|
+ say_red("Description: #{f.desc}") unless f.desc.empty?
+ @facts[f.name] = ask("Enter value for #{f.name}: ") do |q|
+ q.default = f.default
+ end
+ end
+
+ if agree("\nEnter addition facts? (y/n)", true)
+ begin
+ name = ask("Enter fact name: ")
+ value = ask("Enter fact value: ")
+ @facts[name] = value
+ end while agree("Enter another? ", true)
+ end
+ end
+
+ def _run(config_only=false)
+ # Ask all the silly questions
+ get_input
+
+ classes = @genome_repo.classes_for(@machine_type)
+ config = {"classes" => classes, "parameters" => @facts}
+
+ @genome_repo.register_machine(@fqdn, config)
+ unless config_only
+ cloud_master = CloudController.new(@cloudmaster, @genome_repo)
+ cloud_master.create_machine(@fqdn, @email)
+ if @genome_repo.cobbler_dns?
+ @genome_repo.register_dns_entry
+ end
+ end
+ end
+
+ def run
+ _run
+ end
+
+ # Allow user to simply create the cobbler system
+ # but not actually create the VM
+ mode 'config-only' do
+ def run
+ _run(true)
+ end
+ end
+
+ # Allow user to supply a yaml file with the machine
+ # configuration instead of answering all the questions
+ mode 'advanced' do
+ option('fqdn', 'f'){
+ description "Fully qualified domain name of machine to be provisioned"
+ argument_required
+ }
+
+ option('system', 's'){
+ description "Cobbler system name of the machine to be provisioned"
+ argument_required
+ }
+
+ option('repo', '-r'){
+ required
+ description "Fully qualified domain name for the Genome repo machine to use for provisioning"
+ argument_required
+ }
+
+ option('cloudmaster', 'c'){
+ required
+ description "Fully qualified domain name for the machine controlling the cloud"
+ argument_required
+ }
+
+ option('email', 'e'){
+ required
+ description "Your email address to use to help identify the instance owner"
+ argument_required
+ }
+
+ option('yaml', 'y'){
+ description "YAML configuration for this machine"
+ argument_required
+ validate {|f| File.exist?(f)}
+ }
+
+ def run
+ unless params['fqdn'].given? || params['system'].given?
+ say("You must provide either an 'fqdn' parameter or a 'system' parameter")
+ exit(1)
+ end
+
+ # FQDN beats system parameter
+ if params['fqdn'].given?
+ name = params['fqdn'].value
+ else
+ name = params['system'].value
+ end
+
+ config = if params['yaml'].given?
+ YAML.load(File.read(params['yaml'].value))
+ else
+ YAML.load($stdin.read)
+ end
+
+ genome_repo = GenomeRepo.new(params['repo'].value)
+ genome_repo.register_machine(name, config)
+ cloud_master = CloudController.new(params['cloudmaster'].value, genome_repo)
+ host = cloud_master.create_machine(name, params['email'].value)
+
+ installed_system = genome_repo.get_installed_system(name)
+ if not installed_system.empty?
+ if genome_repo.cobbler_dns? and params['fqdn'].given?
+ # register the new system with cobbler dns using the name,
+ # the installed_system's IP, and the given fqdn
+ else
+ fqdn = installed_system["hostname"]
+ end
+ say("Your new system is being provisioned on #{host}.")
+ say("The FQDN of new system is #{fqdn}.")
+ say("The IP address of the new system is #{installed_system["ip"]}.")
+ else
+ say("Your new system is being provisioned on #{host}.")
+ say("You can visit #{cloud_master.cloud} to see the status of the new system.")
+ end
+ end
+ end
+}
diff --git a/genome-bootstrap/extra/genome-bootstrap.spec b/genome-bootstrap/extra/genome-bootstrap.spec
new file mode 100644
index 0000000..04018f5
--- /dev/null
+++ b/genome-bootstrap/extra/genome-bootstrap.spec
@@ -0,0 +1,57 @@
+%define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
+%define gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
+%define gemname genome-bootstrap
+%define geminstdir %{gemdir}/gems/%{gemname}-%{version}
+
+Summary: Tool for provisioning virtual machines
+Name: rubygem-%{gemname}
+
+Version: 1.0.0
+Release: 2%{?dist}
+Group: Development/Languages
+License: Ruby License/GPL
+Source0: %{gemname}-%{version}.gem
+BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(%{__id_u} -n)
+Requires: rubygems
+Requires: rubygem(highline)
+Requires: rubygem(reststop)
+Requires: rubygem(activesupport)
+Requires: rubygem(main)
+Requires: wget
+BuildRequires: rubygems
+BuildArch: noarch
+Provides: rubygem(%{gemname}) = %{version}
+Obsoletes: genome-bootstrap
+Obsoletes: rake
+Obsoletes: highline
+Obsoletes: rubyforge
+
+%description
+Tool for bootstrapping the puppet configuration on machine images
+
+
+%prep
+
+%build
+
+%install
+%{__rm} -rf %{buildroot}
+mkdir -p %{buildroot}%{gemdir}
+gem install --local --install-dir %{buildroot}%{gemdir} --force --rdoc %{SOURCE0}
+mkdir -p %{buildroot}/%{_bindir}
+mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
+rmdir %{buildroot}%{gemdir}/bin
+find %{buildroot}%{geminstdir}/bin -type f | xargs chmod a+x
+
+%clean
+%{__rm} -rf %{buildroot}
+
+%files
+%defattr(-, root, root)
+%{_bindir}/genome-bootstrap
+%{gemdir}/gems/%{gemname}-%{version}/
+%doc %{gemdir}/doc/%{gemname}-%{version}
+%doc %{geminstdir}/LICENSE
+%doc %{geminstdir}/README
+%{gemdir}/cache/%{gemname}-%{version}.gem
+%{gemdir}/specifications/%{gemname}-%{version}.gemspec
diff --git a/genome-bootstrap/lib/genome-bootstrap.rb b/genome-bootstrap/lib/genome-bootstrap.rb
new file mode 100644
index 0000000..4d2bc50
--- /dev/null
+++ b/genome-bootstrap/lib/genome-bootstrap.rb
@@ -0,0 +1,22 @@
+# Copyright (C) 2008 Red Hat, Inc
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# a long with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'optparse'
+require 'ostruct'
+require 'open3'
+require 'genome-bootstrap/ddns'
+require 'genome-bootstrap/core'
+require 'highline'
diff --git a/genome-bootstrap/lib/genome-bootstrap/core.rb b/genome-bootstrap/lib/genome-bootstrap/core.rb
new file mode 100644
index 0000000..4b9ac94
--- /dev/null
+++ b/genome-bootstrap/lib/genome-bootstrap/core.rb
@@ -0,0 +1,188 @@
+# Copyright (C) 2008 Red Hat, Inc
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# a long with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'erb'
+require 'yaml'
+require 'restr'
+require 'xmlrpc/client'
+require 'rubygems'
+
+module GenomeBootstrap
+ class GenomeRepo
+ attr_reader :machines, :machine_types_url, :cobbler_profiles, :fqdn, :repo
+
+ def initialize(repo)
+ @repo = repo
+ # Allow users to pass in just the machine-name or the fqdn
+ @fqdn = @repo.split(".").size > 1 ? @repo : "#{@repo}-repo.usersys.redhat.com"
+ @genomed = "http://#{@fqdn}/genome"
+ @machine_types_url = @genomed + "/machine_types.html"
+
+ @cobblerd = XMLRPC::Client.new2("http://#{@fqdn}:25152")
+
+ # TODO: figure out a way to pass these values in
+ @token = @cobblerd.call2("login", "cobbler", "password")[1]
+ @cobbler_profiles = @cobblerd.call2("get_profiles", @token)[1].map {|p| p["name"]}
+ end
+
+ def machines
+ @machines ||= fetch_data
+ end
+
+ def facts_for(type, machine_name)
+ # Don't want to pull in the genome lib. See below fore more detail.
+ facts = restr_get("#{@genomed}/machine_types/#{type}.xml", "fact")
+ return facts.map do |f|
+ def f.name
+ self["name"]
+ end
+
+ def f.desc
+ self["description"]
+ end
+
+ # Here's where we make use of the DSL's simple templating
+ f.instance_variable_set(:@repo, @repo)
+ f.instance_variable_set(:@machine_name, machine_name)
+ def f.default
+ # handle there case where there is no default
+ self["default"].gsub("%repo%", @repo).gsub("%machine_name%", @machine_name) rescue ""
+ end
+
+ f
+ end
+ end
+
+ def classes_for(type)
+ restr_get("#{@genomed}/machine_types/#{type}.xml", "class")
+ end
+
+ def fetch_data
+ # Build out some mock objects so we don't have to couple to the genome
+ # lib. That lib has lots of funky metaprogramming stuff in it and it
+ # might need to be changed in the future. The fewer tools relying on it
+ # the better.
+ machine_types = restr_get("#{@genomed}/machine_types.xml", "machine_type")
+
+ return machine_types.map do |m|
+ def m.name
+ self["name"]
+ end
+
+ def m.desc
+ self["description"]
+ end
+
+ m
+ end
+ end
+
+ def post_yaml(node_name, machine_type, yaml)
+ Restr.post("#{@genomed}/nodes", :node_name => node_name, :yaml => yaml)
+ end
+
+ def add_system_to_cobbler(name, params, email)
+ system_id = @cobblerd.call2("new_system", @token)[1]
+ @cobblerd.call2('modify_system', system_id, 'name', name, @token)
+ @cobblerd.call2('modify_system', system_id, 'profile', params["cobbler_profile"], @token)
+
+ # These values ultimately get used by genome-firstboot
+ ksmeta = "fqdn=#{name} " +
+ "genome_repo=#{@fqdn}"
+
+ ksmeta << " email=#{email}" if email
+
+ @cobblerd.call2('modify_system', system_id, 'ksmeta', ksmeta, @token)
+ @cobblerd.call2('save_system', system_id, @token)
+ end
+
+ def register_machine(machine_fqdn, config, email="")
+ machine_type = config["parameters"]["genome_machine_type"]
+ post_yaml(machine_fqdn, machine_type, YAML.dump(config))
+ add_system_to_cobbler(machine_fqdn, config["parameters"], email)
+ end
+
+ # Retrive information form the /var/log/cobbler/install.log
+ def get_installed_systems
+ systems = restr_get("#{@genomed}/systems.xml")
+ return systems["system"].map do |system|
+ def system.name
+ self["name"].to_s
+ end
+
+ def system.ip
+ self["ip"].to_s
+ end
+
+ def system.hostname
+ self["hostname"].to_s
+ end
+ system
+ end
+ end
+
+ def get_installed_system(system_name)
+ systems = get_installed_systems
+ systems.delete_if{|system|
+ system.name.to_s != system_name.to_s
+ }
+ end
+
+ def cobbler_dns?
+ return false
+ end
+
+ def register_dns_entry(ip, name)
+
+ end
+
+ # This is a workaround for a Restr "feature". If only one element it is
+ # returned as a Hash instead of an Array. The way we use Restr assumes that it
+ # will always return an Array.
+ def restr_get(url, xml_node=nil)
+ data = xml_node ? Restr.get(url)[xml_node] : Restr.get(url)
+
+ return case data
+ when Hash
+ Array.new << data
+ when Array
+ data
+ end
+ end
+ end
+
+ class CloudController
+ attr_reader :repo, :cloud
+
+ # Create a new CloudController with the given server name (prefix or fqdn)
+ # and repo (full GenomeRepo object)
+ def initialize(name, repo)
+ @repo = repo
+
+ # If @repo is not an GenomeRepo object, assume it's the
+ # fqdn of a repo
+ if not @repo.is_a? GenomeRepo then
+ @repo = GenomeRepo.new(@repo)
+ end
+
+ @cloud = "http://#{name}/cloud"
+ end
+
+ def create_machine(system_name, email)
+ return Restr.post("#{@cloud}/koan", :system_name => system_name, :repo => @repo.fqdn, :email => email)
+ end
+ end
+end
diff --git a/genome-bootstrap/lib/genome-bootstrap/ddns.rb b/genome-bootstrap/lib/genome-bootstrap/ddns.rb
new file mode 100644
index 0000000..e0e982a
--- /dev/null
+++ b/genome-bootstrap/lib/genome-bootstrap/ddns.rb
@@ -0,0 +1,75 @@
+# Copyright (C) 2008 Red Hat, Inc
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# a long with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'net/https'
+
+module RedHatDDNS
+ SERVER = 'kickstart.rdu.redhat.com'
+
+ class DDNS
+ def initialize(username, password, host)
+ @username = username
+ @password = password
+ @hostname = host
+ end
+
+ def ddns_hash
+ @ddns_hash ||= fetch_hash
+ end
+
+ def to_s
+ ddns_hash
+ end
+
+ def main_page
+ req = "wget -q -O- --no-check-certificate " +
+ "--http-user=#{@username} --http-password='#{@password}' " +
+ %["https://#{SERVER}/redhat-ddns/admin/"]
+
+ puts "Fetching DDNS hash..."
+ yield `#{req}`
+ end
+
+ def request_new_hash
+ req = "wget -q -O- --no-check-certificate " +
+ "--http-user=#{@username} --http-password='#{@password}' " +
+ %["https://#{SERVER}/redhat-ddns/admin/add.php?host=#{@hostname}&_submit=Submit+Request"]
+
+ puts "Requesting a new hash"
+ `#{req}`
+ end
+
+ def fetch_hash(options={:tries => 3})
+ options[:tries].times do
+ # In order to test the regex with mocha we can't rely on the
+ # return value from the main_page method. That's why I
+ # declare 'hash' here and store the results from inside the
+ # block
+ hash = nil
+ main_page do |html|
+ hash = /#{@hostname}<\/pre>.*?hash=(.*)\"/.match(html)[1] rescue nil
+ end
+ return hash if hash
+ puts "Hash not found for #{@hostname}"
+ request_new_hash
+ end
+
+ raise RuntimeError.new("Error fetching DDNS hash:\n" +
+ "This usually happens when a hostname is reserved under another " +
+ "user's account or you typed password incorrectly.")
+ end
+ end
+end
diff --git a/genome-bootstrap/spec/genomed_spec.rb b/genome-bootstrap/spec/genomed_spec.rb
new file mode 100644
index 0000000..af38873
--- /dev/null
+++ b/genome-bootstrap/spec/genomed_spec.rb
@@ -0,0 +1,27 @@
+# Copyright (C) 2008 Red Hat, Inc
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# a long with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/spec_helper.rb'
+
+# Time to add your specs!
+# http://rspec.info/
+describe "Place your specs here" do
+
+ it "find this spec in spec directory" do
+ violated "Be sure to write your specs"
+ end
+
+end
diff --git a/genome-bootstrap/spec/spec.opts b/genome-bootstrap/spec/spec.opts
new file mode 100644
index 0000000..cf6add7
--- /dev/null
+++ b/genome-bootstrap/spec/spec.opts
@@ -0,0 +1 @@
+--colour \ No newline at end of file
diff --git a/genome-bootstrap/spec/spec_helper.rb b/genome-bootstrap/spec/spec_helper.rb
new file mode 100644
index 0000000..9102400
--- /dev/null
+++ b/genome-bootstrap/spec/spec_helper.rb
@@ -0,0 +1,26 @@
+# Copyright (C) 2008 Red Hat, Inc
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# a long with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+begin
+ require 'spec'
+rescue LoadError
+ require 'rubygems'
+ gem 'rspec'
+ require 'spec'
+end
+
+$:.unshift(File.dirname(__FILE__) + '/../lib')
+require 'genomed'
diff --git a/genome-bootstrap/test/data/test_main_page.html b/genome-bootstrap/test/data/test_main_page.html
new file mode 100644
index 0000000..fdbd6e3
--- /dev/null
+++ b/genome-bootstrap/test/data/test_main_page.html
@@ -0,0 +1,56 @@
+<html>
+<body>
+
+
+Welcome, bleanhar<br><a href="add.php">Add New Host</a><br><table border=1 ><tr><th><a href=?sort=username&hostname=&username=>username</a></th><th><a href=?sort=system&hostname=&username=>system</a></th><th><a href=?sort=domain&hostname=&username=>domain</a></th><th><a href=?sort=last_update&hostname=&username=>last_update</a></th><th><a href=?sort=address&hostname=&username=>address</a></th><th><a href=?sort=hash&hostname=&username=>hash</a></th><th>Commands</th></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>qax1</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 7 Jan 2008 08:34:44 -0500</pre></td><td><pre>10.11.227.175</pre></td><td><pre>eca4216529d7c1ee7dc5e062dcc1fd4e</pre></td><td><a href="delete.php?hash=eca4216529d7c1ee7dc5e062dcc1fd4e">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>qax</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 29 Jun 2007 09:02:56 -0400</pre></td><td><pre>10.11.227.175</pre></td><td><pre>qax2881b</pre></td><td><a href="delete.php?hash=qax2881b">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>it-selenium</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 21 Jan 2008 14:34:43 -0500</pre></td><td><pre>10.11.227.99</pre></td><td><pre>21ecb1fbdd80bbd1cbb9847ec5157611</pre></td><td><a href="delete.php?hash=21ecb1fbdd80bbd1cbb9847ec5157611">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 4 Feb 2008 10:43:45 -0500</pre></td><td><pre>10.11.227.33</pre></td><td><pre>00179312758b35efcff9d60058a74b14</pre></td><td><a href="delete.php?hash=00179312758b35efcff9d60058a74b14">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>genome-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 18 Feb 2008 14:37:30 -0500</pre></td><td><pre>10.11.227.66</pre></td><td><pre>8dd6d6855724d2f306242d3b60fc2d98</pre></td><td><a href="delete.php?hash=8dd6d6855724d2f306242d3b60fc2d98">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-web-services</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Wed, 30 Jan 2008 16:54:34 -0500</pre></td><td><pre>10.11.227.69</pre></td><td><pre>37f34de7f8e222bb8e44a75401cb5a71</pre></td><td><a href="delete.php?hash=37f34de7f8e222bb8e44a75401cb5a71">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar2-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Thu, 14 Feb 2008 08:29:08 -0500</pre></td><td><pre>10.11.227.109</pre></td><td><pre>7d4a7ff74ee634b82be40e97f811b33f</pre></td><td><a href="delete.php?hash=7d4a7ff74ee634b82be40e97f811b33f">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-laptop</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Thu, 24 Jan 2008 17:40:06 -0500</pre></td><td><pre>10.11.227.147</pre></td><td><pre>97309b1effc757d46aaf45c80e37a43c</pre></td><td><a href="delete.php?hash=97309b1effc757d46aaf45c80e37a43c">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>runlevelzero</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 15 Feb 2008 08:17:39 -0500</pre></td><td><pre>10.11.227.161</pre></td><td><pre>5f1b3d3032c462e87804b2b563ec4470</pre></td><td><a href="delete.php?hash=5f1b3d3032c462e87804b2b563ec4470">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-web-build</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 15 Feb 2008 08:17:39 -0500</pre></td><td><pre>10.11.227.161</pre></td><td><pre>779b7847f26c9f3a7e6e4a57b9c86bf2</pre></td><td><a href="delete.php?hash=779b7847f26c9f3a7e6e4a57b9c86bf2">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-web-apps</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 25 Jan 2008 10:14:37 -0500</pre></td><td><pre>10.11.227.97</pre></td><td><pre>8115f542be5173cac82a6eca4990c5ee</pre></td><td><a href="delete.php?hash=8115f542be5173cac82a6eca4990c5ee">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-web-proxy</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Wed, 6 Feb 2008 08:49:30 -0500</pre></td><td><pre>10.11.227.33</pre></td><td><pre>b3ca867871bba086a4d7f5dcab09c3be</pre></td><td><a href="delete.php?hash=b3ca867871bba086a4d7f5dcab09c3be">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-jboss-mysql</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Thu, 20 Dec 2007 16:55:01 -0500</pre></td><td><pre>10.11.227.39</pre></td><td><pre>bleanhar-jboss-mysql24c50</pre></td><td><a href="delete.php?hash=bleanhar-jboss-mysql24c50">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>training-web-proxy</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Thu, 31 Jan 2008 17:14:36 -0500</pre></td><td><pre>10.11.227.197</pre></td><td><pre>8727cac6206802d16800545fe2449e84</pre></td><td><a href="delete.php?hash=8727cac6206802d16800545fe2449e84">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>ib</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Wed, 9 Jan 2008 10:45:03 -0500</pre></td><td><pre>10.11.227.145</pre></td><td><pre>2e831a400a0ba2c47965052848c25b43</pre></td><td><a href="delete.php?hash=2e831a400a0ba2c47965052848c25b43">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-build</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Thu, 14 Feb 2008 14:59:08 -0500</pre></td><td><pre>10.11.227.171</pre></td><td><pre>6e557e9d171132c1a519892813f997e2</pre></td><td><a href="delete.php?hash=6e557e9d171132c1a519892813f997e2">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar2-build</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Tue, 12 Feb 2008 17:36:56 -0500</pre></td><td><pre>10.11.227.47</pre></td><td><pre>3bd7de9ee626b5962f62751e2e8e57d7</pre></td><td><a href="delete.php?hash=3bd7de9ee626b5962f62751e2e8e57d7">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>archteam-host</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Tue, 12 Feb 2008 04:23:10 -0500</pre></td><td><pre>10.11.227.193</pre></td><td><pre>c2bb389019debccef0a3a92d9e263bf8</pre></td><td><a href="delete.php?hash=c2bb389019debccef0a3a92d9e263bf8">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>genome-cobbler</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Sun, 20 Jan 2008 14:04:18 -0500</pre></td><td><pre>10.11.227.74</pre></td><td><pre>3c4330d39910d9464cea69ee9a5e0ccd</pre></td><td><a href="delete.php?hash=3c4330d39910d9464cea69ee9a5e0ccd">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-cobbler</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Thu, 10 Jan 2008 13:35:06 -0500</pre></td><td><pre>10.11.227.154</pre></td><td><pre>b5c3c86b5ef815060a202c6ff222bb08</pre></td><td><a href="delete.php?hash=b5c3c86b5ef815060a202c6ff222bb08">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-genome-host</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Wed, 31 Dec 1969 19:00:00 -0500</pre></td><td><pre></pre></td><td><pre>471cd9c3a92c3740fb69d420dbf803d5</pre></td><td><a href="delete.php?hash=471cd9c3a92c3740fb69d420dbf803d5">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-test-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Wed, 31 Dec 1969 19:00:00 -0500</pre></td><td><pre></pre></td><td><pre>9dbe5d14fd568de4c3c2aae20cd6a9e2</pre></td><td><a href="delete.php?hash=9dbe5d14fd568de4c3c2aae20cd6a9e2">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-host</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 18 Feb 2008 14:38:49 -0500</pre></td><td><pre>10.11.227.167</pre></td><td><pre>e388be48b4c8a8acadbf5ad02c9a3658</pre></td><td><a href="delete.php?hash=e388be48b4c8a8acadbf5ad02c9a3658">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>genome2-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Tue, 12 Feb 2008 09:04:19 -0500</pre></td><td><pre>10.11.227.30</pre></td><td><pre>077d9f88ce6ac4984088e200b8d68fd0</pre></td><td><a href="delete.php?hash=077d9f88ce6ac4984088e200b8d68fd0">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>genome2-cobbler</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Wed, 9 Jan 2008 15:53:42 -0500</pre></td><td><pre>10.11.227.74</pre></td><td><pre>ab38d0aa051ec9fe7cb2dd74ad739f11</pre></td><td><a href="delete.php?hash=ab38d0aa051ec9fe7cb2dd74ad739f11">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar2-web-build</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 18 Feb 2008 14:37:28 -0500</pre></td><td><pre>10.11.227.61</pre></td><td><pre>0b86602317ca436486f24ebf3a1c6cc4</pre></td><td><a href="delete.php?hash=0b86602317ca436486f24ebf3a1c6cc4">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar2-web-proxy</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 18 Jan 2008 16:54:27 -0500</pre></td><td><pre>10.11.227.42</pre></td><td><pre>fa11ebbdcbbd5097103ffff975f281df</pre></td><td><a href="delete.php?hash=fa11ebbdcbbd5097103ffff975f281df">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>arch-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 18 Feb 2008 14:38:49 -0500</pre></td><td><pre>10.11.227.59</pre></td><td><pre>7816d5dfd412876a16be64b507ee46ce</pre></td><td><a href="delete.php?hash=7816d5dfd412876a16be64b507ee46ce">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>genome2-build</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Tue, 5 Feb 2008 15:39:01 -0500</pre></td><td><pre>10.11.227.42</pre></td><td><pre>d5ec4bc119dc61964054bc5442697e8f</pre></td><td><a href="delete.php?hash=d5ec4bc119dc61964054bc5442697e8f">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanharTest-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Tue, 15 Jan 2008 12:25:03 -0500</pre></td><td><pre>10.11.227.37</pre></td><td><pre>59116ec1aff8677c3597e603e0089ba5</pre></td><td><a href="delete.php?hash=59116ec1aff8677c3597e603e0089ba5">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>archRepo-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 21 Jan 2008 12:09:31 -0500</pre></td><td><pre>10.11.227.187</pre></td><td><pre>f2cef863697288f8918eee9020dc4f3f</pre></td><td><a href="delete.php?hash=f2cef863697288f8918eee9020dc4f3f">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar2-web-apps</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 18 Jan 2008 16:54:27 -0500</pre></td><td><pre>10.11.227.184</pre></td><td><pre>4c86ee566167ef59c1d27501121c7db8</pre></td><td><a href="delete.php?hash=4c86ee566167ef59c1d27501121c7db8">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar2-web-services</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 18 Jan 2008 16:54:26 -0500</pre></td><td><pre>10.11.227.136</pre></td><td><pre>6efb00f35b0968c8fcf5fbc8f700766d</pre></td><td><a href="delete.php?hash=6efb00f35b0968c8fcf5fbc8f700766d">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>test-host</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Wed, 31 Dec 1969 19:00:00 -0500</pre></td><td><pre></pre></td><td><pre>1e9f6ea8ad24030198e59527b8980b38</pre></td><td><a href="delete.php?hash=1e9f6ea8ad24030198e59527b8980b38">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-pc2-web-apps</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 25 Jan 2008 15:49:07 -0500</pre></td><td><pre>10.11.227.11</pre></td><td><pre>7d32ce18b7d39be5d4656af1cb7e1994</pre></td><td><a href="delete.php?hash=7d32ce18b7d39be5d4656af1cb7e1994">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-pc2-web-services</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 25 Jan 2008 15:49:07 -0500</pre></td><td><pre>10.11.227.14</pre></td><td><pre>3f3e6cb856942827c8b6334c09757375</pre></td><td><a href="delete.php?hash=3f3e6cb856942827c8b6334c09757375">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-pc2-web-proxy</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 25 Jan 2008 15:49:07 -0500</pre></td><td><pre>10.11.227.169</pre></td><td><pre>31fb38651780068aa04545bc80adfe71</pre></td><td><a href="delete.php?hash=31fb38651780068aa04545bc80adfe71">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>test-web-proxy</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 28 Jan 2008 19:44:16 -0500</pre></td><td><pre>10.11.227.194</pre></td><td><pre>7384539a9784c6e162ce0638377bc0e1</pre></td><td><a href="delete.php?hash=7384539a9784c6e162ce0638377bc0e1">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar2-jboss</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 11 Feb 2008 08:33:50 -0500</pre></td><td><pre>10.11.227.65</pre></td><td><pre>6aacf7ff55f6e9e6c2b5d7a62362992d</pre></td><td><a href="delete.php?hash=6aacf7ff55f6e9e6c2b5d7a62362992d">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>training-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Tue, 5 Feb 2008 10:29:29 -0500</pre></td><td><pre>10.11.227.130</pre></td><td><pre>f700f65b34bd83da432b12e2dafa3795</pre></td><td><a href="delete.php?hash=f700f65b34bd83da432b12e2dafa3795">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar1-selenium-queue</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Thu, 7 Feb 2008 14:49:26 -0500</pre></td><td><pre>10.11.227.69</pre></td><td><pre>7736926d2b33fcc98bd2858f75924014</pre></td><td><a href="delete.php?hash=7736926d2b33fcc98bd2858f75924014">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-hudson</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Wed, 30 Jan 2008 19:29:36 -0500</pre></td><td><pre>10.11.227.97</pre></td><td><pre>ccafb2ffba93b5f0c20673b170b3d262</pre></td><td><a href="delete.php?hash=ccafb2ffba93b5f0c20673b170b3d262">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>training-host</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 1 Feb 2008 09:41:18 -0500</pre></td><td><pre>10.11.227.29</pre></td><td><pre>72b2541418156a3435b14551348dd463</pre></td><td><a href="delete.php?hash=72b2541418156a3435b14551348dd463">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>training-hudson</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Fri, 1 Feb 2008 09:41:19 -0500</pre></td><td><pre>10.11.227.165</pre></td><td><pre>7d3beb272ec5afb408d0e689820f0cb2</pre></td><td><a href="delete.php?hash=7d3beb272ec5afb408d0e689820f0cb2">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>colgate-host</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 18 Feb 2008 14:36:44 -0500</pre></td><td><pre>10.11.226.201</pre></td><td><pre>97f50f1569a44e07335738aede7a5db8</pre></td><td><a href="delete.php?hash=97f50f1569a44e07335738aede7a5db8">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar1-rq</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Wed, 31 Dec 1969 19:00:00 -0500</pre></td><td><pre></pre></td><td><pre>99c649639e22c22fbe235c17ba0c7f28</pre></td><td><a href="delete.php?hash=99c649639e22c22fbe235c17ba0c7f28">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar1-web-build</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Thu, 7 Feb 2008 14:44:32 -0500</pre></td><td><pre>10.11.227.145</pre></td><td><pre>cc83321aab54eafa2fe6119be4a4897f</pre></td><td><a href="delete.php?hash=cc83321aab54eafa2fe6119be4a4897f">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>genome-staging-repo</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Mon, 18 Feb 2008 14:38:48 -0500</pre></td><td><pre>10.11.227.42</pre></td><td><pre>4837e70d1c38bbd3649bf090723fecdb</pre></td><td><a href="delete.php?hash=4837e70d1c38bbd3649bf090723fecdb">Delete</a></td></tr>
+<tr><td><pre>bleanhar</pre></td><td><pre>bleanhar-ldap</pre></td><td><pre>usersys.redhat.com</pre></td><td><pre>Thu, 14 Feb 2008 08:29:09 -0500</pre></td><td><pre>10.11.227.42</pre></td><td><pre>d6f3fc74e836656f1a6c355667d2afb8</pre></td><td><a href="delete.php?hash=d6f3fc74e836656f1a6c355667d2afb8">Delete</a></td></tr>
+</table></body>
+</html>
diff --git a/genome-bootstrap/test/test_genome-bootstrap.rb b/genome-bootstrap/test/test_genome-bootstrap.rb
new file mode 100644
index 0000000..616d6a4
--- /dev/null
+++ b/genome-bootstrap/test/test_genome-bootstrap.rb
@@ -0,0 +1,53 @@
+# Copyright (C) 2008 Red Hat, Inc
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# a long with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'genome-bootstrap/ddns'
+require 'rubygems'
+require 'mocha'
+
+class TestDDNS < Test::Unit::TestCase
+ def setup
+ @test_main_page = File.read(File.dirname(__FILE__) + "/data/test_main_page.html")
+ end
+
+ def mkddns(hostname)
+ RedHatDDNS::DDNS.new("fakeuser", "fakepass", hostname)
+ end
+
+ def test_exact_match_exists
+ ddns = mkddns("bleanhar-jboss-mysql")
+ ddns.expects(:main_page).yields(@test_main_page)
+ ddns.expects(:request_new_hash).never
+ assert_equal("bleanhar-jboss-mysql24c50", ddns.ddns_hash)
+ end
+
+ def test_hostnames_in_reverse_alphabetical_order
+ ddns = mkddns("qax")
+ ddns.expects(:main_page).yields(@test_main_page)
+ ddns.expects(:request_new_hash).never
+ assert_equal("qax2881b", ddns.ddns_hash)
+ end
+
+ def test_exact_match_doesnt_exist_but_a_superset_does
+ ddns = mkddns("bleanhar-jboss")
+ ddns.stubs(:main_page).yields(@test_main_page)
+ ddns.expects(:request_new_hash).times(3) # This is the default number of tries
+
+ assert_raise RuntimeError do
+ ddns.ddns_hash
+ end
+ end
+end