summaryrefslogtreecommitdiffstats
path: root/genomed
diff options
context:
space:
mode:
authorChris Alfonso <calfonso@redhat.com>2008-07-07 17:20:43 -0400
committerChris Alfonso <calfonso@redhat.com>2008-07-08 10:43:59 -0400
commit40598cb7bfeb6b1042482fe91701770b179c1803 (patch)
tree57d9b019a845fbcf4a7fcb8ccbce836bfc45174c /genomed
parent9b9d481f6684777e90bb144193251244d14926ae (diff)
downloadtools-40598cb7bfeb6b1042482fe91701770b179c1803.tar.gz
tools-40598cb7bfeb6b1042482fe91701770b179c1803.tar.xz
tools-40598cb7bfeb6b1042482fe91701770b179c1803.zip
Renaming everying everest to genome
Diffstat (limited to 'genomed')
-rw-r--r--genomed/LICENSE305
-rw-r--r--genomed/Makefile35
-rw-r--r--genomed/README4
-rw-r--r--genomed/Rakefile46
-rw-r--r--genomed/bin/genomed14
-rw-r--r--genomed/bin/genomed-ctl8
-rw-r--r--genomed/extra/config.yml88
-rw-r--r--genomed/extra/genomed.apache5
-rwxr-xr-xgenomed/extra/genomed.redhat43
-rw-r--r--genomed/extra/genomed.spec70
-rw-r--r--genomed/lib/genomed.rb433
-rwxr-xr-xgenomed/script/destroy14
-rwxr-xr-xgenomed/script/generate14
-rw-r--r--genomed/spec/genomed_spec.rb27
-rw-r--r--genomed/spec/spec.opts1
-rw-r--r--genomed/spec/spec_helper.rb26
16 files changed, 1133 insertions, 0 deletions
diff --git a/genomed/LICENSE b/genomed/LICENSE
new file mode 100644
index 0000000..8764452
--- /dev/null
+++ b/genomed/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/genomed/Makefile b/genomed/Makefile
new file mode 100644
index 0000000..acc024f
--- /dev/null
+++ b/genomed/Makefile
@@ -0,0 +1,35 @@
+NAME := genomed
+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/genomed/README b/genomed/README
new file mode 100644
index 0000000..bf389c3
--- /dev/null
+++ b/genomed/README
@@ -0,0 +1,4 @@
+genomed
+============
+
+A gem that provides...
diff --git a/genomed/Rakefile b/genomed/Rakefile
new file mode 100644
index 0000000..eca48ec
--- /dev/null
+++ b/genomed/Rakefile
@@ -0,0 +1,46 @@
+require 'rubygems'
+require 'rake/gempackagetask'
+require 'rake/clean'
+require 'rubygems/specification'
+require 'date'
+
+GEM = "genomed"
+GEM_VERSION = "1.0.0"
+AUTHOR = "Red Hat IT"
+EMAIL = "genome-project-list@redhat.com"
+HOMEPAGE = "http://fedorahosted.org/genome"
+SUMMARY = "A gem that installs the genomed daemon and service script. The service runs on port 8106 by default"
+
+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 = ["genomed", "genomed-ctl"]
+ s.summary = SUMMARY
+ s.description = s.summary
+ s.author = AUTHOR
+ s.email = EMAIL
+ s.homepage = HOMEPAGE
+ s.add_dependency "picnic"
+ s.require_path = 'lib'
+ s.autorequire = GEM
+ s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,extra,lib,specs}/**/*")
+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/genomed/bin/genomed b/genomed/bin/genomed
new file mode 100644
index 0000000..3736b83
--- /dev/null
+++ b/genomed/bin/genomed
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+#
+# Created by Brenton Leanhardt on 2008-4-9.
+# Copyright (c) 2008. All rights reserved.
+
+require 'rubygems'
+require 'picnic/cli'
+
+cli = Picnic::Cli.new(
+ 'genomed',
+ :app_path => File.expand_path(File.dirname(File.expand_path(__FILE__)))
+)
+
+cli.handle_cli_input
diff --git a/genomed/bin/genomed-ctl b/genomed/bin/genomed-ctl
new file mode 100644
index 0000000..a62d0b6
--- /dev/null
+++ b/genomed/bin/genomed-ctl
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'picnic/service_control'
+
+ctl = Picnic::ServiceControl.new('genomed')
+
+ctl.handle_cli_input
diff --git a/genomed/extra/config.yml b/genomed/extra/config.yml
new file mode 100644
index 0000000..9d91e46
--- /dev/null
+++ b/genomed/extra/config.yml
@@ -0,0 +1,88 @@
+# AN IMPORTANT NOTE ABOUT YAML CONFIGURATION FILES:
+# !!! Be sure to use spaces instead of tabs for indentation, as YAML is very
+# !!! sensitive to white-space inconsistencies!
+
+##### HTTP SERVER #####################################################################
+
+# Under what HTTP environment are you running the Cloudmasterd server? The following methods
+# are currently supported:
+#
+# webrick -- simple stand-alone HTTP server; this is the default method
+# mongrel -- fast stand-alone HTTP server; much faster than webrick, but
+# you'll have to first install the mongrel gem
+#
+
+### webrick example
+
+server: webrick
+port: 8106
+
+### webrick SSL example
+
+#server: webrick
+#port: 443
+#ssl_cert: /path/to/your/ssl.pem
+
+# if the private key is separate from cert:
+#ssl_key: /path/to/your/private_key.pem
+
+
+### mongrel example
+
+#server: mongrel
+#port: 8106
+
+# It is possible to run mongrel over SSL, but you will need to use a reverse proxy
+# (try Pound or Apache).
+
+
+##### DATABASE ########################################################################
+
+# The Blog needs a database to store its records.
+#
+# By default, we use MySQL, since it is widely used and does not require any additional
+# ruby libraries besides ActiveRecord.
+#
+# With MySQL, your config would be something like the following:
+# (be sure to create the blog database in MySQL beforehand,
+# i.e. `mysqladmin -u root create blog`)
+
+#database:
+# adapter: mysql
+# database: blog
+# username: root
+# password:
+# host: localhost
+
+
+# Instead of MySQL you can use SQLite3, PostgreSQL, MSSQL, or anything else supported
+# by ActiveRecord.
+#
+# If you do not have a database server available, you can try using the SQLite3
+# back-end. SQLite3 does not require it's own server. Instead all data is stored
+# in local files. For SQLite3, your configuration would look something like the
+# following (don't forget to install the 'sqlite3-ruby' gem first!):
+#
+#database:
+# adapter: sqlite3
+# dbfile: /var/lib/blog.db
+
+##### GENOMED ########################################################################
+
+
+##### LOGGING #########################################################################
+
+# This log is where you'll want to look in case of problems.
+#
+# By default, we will try to create a log file named 'blog.log' in the current
+# directory (the directory where you're running the blog from). A better place to put
+# the log is in /var/log, but you will have to run blog as root or otherwise give
+# it permissions.
+#
+# Set the level to DEBUG if you want more detailed logging. Other options are
+# INFO, WARN, and ERROR (DEBUG is most verbose, ERROR is least).
+
+log:
+ level: DEBUG
+ file: /var/log/genomed.log
+# level: INFO
diff --git a/genomed/extra/genomed.apache b/genomed/extra/genomed.apache
new file mode 100644
index 0000000..deaee88
--- /dev/null
+++ b/genomed/extra/genomed.apache
@@ -0,0 +1,5 @@
+RewriteEngine On
+RewriteRule ^/genome$ http://%{SERVER_NAME}/genome/nodes.html [NE]
+
+ProxyPass /genome http://localhost:8106
+ProxyPassReverse /genome http://localhost:8106
diff --git a/genomed/extra/genomed.redhat b/genomed/extra/genomed.redhat
new file mode 100755
index 0000000..0b4fd29
--- /dev/null
+++ b/genomed/extra/genomed.redhat
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# genomed: Init script for Genome daemon.
+#
+# chkconfig: 35 91 03
+#
+# description: Web service for Genome repositories.
+#
+#
+#
+
+# Source function library.
+. /etc/init.d/functions
+
+CTL=genomed-ctl
+
+[ -z "$HOME" ] && export HOME=/
+
+case "$1" in
+ start)
+ echo -n $"Starting genomed: "
+ $CTL start
+ RETVAL=$?
+ ;;
+ stop)
+ echo -n $"Stopping genomed: "
+ $CTL stop
+ RETVAL=$?
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ status)
+ $CTL status
+ RETVAL=$?
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart}"
+ RETVAL=1
+esac
+
+exit $RETVAL
diff --git a/genomed/extra/genomed.spec b/genomed/extra/genomed.spec
new file mode 100644
index 0000000..b6b4183
--- /dev/null
+++ b/genomed/extra/genomed.spec
@@ -0,0 +1,70 @@
+# Generated from genomed-0.1.0.gem by gem2rpm -*- rpm-spec -*-
+%define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
+%define gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
+%define gemname genomed
+%define geminstdir %{gemdir}/gems/%{gemname}-%{version}
+
+Summary: Genome Repository daemon for machine configuration
+Name: rubygem-%{gemname}
+Version: 1.0.0
+Release: 6%{?dist}
+Group: Applications/System
+License: GPLv2+
+URL: http://fedorahosted.org/genome
+Source0: %{gemname}-%{version}.gem
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+Requires: httpd
+Requires: rubygems
+Requires: rubygem(picnic)
+Requires: rubygem(activesupport)
+Requires: rubygem(reststop) >= 0.2.1
+Requires: rubygem(genome-dsl)
+Requires: genome-styling
+BuildRequires: rubygems
+BuildArch: noarch
+Provides: rubygem(%{gemname}) = %{version}
+
+%description
+Genome Repository daemon for machine configuration
+
+%prep
+
+%build
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}%{gemdir} %{buildroot}/etc/init.d %{buildroot}/etc/genomed
+gem install --local --install-dir %{buildroot}%{gemdir} \
+ --force --rdoc %{SOURCE0}
+mkdir -p %{buildroot}/%{_bindir}
+mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
+mv %{buildroot}%{geminstdir}/extra/genomed.redhat %{buildroot}/etc/init.d/genomed
+mv %{buildroot}%{geminstdir}/extra/config.yml %{buildroot}/etc/genomed/config.yml
+rmdir %{buildroot}%{gemdir}/bin
+find %{buildroot}%{geminstdir}/bin -type f | xargs chmod a+x
+
+# Put in the apache rules
+mkdir -p %{buildroot}/etc/httpd/conf.d
+mv %{buildroot}%{geminstdir}/extra/genomed.apache %{buildroot}/etc/httpd/conf.d/genomed.conf
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%{_bindir}/genomed
+%{_bindir}/genomed-ctl
+%{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
+%config /etc/genomed/config.yml
+/etc/httpd/conf.d/genomed.conf
+
+%defattr(755, root, root, -)
+/etc/init.d/genomed
+
+%changelog
+* Mon Jun 23 2008 <bleanhar@redhat.com> - 1.0.0-1
+- 1.0 Release
diff --git a/genomed/lib/genomed.rb b/genomed/lib/genomed.rb
new file mode 100644
index 0000000..3a1705e
--- /dev/null
+++ b/genomed/lib/genomed.rb
@@ -0,0 +1,433 @@
+# 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.
+
+$: << File.dirname(File.expand_path(__FILE__))
+
+gem 'reststop', '~> 0.2'
+
+require 'yaml'
+require 'fileutils'
+require 'rubygems'
+require 'picnic'
+require 'reststop'
+require 'genome-dsl'
+require 'restr'
+require 'cgi'
+require 'xmlrpc/client'
+require 'pp'
+
+CONTEXT="/genome"
+
+Camping.goes :Genomed
+Genomed.picnic!
+
+module Genomed::Controllers
+ class Systems < REST 'systems'
+ # OMG, this is ugly
+ def _get_cobbler_installed_systems
+ systems = {}
+ `cat /var/log/cobbler/install.log | cut -f2-3`.each do |line|
+ name, ip = line.split("\t")
+ ip.chomp!
+ name.chomp!
+ hostname = _get_host_name(ip).chomp
+ puts "name: #{name}, ip: #{ip}, hostname: #{hostname}"
+
+ systems[name] = {"ip" => ip, "hostname" => hostname}
+ end
+ return systems
+ end
+
+ def _get_host_name(ip)
+ lookup = `nslookup #{ip} | grep name | cut -f2`
+ unless lookup.empty?
+ return lookup.split("=")[1].strip.split(".").join(".")
+ end
+ end
+
+ def read(name)
+ name = CGI::unescape(name)
+ @systems = _get_cobbler_installed_systems
+ @system = {}
+ if @systems.has_key?(name)
+ @system = {"name" => name, "ip" => @systems[name]["ip"], "hostname" => @systems[name]["hostname"]}
+ end
+ render :view_system
+ end
+
+ def list
+ @systems = _get_cobbler_installed_systems
+ pp @systems
+ render :list_systems
+ end
+ end
+
+ class MachineTypes < REST 'machine_types'
+ include GenomeDsl
+
+ # GET /types/foo
+ # GET /types/foo.xml
+ def read(type)
+ @machine = machines.find {|m| m.name == type}
+ render :view_type
+ end
+
+ # GET /types
+ # GET /types.xml
+ def list
+ @machines = machines
+ render :list_types
+ end
+ end
+
+ class Nodes < REST 'nodes'
+ # GET /nodes/foo
+ # GET /nodes/foo.xml
+ def read(name)
+ @name = name
+ begin
+ @info = YAML.load(File.read("/etc/genome/nodes/#{@name}/node.yaml"))
+ render :view_node
+ rescue
+ # node doesn't exist yet
+ render :add
+ end
+ end
+
+ # GET /nodes
+ # GET /nodes.xml
+ def list
+ @nodes = Dir["/etc/genome/nodes/*"].map { |m| File.basename(m) }
+ render :list_nodes
+ end
+
+ def create
+ if input.wizard
+ puts "You're using the wizard!"
+ puts input.inspect
+ elsif input.yaml
+ node_dir = "/etc/genome/nodes/#{input.node_name}"
+ persist_node(input.node_name, input.yaml)
+ elsif input.xml
+ xml = XmlSimple.xml_in(input.xml)
+
+ params = Hash.new
+ xml["parameters"].each do |p|
+ p.each_key do |k|
+ params[k] = p[k].to_s #The value is an array. Yay.
+ end
+ end
+
+ persist_node(xml["name"].to_s, YAML.dump({"classes" => xml["class"], "parameters" => params}))
+ end
+
+ redirect R(Nodes) if @format == :HTML
+ end
+
+ def persist_node(node, yaml)
+ node_dir = "/etc/genome/nodes/#{node}"
+ FileUtils.mkdir_p(node_dir) unless File.exist?(node_dir)
+ File.open(node_dir + "/node.yaml", "w") {|f| f.puts yaml}
+ end
+ end
+
+ class Wizard < REST 'wizard'
+ include GenomeDsl
+
+ # GET /wizard/foo
+ # GET /wizard/foo.xml
+ def read(type)
+ @machine = machines.find {|m| m.name == type}
+ render :view_type
+ end
+
+ # GET /types
+ # GET /types.xml
+ def list
+ @machines = machines
+ render :list_types
+ end
+
+ def create
+ @machine_type = input.machine_type
+
+ redirect CONTEXT + R(Nodes)
+ end
+ end
+end
+
+module Genomed::Views
+ def initialize(*args)
+ super(*args)
+ @x = Builder::XmlMarkup.new(:indent => 1)
+ end
+
+ module HTML
+ def layout
+ html do
+ head do
+ title 'Genome'
+ link :rel => 'stylesheet', :type => 'text/css', :href => '/styles.css', :media => 'screen'
+ end
+ body do
+ div.header! do
+ div.headerLogo! {}
+ end
+ div.content! do
+ h1 do
+ [a("Machine Types", :href => CONTEXT + R(Genomed::Controllers::MachineTypes)),
+ a("Nodes", :href => CONTEXT + R(Genomed::Controllers::Nodes)),
+ a("Systems", :href => CONTEXT + R(Genomed::Controllers::Systems))].join " | "
+ end
+ self << yield
+ end
+ end
+ end
+ end
+
+ def add
+ form(:method => 'post', :action => CONTEXT + R(Genomed::Controllers::Nodes)) do
+ h2 "YAML"
+
+ textarea :name => 'yaml', :rows => '25', :cols => '100'; br
+
+ input :name => 'node_name', :value => @name
+ input :type => 'submit', :value => "Submit"
+ end
+ end
+
+ def view_type
+ p do
+ h1 @machine.name
+ p @machine.desc
+
+ form(:method => 'post', :action => CONTEXT + R(Genomed::Controllers::Nodes)) do
+ h2 "Fully qualified domain name"
+ input :name => "fqdn", :type => 'text', :size => 45,
+ :value => "[prefix]-#{@machine.name}.usersys.redhat.com"
+
+ h2 "Classes"
+ @machine.classes.each_with_index do |c, i|
+ input :name => "class#{i}", :type => 'text',
+ :value => c; br
+ end
+
+ h2 "Parameters"
+ fieldset do
+ @machine.facts.each do |f|
+ a(f.name, :href => "fix me", :title => f.desc); br
+ input :name => "param_" + f.name, :type => 'text', :size => 45,
+ :value => f.default; br
+ end
+ end
+
+ input :type => 'hidden', :name => 'node_name', :value => @name
+ input :type => 'hidden', :name => 'wizard', :value => true
+ input :type => 'submit', :value => "Submit"
+ end
+ end
+ end
+
+ def view_node
+ h1 @name
+
+ p "This form allows you to submit the YAML to be used by the Puppetmaster to " +
+ "determine the configuration to be compiled for a particular host."
+ form(:method => 'post', :action => CONTEXT + R(Genomed::Controllers::Nodes)) do
+
+ textarea ::YAML.dump(@info), :name => 'yaml', :rows => '25', :cols => '100'; br
+
+ input :type => 'hidden', :name => 'node_name', :value => @name
+ input :type => 'submit', :value => "Submit"
+ end
+ end
+
+ def view_system
+ h1 @system["name"]
+
+ p do
+ "IP Address: #{@system["ip"]} "
+ end
+ p do
+ "Hostname: #{@system["hostname"]}"
+ end
+ end
+
+ def list_nodes
+ h1 "Nodes:"
+ p "To create a new node just browse to the page corresponding to the hostname. " +
+ "eg, #{CONTEXT + R(Genomed::Controllers::Nodes, "[hostname]")}."
+ p do
+ ol do
+ @nodes.each do |n|
+ # BUG: default format is not getting preserved
+ @format = :HTML
+ li {a(n, :href => CONTEXT + R(Genomed::Controllers::Nodes, n))}
+ end
+ end
+ end
+ end
+
+ def list_types
+ p do
+ p "Click the links to create a new instance of a particular machine type."
+ ol do
+ @machines.each do |m|
+ li do
+ #h1 {a(m.name, :href => R(Genomed::Controllers::MachineTypes, m.name))}
+ h1 m.name
+ p(m.desc)
+ end
+ end
+ end
+ end
+ end
+
+ def list_systems
+ host = ENV["HOSTNAME"]
+ cobbler_web = "http://#{host}/cobbler/web"
+ h1 "Systems:"
+ h4 do
+ text("This information is gathered from the /var/log/cobbler/install.log file.\n")
+ text("If you don't see what you're looking for, try ")
+ a("cobbler web", :href => "#{cobbler_web}/?mode=system_list")
+ end
+
+ p do
+ ol do
+ @systems.each_key do |name|
+ li do
+ a(name, :href => URL("http://#{host}/#{CONTEXT}/systems/?id=#{name}"))
+ text(" (")
+ a("edit in cobbler", :href => "#{cobbler_web}/?mode=system_edit&name=#{name}")
+ text(")")
+ ul do
+ li "ip: #{@systems[name]["ip"]}"
+ li "hostname: #{@systems[name]["hostname"]}"
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ default_format :HTML
+
+ module YAML
+ CONTENT_TYPE = 'text/plain'
+
+ def layout
+ yield
+ end
+
+ # This should only be used for Puppet's external nodes
+ def view_node
+ ::YAML.dump(@info)
+ end
+
+ def view_system
+ ::YAML.dump(@system)
+ end
+
+ def list_systems
+ ::YAML.dump(@systems)
+ end
+ end
+
+ module XML
+ def layout
+ yield
+ end
+
+ def list_types
+ @x.instruct!
+ @x.machine_types {
+ @machines.each do |m|
+ @x.machine_type {
+ @x.name(m.name)
+ @x.description(m.desc)
+ }
+ end
+ }
+ end
+
+ def view_type
+ @x.instruct!
+ @x.machine {
+ @x.name(@machine.name)
+ @x.description(@machine.desc)
+ @machine.classes.each {|c| @x.class(c)}
+ @machine.facts.each {|f|
+ @x.fact {
+ @x.name(f.name)
+ @x.description(f.desc)
+ @x.default(f.default)
+ }
+ }
+ }
+ end
+
+ def list_nodes
+ @x.instruct!
+ @x.nodes {
+ @nodes.each {|n| @x.node(n)}
+ }
+ end
+
+ def view_node
+ # There no reason we should only support params and classes.
+ # It might be nice to simply iterate over all the keys and
+ # display their values.
+ @x.instruct!
+ @x.node {
+ @x.name(@name)
+ @info["parameters"].each_pair do |n,v|
+ @x.parameters {
+ instance_eval("@x.#{n}(v)")
+ }
+ end
+ @info["classes"].each {|c| @x.class(c)}
+ }
+ end
+
+ def list_systems
+ @x.instruct!
+ @x.systems {
+ @systems.each_key {|system|
+ @x.system {
+ @x.name(system)
+ @x.ip(@systems[system]["ip"])
+ @x.hostname(@systems[system]["hostname"])
+ }
+ }
+ }
+ end
+
+ def view_system
+ @x.instruct!
+ @x.system {
+ @x.name(@system["name"])
+ @x.ip(@system["ip"])
+ @x.hostname(@system["hostname"])
+ }
+ end
+ end
+end
+
+# Required by picnic
+def Genomed.create; end
+
+Genomed.start_picnic
diff --git a/genomed/script/destroy b/genomed/script/destroy
new file mode 100755
index 0000000..40901a8
--- /dev/null
+++ b/genomed/script/destroy
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/destroy'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
+RubiGen::Scripts::Destroy.new.run(ARGV)
diff --git a/genomed/script/generate b/genomed/script/generate
new file mode 100755
index 0000000..5c8ed01
--- /dev/null
+++ b/genomed/script/generate
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/generate'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
+RubiGen::Scripts::Generate.new.run(ARGV)
diff --git a/genomed/spec/genomed_spec.rb b/genomed/spec/genomed_spec.rb
new file mode 100644
index 0000000..af38873
--- /dev/null
+++ b/genomed/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/genomed/spec/spec.opts b/genomed/spec/spec.opts
new file mode 100644
index 0000000..cf6add7
--- /dev/null
+++ b/genomed/spec/spec.opts
@@ -0,0 +1 @@
+--colour \ No newline at end of file
diff --git a/genomed/spec/spec_helper.rb b/genomed/spec/spec_helper.rb
new file mode 100644
index 0000000..9102400
--- /dev/null
+++ b/genomed/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'