[PATCH aeolus-image] Include git hash and timestamp in extra_release string
by steve linabery
Edit rake/rpmtask.rb to include git hash and timestamp values in the extra_release info
---
rake/rpmtask.rb | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/rake/rpmtask.rb b/rake/rpmtask.rb
index 7534693..64dc14a 100644
--- a/rake/rpmtask.rb
+++ b/rake/rpmtask.rb
@@ -18,6 +18,9 @@ module Rake
# RPM build dir
attr_accessor :topdir
+ # Include extra_release information in the rpm
+ attr_accessor :include_extra_release
+
def initialize(rpm_spec)
init(rpm_spec)
yield self if block_given?
@@ -25,6 +28,7 @@ module Rake
end
def init(rpm_spec)
+ @include_extra_release = true
@rpm_spec = rpm_spec
# parse this out of the rpmbuild macros,
@@ -72,17 +76,21 @@ module Rake
directory "#{@topdir}/SPECS"
desc "Build the rpms"
- task :rpms => [rpm_file]
+ task :rpms, [:include_extra_release] => [rpm_file]
# FIXME properly determine :package build artifact(s) to copy to sources dir
- file rpm_file => [:package, "#{@topdir}/SOURCES", "#{@topdir}/SPECS"] do |t,args|
+ file rpm_file, [:include_extra_release] => [:package, "#{@topdir}/SOURCES", "#{@topdir}/SPECS"] do |t,args|
+ @include_extra_release = args.include_extra_release != "false"
+ git_head = `git log -1 --pretty=format:%h`
+ extra_release = "." + Time.now.strftime("%Y%m%d%H%M%S").gsub(/\s/, '') + "git" + "#{git_head}"
+ puts "here I is #{extra_release}"
cp "#{package_dir}/#{@name}-#{(a)version}.tgz", "#{@topdir}/SOURCES/"
# FIXME - This seems like a hack, but we don't know the gem's name
cp "#{package_dir}/#{(a)name.gsub('rubygem-', '')}-#{(a)version}.gem", "#{@topdir}/SOURCES/"
cp @rpm_spec, "#{@topdir}/SPECS"
sh "#{@rpmbuild_cmd} " +
"--define '_topdir #{@topdir}' " +
- "--define 'extra_release #{args.extra_release}' " +
+ "--define 'extra_release #{@include_extra_release ? extra_release : ''}' " +
"-ba #{@rpm_spec}"
end
end
--
1.7.4.4
12 years, 9 months
[PATCH conductor] update aeolus-image spec to conform to fedora guidelines
by Mo Morsi
---
.../aeolus-image/rubygem-aeolus-image.spec | 52 +++++++++++--------
1 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/services/image_factory/aeolus-image/rubygem-aeolus-image.spec b/services/image_factory/aeolus-image/rubygem-aeolus-image.spec
index f7f5e06..b099cc3 100644
--- a/services/image_factory/aeolus-image/rubygem-aeolus-image.spec
+++ b/services/image_factory/aeolus-image/rubygem-aeolus-image.spec
@@ -1,31 +1,38 @@
-%define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
-%define gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
-%define gemname aeolus-image
-%define geminstdir %{gemdir}/gems/%{gemname}-%{version}
-%define mandir /usr/man/man1
-
-Summary: Commandline interface for working with the Aeolus cloud suite
-Name: rubygem-%{gemname}
+%global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
+%global gemname aeolus-image
+%global geminstdir %{gemdir}/gems/%{gemname}-%{version}
+%global mandir %{_mandir}/man1
+%global rubyabi 1.8
+
+Summary: Command-line interface for working with the Aeolus cloud suite
+Name: rubygem-aeolus-image
Version: 0.0.1
-Release: 1%{?dist}%{?extra_release}
+Release: 3%{?dist}%{?extra_release}
Group: Development/Languages
License: GPLv2+ or Ruby
URL: http://aeolusproject.org
+# The source for this packages was pulled from the upstream's git repo.
+# Use the following commands to generate the gem
+# git clone git://git.fedorahosted.org/aeolus/conductor.git
+# git checkout next
+# cd services/image_factory/aeolus-image
+# rake gem
+# grab image_factory_console-0.0.1.gem from the pkg subdir
Source0: %{gemname}-%{version}.gem
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+Requires: ruby(abi) = %{rubyabi}
Requires: rubygems
Requires: rubygem(nokogiri) >= 1.4.0
Requires: rubygem(rest-client)
-Requires: rubygem(imagefactory-console) >= 0.4.0
+Requires: rubygem(image_factory_console) >= 0.4.0
+BuildRequires: ruby
BuildRequires: rubygems
+
BuildArch: noarch
Provides: rubygem(%{gemname}) = %{version}
-Obsoletes: rubygem-aeolus-cli
-Provides: rubygem(aeolus-cli)
-
%description
QMF Console for Aeolus Image Factory
@@ -34,34 +41,35 @@ QMF Console for Aeolus Image Factory
%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}
-find %{buildroot}%{geminstdir}/bin -type f | xargs chmod a+x
+find %{buildroot}%{geminstdir}/bin -type f | xargs chmod 755
rmdir %{buildroot}%{gemdir}/bin
mkdir -p %{buildroot}%{mandir}
mv %{buildroot}%{geminstdir}/man/* %{buildroot}%{mandir}
-%clean
-rm -rf %{buildroot}
-
%files
-%defattr(-, root, root, -)
%{_bindir}/aeolus-image
%{gemdir}/gems/%{gemname}-%{version}/
%doc %{gemdir}/doc/%{gemname}-%{version}
%{gemdir}/cache/%{gemname}-%{version}.gem
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
-%{mandir}
+%{mandir}/*
%changelog
+* Wed Jul 20 2011 Mo Morsi <mmorsi(a)redhat.com> - 0.0.1-3
+- more updates to conform to fedora guidelines
+
+* Fri Jul 15 2011 Mo Morsi <mmorsi(a)redhat.com> - 0.0.1-2
+- updated package to conform to fedora guidelines
+
* Mon Jul 04 2011 <mtaylor(a)redhat.com> - 0.0.1-1
- Added man files
+
* Wed Jun 15 2011 <jguiditt(a)redhat.com> - 0.0.1-1
- Initial package
--
1.7.6
12 years, 9 months
[PATCH conductor] update imagefactory-console spec to conform to fedora guidelines
by Mo Morsi
---
.../console/rubygem-imagefactory-console.spec | 36 ++++++++++++++------
1 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/services/image_factory/console/rubygem-imagefactory-console.spec b/services/image_factory/console/rubygem-imagefactory-console.spec
index 59cfc8a..2b6fad6 100644
--- a/services/image_factory/console/rubygem-imagefactory-console.spec
+++ b/services/image_factory/console/rubygem-imagefactory-console.spec
@@ -1,25 +1,34 @@
# Generated from image_factory_console-0.2.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 imagefactory-console
-%define geminstdir %{gemdir}/gems/%{gemname}-%{version}
+%global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
+%global gemname imagefactory-console
+%global geminstdir %{gemdir}/gems/%{gemname}-%{version}
+%global rubyabi 1.8
Summary: QMF Console for Aeolus Image Factory
Name: rubygem-%{gemname}
Version: 0.4.0
-Release: 1%{?dist}%{?extra_release}
+Release: 4%{?dist}%{?extra_release}
Group: Development/Languages
License: GPLv2+ or Ruby
URL: http://aeolusproject.org
+
+# The source for this packages was pulled from the upstream's git repo.
+# Use the following commands to generate the gem
+# git clone git://git.fedorahosted.org/aeolus/conductor.git
+# git checkout next
+# cd services/image_factory/console
+# rake gem
+# grab image_factory_console-0.4.0.gem from the pkg subdir
Source0: %{gemname}-%{version}.gem
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: rubygems
+Requires: ruby(abi) = %{rubyabi}
# These can't be deduced by gem2rpm
Requires: qpid-cpp-client >= 0.8-6
Requires: ruby-qpid-qmf >= 0.8-6
Requires: qpid-qmf >= 0.8-6
BuildRequires: rubygems
+BuildRequires: ruby
BuildArch: noarch
Provides: rubygem(%{gemname}) = %{version}
@@ -32,16 +41,11 @@ QMF Console for Aeolus Image Factory
%build
%install
-rm -rf %{buildroot}
mkdir -p %{buildroot}%{gemdir}
gem install --local --install-dir %{buildroot}%{gemdir} \
--force --rdoc %{SOURCE0}
-%clean
-rm -rf %{buildroot}
-
%files
-%defattr(-, root, root, -)
%{gemdir}/gems/%{gemname}-%{version}/
%doc %{gemdir}/doc/%{gemname}-%{version}
%{gemdir}/cache/%{gemname}-%{version}.gem
@@ -49,7 +53,17 @@ rm -rf %{buildroot}
%changelog
+* Wed Jul 20 2011 Mo Morsi <mmorsi(a)redhat.com> - 0.4.0-4
+- renamed packaged to imagefactory-console
+
+* Wed Jul 20 2011 Mo Morsi <mmorsi(a)redhat.com> - 0.4.0-3
+- remove unused sitelib macro
+
+* Fri Jul 15 2011 Mo Morsi <mmorsi(a)redhat.com> - 0.4.0-2
+- fixes for fedora package compliance
+
* Thu Jun 16 2011 <jguiditt(a)redhat.com> - 0.4.0-1
- Add support for push, build and import methods
+
* Thu Mar 10 2011 <morazi(a)redhat.com> - 0.2.0-1
- Initial package
--
1.7.6
12 years, 9 months
[PATCH configure] update rpm spec to conform to fedora guidelines
by Mo Morsi
---
contrib/aeolus-configure.spec | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/contrib/aeolus-configure.spec b/contrib/aeolus-configure.spec
index 982212a..8f21a09 100644
--- a/contrib/aeolus-configure.spec
+++ b/contrib/aeolus-configure.spec
@@ -1,16 +1,20 @@
-%define dchome /usr/share/aeolus-configure
-%define pbuild %{_builddir}/%{name}-%{version}
+%global dchome /usr/share/aeolus-configure
+%global pbuild %{_builddir}/%{name}-%{version}
Summary: Aeolus Configure Puppet Recipe
Name: aeolus-configure
Version: 2.0.1
-Release: 1%{?dist}%{?extra_release}
+Release: 2%{?dist}%{?extra_release}
Group: Applications/Internet
License: GPLv2+
URL: http://aeolusproject.org
+
+# git clone git://git.fedorahosted.org/aeolus/configure.git
+# cd configure
+# rake pkg
+# cp pkg/aeolus-configure-2.0.1.tgz ~/rpmbuild/SOURCES
Source0: %{name}-%{version}.tgz
-BuildRoot: %{_tmppath}/%{name}-%{version}
BuildArch: noarch
Requires: puppet >= 2.6.6
Requires: rubygem(uuidtools)
@@ -29,7 +33,6 @@ Aeolus Configure Puppet Recipe
%build
%install
-rm -rf %{buildroot}
%{__mkdir} -p %{buildroot}/%{dchome}/modules/aeolus %{buildroot}/%{_sbindir}
%{__mkdir} -p %{buildroot}%{_sysconfdir}/aeolus-configure/nodes
%{__cp} -R %{pbuild}/conf/* %{buildroot}%{_sysconfdir}/aeolus-configure/nodes
@@ -42,11 +45,7 @@ rm -rf %{buildroot}
%{__cp} -R %{pbuild}/bin/aeolus-cleanup %{buildroot}/%{_sbindir}/
%{__cp} -R %{pbuild}/bin/aeolus-node %{buildroot}/%{_sbindir}/\
-%clean
-rm -rf %{buildroot}
-
%files
-%defattr(-,root,root,-)
%attr(0755, root, root) %{_sbindir}/aeolus-configure
%attr(0755, root, root) %{_sbindir}/aeolus-cleanup
%attr(0755, root, root) %{_sbindir}/aeolus-node
@@ -54,6 +53,9 @@ rm -rf %{buildroot}
%{dchome}
%changelog
+* Wed Jul 20 2011 Mo Morsi <mmorsi(a)redhat.com> 2.0.1-2
+- updates to conform to Fedora package guidelines
+
* Tue Jul 19 2011 Mike Orazi <morazi(a)redhat.com> 2.0.1-1
- vSphere configuration
- RHEV configuration
--
1.7.6
12 years, 9 months
Time to split aeolus-devel?
by Justin Clift
Hi all,
Now that aeolus-discuss is a fairly high volume mailing list, would people be
ok with us splitting it into two?
A mailing list just for patches/reviews/acks (and similar), and another just for
discussion/planning/etc (no patches).
Thinking that it will make it easier for people wanting to be across feature
planning, but who have no interest in patches/reviewing/etc.
If that's workable, two approaches stand out immediately:
a) We create a new "aeolus-patches" mailing list for patches, and use
aeolus-devel for discussion. Or,
b) We create a new "aeolus-discuss" mailing list for discussion, using
aeolus-devel for patches.
(I'd have a slight preference for (a), but completely not fussed)
Thoughts?
Regards and best wishes,
Justin Clift
--
Aeolus Community Manager
http://www.aeolusproject.org
12 years, 9 months
[PATCH conductor] Remove aeolus-image and imagefactory-console
by Mark McLoughlin
These have now moved to:
https://github.com/aeolusproject/aeolus-image
https://github.com/aeolusproject/imagefactory-console
---
Makefile | 3 -
services/image_factory/.gitignore | 2 -
services/image_factory/README | 52 ----
services/image_factory/aeolus-image/Rakefile | 62 -----
.../image_factory/aeolus-image/bin/aeolus-image | 6 -
.../image_factory/aeolus-image/examples/aeolus-cli | 9 -
.../aeolus-image/examples/custom_repo.tdl | 18 --
.../aeolus-image/examples/image_description.xml | 3 -
.../image_factory/aeolus-image/examples/tdl.rng | 207 ----------------
.../image_factory/aeolus-image/lib/base_command.rb | 134 -----------
.../aeolus-image/lib/build_command.rb | 68 ------
.../aeolus-image/lib/config_parser.rb | 212 -----------------
.../aeolus-image/lib/delete_command.rb | 9 -
.../aeolus-image/lib/import_command.rb | 44 ----
.../image_factory/aeolus-image/lib/list_command.rb | 132 ----------
.../image_factory/aeolus-image/lib/push_command.rb | 72 ------
.../aeolus-image/man/aeolus-image-build.1 | 36 ---
.../aeolus-image/man/aeolus-image-import.1 | 57 -----
.../aeolus-image/man/aeolus-image-list.1 | 80 -------
.../aeolus-image/man/aeolus-image-push.1 | 40 ---
.../image_factory/aeolus-image/man/aeolus-image.1 | 16 --
.../image_factory/aeolus-image/rake/rpmtask.rb | 95 --------
.../aeolus-image/rubygem-aeolus-image.spec | 67 ------
.../aeolus-image/spec/base_command_spec.rb | 76 ------
.../aeolus-image/spec/build_command_spec.rb | 63 -----
.../aeolus-image/spec/config_parser_spec.rb | 82 -------
.../spec/fixtures/invalid_template.tdl | 18 --
.../aeolus-image/spec/fixtures/valid_template.tdl | 18 --
.../aeolus-image/spec/import_command_spec.rb | 43 ----
.../aeolus-image/spec/list_command_spec.rb | 21 --
.../aeolus-image/spec/push_command_spec.rb | 56 -----
services/image_factory/aeolus-image/spec/spec.opts | 3 -
.../image_factory/aeolus-image/spec/spec_helper.rb | 52 ----
services/image_factory/console/Rakefile | 77 ------
services/image_factory/console/lib/imagefactory.rb | 2 -
.../console/lib/imagefactory/base_handler.rb | 56 -----
.../console/lib/imagefactory/console.rb | 251 --------------------
services/image_factory/console/rake/rpmtask.rb | 95 --------
.../console/rubygem-imagefactory-console.spec | 55 -----
.../console/spec/image_factory/console_spec.rb | 217 -----------------
services/image_factory/console/spec/spec_helper.rb | 3 -
41 files changed, 0 insertions(+), 2612 deletions(-)
delete mode 100644 services/image_factory/.gitignore
delete mode 100644 services/image_factory/README
delete mode 100644 services/image_factory/aeolus-image/Rakefile
delete mode 100755 services/image_factory/aeolus-image/bin/aeolus-image
delete mode 100644 services/image_factory/aeolus-image/examples/aeolus-cli
delete mode 100644 services/image_factory/aeolus-image/examples/custom_repo.tdl
delete mode 100644 services/image_factory/aeolus-image/examples/image_description.xml
delete mode 100644 services/image_factory/aeolus-image/examples/tdl.rng
delete mode 100644 services/image_factory/aeolus-image/lib/base_command.rb
delete mode 100644 services/image_factory/aeolus-image/lib/build_command.rb
delete mode 100644 services/image_factory/aeolus-image/lib/config_parser.rb
delete mode 100644 services/image_factory/aeolus-image/lib/delete_command.rb
delete mode 100644 services/image_factory/aeolus-image/lib/import_command.rb
delete mode 100644 services/image_factory/aeolus-image/lib/list_command.rb
delete mode 100644 services/image_factory/aeolus-image/lib/push_command.rb
delete mode 100644 services/image_factory/aeolus-image/man/aeolus-image-build.1
delete mode 100644 services/image_factory/aeolus-image/man/aeolus-image-import.1
delete mode 100644 services/image_factory/aeolus-image/man/aeolus-image-list.1
delete mode 100644 services/image_factory/aeolus-image/man/aeolus-image-push.1
delete mode 100644 services/image_factory/aeolus-image/man/aeolus-image.1
delete mode 100644 services/image_factory/aeolus-image/rake/rpmtask.rb
delete mode 100644 services/image_factory/aeolus-image/rubygem-aeolus-image.spec
delete mode 100644 services/image_factory/aeolus-image/spec/base_command_spec.rb
delete mode 100644 services/image_factory/aeolus-image/spec/build_command_spec.rb
delete mode 100644 services/image_factory/aeolus-image/spec/config_parser_spec.rb
delete mode 100644 services/image_factory/aeolus-image/spec/fixtures/invalid_template.tdl
delete mode 100644 services/image_factory/aeolus-image/spec/fixtures/valid_template.tdl
delete mode 100644 services/image_factory/aeolus-image/spec/import_command_spec.rb
delete mode 100644 services/image_factory/aeolus-image/spec/list_command_spec.rb
delete mode 100644 services/image_factory/aeolus-image/spec/push_command_spec.rb
delete mode 100644 services/image_factory/aeolus-image/spec/spec.opts
delete mode 100644 services/image_factory/aeolus-image/spec/spec_helper.rb
delete mode 100644 services/image_factory/console/Rakefile
delete mode 100644 services/image_factory/console/lib/imagefactory.rb
delete mode 100644 services/image_factory/console/lib/imagefactory/base_handler.rb
delete mode 100644 services/image_factory/console/lib/imagefactory/console.rb
delete mode 100644 services/image_factory/console/rake/rpmtask.rb
delete mode 100644 services/image_factory/console/rubygem-imagefactory-console.spec
delete mode 100644 services/image_factory/console/spec/image_factory/console_spec.rb
delete mode 100644 services/image_factory/console/spec/spec_helper.rb
diff --git a/Makefile b/Makefile
index df9d074..fce716c 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,6 @@ GIT_RELEASE = $(date)git$(git_head)
RPMDIR = $$(rpm --eval '%{_rpmdir}')
RPM_FLAGS = --define "conductor_cache_dir $(CONDUCTOR_CACHE_DIR)"
RPM_FLAGS += $(if $(_conductor_dev),--define "extra_release .$(GIT_RELEASE)")
-RAKE_EXTRA_RELEASE = $(if $(_conductor_dev),"extra_release=.$(GIT_RELEASE)")
dist:
sed -e 's/@VERSION@/$(VERSION)/' aeolus-all.spec.in > aeolus-all.spec
@@ -45,8 +44,6 @@ dist:
rpms: dist
- cd services/image_factory/console; rake rpms $(RAKE_EXTRA_RELEASE)
- cd services/image_factory/aeolus-image; rake rpms $(RAKE_EXTRA_RELEASE)
rpmbuild $(RPM_FLAGS) -ta aeolus-conductor-$(VERSION).tar.gz
rpmbuild $(RPM_FLAGS) -ba aeolus-all.spec
diff --git a/services/image_factory/.gitignore b/services/image_factory/.gitignore
deleted file mode 100644
index 15030e5..0000000
--- a/services/image_factory/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-pkg/
-nbproject/
diff --git a/services/image_factory/README b/services/image_factory/README
deleted file mode 100644
index 889c402..0000000
--- a/services/image_factory/README
+++ /dev/null
@@ -1,52 +0,0 @@
-First, you'll need:
-* rebuild the rpms for new qpid/qmf:
- http://koji.fedoraproject.org/koji/packageinfo?packageID=10015
-* build rpm for oz (http://www.aeolusproject.org/oz-download.html)
-* You can run imageFactory from src, or build the rpm, source is here:
- git://github.com/aeolusproject/image_factory
-
-I have been developing for now using the following packages for qpid:
-qpid-cpp-server-0.8-6.fc14.x86_64
-python-qpid-qmf-0.8-6.fc14.x86_64
-ruby-qpid-qmf-0.8-6.fc14.x86_64
-qpid-tools-0.8-6.fc14.noarch
-qpid-qmf-0.8-6.fc14.x86_64
-qpid-cpp-client-0.8-6.fc14.x86_64
-qpid-cpp-server-store-0.8-6.fc14.x86_64
-
-Note that you will need to rpm -e --nodeps all older qpid stuff
-if you dont want to uninstall the entire conductor stack.
-
-Make sure /etc/qpidd.conf has the line:
-auth=no
-and restart qpidd service
-
-Build the console gem and install:
-[console]$ rake gem
-[console]$ sudo gem install pkg/image_factory_console-0.2.0.gem
-
-You can start the factory (from src) with:
-[factory-checkout]$ sudo ./imgfac.py --qmf --foreground
-
-In the console dir,
-run tests with:
-[console]$ rake spec
-
-For the connector, build and install the gem:
-[image_factory_connector]$ rake package
-[image_factory_connector]$ sudo gem install pkg/#{connector-gem}
-
-You can then start it anywhere, with:
-$ image_factory_connector -p 2003 start
-
-Alternatively, in the image_factory_connector/bin dir, run the app in any of the following ways:
-* [image_factory_connector/bin]$ ./image_factory_connector -p 2003 start
-* [image_factory_connector/lib]$ thin -R config.ru -p 2003 start
-* [image_factory_connector/lib]$ ruby -r 'rubygems' image_factory_connector/image_factory_connector.rb
-
-View some simple interactions (defined in image_factory_connector) from browser with:
-http://localhost:2003/
-http://localhost:2003/shutdown (note that this one shuts down the console, so you will need to restart
- connector if you run this)
-
-The remaining 2 public methods are POST actions, so you can try them out with curl if you like.
diff --git a/services/image_factory/aeolus-image/Rakefile b/services/image_factory/aeolus-image/Rakefile
deleted file mode 100644
index 2bac2e0..0000000
--- a/services/image_factory/aeolus-image/Rakefile
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'rubygems'
-require 'rake'
-require 'rake/clean'
-require 'rake/gempackagetask'
-require 'rake/rdoctask'
-require 'rake/testtask'
-require 'spec/rake/spectask'
-require 'rake/rpmtask'
-
-RPMBUILD_DIR = "#{File.expand_path('~')}/rpmbuild"
-RPM_SPEC = "rubygem-aeolus-image.spec"
-
-spec = Gem::Specification.new do |s|
- s.name = 'aeolus-image'
- s.version = '0.0.1'
- s.has_rdoc = true
- s.summary= 'cli for aeolus cloud suite'
- s.description = 'Commandline interface for working with the aeolus cloud management suite'
- s.author = 'Jason Guiditta, Martyn Taylor'
- s.email = 'jguiditt(a)redhat.com, mtaylor(a)redhat.com'
- s.license = 'GPL-2'
- s.homepage = 'http://aeolusproject.org'
- s.executables << 'aeolus-image'
- s.files = %w(Rakefile) + Dir.glob("{bin,lib,spec,examples,man}/**/*")
- s.require_path = "lib"
- s.bindir = "bin"
- s.add_dependency('nokogiri', '>=0.4.0')
- s.add_dependency('rest-client')
- s.add_dependency('imagefactory-console', '>=0.4.0')
-
- s.add_development_dependency('rspec', '~>1.3.0')
-end
-
-Rake::GemPackageTask.new(spec) do |p|
- p.gem_spec = spec
- p.need_tar = true
- p.need_zip = true
-end
-
-Rake::RDocTask.new do |rdoc|
- files =['README', 'LICENSE', 'lib/**/*.rb']
- rdoc.rdoc_files.add(files)
- rdoc.main = "README" # page to start on
- rdoc.title = "aeolus-image Docs"
- rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
- rdoc.options << '--line-numbers'
-end
-
-Rake::TestTask.new do |t|
- t.test_files = FileList['test/**/*.rb']
-end
-
-Spec::Rake::SpecTask.new do |t|
- t.spec_files = FileList['spec/**/*.rb']
- t.libs << Dir["lib"]
-end
-
-Rake::RpmTask.new(RPM_SPEC) do |rpm|
- rpm.need_tar = true
- rpm.package_files.include("lib/*")
- rpm.topdir = "#{RPMBUILD_DIR}"
-end
diff --git a/services/image_factory/aeolus-image/bin/aeolus-image b/services/image_factory/aeolus-image/bin/aeolus-image
deleted file mode 100755
index 9c8c4ff..0000000
--- a/services/image_factory/aeolus-image/bin/aeolus-image
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
-require 'config_parser.rb'
-parser = Aeolus::Image::ConfigParser.new(ARGV)
-puts parser.process
diff --git a/services/image_factory/aeolus-image/examples/aeolus-cli b/services/image_factory/aeolus-image/examples/aeolus-cli
deleted file mode 100644
index 22c4a17..0000000
--- a/services/image_factory/aeolus-image/examples/aeolus-cli
+++ /dev/null
@@ -1,9 +0,0 @@
-
-# Below is the correct format for this file, please update any older version you may have
-:iwhd:
- :url: http://localhost:9090
-
-:conductor:
- :url: http://localhost:3000/conductor
- :username: admin
- :password: password
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/examples/custom_repo.tdl b/services/image_factory/aeolus-image/examples/custom_repo.tdl
deleted file mode 100644
index 2f96604..0000000
--- a/services/image_factory/aeolus-image/examples/custom_repo.tdl
+++ /dev/null
@@ -1,18 +0,0 @@
-<template>
- <name>tmpl1</name>
- <description>foo</description>
- <os>
- <name>Fedora</name>
- <arch>x86_64</arch>
- <version>14</version>
- <install type="url">
- <url>http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fedora/x86...</url>
- </install>
- </os>
- <repositories>
- <repository name="custom">
- <url>http://repos.fedorapeople.org/repos/aeolus/demo/webapp/</url>
- <signed>false</signed>
- </repository>
- </repositories>
-</template>
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/examples/image_description.xml b/services/image_factory/aeolus-image/examples/image_description.xml
deleted file mode 100644
index ecfd9ce..0000000
--- a/services/image_factory/aeolus-image/examples/image_description.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<image>
- <name>Test Image</name>
-</image>
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/examples/tdl.rng b/services/image_factory/aeolus-image/examples/tdl.rng
deleted file mode 100644
index ac2faf9..0000000
--- a/services/image_factory/aeolus-image/examples/tdl.rng
+++ /dev/null
@@ -1,207 +0,0 @@
-<?xml version="1.0"?>
-<!-- This Schema is lifted from the OZ project: http://www.aeolusproject.org/oz.html any changes to this schema should be done in the upstream project, then added here-->
-<!-- A Relax NG schema for the TDL (template description language) format -->
-<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <start>
- <ref name='template'/>
- </start>
-
- <define name='template'>
- <element name='template'>
- <interleave>
- <element name='name'>
- <text/>
- </element>
- <element name='os'>
- <interleave>
- <element name='name'>
- <text/>
- </element>
- <element name='version'>
- <text/>
- </element>
- <element name='arch'>
- <choice>
- <value>i386</value>
- <value>x86_64</value>
- </choice>
- </element>
- <element name='install'>
- <choice>
- <ref name='url'/>
- <ref name='iso'/>
- </choice>
- </element>
- <optional>
- <element name='rootpw'>
- <text/>
- </element>
- </optional>
- <optional>
- <element name='key'>
- <text/>
- </element>
- </optional>
- </interleave>
- </element>
- <optional>
- <element name='description'>
- <text/>
- </element>
- </optional>
- <optional>
- <element name='packages'>
- <zeroOrMore>
- <element name='package'>
- <attribute name='name'>
- <text/>
- </attribute>
- <interleave>
- <optional>
- <element name='repository'>
- <text/>
- </element>
- </optional>
- <optional>
- <element name='file'>
- <text/>
- </element>
- </optional>
- <optional>
- <element name='arguments'>
- <text/>
- </element>
- </optional>
- </interleave>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- <optional>
- <element name='files'>
- <zeroOrMore>
- <element name='file'>
- <attribute name='name'>
- <text/>
- </attribute>
- <choice>
- <ref name='rawtype'/>
- <ref name='base64type'/>
- </choice>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- <optional>
- <element name='commands'>
- <zeroOrMore>
- <element name='command'>
- <attribute name='name'>
- <text/>
- </attribute>
- <choice>
- <ref name='rawtype'/>
- <ref name='base64type'/>
- </choice>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- <optional>
- <element name='repositories'>
- <zeroOrMore>
- <element name='repository'>
- <attribute name='name'>
- <text/>
- </attribute>
- <interleave>
- <element name='url'>
- <text/>
- </element>
- <optional>
- <element name='signed'>
- <ref name='bool'/>
- </element>
- </optional>
- </interleave>
- </element>
- </zeroOrMore>
- </element>
- </optional>
- </interleave>
- </element>
- </define>
-
- <define name='url'>
- <attribute name='type'>
- <value>url</value>
- </attribute>
- <element name='url'>
- <text/>
- </element>
- </define>
-
- <define name='iso'>
- <attribute name='type'>
- <value>iso</value>
- </attribute>
- <interleave>
- <element name='iso'>
- <text/>
- </element>
- <optional>
- <choice>
- <element name='md5sum'>
- <text/>
- </element>
- <element name='sha1sum'>
- <text/>
- </element>
- <element name='sha256sum'>
- <text/>
- </element>
- </choice>
- </optional>
- </interleave>
- </define>
-
- <define name='bool'>
- <choice>
- <data type="string">
- <param name="pattern">[Tt][Rr][Uu][Ee]</param>
- </data>
- <data type="string">
- <param name="pattern">[Ff][Aa][Ll][Ss][Ee]</param>
- </data>
- <data type="string">
- <param name="pattern">[Yy][Ee][Ss]</param>
- </data>
- <data type="string">
- <param name="pattern">[Nn][Oo]</param>
- </data>
- </choice>
- </define>
-
- <define name='rawtype'>
- <optional>
- <attribute name='type'>
- <value>raw</value>
- </attribute>
- </optional>
- <text/>
- </define>
-
- <define name='base64'>
- <data type="string">
- <param name="pattern">[a-zA-Z0-9+/]+={0,2}</param>
- </data>
- </define>
-
- <define name='base64type'>
- <attribute name='type'>
- <value>base64</value>
- </attribute>
- <ref name='base64'/>
- </define>
-
-</grammar>
diff --git a/services/image_factory/aeolus-image/lib/base_command.rb b/services/image_factory/aeolus-image/lib/base_command.rb
deleted file mode 100644
index f1adcad..0000000
--- a/services/image_factory/aeolus-image/lib/base_command.rb
+++ /dev/null
@@ -1,134 +0,0 @@
-require 'yaml'
-require 'rest_client'
-require 'nokogiri'
-
-module Aeolus
- module Image
- #This will house some methods that multiple Command classes need to use.
- class BaseCommand
- attr_accessor :options
-
- def initialize(opts={}, logger=nil)
- logger(logger)
- @options = opts
- @config_location = "~/.aeolus-cli"
- @config = load_config
- end
-
- protected
- def not_implemented
- "This option or combination is not yet implemented"
- end
-
- def logger(logger=nil)
- @logger ||= logger
- unless @logger
- @logger = Logger.new(STDOUT)
- @logger.level = Logger::INFO
- @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
- end
- return @logger
- end
-
- def iwhd
- create_resource(:iwhd)
- end
-
- def conductor
- create_resource(:conductor)
- end
-
- def read_file(path)
- begin
- full_path = File.expand_path(path)
- if is_file?(path)
- File.read(full_path)
- else
- return nil
- end
- rescue
- nil
- end
- end
-
- # TODO: Consider ripping all this file-related stuff into a module or
- # class for better encapsulation and testability
- def is_file?(path)
- full_path = File.expand_path(path)
- if File.exist?(full_path) && !File.directory?(full_path)
- return true
- end
- false
- end
-
- def quit(code)
- exit(code)
- end
-
- def validate_xml_document(schema_path, xml_string)
- schema = Nokogiri::XML::RelaxNG(File.read(schema_path))
- doc = Nokogiri::XML xml_string
- schema.validate(doc)
- end
-
- private
- def load_config
- begin
- file_str = read_file(@config_location)
- if is_file?(@config_location) && !file_str.include?(":url")
- lines = File.readlines(File.expand_path((a)config_location)).map do |line|
- "#" + line
- end
- File.open(File.expand_path(@config_location), 'w') do |file|
- file.puts lines
- end
- write_file
- end
- write_file unless is_file?(@config_location)
- YAML::load(File.open(File.expand_path(@config_location)))
- rescue Errno::ENOENT
- #TODO: Create a custom exception to wrap CLI Exceptions
- raise "Unable to locate or write configuration file: \"" + @config_location + "\""
- end
- end
-
- def write_file
- example = File.read(File.expand_path(File.dirname(__FILE__) + "/../examples/aeolus-cli"))
- File.open(File.expand_path(@config_location), 'a+') do |f|
- f.write(example)
- end
- end
-
- def create_resource(resource_name)
- # Check to see if config has a resource with this name
- if !(a)config.has_key?(resource_name)
- raise "Unable to determine resource: " + resource_name.to_s + " from configuration file. Please check: " + @config_location
- return
- end
-
- #Use command line arguments for username/password
- if @options.has_key?(:username)
- if @options.has_key?(:password)
- RestClient::Resource.new(@config[resource_name][:url], :user => @options[:username], :password => @options[:password])
- else
- #TODO: Create a custom exception to wrap CLI Exceptions
- raise "Password not found for user: " + @options[:username]
- end
-
- #Use config for username/password
- elsif @config[resource_name].has_key?(:username)
- if @config[resource_name].has_key?(:password)
- RestClient::Resource.new(@config[resource_name][:url], :user => @config[resource_name][:username], :password => @config[resource_name][:password])
- else
- #TODO: Create a custom exception to wrap CLI Exceptions
- raise "Password not found for user: " + @config[resource_name][:username]
- end
-
- # Do not use authentication
- else
- RestClient::Resource.new(@config[resource_name][:url])
- end
- end
- end
- end
-end
diff --git a/services/image_factory/aeolus-image/lib/build_command.rb b/services/image_factory/aeolus-image/lib/build_command.rb
deleted file mode 100644
index 8712a55..0000000
--- a/services/image_factory/aeolus-image/lib/build_command.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-require 'imagefactory'
-
-module Aeolus
- module Image
- class BuildCommand < BaseCommand
- attr_accessor :console
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- default = {
- :template_str => '',
- :template => '',
- :target => [],
- :image => '',
- :build => ''
- }
- @options = default.merge(@options)
- @console = ImageFactoryConsole.new()
- @console.start
- end
-
- def run
- if combo_implemented?
- @options[:template_str] = read_file(@options[:template])
- if @options[:template_str].nil?
- puts "Cannot find specified file"
- quit(1)
- end
-
- # Validate XML against TDL Schema
- errors = validate_xml_document(File.dirname(__FILE__) + "/../examples/tdl.rng", @options[:template_str])
- if errors.length > 0
- puts "ERROR: The given Template does not conform to the TDL Schema, see below for specific details:"
- errors.each do |error|
- puts "- " + error.message
- end
- quit(1)
- end
-
- #This is a temporary hack in case the agent doesn't show up on bus immediately
- sleep(5)
- @console.build(@options[:template_str], @options[:target], @options[:image], @options[:build]).each do |adaptor|
- puts ""
- puts "Target Image: #{adaptor.image_id}"
- puts "Image: #{adaptor.image}"
- puts "Build: #{adaptor.build}"
- puts "Status: #{adaptor.status}"
- puts "Percent Complete: #{adaptor.percent_complete}"
- end
- quit(0)
- end
- end
-
- def combo_implemented?
- if @options[:template].empty? || @options[:target].empty?
- puts "This combination of parameters is not currently supported"
- quit(1)
- end
- true
- end
-
- def quit(code)
- @console.shutdown
- super
- end
-
- end
- end
-end
diff --git a/services/image_factory/aeolus-image/lib/config_parser.rb b/services/image_factory/aeolus-image/lib/config_parser.rb
deleted file mode 100644
index 8e98971..0000000
--- a/services/image_factory/aeolus-image/lib/config_parser.rb
+++ /dev/null
@@ -1,212 +0,0 @@
-require 'optparse'
-require 'logger'
-require 'base_command'
-require 'list_command'
-require 'build_command'
-require 'push_command'
-require 'import_command'
-require 'delete_command'
-
-module Aeolus
- module Image
- class ConfigParser
- COMMANDS = %w(list build push import delete)
- attr_accessor :options, :command, :args
-
- def initialize(argv)
- @args = argv
- # Default options
- @options = {}
- parse
- end
-
- def process
- # Check for command, then call appropriate Optionparser and initiate
- # call to that class.
- @command = @args.shift
- # Eventually get the config file from user dir if it exists.
- # File.expand_path("~")
- if COMMANDS.include?(@command)
- self.send((a)command.to_sym)
- else
- @args << "-h"
- puts "Valid command required: \n\n"
- parse
- end
- end
-
- private
- def parse
- @optparse ||= OptionParser.new do|opts|
- opts.banner = "Usage: aeolus-image [#{COMMANDS.join('|')}] [general options] [command options]"
-
- opts.separator ""
- opts.separator "General options:"
- opts.on('-u', '--user USERNAME', 'Conductor username') do |user|
- @options[:user] = user
- end
- opts.on('-w', '--password PASSWORD', 'Conductor password') do |pw|
- @options[:password] = pw
- end
- opts.on('-d', '--id ID', 'id for a given object') do |id|
- @options[:id] = id
- end
- opts.on('-r', '--description NAME', 'description (e.g. "<image><name>MyImage</name></image>" or "/home/user/myImage.xml")') do |description|
- @options[:description] = description
- end
- opts.on('-r', '--provider NAME1,NAME2', Array,'name of specific provider (ie ec2-us-east1)') do |name|
- @options[:provider] = name
- end
- opts.on('-I', '--image ID', 'ID of the base image, can be used in build and push commands, see examples') do |id|
- @options[:image] = id
- end
- opts.on('-T', '--target TARGET1,TARGET2', Array, 'provider type (ec2, rackspace, rhevm, etc)') do |name|
- @options[:target] = name
- end
- opts.on('-d', '--daemon', 'run as a background process') do
- @options[:subcommand] = :images
- end
- opts.on( '-h', '--help', 'Get usage information for this tool') do
- puts opts
- exit(0)
- end
-
- opts.separator ""
- opts.separator "List options:"
- opts.on('-i', '--images', 'Retrieve a list of images') do
- @options[:subcommand] = :images
- end
- opts.on('-b', '--builds ID', 'Retrieve the builds of an image') do |id|
- @options[:subcommand] = :builds
- @options[:id] = id
- end
- opts.on('-t', '--targetimages ID', 'Retrieve the target images from a build') do |id|
- @options[:subcommand] = :targetimages
- @options[:id] = id
- end
- opts.on('-P', '--providerimages ID', 'Retrieve the provider images from a target image') do |id|
- @options[:subcommand] = :targetimages
- @options[:id] = id
- end
- opts.on('-g', '--targets', 'Retrieve the values available for the --target parameter') do
- @options[:subcommand] = :targets
- end
- opts.on('-p', '--providers', 'Retrieve the values available for the --provider parameter') do
- @options[:subcommand] = :providers
- end
- opts.on('-a', '--accounts', 'Retrieve the values available for the --account parameter') do
- @options[:subcommand] = :accounts
- end
-
- opts.separator ""
- opts.separator "Build options:"
- opts.on('-e', '--template FILE', 'path to file that contains template xml') do |file|
- @options[:template] = file
- end
-
- opts.separator ""
- opts.separator "Push options:"
- opts.on('-B', '--build ID', 'push all target images for a build, to same providers as previously') do |id|
- @options[:build] = id
- end
- opts.on('-A', '--account NAME', 'name of specific provider account to use for push') do |name|
- @options[:account] = name
- end
-
- opts.separator ""
- opts.separator "Delete options:"
- opts.on('-m', '--targetimage ID', 'delete target image and its provider images') do |id|
- @options[:targetimage] = id
- end
- opts.on('-D', '--providerimage ID', 'delete provider image') do |id|
- @options[:providerimage] = id
- end
-
- opts.separator ""
- opts.separator "List Examples:"
- opts.separator "aeolus-image list --images # list available images"
- opts.separator "aeolus-image list --builds $image_id # list the builds of an image"
- opts.separator "aeolus-image list --targetimages $build_id # list the target images from a build"
- opts.separator "aeolus-image list --targets # list the values available for the --target parameter"
- opts.separator "aeolus-image list --providers # list the values available for the --provider parameter"
- opts.separator "aeolus-image list --accounts # list the values available for the --account parameter"
-
- opts.separator ""
- opts.separator "Build examples:"
- opts.separator "aeolus-image build --target ec2 --template my.tmpl # build a new image for ec2 from the template"
- opts.separator "aeolus-image build --image $image_id # (NOT IMPLEMENTED) rebuild the image template and targets from latest build"
- opts.separator %q{aeolus-image build --target ec2,rackspace \ # rebuild the image with a new template and set of targets
- --image $image_i \
- --template my.tmpl}
-
- opts.separator ""
- opts.separator "Push examples:"
- opts.separator "aeolus-image push --provider ec2-us-east-1 --id $image_id # initial push of an image build via image id to the specified provider"
- opts.separator "aeolus-image push --build $build_id # push an image build via build id to the specified provider"
- opts.separator "aeolus-image push --account $provider_account --build $build_id # (NOT IMPLEMENTED) ditto, using a specific provider account"
- opts.separator "aeolus-image push --image $image_id # (NOT IMPLEMENTED) push all the target images for the latest build"
-
- opts.separator ""
- opts.separator "Import examples:"
- opts.separator "aeolus-image import --provider ec2-us-east-1 --target ec2 --id $ami_id # import an AMI from the specified provider"
- opts.separator "aeolus-image import --provider ec2-us-east-1 --target ec2 --id $ami_id --description '<image><name>My Image</name></image>' # import an AMI from the specified provider"
- opts.separator "aeolus-image import --provider ec2-us-east-1 --target ec2 --id $ami_id --description <path_to_xml_file> # import an AMI from the specified provider"
-
- opts.separator ""
- opts.separator "Delete examples: (DELETE CURRENTLY NOT IMPLEMENTED) "
- opts.separator "aeolus-image delete --build $build_id # deletes a build, updating latest/parent references as appropriate"
- opts.separator "aeolus-image delete --targetimage $target_image # deletes a target image and its provider images"
- opts.separator "aeolus-image delete --providerimage $provider_image # deletes a provider image"
- end
-
- begin
- @optparse.parse!(@args)
- rescue OptionParser::InvalidOption
- puts "Warning: Invalid option"
- exit(1)
- rescue OptionParser::MissingArgument => e
- puts "Warning, #{e.message}"
- exit(1)
- end
- end
-
- # TODO: Remove all this boilerplate and replace with some metaprogramming,
- # perhaps method_missing
- def list
- # TODO: Instantiate and call object matching command type, for example:
- # l = ListCommand.new(@options)
- # Each Command will call it's own internal method depending on the contents of the hash.
- # For the list example above, that object would call a method 'images' based on the item
- # @options[:subcommand] being :images, so internally that class may do something like:
- # self.send(@options[:subcommand])
- if @options[:subcommand].nil?
- # TODO: Pull out Print Usage into seporate method, and print
- puts "Could not find subcommand for list, run `./aeolus-image --help` for usage instructions"
- exit(1)
- else
- list_command = ListCommand.new(@options)
- list_command.send(@options[:subcommand])
- end
- end
-
- def build
- b = BuildCommand.new(@options)
- b.run
- end
-
- def push
- b = PushCommand.new(@options)
- b.run
- end
-
- def import
- import_command = ImportCommand.new(@options)
- import_command.import_image
- end
-
- def delete
- "Not implemented"
- end
- end
- end
-end
diff --git a/services/image_factory/aeolus-image/lib/delete_command.rb b/services/image_factory/aeolus-image/lib/delete_command.rb
deleted file mode 100644
index ba63732..0000000
--- a/services/image_factory/aeolus-image/lib/delete_command.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module Aeolus
- module Image
- class DeleteCommand < BaseCommand
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- end
- end
- end
-end
diff --git a/services/image_factory/aeolus-image/lib/import_command.rb b/services/image_factory/aeolus-image/lib/import_command.rb
deleted file mode 100644
index 158f740..0000000
--- a/services/image_factory/aeolus-image/lib/import_command.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-module Aeolus
- module Image
- class ImportCommand < BaseCommand
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- default = {
- :image => '',
- :build => '',
- :id => '',
- :description => '<image><name>' + @options[:id] + '</name></image>',
- :target => '',
- :provider => ''
- }
- @options = default.merge(@options)
- @console = ImageFactoryConsole.new()
- @console.start
- end
-
- def import_image
- description = read_file(@options[:description])
- if !description.nil?
- @options[:description] = description
- end
- # TODO: Validate Description XML
-
- #This is a temporary hack in case the agent doesn't show up on bus
- #immediately
- sleep(5)
- import_map = @console.import_image(@options[:image], @options[:build], @options[:id], @options[:description], @options[:target].first, @options[:provider].first)
- puts ""
- puts "Target Image: " + import_map['target_image']
- puts "Image: " + import_map['image']
- puts "Build: " + import_map['build']
- puts "Provider Image: " + import_map['provider_image']
- quit(0)
- end
-
- def quit(code)
- @console.shutdown
- super
- end
- end
- end
-end
diff --git a/services/image_factory/aeolus-image/lib/list_command.rb b/services/image_factory/aeolus-image/lib/list_command.rb
deleted file mode 100644
index e8a4f67..0000000
--- a/services/image_factory/aeolus-image/lib/list_command.rb
+++ /dev/null
@@ -1,132 +0,0 @@
-module Aeolus
- module Image
- class ListCommand < BaseCommand
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- end
-
- def images
- images = [["UUID", "NAME", "TARGET", "OS", "OS VERSION", "ARCH", "DESCRIPTION"]]
- doc = Nokogiri::XML iwhd['/target_images'].get
- # Check for any invalid data in iwhd
- invalid_images = []
- doc.xpath("/objects/object/key").each do |targetimage|
- begin
- build = iwhd["/target_images/" + targetimage.text + "/build"].get
- image = iwhd["/builds/" + build + "/image"].get
- template_info = get_template_info(image, targetimage.text)
- if template_info
- images << template_info
- else
- images << [image, get_image_name(image), iwhd["/target_images/" + targetimage + "/target"].get, "", "", "", ""]
- end
- rescue
- invalid_images << targetimage.text
- end
- end
- format_print(images)
-
- unless invalid_images.empty?
- puts "\nN.B. following images were not listed, aeolus-image encountered some invalid data in iwhd:"
- puts invalid_images.join "\n"
- end
- quit(0)
- end
-
- def builds
- doc = Nokogiri::XML iwhd['/builds'].get
- doc.xpath("/objects/object/key").each do |build|
- if iwhd['/builds/' + build.text + "/image"].get == @options[:id]
- puts build.text
- end
- end
- quit(0)
- end
-
- def targetimages
- doc = Nokogiri::XML iwhd['/target_images'].get
- doc.xpath("/objects/object/key").each do |target_image|
- begin
- if iwhd['/target_images/' + target_image.text + "/build"].get == @options[:id]
- puts target_image.text
- end
- rescue RestClient::ResourceNotFound
- end
- end
- quit(0)
- end
-
- def targets
- targets = [["NAME", "TARGET CODE"]]
- targets << ["Mock", "mock"]
- targets << ["Amazon EC2", "ec2"]
- targets << ["RHEV-M", "rhevm"]
- targets << ["VMware vSphere", "vsphere"]
- targets << ["Condor Cloud", "condor_cloud"]
- format_print(targets)
- quit(0)
- end
-
- def providers
- print_values = [["NAME", "TYPE", "URL"]]
-
- doc = Nokogiri::XML conductor['/providers'].get
- doc.xpath("/providers/provider").each do |provider|
- print_values << [provider.xpath("name").text, provider.xpath("provider_type").text, provider.xpath("url").text]
- end
-
- format_print(print_values)
- quit(0)
- end
-
- def accounts
- print_values = [["NAME", "PROVIDER", "PROVIDER TYPE"]]
- doc = Nokogiri::XML conductor['/provider_accounts/'].get
- doc.xpath("/provider_accounts/provider_account").each do |account|
- print_values << [account.xpath("name").text, account.xpath("provider").text, account.xpath("provider_type").text]
- end
-
- format_print(print_values)
- quit(0)
- end
-
- private
- # Takes a 2D array of strings and neatly prints them to STDOUT
- def format_print(print_values)
- widths = Array.new(print_values[0].size, 0)
- print_values.each do |print_value|
- widths = widths.zip(print_value).map! {|width, value| value.length > width ? value.length : width }
- end
-
- print_values.each do |print_value|
- widths.zip(print_value) do |width, value|
- printf("%-#{width + 5}s", value)
- end
- puts ""
- end
- end
-
- def get_template_info(image, targetimage)
- begin
- template = Nokogiri::XML iwhd["/templates/" + iwhd["/target_images/" + targetimage + "/template"].get].get
- [image, template.xpath("/template/name").text,
- iwhd["/target_images/" + targetimage + "/target"].get,
- template.xpath("/template/os/name").text,
- template.xpath("/template/os/version").text,
- template.xpath("/template/os/arch").text,
- template.xpath("/template/description").text]
- rescue
- end
- end
-
- def get_image_name(image)
- begin
- template_xml = Nokogiri::XML iwhd["images/" + image].get
- template_xml.xpath("/image/name").text
- rescue
- ""
- end
- end
- end
- end
-end
diff --git a/services/image_factory/aeolus-image/lib/push_command.rb b/services/image_factory/aeolus-image/lib/push_command.rb
deleted file mode 100644
index 47baec6..0000000
--- a/services/image_factory/aeolus-image/lib/push_command.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-require 'rest_client'
-
-module Aeolus
- module Image
- class PushCommand < BaseCommand
- attr_accessor :console
- def initialize(opts={}, logger=nil)
- super(opts, logger)
- default = {
- :provider => [],
- :id => '',
- :build => ''
- }
- @options = default.merge(@options)
- @console = ImageFactoryConsole.new()
- @console.start
- end
- def run
- begin
- if combo_implemented?
- if !@options[:id].empty? && pushed?(@options[:id])
- puts "ERROR: This image has already been pushed, to push to another provider please push via build-id rather than image-id"
- puts "e.g. aeolus-image push --provider <provider> --build <build-id>"
- quit(1)
- end
-
- sleep(5)
- @console.push(@options[:provider], get_creds, @options[:id], @options[:build]).each do |adaptor|
- puts ""
- puts "Provider Image: #{adaptor.image_id}"
- puts "Image: #{adaptor.image}"
- puts "Build: #{adaptor.build}"
- puts "Status: #{adaptor.status}"
- puts "Percent Complete: #{adaptor.percent_complete}"
- end
- quit(0)
- end
- rescue
- puts "An Error occured whilst trying to push this build, please check aeolus-image --help for details on how to use this command"
- quit(1)
- end
- end
-
- def get_creds
- conductor['provider_accounts'].get
- end
-
- def combo_implemented?
- if @options[:provider].empty? || (@options[:build].empty? && @options[:id].empty?)
- puts "This combination of parameters is not currently supported"
- quit(1)
- end
- true
- end
-
- private
- def quit(code)
- @console.shutdown
- exit(code)
- end
-
- def pushed?(image)
- begin
- uuid = Regexp.new('[\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
- uuid.match(iwhd["/images/" + image + "/latest_unpushed"].get).nil? ? true : false
- rescue
- true
- end
- end
- end
- end
-end
diff --git a/services/image_factory/aeolus-image/man/aeolus-image-build.1 b/services/image_factory/aeolus-image/man/aeolus-image-build.1
deleted file mode 100644
index ba238e1..0000000
--- a/services/image_factory/aeolus-image/man/aeolus-image-build.1
+++ /dev/null
@@ -1,36 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
-.SH NAME
-aeolus-image build \- command for building aeolus images
-.SH SYNOPSIS
-.B aeolus-image build [\-h|--help] [\-u|--username] [\-w|--password] [\-I|--image [image-id]] [\-e|--template [path-to-template]] [\-t|--targets [targets]] [\-d|--daemon]
-.SH DESCRIPTION
-aeolus-image build command allows users to build new images based on a given TDL template file for a set of specified targets such e.g. EC2, RHEVM etc...
-.SH OPTIONS
-.TP
-\-u, --user <username>
-Conductor username
-.TP
-\-w, --password <password>
-Conductor password
-.TP
-\-T, --target
-Provide a list of targets for the build
-.TP
-\-e, --template
-Provide path to a TDL template file for building against
-.TP
-\-d, --daemon
-Run as a background process
-.TP
-Get usage information for this command and associated commmands
-\-h, --help
-.SH EXAMPLES
-.TP
-Build a new image for ec2 based on the specified template TDL file template.tdl
-.B aeolus-image build
-\--targets ec2
-\--template ./template.tdl
-.TP
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-list(1), aeolus-image-push(1), aeolus-image-import(1)
diff --git a/services/image_factory/aeolus-image/man/aeolus-image-import.1 b/services/image_factory/aeolus-image/man/aeolus-image-import.1
deleted file mode 100644
index 82ee0ce..0000000
--- a/services/image_factory/aeolus-image/man/aeolus-image-import.1
+++ /dev/null
@@ -1,57 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
-.SH NAME
-aeolus-image import \- command for importing existing provider images into aeolus
-.SH SYNOPSIS
-.B aeolus-image import [\-h|--help] [\-u|--username] [\-w|--password] [\-r|--provider [provider-name]] [\--id [provider-image-id]] [--description [path-to-file|xml string]] [\T|--target [target]] [\-d|--daemon]
-.SH DESCRIPTION
-aeolus-image import allows users to import pre-existing images that exist in cloud provders for example AMI from EC2, into aeolus.
-.SH OPTIONS
-.TP
-\-u, --user <username>
-Conductor username
-.TP
-\-w, --password <password>
-Conductor password
-.TP
-\-r, --provider <provider-name>
-The provider name as it exists in conductor from where the importing image resides
-.TP
-\--id <provider-image-id>
-The providers ID given to the importing image
-.TP
-\-T, --target
-The target type for the given provider
-.TP
-\--description <path-to-xml-description|xml string>
-A user defined description to associate with the importing image
-.TP
-\-d, --daemon
-Run as a background process
-.TP
-Get usage information for this command and associated commmands
-\-h, --help
-.SH EXAMPLES
-.TP
-Import the AMI ami-1234567 from the provider ec2-us-east-1 into aeolus
-.B aeolus-image import
-\--provider ec2-us-east-1
-\--target ec2
-\--id ami-1234567
-.TP
-Import the AMI ami-1234567 from the provider ec2-us-west-1 into aeolus with a given xml description
-.B aeolus-image import
-\--provider ec2-us-west-1
-\--target ec2
-\--id ami-1234567
-\--description '<image><name>myAMI</name></image>'
-.TP
-Import the AMI ami-1234567 from the provider ec2-us-west-1 into aeolus providing a path to the description XML file
-.B aeolus-image import
-\--provider ec2-us-west-1
-\--target ec23
-\--id ami-1234567
-\--description /foo/bar/description.xml
-.SH AUTHOR
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-list(1), aeolus-image-push(1), aeolus-image-build(1)
diff --git a/services/image_factory/aeolus-image/man/aeolus-image-list.1 b/services/image_factory/aeolus-image/man/aeolus-image-list.1
deleted file mode 100644
index f6ab0d3..0000000
--- a/services/image_factory/aeolus-image/man/aeolus-image-list.1
+++ /dev/null
@@ -1,80 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
-.SH NAME
-aeolus-image \- command for listing aeolus image associated objects.
-.SH SYNOPSIS
-.B aeolus-image list [\-h|--help] [\-u|--username] [\-w|--password] [\-i|--images] [\-b|--builds [image id]] [\-t|--targetimages [build id]] [\-g|--targets] [\-a|--accounts] [\-p|--providers]
-.SH DESCRIPTION
-aeolus-image list commands allows users to list information on the contents of particular objects in image warehouse including:
-.P
-images: high level image representation associated with underlying provider and target images
-.br
-builds: an object representation of a particular build that has taken place for a high level image
-.br
-targets: particular targets available to build against, for example 'ec2'
-.br
-targetimages: represents builds of particular image against a target. For example building against target 'ec2' would create an AMI specific image
-.br
-providerimages: represents the actual images that have been uploaded to a provider. Similiar to a target image but specific to a particular provider
-.SH OPTIONS
-.TP
-\-u, --user <username>
-Conductor username
-.TP
-\-w, --password <password>
-Conductor password
-Get usage information for this command and associated commmands
-.TP
-\-i, --images
-Retrieve a list of images
-.TP
-\-b, --builds <image id>
-Retrieve the builds of an image
-.TP
-\-t, --targetimages <build id>
-Retrieve the target images from a build
-.TP
-\-P, --providerimages
-Retrieve the provider images from a target image
-.TP
-\-g, --targets
-Retrieve a list of available targets
-.TP
-\-p, --providers
-Retrieve a list of available providers
-.TP
-\-a, --accounts
-Retrieve a list of available accounts
-.TP
-\-d, --daemon
-Run as a background process
-.TP
-\-h, --help
-.SH EXAMPLES
-.TP
-List all images
-.B aeolus-image list
-\--images
-.TP
-List all builds for an image with id: 12345678-aaaa-1234--1234567890ab
-.B aeolus-image list
-\--builds 12345678-aaaa-1234--1234567890ab
-.TP
-List all target images for a given build with id: 12345678-bbbb-1234--1234567890ab
-.B aeolus-image list
-\--builds 12345678-bbbb-1234--1234567890ab
-.TP
-List all available targets
-.B aeolus-image list
-\--targets
-.TP
-List all available providers
-.B aeolus-image list
-\--providers
-.TP
-List all available accounts
-.B aeolus-image list
-\--account
-.SH AUTHOR
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-build(1), aeolus-image-push(1), aeolus-image-import(1), aeolus-image-delete(1)
diff --git a/services/image_factory/aeolus-image/man/aeolus-image-push.1 b/services/image_factory/aeolus-image/man/aeolus-image-push.1
deleted file mode 100644
index c2e0215..0000000
--- a/services/image_factory/aeolus-image/man/aeolus-image-push.1
+++ /dev/null
@@ -1,40 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
-.SH NAME
-aeolus-image push \- command for pushing aeolus images to back end providers
-.SH SYNOPSIS
-.B aeolus-image push [\-h|--help] [\-u|--username] [\-w|--password] [\-id [image-id]] [-r|--provider [provider-name]]
-.SH DESCRIPTION
-aeolus-image push allows users to push built images to a particular backend provider
-.SH OPTIONS
-.TP
-\-u, --user <username>
-Conductor username
-.TP
-\-w, --password <password>
-Conductor password
-.TP
-\-r|--provider
-The provider name this image should be pushed to
-.TP
-\--id <id>
-The id of the image for pushing
-.TP
-\-d, --daemon
-Run as a background process
-.TP
-Get usage information for this command and associated commmands
-\-h, --help
-.SH EXAMPLES
-.TP
-Initial push of an image with id 12345678-bbbb-1234--1234567890ab to provider ec2-us-east-1
-.B aeolus-image push
-\--id 12345678-bbbb-1234--1234567890ab
-\--provider ec2-us-east-1
-Push a build with id 12345678-bbbb-1234--1234567890ab to provider ec2-us-east-1
-.B aeolus-image push
-\--build 12345678-bbbb-1234--1234567890ab
-\--provider ec2-us-east-1
-.SH AUTHOR
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-list(1), aeolus-image-build(1), aeolus-image-import(1)
diff --git a/services/image_factory/aeolus-image/man/aeolus-image.1 b/services/image_factory/aeolus-image/man/aeolus-image.1
deleted file mode 100644
index 7e7cc04..0000000
--- a/services/image_factory/aeolus-image/man/aeolus-image.1
+++ /dev/null
@@ -1,16 +0,0 @@
-.TH aeolus-image 1 "July 07, 2011" "version 0.4" "USER COMMANDS"
-.SH NAME
-aeolus-image \- command line tool for managing aeolus images
-.SH SYNOPSIS
-.B aeolus-image
-[\-h]
-.SH DESCRIPTION
-aeolus-image is a tool that allows users to control their aeolus images through image builder and aeolus conductor. aeolus-image offers four commands options; list, build, push, import. For more information on each command please run man aeolus-image <command> or aeolus-image --help
-.SH OPTIONS
-.TP
-\-h, --help
-Get usage information for this tool and subcommands
-.SH AUTHOR
-Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
-.SH SEE ALSO
-aeolus-image-build(1), aeolus-image-push(1), aeolus-image-list(1), aeolus-image-import(1)
diff --git a/services/image_factory/aeolus-image/rake/rpmtask.rb b/services/image_factory/aeolus-image/rake/rpmtask.rb
deleted file mode 100644
index 7534693..0000000
--- a/services/image_factory/aeolus-image/rake/rpmtask.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-# Define a package task library to aid in the definition of RPM
-# packages.
-
-require 'rubygems'
-require 'rake'
-require 'rake/packagetask'
-
-require 'rbconfig' # used to get system arch
-
-module Rake
-
- # Create a package based upon a RPM spec.
- # RPM packages, can be produced by this task.
- class RpmTask < PackageTask
- # RPM spec containing the metadata for this package
- attr_accessor :rpm_spec
-
- # RPM build dir
- attr_accessor :topdir
-
- def initialize(rpm_spec)
- init(rpm_spec)
- yield self if block_given?
- define if block_given?
- end
-
- def init(rpm_spec)
- @rpm_spec = rpm_spec
-
- # parse this out of the rpmbuild macros,
- # not ideal but better than hardcoding this
- File.open('/etc/rpm/macros.dist', "r") { |f|
- f.read.scan(/%dist\s*\.(.*)\n/)
- @distro = $1
- }
-
- # Parse rpm name / version out of spec
- # FIXME hacky way to do this for now
- # (would be nice to implement a full blown rpm spec parser for ruby)
- File.open(rpm_spec, "r") { |f|
- contents = f.read
- # Parse out definitions and crudely expand them
- contents.scan(/%define .*\n/).each do |definition|
- words = definition.strip.split(' ')
- key = words[1]
- value = words[2..-1].to_s
- # Modify the contents with expanded values, unless they contain
- # a shell command (since we're not modifying them)
- contents.gsub!("%{#{key}}", value) unless value.match('%\(')
- end
- @name = contents.scan(/\nName: .*\n/).first.split.last
- @version = contents.scan(/\nVersion: .*\n/).first.split.last
- @release = contents.scan(/\nRelease: .*\n/).first.split.last
- @release.gsub!("%{?dist}", ".#{@distro}")
- @arch = contents.scan(/\nBuildArch: .*\n/) # TODO grab local arch if not defined
- if @arch.nil?
- @arch = Config::CONFIG["target_cpu"] # hoping this will work for all cases,
- # can just run the 'arch' cmd if we want
- else
- @arch = @arch.first.split.last
- end
- }
- super(@name, @version)
-
- @rpmbuild_cmd = 'rpmbuild'
- end
-
- def define
- super
-
- directory "#{@topdir}/SOURCES"
- directory "#{@topdir}/SPECS"
-
- desc "Build the rpms"
- task :rpms => [rpm_file]
-
- # FIXME properly determine :package build artifact(s) to copy to sources dir
- file rpm_file => [:package, "#{@topdir}/SOURCES", "#{@topdir}/SPECS"] do |t,args|
- cp "#{package_dir}/#{@name}-#{(a)version}.tgz", "#{@topdir}/SOURCES/"
- # FIXME - This seems like a hack, but we don't know the gem's name
- cp "#{package_dir}/#{(a)name.gsub('rubygem-', '')}-#{(a)version}.gem", "#{@topdir}/SOURCES/"
- cp @rpm_spec, "#{@topdir}/SPECS"
- sh "#{@rpmbuild_cmd} " +
- "--define '_topdir #{@topdir}' " +
- "--define 'extra_release #{args.extra_release}' " +
- "-ba #{@rpm_spec}"
- end
- end
-
- def rpm_file
- # FIXME support all a spec's subpackages as well
- "#{@topdir}/RPMS/#{@arch}/#{@name}-#{@version}-#{@release}.#{(a)arch}.rpm"
- end
- end
-end
diff --git a/services/image_factory/aeolus-image/rubygem-aeolus-image.spec b/services/image_factory/aeolus-image/rubygem-aeolus-image.spec
deleted file mode 100644
index f7f5e06..0000000
--- a/services/image_factory/aeolus-image/rubygem-aeolus-image.spec
+++ /dev/null
@@ -1,67 +0,0 @@
-%define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
-%define gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
-%define gemname aeolus-image
-%define geminstdir %{gemdir}/gems/%{gemname}-%{version}
-%define mandir /usr/man/man1
-
-Summary: Commandline interface for working with the Aeolus cloud suite
-Name: rubygem-%{gemname}
-Version: 0.0.1
-Release: 1%{?dist}%{?extra_release}
-Group: Development/Languages
-License: GPLv2+ or Ruby
-URL: http://aeolusproject.org
-
-Source0: %{gemname}-%{version}.gem
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires: rubygems
-Requires: rubygem(nokogiri) >= 1.4.0
-Requires: rubygem(rest-client)
-Requires: rubygem(imagefactory-console) >= 0.4.0
-
-BuildRequires: rubygems
-BuildArch: noarch
-Provides: rubygem(%{gemname}) = %{version}
-
-Obsoletes: rubygem-aeolus-cli
-Provides: rubygem(aeolus-cli)
-
-%description
-QMF Console for Aeolus Image Factory
-
-%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}
-find %{buildroot}%{geminstdir}/bin -type f | xargs chmod a+x
-rmdir %{buildroot}%{gemdir}/bin
-
-mkdir -p %{buildroot}%{mandir}
-mv %{buildroot}%{geminstdir}/man/* %{buildroot}%{mandir}
-
-%clean
-rm -rf %{buildroot}
-
-%files
-%defattr(-, root, root, -)
-%{_bindir}/aeolus-image
-%{gemdir}/gems/%{gemname}-%{version}/
-%doc %{gemdir}/doc/%{gemname}-%{version}
-%{gemdir}/cache/%{gemname}-%{version}.gem
-%{gemdir}/specifications/%{gemname}-%{version}.gemspec
-%{mandir}
-
-%changelog
-* Mon Jul 04 2011 <mtaylor(a)redhat.com> - 0.0.1-1
-- Added man files
-* Wed Jun 15 2011 <jguiditt(a)redhat.com> - 0.0.1-1
-- Initial package
diff --git a/services/image_factory/aeolus-image/spec/base_command_spec.rb b/services/image_factory/aeolus-image/spec/base_command_spec.rb
deleted file mode 100644
index 31a0aa0..0000000
--- a/services/image_factory/aeolus-image/spec/base_command_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-require 'spec_helper'
-
-module Aeolus
- module Image
- describe BaseCommand do
-
- it "should determine the correct credentials for HTTP Authentication" do
- basec = BaseCommand.new
- iwhd = basec.send :iwhd
- iwhd.user.should == nil
-
- conductor = basec.send :conductor
- conductor.user.should == "admin"
- conductor.password.should == "password"
-
- basec = BaseCommand.new({:username => "testusername", :password=> "testpassword"})
- conductor = basec.send :conductor
- conductor.user.should == "testusername"
- conductor.password.should == "testpassword"
- end
-
- describe "#read_file" do
-
- it "should return nil when it cannot find file" do
- b = BaseCommand.new
- b.send(:read_file, "foo.fake").should be_nil
- end
-
- it "should read file content into string variable" do
- b = BaseCommand.new
- template_str = b.send(:read_file, "#{File.dirname(__FILE__)}" + "/../examples/custom_repo.tdl")
- template_str.should include("<template>")
- end
- end
-
- describe "#is_file?" do
- it "should return false if no file found" do
- b = BaseCommand.new
- b.send(:is_file?, "foo.fake").should be_false
- end
- it "should return true if file found" do
- b = BaseCommand.new
- valid_file = "#{File.dirname(__FILE__)}" + "/../examples/aeolus-cli"
- b.instance_eval {@config_location = valid_file}
- b.send(:is_file?, valid_file).should be_true
- end
- end
-
- describe "#write_file" do
- it "should write a new file" do
- b = BaseCommand.new
- new_file = "/tmp/foo.fake"
- b.instance_eval {@config_location = new_file}
- b.send(:write_file)
- conf = YAML::load(File.open(File.expand_path(new_file)))
- conf.has_key?(:iwhd).should be_true
- File.delete(new_file)
- end
- end
-
- describe "#validate_xml_document?" do
- it "should return errors given non compliant xml" do
- b = BaseCommand.new
- errors = b.send(:validate_xml_document, "examples/tdl.rng", File.read("spec/fixtures/invalid_template.tdl"))
- errors.length.should > 0
- end
-
- it "should return no errors" do
- b = BaseCommand.new
- errors = b.send(:validate_xml_document, "examples/tdl.rng", File.read("spec/fixtures/valid_template.tdl"))
- errors.length.should == 0
- end
- end
- end
- end
-end
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/build_command_spec.rb b/services/image_factory/aeolus-image/spec/build_command_spec.rb
deleted file mode 100644
index adabb19..0000000
--- a/services/image_factory/aeolus-image/spec/build_command_spec.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-require 'spec_helper'
-
-module Aeolus
- module Image
- describe BuildCommand do
- before(:each) do
- @options[:target] = ['mock','ec2']
- @options[:template] = "#{File.dirname(__FILE__)}" + "/../examples/custom_repo.tdl"
- end
-
- describe "#run" do
- it "should kick off a build with valid options" do
- b = BuildCommand.new(@options, @output)
- begin
- b.run
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Target Image:")
- $stdout.string.should include("Build:")
- end
- it "should exit with a message if only image id is provided" do
- @options.delete(:template)
- @options.delete(:target)
- @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
- b = BuildCommand.new(@options, @output)
- begin
- b.run
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("This combination of parameters is not currently supported")
- end
- it "should exit with appropriate message when a non compliant template is given" do
- @options[:template] = "spec/fixtures/invalid_template.tdl"
- @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
- b = BuildCommand.new(@options, @output)
- begin
- b.run
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("ERROR: The given Template does not conform to the TDL Schema")
- end
- end
-
- describe "#combo_implemented?" do
- it "should give useful feedback if no template or target is specified" do
- @options[:template] = ''
- @options[:target] = []
- b = BuildCommand.new(@options, @output)
- begin
- b.combo_implemented?
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("This combination of parameters is not currently supported")
- end
- end
- end
- end
-end
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/config_parser_spec.rb b/services/image_factory/aeolus-image/spec/config_parser_spec.rb
deleted file mode 100644
index 724ed4d..0000000
--- a/services/image_factory/aeolus-image/spec/config_parser_spec.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-require 'spec_helper'
-
-module Aeolus
- module Image
- describe ConfigParser do
- it "should parse the specified command" do
- config_parser = ConfigParser.new(%w(list --images))
- config_parser.process
- config_parser.command.should == 'list'
- end
-
- it "should exit gracefully when a required subcommand is not provided" do
- begin
- silence_stream(STDOUT) do
- config_parser = ConfigParser.new(%w(list))
- config_parser.process
- config_parser.should_receive(:exit).with(1)
- end
- rescue SystemExit => e
- e.status.should == 1
- end
- end
-
- it "should notify the user of an invalid command" do
- config_parser = ConfigParser.new(%w(sparkle))
- config_parser.should_receive(:exit).with(0)
- silence_stream(STDOUT) do
- config_parser.process
- end
- end
-
- it "should exit gracefully with bad params" do
- begin
- silence_stream(STDOUT) do
- ConfigParser.new(%w(delete --fred)).should_receive(:exit).with(1)
- end
- rescue SystemExit => e
- e.status.should == 1
- end
- end
-
- it "should set options hash for valid general options" do
- config_parser = ConfigParser.new(%w(list --user joe --password cloud --images))
- config_parser.options[:user].should == 'joe'
- config_parser.options[:password].should == 'cloud'
- config_parser.options[:subcommand].should == :images
- end
-
- it "should set options hash for valid list options" do
- config_parser = ConfigParser.new(%w(list --builds 12345))
- config_parser.options[:subcommand].should == :builds
- config_parser.options[:id].should == '12345'
- end
-
- it "should set options hash for valid build options" do
- config_parser = ConfigParser.new(%w(build --target ec2,rackspace --image 12345 --template my.tmpl))
- config_parser.options[:target].should == ['ec2','rackspace']
- config_parser.options[:image].should == '12345'
- config_parser.options[:template].should == 'my.tmpl'
- end
-
- it "should set options hash for valid push options" do
- config_parser = ConfigParser.new(%w(push --provider ec2-us-east1 --id 12345))
- config_parser.options[:provider].should == ['ec2-us-east1']
- config_parser.options[:id].should == '12345'
- end
-
- it "should set options hash for valid delete options" do
- config_parser = ConfigParser.new(%w(delete --build 12345))
- config_parser.options[:build].should == '12345'
- end
-
- it "should set options hash for valid import options" do
- config_parser = ConfigParser.new(%w(import --provider ec2-us-east-1a --description /path/to/file --id ami-123456 --target ec2))
- config_parser.options[:provider].should == ['ec2-us-east-1a']
- config_parser.options[:target].should == ['ec2']
- config_parser.options[:description].should == '/path/to/file'
- config_parser.options[:id].should == 'ami-123456'
- end
- end
- end
-end
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/fixtures/invalid_template.tdl b/services/image_factory/aeolus-image/spec/fixtures/invalid_template.tdl
deleted file mode 100644
index c6395d0..0000000
--- a/services/image_factory/aeolus-image/spec/fixtures/invalid_template.tdl
+++ /dev/null
@@ -1,18 +0,0 @@
-<bad_template>
- <name>tmpl1</name>
- <description>foo</description>
- <os>
- <name>Fedora</name>
- <arch>x86_64</arch>
- <version>14</version>
- <install type="url">
- <url>http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fedora/x86...</url>
- </install>
- </os>
- <bad_repositories>
- <repository name="custom">
- <url>http://repos.fedorapeople.org/repos/aeolus/demo/webapp/</url>
- <signed>false</signed>
- </repository>
- </bad_repositories>
-</bad_template>
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/fixtures/valid_template.tdl b/services/image_factory/aeolus-image/spec/fixtures/valid_template.tdl
deleted file mode 100644
index 2f96604..0000000
--- a/services/image_factory/aeolus-image/spec/fixtures/valid_template.tdl
+++ /dev/null
@@ -1,18 +0,0 @@
-<template>
- <name>tmpl1</name>
- <description>foo</description>
- <os>
- <name>Fedora</name>
- <arch>x86_64</arch>
- <version>14</version>
- <install type="url">
- <url>http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fedora/x86...</url>
- </install>
- </os>
- <repositories>
- <repository name="custom">
- <url>http://repos.fedorapeople.org/repos/aeolus/demo/webapp/</url>
- <signed>false</signed>
- </repository>
- </repositories>
-</template>
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/import_command_spec.rb b/services/image_factory/aeolus-image/spec/import_command_spec.rb
deleted file mode 100644
index 4ce1d6f..0000000
--- a/services/image_factory/aeolus-image/spec/import_command_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require 'spec_helper'
-
-module Aeolus
- module Image
- describe ImportCommand do
- before(:each) do
- @options[:id] = "ami-test"
- @options[:target] = "ec2"
- @options[:provider] = "ec2-us-east-1"
- end
-
- describe "#import_image" do
- it "should import an image with default description values" do
- importc = ImportCommand.new(@options)
- begin
- importc.import_image
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Target Image:")
- $stdout.string.should include("Build:")
- $stdout.string.should include("Provider Image:")
- end
-
- it "should import an image with file description" do
- @options[:description] = 'spec/sample_data/image_description.xml'
- importc = ImportCommand.new(@options)
- begin
- importc.import_image
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Target Image:")
- $stdout.string.should include("Build:")
- $stdout.string.should include("Provider Image:")
- #TODO: Add test to check that file was uploaded properly (when we have implemented a show/view image command)
- end
- end
- end
- end
-end
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/list_command_spec.rb b/services/image_factory/aeolus-image/spec/list_command_spec.rb
deleted file mode 100644
index 9807d93..0000000
--- a/services/image_factory/aeolus-image/spec/list_command_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require 'spec_helper'
-
-module Aeolus
- module Image
- describe ListCommand do
- it "should return a list of images" do
- regexp = Regexp.new('[uuid:\s][\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
- listc = ListCommand.new(:subcommand => 'images')
- images = listc.images
- images.each do |image|
- regexp.match(image.to_s).should_not == nil
- end
- end
- it "should return not implemented for unimplemented subcommands" do
- l = ListCommand.new()
- r = l.targets
- r.should eql("This option or combination is not yet implemented")
- end
- end
- end
-end
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/push_command_spec.rb b/services/image_factory/aeolus-image/spec/push_command_spec.rb
deleted file mode 100644
index 83cb48b..0000000
--- a/services/image_factory/aeolus-image/spec/push_command_spec.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require 'spec_helper'
-
-module Aeolus
- module Image
- describe PushCommand do
-
- before(:each) do
- @options[:provider] = ['mock']
- @options[:user] = 'admin'
- @options[:password] = 'password'
- end
-
- describe "#run" do
- before(:each) do
- options = {}
- options[:target] = ['mock','ec2']
- options[:template] = "#{File.dirname(__FILE__)}" + "/../examples/custom_repo.tdl"
- b = BuildCommand.new(options)
- sleep(5)
- tmpl_str = b.send(:read_file, options[:template])
- b.console.build(tmpl_str, ['mock','ec2']).each do |adaptor|
- @build_id = adaptor.image
- end
- b.console.shutdown
- @options[:id] = @build_id
- end
-
- it "should push an image with valid options" do
- p = PushCommand.new(@options, @output)
- begin
- p.run
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Provider Image:")
- $stdout.string.should include("Build:")
- end
- end
-
- describe "#combo_implemented?" do
- it "should give useful feedback if no template or target is specified" do
- @options.delete(:id)
- @options.delete(:provider)
- b = PushCommand.new(@options, @output)
- begin
- b.combo_implemented?
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("This combination of parameters is not currently supported")
- end
- end
- end
- end
-end
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/spec.opts b/services/image_factory/aeolus-image/spec/spec.opts
deleted file mode 100644
index 4154052..0000000
--- a/services/image_factory/aeolus-image/spec/spec.opts
+++ /dev/null
@@ -1,3 +0,0 @@
---color
---format specdoc
---diff
\ No newline at end of file
diff --git a/services/image_factory/aeolus-image/spec/spec_helper.rb b/services/image_factory/aeolus-image/spec/spec_helper.rb
deleted file mode 100644
index 013fbd3..0000000
--- a/services/image_factory/aeolus-image/spec/spec_helper.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
-$: << File.expand_path(File.join(File.dirname(__FILE__), "."))
-require 'rubygems'
-require 'config_parser'
-require 'stringio'
-require 'base_command'
-require 'list_command'
-require 'build_command'
-require 'push_command'
-require 'import_command'
-require 'delete_command'
-
-
-module Helpers
- # Silences any stream for the duration of the block.
- #
- # silence_stream(STDOUT) do
- # puts 'This will never be seen'
- # end
- #
- # puts 'But this will'
- #
- # (Taken from ActiveSupport)
- def silence_stream(stream)
- old_stream = stream.dup
- stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
- stream.sync = true
- yield
- ensure
- stream.reopen(old_stream)
- end
-end
-
-Spec::Runner.configure do |config|
- config.include Helpers
- config.before(:all) do
- Aeolus::Image::BaseCommand.class_eval do
- def load_config
- YAML::load(File.open(File.join(File.dirname(__FILE__), "/../examples/aeolus-cli")))
- end
- end
- end
- config.before(:each) do
- @output = double('output')
- @stdout_orig = $stdout
- $stdout = StringIO.new
- @options = {}
- end
- config.after(:each) do
- $stdout = @stdout_orig
- end
-end
\ No newline at end of file
diff --git a/services/image_factory/console/Rakefile b/services/image_factory/console/Rakefile
deleted file mode 100644
index 42e576a..0000000
--- a/services/image_factory/console/Rakefile
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# Copyright (C) 2011 Red Hat, Inc.
-# Written by Jason Guiditta <jguiditt(a)redhat.com>
-#
-# 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; version 2 of the License.
-#
-# 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
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-
-require 'rubygems'
-require 'rake'
-require 'rake/clean'
-require 'rake/gempackagetask'
-require 'rake/rdoctask'
-require 'rake/testtask'
-require 'spec/rake/spectask'
-require 'rake/rpmtask'
-
-RPMBUILD_DIR = "#{File.expand_path('~')}/rpmbuild"
-RPM_SPEC = "rubygem-imagefactory-console.spec"
-
-spec = Gem::Specification.new do |s|
- s.name = 'imagefactory-console'
- s.version = '0.4.0'
- s.has_rdoc = true
- #s.extra_rdoc_files = ['README', 'COPYING']
- s.summary = 'QMF Console for Aeolus Image Factory'
- s.description = s.summary
- s.author = 'Jason Guiditta'
- s.email = 'jguiditt(a)redhat.com'
- # s.executables = ['your_executable_here']
- s.files = %w(Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
- s.require_path = "lib"
- s.bindir = "bin"
-end
-
-Rake::GemPackageTask.new(spec) do |p|
- p.gem_spec = spec
- p.need_tar = true
- p.need_zip = true
-end
-
-Rake::RDocTask.new do |rdoc|
- files =['lib/**/*.rb'] #'README', 'COPYING',
- rdoc.rdoc_files.add(files)
- #rdoc.main = "README" # page to start on
- rdoc.title = "console Docs"
- rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
- rdoc.options << '--line-numbers'
-end
-
-Rake::TestTask.new do |t|
- t.test_files = FileList['test/**/*.rb']
-end
-
-Spec::Rake::SpecTask.new do |t|
- t.libs << 'lib'
- t.spec_files = FileList['spec/**/*.rb']
- t.spec_opts = ['--color', '--format nested']
-end
-
-Rake::RpmTask.new(RPM_SPEC) do |rpm|
- rpm.need_tar = true
- rpm.package_files.include("lib/*")
- rpm.topdir = "#{RPMBUILD_DIR}"
-end
diff --git a/services/image_factory/console/lib/imagefactory.rb b/services/image_factory/console/lib/imagefactory.rb
deleted file mode 100644
index 2a8bc29..0000000
--- a/services/image_factory/console/lib/imagefactory.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require 'imagefactory/console'
-require 'imagefactory/base_handler'
diff --git a/services/image_factory/console/lib/imagefactory/base_handler.rb b/services/image_factory/console/lib/imagefactory/base_handler.rb
deleted file mode 100644
index 17756ec..0000000
--- a/services/image_factory/console/lib/imagefactory/base_handler.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Copyright (C) 2011 Red Hat, Inc.
-# Written by Jason Guiditta <jguiditt(a)redhat.com>
-#
-# 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; version 2 of the License.
-#
-# 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
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-require 'logger'
-
-class BaseHandler
-
- def initialize(logger=nil)
- logger(logger)
- end
-
- def handle(data)
- logger.debug "====== Type of event: #{data.event}"
- if data.event == 'STATUS'
- logger.debug "calling handle status in base handler"
- handle_status(data)
- elsif data.event == 'FAILURE'
- handle_failed(data)
- end
- end
-
- def handle_status(data)
- logger.debug "{data.event}, #{data.new_status}"
- end
-
- def handle_failed(data)
- logger.error "#{data.to_s}"
- end
-
- protected
- def logger(logger=nil)
- @logger ||= logger
- unless @logger
- @logger = Logger.new(STDOUT)
- @logger.level = Logger::ERROR
- @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
- end
- return @logger
- end
-end
diff --git a/services/image_factory/console/lib/imagefactory/console.rb b/services/image_factory/console/lib/imagefactory/console.rb
deleted file mode 100644
index c1cfb7d..0000000
--- a/services/image_factory/console/lib/imagefactory/console.rb
+++ /dev/null
@@ -1,251 +0,0 @@
-#
-# Copyright (C) 2011 Red Hat, Inc.
-# Written by Jason Guiditta <jguiditt(a)redhat.com>
-#
-# 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; version 2 of the License.
-#
-# 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
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-# TODO: figure out what I am doing wrong here that I need this line
-$: << File.expand_path(File.join(File.dirname(__FILE__), "."))
-require 'cqpid'
-require 'qmf2'
-require 'logger'
-require 'base_handler'
-
-class ImageFactoryConsole < Qmf2::ConsoleHandler
-
- attr_accessor :q, :handler
-
- def initialize(args={})
-# @retry_limit = args.include?(:retry_limit) ? args[:retry_limit] : 20
-# @delay = args.include?(:delay) ? args[:delay] : 15
- host = args.include?(:host) ? args[:host] : "localhost"
- port = args.include?(:port) ? args[:port] : 5672
-# url = "amqp://#{host}:#{port}" <- the amqp part here doesnt work yet
- url = "#{host}:#{port}"
- opts = {"reconnect"=>"true"}
- @connection = Cqpid::Connection.new(url, opts)
- @connection.open
- @session = Qmf2::ConsoleSession.new(@connection)
- @session.open
- @session.set_agent_filter("[and, [eq, _vendor, [quote, 'redhat.com']], [eq, _product, [quote, 'imagefactory']]]")
-
- if args.include?(:logger)
- @logger = args[:logger]
- else
- @logger = Logger.new(STDOUT)
- @logger.level = Logger::ERROR
- @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
- end
- @handler = args.include?(:handler)? args[:handler]: BaseHandler.new(@logger)
- super(@session)
- end
-
- # Call this method to initiate a build, and get back an
- # array of BuildAdaptor objects.
- # * template => String
- # Description of what to build. Can be xml, uuid, or url
- # * targets => Array
- # Represents the names of the clouds to target (ec2, mock, rackspace, etc)
- # * image_id => String
- # The UUID of an image previously built
- # * build_id => String
- # The UUID of a previous build of the image
- # * Returns => an array of BuildAdaptor objects
- #
- def build(template, targets, image='', build='')
- targets = [targets] unless targets.instance_of?(Array)
- # TODO: return error if there is a problem calling this method or getting
- # a factory instance
- begin
- response = factory.build_image(image, build, template, targets)
- build_adaptors(response)
- rescue Exception => e
- @logger.debug "Encountered error in build_image: #{e}"
- return e
- end
- end
-
- # Call this method to push an image to a provider, and get back an
- # array of BuildAdaptor objects.
- # * providers => Array
- # Represents the target providers to build for (ec2-us-east, mock1, etc)
- # * credentials => String
- # XML block to be used for registration, upload, etc
- # * image_id => String
- # The UUID of an image previously built
- # * build_id => String
- # The UUID of a previous build of the image
- # * Returns => an array of BuildAdaptor objects
- #
- def push(providers, credentials, image_id, build_id='')
- providers = [providers] unless providers.instance_of?(Array)
- # TODO: return error if there is a problem calling this method or getting
- # a factory instance
- begin
- response = factory.push_image(image_id, build_id, providers, credentials)
- build_adaptors(response)
- rescue Exception => e
- @logger.debug "Encountered error in push_image: #{e}"
- return e
- end
- end
-
-# Call this method to import an image
-# array of BuildAdaptor objects.
-# * image => string
-# The uuid of an existing image
-# * build => string
-# the uuid of an existing build, or the empty string
-# * target_identifier => string
-# the target specific image ID
-# * image_desc => string
-# an xml string description of the image
-# * target => string
-# name of the cloud to target
-# * provider => string
-# the name of the cloud provider, often a region
-# Returns => a map including UUIDs as strings for 'target_image', 'build', 'image', 'provider_image'
-
- def import_image(image, build, target_identifier, image_description, target, provider)
- # TODO: return error if there is a problem calling this method or getting
- # a factory instance
- begin
- factory.import_image(image, build, target_identifier, image_description, target, provider)
- rescue Exception => e
- @logger.debug "Encountered error in import_image: #{e}"
- return e
- end
- end
-
- # <b>DEPRECATED:</b> Please use <tt>build</tt> instead.
- # Call this method to initiate a build, and get back an
- # BuildAdaptor object.
- # * descriptor => String
- # This can be either xml or a url pointing to the xml
- # * target => String
- # Represents the target provider type to build for (ec2, mock, etc)
- # * Returns => a BuildAdaptor object
- #
- def build_image(descriptor, target)
- @logger.warn "[DEPRECATION] 'build_image' is deprecated. Please use 'build' instead."
- # TODO: return error if there is a problem calling this method or getting
- # a factory instance
- begin
- response = factory.image(descriptor, target)
- build_adaptor(response)
- rescue Exception => e
- @logger.debug "Encountered error in build_image: #{e}"
- return e
- end
- end
-
- # <b>DEPRECATED:</b> Please use <tt>push</tt> instead.
- # Call this method to push an image to a provider, and get back an
- # BuildAdaptor object.
- # * image_id => String (uuid)
- # * provider => String
- # Represents the target provider to build for (ec2-us-east, mock, etc)
- # * credentials => String
- # XML block to be used for registration, upload, etc
- # * Returns => a BuildAdaptor object
- #
- def push_image(image_id, provider, credentials)
- @logger.warn "[DEPRECATION] 'push_image' is deprecated. Please use 'push' instead."
- # TODO: return error if there is a problem calling this method or getting
- # a factory instance
- begin
- response = factory.provider_image(image_id, provider, credentials)
- build_adaptor(response)
- rescue Exception => e
- @logger.debug "Encountered error in push_image: #{e}"
- return e
- end
- end
-
- #TODO: enhance both of these methods to handle multiple agents
- def agent_added(agent)
- @logger.debug "GOT AN AGENT: #{agent} at #{Time.now.utc}"
- @q = agent if agent.product == "imagefactory"
- end
-
- def agent_deleted(agent, reason)
- @logger.debug "AGENT GONE: #{agent} at #{Time.now.utc}, because #{reason}"
- unless @q==nil
- @q = nil if (@q.product == agent.product && @q.name.eql?(agent.name))
- end
- end
-
- # TODO: handle agent restart events (this will be more useful when
- # restarted agent can recover an in-process build
- def agent_restarted(agent)
- @logger.debug "AGENT RESTARTED: #{agent.product}"
- end
-
- # TODO: handle schema updates. This will be more useful when/if
- # we make this a more generic console to talk to different agents.
- def agent_schema_updated(agent)
- @logger.debug "AGENT SCHEMA UPDATED: #{agent.product}"
- end
-
- def event_raised(agent, data, timestamp, severity)
- @logger.debug "GOT AN EVENT: #{agent}, #{data} at #{timestamp}"
- @handler.handle(data)
- end
-
- def shutdown
- @logger.debug "Closing connections.."
- if @session
- @session.close
- end
- @connection.close
-
- #TODO Replace this with some control flow to manage the cancelling of the console handler, atm
- # this code swallows error message generated by closing connection, then cancelling console.
- begin
- self.cancel
- rescue QmfError
- # TODO We should be logging to a file rather than STDOUT, uncomment this code when logging is configured properly
- # Commented out to clean up user output
- #(a)logger.error "Issue Closing Console Handler"
- end
- end
-
- private
-
- def factory
- @factory ||= @q.query("{class:ImageFactory, package:'com.redhat.imagefactory'}").first
- end
-
- def build_adaptors(response)
- ret = []
- response['build_adaptors'].each do |imgfacaddr|
- query = Qmf2::Query.new(Qmf2::DataAddr.new(imgfacaddr))
- ret << @q.query(query,5).first
- end
- ret
- end
-
- def build_adaptor(response)
- @logger.warn "[DEPRECATION] 'build_adaptor' is deprecated. Please use 'build_adaptors' instead."
- imgfacaddr = Qmf2::DataAddr.new(response['build_adaptor'])
- query = Qmf2::Query.new(imgfacaddr)
- @q.query(query,5).first
- end
-
- def make_array(a)
- return a ||= [a] unless a.instance_of?(Array)
- end
-end
\ No newline at end of file
diff --git a/services/image_factory/console/rake/rpmtask.rb b/services/image_factory/console/rake/rpmtask.rb
deleted file mode 100644
index 7534693..0000000
--- a/services/image_factory/console/rake/rpmtask.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-# Define a package task library to aid in the definition of RPM
-# packages.
-
-require 'rubygems'
-require 'rake'
-require 'rake/packagetask'
-
-require 'rbconfig' # used to get system arch
-
-module Rake
-
- # Create a package based upon a RPM spec.
- # RPM packages, can be produced by this task.
- class RpmTask < PackageTask
- # RPM spec containing the metadata for this package
- attr_accessor :rpm_spec
-
- # RPM build dir
- attr_accessor :topdir
-
- def initialize(rpm_spec)
- init(rpm_spec)
- yield self if block_given?
- define if block_given?
- end
-
- def init(rpm_spec)
- @rpm_spec = rpm_spec
-
- # parse this out of the rpmbuild macros,
- # not ideal but better than hardcoding this
- File.open('/etc/rpm/macros.dist', "r") { |f|
- f.read.scan(/%dist\s*\.(.*)\n/)
- @distro = $1
- }
-
- # Parse rpm name / version out of spec
- # FIXME hacky way to do this for now
- # (would be nice to implement a full blown rpm spec parser for ruby)
- File.open(rpm_spec, "r") { |f|
- contents = f.read
- # Parse out definitions and crudely expand them
- contents.scan(/%define .*\n/).each do |definition|
- words = definition.strip.split(' ')
- key = words[1]
- value = words[2..-1].to_s
- # Modify the contents with expanded values, unless they contain
- # a shell command (since we're not modifying them)
- contents.gsub!("%{#{key}}", value) unless value.match('%\(')
- end
- @name = contents.scan(/\nName: .*\n/).first.split.last
- @version = contents.scan(/\nVersion: .*\n/).first.split.last
- @release = contents.scan(/\nRelease: .*\n/).first.split.last
- @release.gsub!("%{?dist}", ".#{@distro}")
- @arch = contents.scan(/\nBuildArch: .*\n/) # TODO grab local arch if not defined
- if @arch.nil?
- @arch = Config::CONFIG["target_cpu"] # hoping this will work for all cases,
- # can just run the 'arch' cmd if we want
- else
- @arch = @arch.first.split.last
- end
- }
- super(@name, @version)
-
- @rpmbuild_cmd = 'rpmbuild'
- end
-
- def define
- super
-
- directory "#{@topdir}/SOURCES"
- directory "#{@topdir}/SPECS"
-
- desc "Build the rpms"
- task :rpms => [rpm_file]
-
- # FIXME properly determine :package build artifact(s) to copy to sources dir
- file rpm_file => [:package, "#{@topdir}/SOURCES", "#{@topdir}/SPECS"] do |t,args|
- cp "#{package_dir}/#{@name}-#{(a)version}.tgz", "#{@topdir}/SOURCES/"
- # FIXME - This seems like a hack, but we don't know the gem's name
- cp "#{package_dir}/#{(a)name.gsub('rubygem-', '')}-#{(a)version}.gem", "#{@topdir}/SOURCES/"
- cp @rpm_spec, "#{@topdir}/SPECS"
- sh "#{@rpmbuild_cmd} " +
- "--define '_topdir #{@topdir}' " +
- "--define 'extra_release #{args.extra_release}' " +
- "-ba #{@rpm_spec}"
- end
- end
-
- def rpm_file
- # FIXME support all a spec's subpackages as well
- "#{@topdir}/RPMS/#{@arch}/#{@name}-#{@version}-#{@release}.#{(a)arch}.rpm"
- end
- end
-end
diff --git a/services/image_factory/console/rubygem-imagefactory-console.spec b/services/image_factory/console/rubygem-imagefactory-console.spec
deleted file mode 100644
index 59cfc8a..0000000
--- a/services/image_factory/console/rubygem-imagefactory-console.spec
+++ /dev/null
@@ -1,55 +0,0 @@
-# Generated from image_factory_console-0.2.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 imagefactory-console
-%define geminstdir %{gemdir}/gems/%{gemname}-%{version}
-
-Summary: QMF Console for Aeolus Image Factory
-Name: rubygem-%{gemname}
-Version: 0.4.0
-Release: 1%{?dist}%{?extra_release}
-Group: Development/Languages
-License: GPLv2+ or Ruby
-URL: http://aeolusproject.org
-Source0: %{gemname}-%{version}.gem
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires: rubygems
-# These can't be deduced by gem2rpm
-Requires: qpid-cpp-client >= 0.8-6
-Requires: ruby-qpid-qmf >= 0.8-6
-Requires: qpid-qmf >= 0.8-6
-
-BuildRequires: rubygems
-BuildArch: noarch
-Provides: rubygem(%{gemname}) = %{version}
-
-%description
-QMF Console for Aeolus Image Factory
-
-
-%prep
-
-%build
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}%{gemdir}
-gem install --local --install-dir %{buildroot}%{gemdir} \
- --force --rdoc %{SOURCE0}
-
-%clean
-rm -rf %{buildroot}
-
-%files
-%defattr(-, root, root, -)
-%{gemdir}/gems/%{gemname}-%{version}/
-%doc %{gemdir}/doc/%{gemname}-%{version}
-%{gemdir}/cache/%{gemname}-%{version}.gem
-%{gemdir}/specifications/%{gemname}-%{version}.gemspec
-
-
-%changelog
-* Thu Jun 16 2011 <jguiditt(a)redhat.com> - 0.4.0-1
-- Add support for push, build and import methods
-* Thu Mar 10 2011 <morazi(a)redhat.com> - 0.2.0-1
-- Initial package
diff --git a/services/image_factory/console/spec/image_factory/console_spec.rb b/services/image_factory/console/spec/image_factory/console_spec.rb
deleted file mode 100644
index a575135..0000000
--- a/services/image_factory/console/spec/image_factory/console_spec.rb
+++ /dev/null
@@ -1,217 +0,0 @@
-require 'spec_helper'
-
-module ImageFactory
- describe ImageFactoryConsole do
- context "needs a real agent running" do
- # for now, these all require an actual agent on the bus
- before(:all) do
- @logger = Logger.new(STDOUT)
- @logger.level = Logger::DEBUG
- @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
- @i = ImageFactoryConsole.new() # Pass this in for more logging: (:logger => @logger)
- @i.start
- # Sadly, this is needed so we wait for an agent to appear.
- # We might be able to extract this somewhere to hold off
- # on tests until we get an agent_added notification
- sleep(5)
- #TODO: take this snippet and make a fixture of some sort to use in tests
- #tmpl = '<template> <name>tmpl1</name> <description>foo</description> <os> <name>Fedora</name>
- # <arch>x86_64</arch> <version>14</version> <install type="url">
- # <url>http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fedora/x86...</url> </install>
- # </os> <repositories> <repository name="custom"> <url>http://repos.fedorapeople.org/repos/aeolus/demo/webapp/</url>
- # <signed>false</signed> </repository> </repositories> </template>'
- end
-
- describe "#q" do
- it "should get an agent set" do
- @i.q.should_not be_nil
- end
- end
-
- describe "#build_image" do
- it "should return a build-adaptor with uuid" do
- @i.build_image("<template></template>", "mock").image_id.should_not be_nil
- end
- end
-
- describe "#push_image" do
- it "should return a build-adaptor with uuid" do
- @image = @i.build_image("<template></template>", "mock")
- #(a)i.handler = BaseHandler.new(@logger)
- @i.handler.should_not_receive(:handle_failed)
- @i.push_image((a)image.image_id, "mock", "some creds").image_id.should_not be_nil
- end
- end
-
- describe "#import_image" do
- it "should return a build-adaptor with uuid" do
- @import = @i.import_image("", "", "ami-test", "<image><name>Test Image</name></image>", "ec2", "ec2-us-east-1")
- is_uuid?(@import['image']).should == true
- is_uuid?(@import['target_image']).should == true
- is_uuid?(@import['build']).should == true
- is_uuid?(@import['provider_image']).should == true
- end
- end
-
- describe "#build" do
- it "should return an array of build-adaptors with uuids" do
- @i.build("<template></template>", ["mock"]).each do |adaptor|
- adaptor.image_id.should_not be_nil
- adaptor.image.should_not be_nil
- adaptor.build.should_not be_nil
- end
- end
-
- it "should work with single target as string" do
- @i.build("<template></template>", "mock").each do |adaptor|
- adaptor.image_id.should_not be_nil
- adaptor.image.should_not be_nil
- adaptor.build.should_not be_nil
- end
- end
- end
-
- describe "#push" do
- it "should return an array of build-adaptors with uuids" do
- @i.build("<template></template>", ["mock"]).each do |adaptor|
- #(a)i.handler = BaseHandler.new(@logger)
- @i.handler.should_not_receive(:handle_failed)
- @i.push(["mock"], "<provider_credentials/>", adaptor.image).each do |a|
- a.image_id.should_not be_nil
- a.image.should_not be_nil
- a.build.should_not be_nil
- end
- end
- end
-
- it "should work with single provider as string" do
- @i.build("<template></template>", "mock").each do |adaptor|
- #(a)i.handler = BaseHandler.new(@logger)
- @i.handler.should_not_receive(:handle_failed)
- @i.push("mock1", "<provider_credentials/>", adaptor.image).each do |a|
- a.image_id.should_not be_nil
- a.image.should_not be_nil
- a.build.should_not be_nil
- end
- end
- end
- end
-
- after(:all) do
- @i.shutdown
- end
- end
-
- context "agent is stubbed" do
- before(:each) do
- @agent = mock('agent', :null_object => true)
- @agent.stub(:product).and_return("imagefactory")
- @agent.stub(:name).and_return("redhat.com:imagefactory:b9e131c7-7905-409e-bfb5-dd4848a776a7")
- @output = double('output')
- @i2 = ImageFactoryConsole.new(:logger => @output)
- end
-
- describe "#agent_added" do
- it "logs when a new agent appears" do
- @output.should_receive(:debug).with(/GOT AN AGENT/).as_null_object
- @i2.agent_added(@agent)
- end
-
- it "stores a reference to that agent if it is a factory" do
- @output.should_receive(:debug).with(/GOT AN AGENT/)
- @i2.agent_added(@agent)
- @i2.q.should respond_to(:product)
- end
- end
-
- describe "#agent_deleted" do
- before(:each) do
- @old_agent = mock('agent', :null_object => true)
- @old_agent.stub(:product).and_return("imagefactory")
- @old_agent.stub(:name).and_return("redhat.com:imagefactory:4eb3776e-d91e-4239-9a73-3ab43ecc7e15")
- @output.should_receive(:debug).with(/GOT AN AGENT/)
- @i2.agent_added(@agent)
- end
-
- it "logs when an agent is removed" do
- @output.should_receive(:debug).with(/AGENT GONE/).as_null_object
- @i2.agent_deleted(@agent, "aged")
- end
-
- it "removes the agent reference if removed agent is the same as console reference" do
- @output.should_receive(:debug).with(/AGENT GONE/).as_null_object
- @i2.agent_deleted(@agent, "aged")
- @i2.q.should be_nil
- end
-
- it "does not remove the agent reference if removed agent is the not same as console reference" do
- @output.should_receive(:debug).with(/AGENT GONE/).as_null_object
- @i2.agent_deleted(@old_agent, "aged")
- @i2.q.should_not be_nil
- end
- end
-
- describe "#event_raised" do
- before(:each) do
- @data = mock('data', :null_object => true)
- @data.stub(:event).and_return("STATUS")
- end
-
- it "should call handle on an event" do
- @output.should_receive(:debug).with(/GOT AN EVENT/)
-
- @i2.handler.should_receive(:handle).once
- @i2.event_raised(@agent, @data, Time.now, "horrid")
- end
- end
-
- describe "#build_image" do
- it "should gracefully handle errors" do
- @output.should_receive(:debug).with(/Encountered error in build_image/)
- @output.should_receive(:warn).with("[DEPRECATION] 'build_image' is deprecated. Please use 'build' instead.")
- @i2.q=nil
- error = @i2.build_image("<template></template>", "mock")
- error.to_s.should include("undefined method")
- end
- end
-
- describe "#push_image" do
- it "should gracefully handle errors" do
- @output.should_receive(:debug).with(/Encountered error in push_image/)
- @output.should_receive(:warn).with("[DEPRECATION] 'push_image' is deprecated. Please use 'push' instead.")
- @i2.q=nil
- error = @i2.push_image(123, "mock", "some creds")
- error.to_s.should include("undefined method")
- end
- end
-
- describe "#build" do
- it "should gracefully handle errors" do
- @output.should_receive(:debug).with(/Encountered error in build_image/)
- @i2.q=nil
- error = @i2.build("<template></template>", "mock")
- error.to_s.should include("undefined method")
- end
- end
-
- describe "#push" do
- it "should gracefully handle errors" do
- @output.should_receive(:debug).with(/Encountered error in push_image/)
- @i2.q=nil
- error = @i2.push(123, "mock", "some creds")
- error.to_s.should include("undefined method")
- end
- end
-
- after(:each) do
- @output.should_receive(:debug).with(/Closing/)
- @i2.shutdown
- end
- end
-
- def is_uuid?(test_string)
- regexp = Regexp.new('^[\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
- regexp.match(test_string) ? true : false
- end
- end
-end
diff --git a/services/image_factory/console/spec/spec_helper.rb b/services/image_factory/console/spec/spec_helper.rb
deleted file mode 100644
index 3772953..0000000
--- a/services/image_factory/console/spec/spec_helper.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
-require 'rubygems'
-require 'imagefactory'
--
1.7.4.4
12 years, 9 months
[PATCH conductor] When deleting a deployment, stop running instances
by Tomas Sedovic
From: Tomas Sedovic <tsedovic(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=721351
If all deployment's instances are either stopped or running, the UI will allow
the deployment to be deleted.
All the running instances will be stopped. Once that's done, the deployment
and all its associated instances will be deleted from the database.
Since we don't have a better way to handle arbitrary Condor callbacks, this
relies on dbomatic to set the instance to 'stopped' and the ImageObserver
'after_save' callback to trigger the deletion.
---
src/app/controllers/deployments_controller.rb | 10 +++++--
src/app/models/deployment.rb | 27 ++++++++++++++++++++
src/app/models/instance_observer.rb | 11 ++++++++
src/config/locales/en.yml | 4 +-
...30_add_scheduled_for_deletion_to_deployments.rb | 10 +++++++
src/features/deployment.feature | 11 +++++++-
src/features/step_definitions/instance_steps.rb | 6 ++++
src/spec/models/deployment_spec.rb | 19 ++++++++++++++
8 files changed, 92 insertions(+), 6 deletions(-)
create mode 100644 src/db/migrate/20110719140430_add_scheduled_for_deletion_to_deployments.rb
diff --git a/src/app/controllers/deployments_controller.rb b/src/app/controllers/deployments_controller.rb
index c10ef01..ee3039e 100644
--- a/src/app/controllers/deployments_controller.rb
+++ b/src/app/controllers/deployments_controller.rb
@@ -166,9 +166,13 @@ class DeploymentsController < ApplicationController
destroyed = []
failed = []
Deployment.find(ids_list).each do |deployment|
- if check_privilege(Privilege::MODIFY, deployment) && deployment.destroyable?
- deployment.destroy
- destroyed << deployment.name
+ if check_privilege(Privilege::MODIFY, deployment)
+ begin
+ deployment.stop_instances_and_destroy!
+ destroyed << deployment.name
+ rescue
+ failed << deployment.name
+ end
else
failed << deployment.name
end
diff --git a/src/app/models/deployment.rb b/src/app/models/deployment.rb
index 49b440a..57b82aa 100644
--- a/src/app/models/deployment.rb
+++ b/src/app/models/deployment.rb
@@ -115,6 +115,33 @@ class Deployment < ActiveRecord::Base
instances.all? {|i| i.destroyable? }
end
+ def stop_instances_and_destroy!
+ if destroyable?
+ destroy
+ return
+ end
+
+ if instances.all? {|i| i.destroyable? or i.state == Instance::STATE_RUNNING}
+ # The deployment will be destroyed from an InstanceObserver callback once
+ # all instances are stopped.
+ self.scheduled_for_deletion = true
+ self.save!
+
+ # stop all deployment's instances
+ instances.each do |instance|
+ break unless instance.state == Instance::STATE_RUNNING
+
+ @task = instance.queue_action(instance.owner, 'stop')
+ unless @task
+ raise ActionError.new("stop cannot be performed on this instance.")
+ end
+ condormatic_instance_stop(@task)
+ end
+ else
+ raise ActionError.new 'all instances must be stopped or running'
+ end
+ end
+
def launch(user)
status = { :errors => {}, :successes => {} }
deployable_xml.assemblies.each do |assembly|
diff --git a/src/app/models/instance_observer.rb b/src/app/models/instance_observer.rb
index 4366b4e..c71454a 100644
--- a/src/app/models/instance_observer.rb
+++ b/src/app/models/instance_observer.rb
@@ -83,6 +83,17 @@ class InstanceObserver < ActiveRecord::Observer
end
end
+ def after_save(instance)
+ if instance.state_changed? and
+ instance.state == Instance::STATE_STOPPED and
+ instance.deployment and
+ instance.deployment.scheduled_for_deletion and
+ instance.deployment.destroyable?
+
+ instance.deployment.destroy
+ end
+ end
+
end
InstanceObserver.instance
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 519fb9a..8e9b61e 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -90,8 +90,8 @@ en:
one: "The deployment %{list} could not be updated."
other: "The deployments %{list} could not be updated."
deleted:
- one: "The deployment %{list} was successfully deleted."
- other: "The deployments %{list} were succesfully deleted."
+ one: "The deployment %{list} was scheduled for deletion."
+ other: "The deployments %{list} were scheduled for deletion."
not_deleted:
one: "The deployment %{list} could not be deleted."
other: "The deployments %{list} could not be deleted."
diff --git a/src/db/migrate/20110719140430_add_scheduled_for_deletion_to_deployments.rb b/src/db/migrate/20110719140430_add_scheduled_for_deletion_to_deployments.rb
new file mode 100644
index 0000000..3d98889
--- /dev/null
+++ b/src/db/migrate/20110719140430_add_scheduled_for_deletion_to_deployments.rb
@@ -0,0 +1,10 @@
+class AddScheduledForDeletionToDeployments < ActiveRecord::Migration
+ def self.up
+ add_column(:deployments, :scheduled_for_deletion,
+ :boolean, :null => false, :default => false)
+ end
+
+ def self.down
+ remove_column :deployments, :scheduled_for_deletion
+ end
+end
diff --git a/src/features/deployment.feature b/src/features/deployment.feature
index b862ab1..bdd9186 100644
--- a/src/features/deployment.feature
+++ b/src/features/deployment.feature
@@ -181,7 +181,16 @@ Feature: Manage Deployments
And I am on the pools page
When I follow "testdeployment"
And I press "Delete"
- Then I should see "The deployment testdeployment was successfully deleted"
+ Then I should see "The deployment testdeployment was scheduled for deletion"
+
+ Scenario: Delete a deployment with running instances
+ Given a deployment "mockdeployment" exists
+ And the deployment "mockdeployment" has an instance named "myinstance"
+ And the instance "myinstance" is in the running state
+ And I am on the pools page
+ When I follow "mockdeployment"
+ And I press "Delete"
+ Then I should see "The deployment mockdeployment was scheduled for deletion"
Scenario: Launch a deployment which is not launchable
Given a pool "mockpool" exists
diff --git a/src/features/step_definitions/instance_steps.rb b/src/features/step_definitions/instance_steps.rb
index a181c62..9a9cb88 100644
--- a/src/features/step_definitions/instance_steps.rb
+++ b/src/features/step_definitions/instance_steps.rb
@@ -18,6 +18,12 @@ Given /^I am viewing the mock instance detail$/ do
visit instance_url(mock_instance)
end
+Given /^the instance "([^"]*)" is in the (\w*) state$/ do |instance, state|
+ instance = Instance.find_by_name(instance)
+ instance.state = state
+ instance.save!
+end
+
When /^I am viewing the pending instance detail$/ do
visit instance_url(pending_instance)
end
diff --git a/src/spec/models/deployment_spec.rb b/src/spec/models/deployment_spec.rb
index e6c423c..13f922c 100644
--- a/src/spec/models/deployment_spec.rb
+++ b/src/spec/models/deployment_spec.rb
@@ -105,4 +105,23 @@ describe Deployment do
@deployment.pool.pool_family.provider_accounts.destroy_all
@deployment.check_assemblies_matches(user).should_not be_empty
end
+
+ it "should be able to stop running instances on deletion" do
+ @deployment.save!
+ inst1 = Factory.create :mock_running_instance, :deployment_id => @deployment.id
+ inst2 = Factory.create :mock_running_instance, :deployment_id => @deployment.id
+
+ @deployment.stop_instances_and_destroy!
+
+ # this emulates Condor stopping the actual instances
+ # and dbomatic reflecting the changes back to Conductor
+ inst1.state = Instance::STATE_STOPPED; inst1.save!
+ inst2.state = Instance::STATE_STOPPED; inst2.save!
+
+
+ # verify that the deployment and all its instances are deleted
+ lambda {Deployment.find((a)deployment.id)}.should raise_error(ActiveRecord::RecordNotFound)
+ lambda {Instance.find(inst1.id)}.should raise_error(ActiveRecord::RecordNotFound)
+ lambda {Instance.find(inst2.id)}.should raise_error(ActiveRecord::RecordNotFound)
+ end
end
--
1.7.4.4
12 years, 9 months
(no subject)
by Mark McLoughlin
Jay, Martyn, Mo and Chris,
I just reviewed the rubygem-aeolus-image[1] RPM and it looks great,
except for one thing - the RPM should be built from a published gem or
tarball which corresponds to a tag in git.
If aeolus-image is to be in the same git repo as conductor (and I don't
think it needs to be), then it should have the same version as
conductor ... otherwise you'll have two git tags per release, which is
weird.
Also, thinking about the rubygem-image_factory_console[2] RPM, I had
some suggestions:
1) Do we really want to push the image_factory_console ruby API as
something that should be consumed by others yet?
To me, it looks like it's in its very early stages and could just
be internal to aeolus-image for now. That would save us worrying
about API changes etc.
2) If we do want it to push it, why not call the gem imagefactory?
That's the upstream name for image factory, and all this is is a
Ruby API for imagefactory. The fact that it's QMF behind the
scenes should be unimportant IMHO.
Thanks,
Mark.
[1] https://bugzilla.redhat.com/721069
[2] https://bugzilla.redhat.com/721066
12 years, 9 months
[PATCH aeolus] BZ#722994 Added Lastest Push field to list images
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
This is added in order to determine if an image has been pushed, and what the last successfully pushed build was
---
.../image_factory/aeolus-image/lib/list_command.rb | 31 +++++++++++++-------
1 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/services/image_factory/aeolus-image/lib/list_command.rb b/services/image_factory/aeolus-image/lib/list_command.rb
index e8a4f67..52f112b 100644
--- a/services/image_factory/aeolus-image/lib/list_command.rb
+++ b/services/image_factory/aeolus-image/lib/list_command.rb
@@ -6,7 +6,7 @@ module Aeolus
end
def images
- images = [["UUID", "NAME", "TARGET", "OS", "OS VERSION", "ARCH", "DESCRIPTION"]]
+ images = [["IMAGE ID", "LASTEST PUSHED BUILD", "NAME", "TARGET", "OS", "OS VERSION", "ARCH", "DESCRIPTION"]]
doc = Nokogiri::XML iwhd['/target_images'].get
# Check for any invalid data in iwhd
invalid_images = []
@@ -14,11 +14,11 @@ module Aeolus
begin
build = iwhd["/target_images/" + targetimage.text + "/build"].get
image = iwhd["/builds/" + build + "/image"].get
- template_info = get_template_info(image, targetimage.text)
- if template_info
- images << template_info
+
+ if template_info = get_template_info(image, targetimage.text)
+ images << [image] + [lastest_pushed(image)] + template_info
else
- images << [image, get_image_name(image), iwhd["/target_images/" + targetimage + "/target"].get, "", "", "", ""]
+ images << [image] + [lastest_pushed(image)] +[get_image_name(image), iwhd["/target_images/" + targetimage + "/target"].get, "", "", "", ""]
end
rescue
invalid_images << targetimage.text
@@ -109,12 +109,12 @@ module Aeolus
def get_template_info(image, targetimage)
begin
template = Nokogiri::XML iwhd["/templates/" + iwhd["/target_images/" + targetimage + "/template"].get].get
- [image, template.xpath("/template/name").text,
- iwhd["/target_images/" + targetimage + "/target"].get,
- template.xpath("/template/os/name").text,
- template.xpath("/template/os/version").text,
- template.xpath("/template/os/arch").text,
- template.xpath("/template/description").text]
+ [template.xpath("/template/name").text,
+ iwhd["/target_images/" + targetimage + "/target"].get,
+ template.xpath("/template/os/name").text,
+ template.xpath("/template/os/version").text,
+ template.xpath("/template/os/arch").text,
+ template.xpath("/template/description").text]
rescue
end
end
@@ -127,6 +127,15 @@ module Aeolus
""
end
end
+
+ def lastest_pushed(image)
+ begin
+ build = iwhd["/images/" + image + "/latest_build"].get
+ build.nil? ? "" : build
+ rescue
+ ""
+ end
+ end
end
end
end
--
1.7.4
12 years, 9 months