diff options
| author | Brenton Leanhardt <bleanhar@redhat.com> | 2008-02-18 11:26:14 -0500 |
|---|---|---|
| committer | Brenton Leanhardt <bleanhar@redhat.com> | 2008-02-18 11:26:14 -0500 |
| commit | 7344f01ef857cdfe22511002f145e8df73ff2c04 (patch) | |
| tree | 755d8219bce0580545344b0494f1170e16f5d603 | |
| download | tools-7344f01ef857cdfe22511002f145e8df73ff2c04.tar.gz tools-7344f01ef857cdfe22511002f145e8df73ff2c04.tar.xz tools-7344f01ef857cdfe22511002f145e8df73ff2c04.zip | |
A simple prototype for backing up Xen guests to S3
44 files changed, 1048 insertions, 0 deletions
diff --git a/everest-backup/.gitignore b/everest-backup/.gitignore new file mode 100644 index 0000000..3e57bca --- /dev/null +++ b/everest-backup/.gitignore @@ -0,0 +1,3 @@ +*.swp +*.swo +pkg/* diff --git a/everest-backup/History.txt b/everest-backup/History.txt new file mode 100644 index 0000000..60e601c --- /dev/null +++ b/everest-backup/History.txt @@ -0,0 +1,4 @@ +== 1.0.0 / 2008-01-16 + +* 1 major enhancement + * Birthday! diff --git a/everest-backup/Manifest.txt b/everest-backup/Manifest.txt new file mode 100644 index 0000000..bdbbd23 --- /dev/null +++ b/everest-backup/Manifest.txt @@ -0,0 +1,10 @@ +History.txt +Manifest.txt +README.txt +Rakefile +bin/everest-backup +lib/everest-backup.rb +lib/everest-backup/commands.rb +lib/everest-backup/version.rb +ext/rubygem-everest-backup.spec +test/test_everest-backup.rb diff --git a/everest-backup/README.txt b/everest-backup/README.txt new file mode 100644 index 0000000..b16b68f --- /dev/null +++ b/everest-backup/README.txt @@ -0,0 +1,41 @@ +everest-backup + by it-arch + +== DESCRIPTION: + +This is a backup tool for virtual images + +== FEATURES/PROBLEMS: + +== SYNOPSIS: + + everest-backup -h + +== INSTALL: + +* sudo gem/yum install everest-backup + +== LICENSE: + +(The MIT License) + +Copyright (c) 2007 FIX + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/everest-backup/Rakefile b/everest-backup/Rakefile new file mode 100644 index 0000000..786827e --- /dev/null +++ b/everest-backup/Rakefile @@ -0,0 +1,18 @@ +# -*- ruby -*- + +require 'rubygems' +require 'hoe' +require './lib/everest-backup/version.rb' + +Hoe.new('everest-backup', EverestBackup::Version::STRING) do |p| + p.author = 'it-arch' + p.email = "it-archlist@redhat.com" + p.rubyforge_name = 'everest-backup' + p.summary = 'Everest image backup tool' + p.description = 'Tool for backing up Everest virtual machines' + # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1] + p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n") + p.extra_deps = %w[highline main] +end + +# vim: syntax=Ruby diff --git a/everest-backup/bin/everest-backup b/everest-backup/bin/everest-backup new file mode 100644 index 0000000..3247a7c --- /dev/null +++ b/everest-backup/bin/everest-backup @@ -0,0 +1,96 @@ +#!/usr/bin/env ruby +require 'ostruct' +require 'everest-backup' +require 'main' +require 'net/http' +require 'uri' + +COMMANDS = [] +def command(name, &task) + COMMANDS << OpenStruct.new(:name => name, :task => task) +end + +def sh(cmd) + puts cmd + puts `#{cmd}` +end + +def fail(msg) + puts "ERROR: " + msg + exit 1 +end + +# Make sure the user is root +fail("You must run this as root") unless ENV['USER'] == "root" + +# Load the commands +instance_eval(File.read(File.dirname(__FILE__) + "/../lib/everest-backup/commands.rb")) + +Main { + version EverestBackup::Version::STRING + + option("virt-path", "p") do + required + argument_required + description "The path to the virtual image (this could be a file path or a logical volume name)" + end + + option("qualifier", "q") do + required + argument_required + description "A unique qualifier to add as a prefix so that you don't clobber other people's backups (e.g. your kerberos name)" + end + + option("size", "s") do + argument_required + description "The split size in gigabytes in case your image needs to be split into multiple files (e.g. 5, 10, 20)" + default 5 + cast :int + end + + option("remote", "r") do + argument_required + description "The remote backup share (e.g. server:/share)" + default "everest-repo.usersys.redhat.com:/backup" + end + + option("dest", "d") do + argument_required + description "The backup destination. If --remote is supplied, this will be the mount point." + default "/mnt/backup" + end + + option("local", "l") do + description "Do not use a remote share, but backup to the --dest parameter without mounting the share" + end + + option("force", "f") do + description "Force the backup - don't restrict to a single backup and overwrite existing backups if necessary" + end + + # Figure out the virt-path destination + def virt_path + if /^\// =~ params['virt-path'].value + params['virt-path'].value + else + build_lvm_path + end + end + + def build_lvm_path + # Find the volume group for the specified LVM name + # Get a table of output with the lvm name and volume group + lvs_table = `/usr/sbin/lvs --noheadings -o lv_name,vg_name`.split + + # Find the matching logical volume and read corresponding volume group + volume_group = lvs_table[lvs_table.index(params['virt-path'].value) + 1] + + # Build up the device path + return "/dev/#{volume_group}/#{params['virt-path'].value}" + end + + # Run all the commands in order + def run + COMMANDS.each {|c| instance_eval(&c.task)} + end +} diff --git a/everest-backup/ext/eb.rb b/everest-backup/ext/eb.rb new file mode 100755 index 0000000..64e5dc7 --- /dev/null +++ b/everest-backup/ext/eb.rb @@ -0,0 +1,90 @@ +#!/usr/bin/env ruby +# This is a prototype for backing up Xen guests to S3 + +require 'rubygems' +require 'aws/s3' +require 'main' + +include AWS::S3 + +Main { + keyword("id"){ + required + description "Access key id" + } + + keyword("secret"){ + required + description "Secret acess key" + } + + keyword("project"){ + required + description "The project this image should be stored under" + } + + keyword("virt-path"){ + required + description "Block device or a file" + validate {|f| File.exist?(f)} + } + + keyword("org"){ + description "Your organization" + default "leanhardt" + } + + keyword("machine-name"){ + required + description "The name of your machine" + } + + keyword("chunk-size") + required + description "Measured in megabytes. Used to split the backup" + default 5120 + cast :int + } + + def sh(cmd) + puts cmd + #`#{cmd}` + end + + def run + AWS::S3::Base.establish_connection!( + :access_key_id => params['id'].value, + :secret_access_key => params['secret'].value + ) + + bucket_name = params['org'].value + "." + params['project'].value + virt_path = params['virt-path'].value + filename = params['machine-name'].value + Time.now.strftime("-%Y-%m-%d-%H-%M") + chunk_size = params['chunk-size'].value + + unless bucket = Bucket.find(bucket_name) + Bucket.create(bucket_name) + end + + #Split things up + if File.blockdev?(virt_path) + vg, lv = virt_path.split("/")[-2..-1] + snapshot = lv + "-snap" + sh "/usr/sbin/lvcreate -s -n #{snapshot} -L 1G #{vg}" + sh "/bin/dd if=/dev/#{vg}/#{snapshot} | " + + "/bin/gzip | " + + "/usr/bin/split -b #{chunk_size}m - /tmp/#{filename}" + else + sh "/bin/gzip #{virt_path} | " + + "/usr/bin/split -b #{chunk_size}m - /tmp/#{filename}" + end + + #Stream it to S3 + Dir["/tmp/#{filename}*"].each do |f| + chunk = File.basename f + S3Object.store(chunk, open(f), bucket.name) + end + + end + +} diff --git a/everest-backup/ext/rubygem-everest-backup.spec b/everest-backup/ext/rubygem-everest-backup.spec new file mode 100644 index 0000000..188bad6 --- /dev/null +++ b/everest-backup/ext/rubygem-everest-backup.spec @@ -0,0 +1,63 @@ +# Based on gem2rpm generation for rvm +%define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']") +%define gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null) +%define gemname everest-backup +%define geminstdir %{gemdir}/gems/%{gemname}-%{version} + +Summary: Tool for provisioning virtual machines +Name: rubygem-%{gemname} + +Version: 0.1.0 +Release: 1%{?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(main) +Requires: rubygem(hoe) >= 1.3.0 +Requires: lvm2 +BuildRequires: rubygems +BuildArch: noarch +Provides: rubygem(%{gemname}) = %{version} +Obsoletes: everest-backup +Obsoletes: rake +Obsoletes: hoe +Obsoletes: rubyforge + +%description +Tool for provisioning virtual machines + + +%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}/everest-backup +%{gemdir}/gems/%{gemname}-%{version}/ +%doc %{gemdir}/doc/%{gemname}-%{version} +%doc %{geminstdir}/History.txt +%doc %{geminstdir}/Manifest.txt +%doc %{geminstdir}/README.txt +%{gemdir}/cache/%{gemname}-%{version}.gem +%{gemdir}/specifications/%{gemname}-%{version}.gemspec + + +%changelog +* Thu Jan 17 2008 <mhicks@mhicks-desktop.usersys.redhat.com> - 0.1.0-1 +- Initial package diff --git a/everest-backup/lib/everest-backup.rb b/everest-backup/lib/everest-backup.rb new file mode 100644 index 0000000..1396460 --- /dev/null +++ b/everest-backup/lib/everest-backup.rb @@ -0,0 +1,5 @@ +require 'optparse' +require 'ostruct' +require 'open3' +require 'everest-backup/version' +require 'highline' diff --git a/everest-backup/lib/everest-backup/commands.rb b/everest-backup/lib/everest-backup/commands.rb new file mode 100644 index 0000000..2c73ae0 --- /dev/null +++ b/everest-backup/lib/everest-backup/commands.rb @@ -0,0 +1,49 @@ +# These commands will be executed in the order they are defined + +command :prepare_dest do + dest = params['dest'].value + puts "Making sure the destination location exists" + sh "mkdir -p #{dest}" + + unless params['local'].given? + # The --local option was not supplied, so mount the remote share + remote_share = params['remote'].value + puts "Mounting remote share on #{remote_share}" + sh "mount #{remote_share} #{dest}" + end +end + +command :backup do + puts "Backing up image" + + # Figure the 'split' complain size to pass in + size = params['size'].value * 1000 + + # Get the 'name' of the image + name = File.basename virt_path + + # Get the qualified destination location (to make deleting their files easy) + dest_partial = "#{params['dest'].value}/#{params['qualifier'].value}-" + + # Get the full destination location, adding the name and a timestamp + dest_full = dest_partial + "#{name}-#{Time.now.strftime("%Y-%m-%d")}." + + # By default, don't allow backups to be overwritten + puts "Directory #{dest_full}* empty?: #{Dir.glob(dest_full + "*").empty?}" + unless Dir.glob(dest_full + "*").empty? + if params['force'].given? + puts "Removing existing backup" + sh "rm -rf #{dest_full}*" + else + fail("Cannot overwrite backup. Backup for '#{dest_full}' already exists.") + end + end + + # Remove existing backups unless --force is specified + sh "rm -rf #{dest_partial}*" unless params['force'].given? + + # Do the actual backup + sh "dd bs=8k if=#{virt_path} | split -b #{size}m - #{dest_full}" + + puts "Finished backing up image" +end diff --git a/everest-backup/lib/everest-backup/version.rb b/everest-backup/lib/everest-backup/version.rb new file mode 100644 index 0000000..b04069f --- /dev/null +++ b/everest-backup/lib/everest-backup/version.rb @@ -0,0 +1,9 @@ +module EverestBackup + module Version + MAJOR = 0 + MINOR = 2 + BUILD = 0 + + STRING = [MAJOR, MINOR, BUILD].join(".") + end +end diff --git a/everest-backup/test/test_everest-backup.rb b/everest-backup/test/test_everest-backup.rb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/everest-backup/test/test_everest-backup.rb diff --git a/everest-bootstrap/.gitignore b/everest-bootstrap/.gitignore new file mode 100644 index 0000000..3e57bca --- /dev/null +++ b/everest-bootstrap/.gitignore @@ -0,0 +1,3 @@ +*.swp +*.swo +pkg/* diff --git a/everest-bootstrap/History.txt b/everest-bootstrap/History.txt new file mode 100644 index 0000000..7bb5120 --- /dev/null +++ b/everest-bootstrap/History.txt @@ -0,0 +1,2 @@ +== 0.1.0 / 2008-01-18 + * Birthday! diff --git a/everest-bootstrap/Manifest.txt b/everest-bootstrap/Manifest.txt new file mode 100644 index 0000000..d61736c --- /dev/null +++ b/everest-bootstrap/Manifest.txt @@ -0,0 +1,12 @@ +History.txt +Manifest.txt +README.txt +Rakefile +bin/everest-bootstrap +lib/everest-bootstrap.rb +lib/everest-bootstrap/core.rb +lib/everest-bootstrap/commands.rb +lib/everest-bootstrap/ddns.rb +lib/everest-bootstrap/version.rb +ext/rubygem-everest-bootstrap.spec +test/test_everest-bootstrap.rb diff --git a/everest-bootstrap/README.txt b/everest-bootstrap/README.txt new file mode 100644 index 0000000..c079afb --- /dev/null +++ b/everest-bootstrap/README.txt @@ -0,0 +1,43 @@ +everest-bootstrap + by it-arch + +== DESCRIPTION: + +This is a provisioning too for IT puppet machines. + +== FEATURES/PROBLEMS: + +* CLI interface + +== SYNOPSIS: + + everest-bootstrap -h + +== INSTALL: + +* sudo gem/yum install everest-bootstrap + +== LICENSE: + +(The MIT License) + +Copyright (c) 2007 FIX + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/everest-bootstrap/Rakefile b/everest-bootstrap/Rakefile new file mode 100644 index 0000000..4e0517d --- /dev/null +++ b/everest-bootstrap/Rakefile @@ -0,0 +1,18 @@ +# -*- ruby -*- + +require 'rubygems' +require 'hoe' +require './lib/everest-bootstrap/version.rb' + +Hoe.new('everest-bootstrap', EverestBootstrap::Version::STRING) do |p| + p.author = 'it-arch' + p.email = "gis-java@redhat.com" + p.rubyforge_name = 'everest-bootstrap' + p.summary = 'Tool for provisioning virtual machines' + p.description = 'Tool for provisioning virtual machines' + # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1] + p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n") + p.extra_deps = %w[highline main] +end + +# vim: syntax=Ruby diff --git a/everest-bootstrap/bin/everest-bootstrap b/everest-bootstrap/bin/everest-bootstrap new file mode 100644 index 0000000..855d065 --- /dev/null +++ b/everest-bootstrap/bin/everest-bootstrap @@ -0,0 +1,152 @@ +#!/usr/bin/env ruby +require 'ostruct' +require 'everest-bootstrap' +require 'main' +require 'net/http' +require 'uri' + +COMMANDS = [] +def command(name, &task) + COMMANDS << OpenStruct.new(:name => name, :task => task) +end + +def sh(cmd) + puts cmd + print `#{cmd}` +end + +# Load the commands +instance_eval(File.read(File.dirname(__FILE__) + "/../lib/everest-bootstrap/commands.rb")) + +Main { + version EverestBootstrap::Version::STRING + + def handle_exception e + puts e.message + end unless $DEBUG + + def get_node_types(machine_name="everest") + url = "http://#{machine_name}-repo.usersys.redhat.com/cgi-bin/nodetypes.cgi" + Net::HTTP.get_response(URI.parse(url)) do |res| + if res.code == "200" + return res.body.split(" ").sort + else + error "#{url} returned a bad response" + return Array.new + end + end + end + + mode 'setup' do + option("machine-type") do + required + argument_required + description "Run 'everest-boostrap list-machines to see valid types" + end + + option("machine-name") do + argument_required + description 'The name of the machine (the part of the hostname before the machine type)' + end + + option("repo", "r") do + argument_required + description "Repo machine to use for puppet/git/archiva (leave off the '-repo' part)" + default 'everest' + end + + option("user", "u") do + required + argument_required + description 'Your kerberos username' + end + + option("facts", "f") do + argument_required + description 'Additional facts to lay down on the guest. Format is --facts=factname=foo|factname2=bar' + end + + mode 'guest' do + def everest_machine + @everest_machine ||= EverestBootstrap::EverestMachine.new(params['machine-type'].value, + params['machine-name'].given? ? params['machine-name'].value : params['user'].value, + params['user'].value, + params['repo'].value, + params['facts'].value) + end + + option("virt-path", "p") do + required + argument_required + description 'The path to the virtual image (this could be a file path or a logical volume name)' + end + + COMMANDS.each do |c| + mode c.name do + # We are forced to dynamically define the run method + # for the modules. Otherwise our 'c' would be out of + # scope. + define_method(:run) {instance_eval(&c.task)} + end + end + + # Figure out the virt-path destination + def virt_path + vpath = params['virt-path'].value + + # If the path doesn't start with a '/', assume it's a logical volume + unless /^\// =~ vpath + vpath = build_lvm_path + end + + return vpath + end + + def build_lvm_path + # Find the volume group for the specified LVM name + # Get a table of output with the lvm name and volume group + lvs_table = `/usr/sbin/lvs --noheadings -o lv_name,vg_name`.split + + # Find the matching logical volume and read corresponding volume group + volume_group = lvs_table[lvs_table.index(params['virt-path'].value) + 1] + + # Build up the device path + return "/dev/#{volume_group}/#{params['virt-path'].value}" + end + + # Run all the commands in order + def run + COMMANDS.each {|c| instance_eval(&c.task)} + end + end + + mode 'host' do + def everest_machine + @everest_machine ||= EverestBootstrap::EverestMachine.new(params['machine-type'].value, + params['machine-name'].given? ? params['machine-name'].value : params['user'].value, + params['user'].value, + params['repo'].value, + params['facts'].value, + :vm => false) + end + + def run + puts "Laying down firstboot script" + everest_machine.bootstrap + end + end + end + + mode 'list-machines' do + option("repo", "r") do + argument_required + description "Repo machine to use for puppet/git/artifactory (leave off the '-repo' part)" + default 'everest' + end + + def run() + repo = params["repo"].given? ? params["repo"].value : "everest" + puts get_node_types(repo) + end + end +} diff --git a/everest-bootstrap/ext/rubygem-everest-bootstrap.spec b/everest-bootstrap/ext/rubygem-everest-bootstrap.spec new file mode 100644 index 0000000..52f54cc --- /dev/null +++ b/everest-bootstrap/ext/rubygem-everest-bootstrap.spec @@ -0,0 +1,60 @@ +%define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']") +%define gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null) +%define gemname everest-bootstrap +%define geminstdir %{gemdir}/gems/%{gemname}-%{version} + +Summary: Tool for provisioning virtual machines +Name: rubygem-%{gemname} + +Version: 0.2.2 +Release: 1%{?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(main) +Requires: rubygem(hoe) >= 1.3.0 +Requires: wget +Requires: lvm2 +BuildRequires: rubygems +BuildArch: noarch +Provides: rubygem(%{gemname}) = %{version} +Obsoletes: everest-bootstrap +Obsoletes: rake +Obsoletes: hoe +Obsoletes: highline +Obsoletes: rubyforge +Obsoletes: rvm + +%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}/everest-bootstrap +%{gemdir}/gems/%{gemname}-%{version}/ +%doc %{gemdir}/doc/%{gemname}-%{version} +%doc %{geminstdir}/History.txt +%doc %{geminstdir}/Manifest.txt +%doc %{geminstdir}/README.txt +%{gemdir}/cache/%{gemname}-%{version}.gem +%{gemdir}/specifications/%{gemname}-%{version}.gemspec diff --git a/everest-bootstrap/lib/everest-bootstrap.rb b/everest-bootstrap/lib/everest-bootstrap.rb new file mode 100644 index 0000000..be3f402 --- /dev/null +++ b/everest-bootstrap/lib/everest-bootstrap.rb @@ -0,0 +1,7 @@ +require 'optparse' +require 'ostruct' +require 'open3' +require 'everest-bootstrap/ddns' +require 'everest-bootstrap/core' +require 'everest-bootstrap/version' +require 'highline' diff --git a/everest-bootstrap/lib/everest-bootstrap/commands.rb b/everest-bootstrap/lib/everest-bootstrap/commands.rb new file mode 100644 index 0000000..9e0f9f8 --- /dev/null +++ b/everest-bootstrap/lib/everest-bootstrap/commands.rb @@ -0,0 +1,41 @@ +# These commands will be executed in the order they are defined + +command :mount do + puts "Mounting the guests logical volume..." + sh "mkdir /mnt/#{everest_machine.fqmn}" + + if File.blockdev? virt_path + sh "/sbin/kpartx -a #{virt_path}" + sh "mount /dev/mapper/#{File.basename(virt_path)}p1 /mnt/#{everest_machine.fqmn}" + else + # This is not a block device, so we have to access it through a loopback + sh "/sbin/losetup /dev/loop0 #{virt_path}" + sh "/sbin/kpartx -a /dev/loop0" + sh "mount /dev/mapper/loop0p1 /mnt/#{everest_machine.fqmn}" + end +end + +command :prime_firstboot do + everest_machine.bootstrap +end + +command :unmount do + puts "Cleaning up..." + sh "umount /mnt/#{everest_machine.fqmn}" + + if File.blockdev? virt_path + sh "/sbin/kpartx -d #{virt_path}" + else + # This is not a block device, so cleanup the loopback + sh "/sbin/kpartx -d /dev/loop0" + sh "/sbin/losetup -d /dev/loop0" + end + + sh "rmdir /mnt/#{everest_machine.fqmn}" +end + +command :finish do + puts "Finished configuring puppet to run on first boot." + puts "The next time you start this machine, puppet will configure it as #{everest_machine.fqdn}" + puts "Once you are logged in `tail -f /var/log/messages` to see how puppet is doing." +end diff --git a/everest-bootstrap/lib/everest-bootstrap/core.rb b/everest-bootstrap/lib/everest-bootstrap/core.rb new file mode 100644 index 0000000..377795e --- /dev/null +++ b/everest-bootstrap/lib/everest-bootstrap/core.rb @@ -0,0 +1,54 @@ +module EverestBootstrap + class EverestMachine + include RedHatDDNS + attr_reader :type, :hostname, :fqdn, :fqmn + + def initialize(machine_type, machine_name, kerb_user, repo, facts, options = {:vm => true}) + @kerb_user = kerb_user + @machine_name = machine_name + # Fully qualified machine name (like 'team1Repo' or 'bleanharBuild') + @fqmn = machine_name + machine_type + # This is the "Everest" machine type. ie, web-build instead of WebBuild + @hostname_suffix = machine_type.gsub(/(.)([A-Z])/, '\1-\2').downcase + @hostname = @machine_name + "-" + @hostname_suffix + @fqdn = @hostname + ".usersys.redhat.com" + @repo = repo + "-repo" + @ui = HighLine.new + @password = @ui.ask("Enter your kerberos password to setup DDNS: ") { |q| q.echo = "*" } + @facts = facts + @vm = options[:vm] + end + + def ddns_hash + @ddns_hash ||= DDNS.new(@kerb_user, @password, @hostname) + end + + def bootstrap + firstboot_path = "/usr/sbin/everest-firstboot" + sysconfig_path = "/etc/sysconfig/everest-firstboot" + + # If this is a vm, use the vm mount point + firstboot_path = "/mnt/#{@fqmn}" + firstboot_path if @vm + sysconfig_path = "/mnt/#{@fqmn}" + sysconfig_path if @vm + + # This firstboot script is executed by a firstboot-like service script + # that is layed down at provisioning time by an rpm called everest-firstboot. + # That service wrapper in that rpm is configured to run at system startup + # which checks the /etc/sysconfig file to determine whether or not to run + # the dynamically generated puppet firstboot file. + puts "Laying down firstboot script" + File.open(firstboot_path, "w") do |f| + f.puts `#{"curl --get -d template=bootstrap " + + "-d node_type=#{@hostname_suffix} " + + "-d username=#{@kerb_user} " + + "-d machine_name=#{@machine_name} " + + "-d ddns_hash=#{ddns_hash} " + + "-d facts=#{@facts} " + + "http://#{@repo}.usersys.redhat.com/cgi-bin/everest.cgi"}` + end + + File.chmod(0755, firstboot_path) + File.open(sysconfig_path, "w") { |f| f.puts "RUN_BOOTSTRAP=YES" } + end + end +end diff --git a/everest-bootstrap/lib/everest-bootstrap/ddns.rb b/everest-bootstrap/lib/everest-bootstrap/ddns.rb new file mode 100644 index 0000000..176009a --- /dev/null +++ b/everest-bootstrap/lib/everest-bootstrap/ddns.rb @@ -0,0 +1,57 @@ +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 try_fetch + main_page do |html| + /#{@hostname}.*?hash=(.*)\"/.match(html)[1] rescue nil + end + 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 + hash = try_fetch + return hash if hash + puts "Hash not found for #{@hostname}" + request_new_hash + end + + $stderr.puts "Error fetching DDNS hash. Maybe you typed your password incorrectly." + exit 1 + end + end +end diff --git a/everest-bootstrap/lib/everest-bootstrap/version.rb b/everest-bootstrap/lib/everest-bootstrap/version.rb new file mode 100644 index 0000000..a8e8aaf --- /dev/null +++ b/everest-bootstrap/lib/everest-bootstrap/version.rb @@ -0,0 +1,9 @@ +module EverestBootstrap + module Version + MAJOR = 0 + MINOR = 2 + BUILD = 2 + + STRING = [MAJOR, MINOR, BUILD].join(".") + end +end diff --git a/everest-bootstrap/test/test_everest-bootstrap.rb b/everest-bootstrap/test/test_everest-bootstrap.rb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/everest-bootstrap/test/test_everest-bootstrap.rb diff --git a/gwt-linux-1.4.60/about.txt b/gwt-linux-1.4.60/about.txt new file mode 100755 index 0000000..e810d03 --- /dev/null +++ b/gwt-linux-1.4.60/about.txt @@ -0,0 +1,21 @@ +Google Web Toolkit 1.4.60 +Copyright (c) Google, Inc. 2007. All rights reserved. +Visit Google Code (http://code.google.com/webtoolkit/). + +This product includes software developed by: + - The Apache Software Foundation (http://www.apache.org/). + - Tomcat (http://tomcat.apache.org/) with modifications + - Xerces (http://xerces.apache.org/) + - Tapestry (http://tapestry.apache.org/) + - The Eclipse Foundation (http://www.eclipse.org/). + - Java Development Tools (http://www.eclipse.org/jdt/) + - Standard Widget Toolkit (http://www.eclipse.org/swt/) with modifications + - The JFreeChart project (http://www.jfree.org/jfreechart/) + - The Mozilla Foundation (http://www.mozilla.org/). + - Mozilla 1.7.12 (http://www.mozilla.org/releases/mozilla1.7.12/) + - Rhino (http://www.mozilla.org/rhino/) with modifications + - The SAX project (http://www.saxproject.org/) + - The WebKit Open Source Project (http://www.webkit.org) + - The W3C consortium (http://www.w3.org/) + +For source availability and license information see COPYING. diff --git a/gwt-linux-1.4.60/applicationCreator b/gwt-linux-1.4.60/applicationCreator new file mode 100755 index 0000000..f60fa07 --- /dev/null +++ b/gwt-linux-1.4.60/applicationCreator @@ -0,0 +1,3 @@ +#!/bin/sh +HOMEDIR=`dirname $0`; +java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev-linux.jar com.google.gwt.user.tools.ApplicationCreator "$@"; diff --git a/gwt-linux-1.4.60/benchmarkViewer b/gwt-linux-1.4.60/benchmarkViewer new file mode 100755 index 0000000..1735d0a --- /dev/null +++ b/gwt-linux-1.4.60/benchmarkViewer @@ -0,0 +1,3 @@ +#!/bin/sh +APPDIR=`dirname $0`; +java -Dcom.google.gwt.junit.reportPath="$1" -cp "$APPDIR/gwt-user.jar:$APPDIR/gwt-dev-linux.jar:$APPDIR/gwt-benchmark-viewer.jar" com.google.gwt.dev.GWTShell -port auto com.google.gwt.junit.viewer.ReportViewer/ReportViewer.html?gwt.hybrid; diff --git a/gwt-linux-1.4.60/gwt-benchmark-viewer.jar b/gwt-linux-1.4.60/gwt-benchmark-viewer.jar Binary files differnew file mode 100755 index 0000000..11e9f22 --- /dev/null +++ b/gwt-linux-1.4.60/gwt-benchmark-viewer.jar diff --git a/gwt-linux-1.4.60/gwt-dev-linux.jar b/gwt-linux-1.4.60/gwt-dev-linux.jar Binary files differnew file mode 100755 index 0000000..f40f35c --- /dev/null +++ b/gwt-linux-1.4.60/gwt-dev-linux.jar diff --git a/gwt-linux-1.4.60/gwt-module.dtd b/gwt-linux-1.4.60/gwt-module.dtd new file mode 100755 index 0000000..0909f53 --- /dev/null +++ b/gwt-linux-1.4.60/gwt-module.dtd @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!-- -->
+<!-- Copyright 2007 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- may obtain a copy of the License at -->
+<!-- -->
+<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
+<!-- -->
+<!-- Unless required by applicable law or agreed to in writing, software -->
+<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -->
+<!-- implied. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<!-- The module root element -->
+<!ELEMENT module (inherits | source | public | super-source | entry-point |
+ stylesheet | script | servlet | replace-with | generate-with |
+ define-property | extend-property | set-property | property-provider)*>
+<!-- Inherit the contents of another module -->
+<!ELEMENT inherits EMPTY>
+<!ATTLIST inherits
+ name CDATA #REQUIRED
+>
+<!-- Specify the source path, relative to the classpath location of the module descriptor -->
+<!ELEMENT source EMPTY>
+<!ATTLIST source
+ path CDATA #REQUIRED
+>
+<!-- Specify the public resource path, relative to the classpath location of the module descriptor -->
+<!ELEMENT public (include | exclude)*>
+<!ATTLIST public
+ path CDATA #REQUIRED
+ includes CDATA #IMPLIED
+ excludes CDATA #IMPLIED
+ defaultexclude (yes | no) "yes"
+ casesensitive (true | false) "true"
+>
+<!ELEMENT include EMPTY>
+<!ATTLIST include
+ name CDATA #REQUIRED
+>
+<!ELEMENT exclude EMPTY>
+<!ATTLIST exclude
+ name CDATA #REQUIRED
+>
+
+<!-- Define a module entry point -->
+<!ELEMENT entry-point EMPTY>
+<!ATTLIST entry-point
+ class CDATA #REQUIRED
+>
+<!-- Preload a stylesheet before executing the GWT application -->
+<!ELEMENT stylesheet EMPTY>
+<!ATTLIST stylesheet
+ src CDATA #REQUIRED
+>
+<!-- Preload an external JavaScript file before executing the GWT application -->
+<!ELEMENT script (#PCDATA)>
+<!ATTLIST script
+ src CDATA #REQUIRED
+>
+<!-- Map a named servlet class to a module-relative path in hosted mode -->
+<!ELEMENT servlet EMPTY>
+<!ATTLIST servlet
+ path CDATA #REQUIRED
+ class CDATA #REQUIRED
+>
+
+<!-- ^^^ Commonly-used elements ^^^ -->
+<!-- VVV Deferred binding elements VVV -->
+
+<!-- Define a property and allowable values (comma-separated identifiers) -->
+<!ELEMENT define-property EMPTY>
+<!ATTLIST define-property
+ name CDATA #REQUIRED
+ values CDATA #REQUIRED
+>
+<!-- Set the value of a previously-defined property -->
+<!ELEMENT set-property EMPTY>
+<!ATTLIST set-property
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED
+>
+<!-- Add additional allowable values to a property -->
+<!ELEMENT extend-property EMPTY>
+<!ATTLIST extend-property
+ name CDATA #REQUIRED
+ values CDATA #REQUIRED
+>
+<!-- Define a JavaScript fragment that will return the value for the named property at runtime -->
+<!ELEMENT property-provider (#PCDATA)>
+<!ATTLIST property-provider
+ name CDATA #REQUIRED
+>
+<!-- All possible predicates -->
+<!ENTITY % predicates "when-property-is | when-type-assignable | when-type-is | all | any | none">
+<!-- Deferred binding assignment to substitute a named class -->
+<!ELEMENT replace-with (%predicates;)*>
+<!ATTLIST replace-with
+ class CDATA #REQUIRED
+>
+<!-- Deferred binding assignment to substitute a generated class -->
+<!ELEMENT generate-with (%predicates;)*>
+<!ATTLIST generate-with
+ class CDATA #REQUIRED
+>
+<!-- Deferred binding predicate that is true when a named property has a given value-->
+<!ELEMENT when-property-is EMPTY>
+<!ATTLIST when-property-is
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED
+>
+<!-- Deferred binding predicate that is true for types in the type system that are assignable to the specified type -->
+<!ELEMENT when-type-assignable EMPTY>
+<!ATTLIST when-type-assignable
+ class CDATA #REQUIRED
+>
+<!-- Deferred binding predicate that is true for exactly one type in the type system -->
+<!ELEMENT when-type-is EMPTY>
+<!ATTLIST when-type-is
+ class CDATA #REQUIRED
+>
+<!-- Predicate that ANDs all child conditions -->
+<!ELEMENT all (%predicates;)*>
+<!-- Predicate that ORs all child conditions -->
+<!ELEMENT any (%predicates;)*>
+<!-- Predicate that NANDs all child conditions -->
+<!ELEMENT none (%predicates;)*>
+<!-- Used internally by GWT system modules to rebase packages into the root namespace -->
+<!ELEMENT super-source EMPTY>
diff --git a/gwt-linux-1.4.60/gwt-servlet.jar b/gwt-linux-1.4.60/gwt-servlet.jar Binary files differnew file mode 100755 index 0000000..e8b1b09 --- /dev/null +++ b/gwt-linux-1.4.60/gwt-servlet.jar diff --git a/gwt-linux-1.4.60/gwt-user.jar b/gwt-linux-1.4.60/gwt-user.jar Binary files differnew file mode 100755 index 0000000..57ad8a1 --- /dev/null +++ b/gwt-linux-1.4.60/gwt-user.jar diff --git a/gwt-linux-1.4.60/i18nCreator b/gwt-linux-1.4.60/i18nCreator new file mode 100755 index 0000000..0e05618 --- /dev/null +++ b/gwt-linux-1.4.60/i18nCreator @@ -0,0 +1,3 @@ +#!/bin/sh +HOMEDIR=`dirname $0`; +java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev-linux.jar com.google.gwt.i18n.tools.I18NCreator "$@"; diff --git a/gwt-linux-1.4.60/junitCreator b/gwt-linux-1.4.60/junitCreator new file mode 100755 index 0000000..9775188 --- /dev/null +++ b/gwt-linux-1.4.60/junitCreator @@ -0,0 +1,3 @@ +#!/bin/sh +HOMEDIR=`dirname $0`; +java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev-linux.jar com.google.gwt.junit.tools.JUnitCreator "$@"; diff --git a/gwt-linux-1.4.60/libgwt-ll.so b/gwt-linux-1.4.60/libgwt-ll.so Binary files differnew file mode 100755 index 0000000..48351ee --- /dev/null +++ b/gwt-linux-1.4.60/libgwt-ll.so diff --git a/gwt-linux-1.4.60/libswt-gtk-3235.so b/gwt-linux-1.4.60/libswt-gtk-3235.so Binary files differnew file mode 100755 index 0000000..ccf617f --- /dev/null +++ b/gwt-linux-1.4.60/libswt-gtk-3235.so diff --git a/gwt-linux-1.4.60/libswt-mozilla-gcc3-gtk-3235.so b/gwt-linux-1.4.60/libswt-mozilla-gcc3-gtk-3235.so Binary files differnew file mode 100755 index 0000000..88acc1a --- /dev/null +++ b/gwt-linux-1.4.60/libswt-mozilla-gcc3-gtk-3235.so diff --git a/gwt-linux-1.4.60/libswt-mozilla-gtk-3235.so b/gwt-linux-1.4.60/libswt-mozilla-gtk-3235.so Binary files differnew file mode 100755 index 0000000..5781773 --- /dev/null +++ b/gwt-linux-1.4.60/libswt-mozilla-gtk-3235.so diff --git a/gwt-linux-1.4.60/libswt-mozilla17-profile-gcc3-gtk-3235.so b/gwt-linux-1.4.60/libswt-mozilla17-profile-gcc3-gtk-3235.so Binary files differnew file mode 100755 index 0000000..4d04621 --- /dev/null +++ b/gwt-linux-1.4.60/libswt-mozilla17-profile-gcc3-gtk-3235.so diff --git a/gwt-linux-1.4.60/libswt-mozilla17-profile-gtk-3235.so b/gwt-linux-1.4.60/libswt-mozilla17-profile-gtk-3235.so Binary files differnew file mode 100755 index 0000000..0824c20 --- /dev/null +++ b/gwt-linux-1.4.60/libswt-mozilla17-profile-gtk-3235.so diff --git a/gwt-linux-1.4.60/libswt-pi-gtk-3235.so b/gwt-linux-1.4.60/libswt-pi-gtk-3235.so Binary files differnew file mode 100755 index 0000000..0905c09 --- /dev/null +++ b/gwt-linux-1.4.60/libswt-pi-gtk-3235.so diff --git a/gwt-linux-1.4.60/mozilla-hosted-browser.conf b/gwt-linux-1.4.60/mozilla-hosted-browser.conf new file mode 100755 index 0000000..743c8d0 --- /dev/null +++ b/gwt-linux-1.4.60/mozilla-hosted-browser.conf @@ -0,0 +1,35 @@ +# This file specifies a list of possible mozilla installations to load, in +# priority order. Non-existent paths are ignored, and the next location is +# searched. A best effort attempt is also made to ignore paths containing +# incompatible mozilla installations (for example, ones which use GTK1 instead +# of GTK2, which is required). The first apparently valid installation found +# will be used (although it could still fail later). +# +# Non-absolute paths are relative to the directory containing this file (that +# is, the GWT install directory). +# +# Non-system installations should contain a file named "gwt-dl-loadorder.conf". +# The format of such a file is one shared library per line which dictates the +# order in which that installation's shared libraries must be loaded to prevent +# implicit loading of other libraries. In other words, no library should be +# loaded before its dependencies. This is to prevent the LD_LIBRARY_PATH or +# other system library load configuration from loading the default system +# version of the library instead of the version in the target installation. + + +# Prefer mozilla 1.7.13 if it exists, because it supports mouse wheel events. +# If you need mouse wheel events, you can install the distribution available at: +# +# http://google-web-toolkit.googlecode.com/svn/tools/redist/mozilla/mozilla-1.7.13.tar.gz +# +# However, this version may not run correctly on your system. If it doesn't, +# you can try installing a mozilla 1.7.13 built for your system. +mozilla-1.7.13 + +# This is the default mozilla that ships with GWT. +mozilla-1.7.12 + +# See if there are compatible mozilla distributions already installed. +/usr/lib/mozilla-1.7.13 +/usr/lib/mozilla-1.7.12 +/usr/lib/mozilla diff --git a/gwt-linux-1.4.60/projectCreator b/gwt-linux-1.4.60/projectCreator new file mode 100755 index 0000000..ada82c5 --- /dev/null +++ b/gwt-linux-1.4.60/projectCreator @@ -0,0 +1,3 @@ +#!/bin/sh +HOMEDIR=`dirname $0`; +java -cp $HOMEDIR/gwt-user.jar:$HOMEDIR/gwt-dev-linux.jar com.google.gwt.user.tools.ProjectCreator "$@"; |
