BZ #761160 - Don't offer to build/push imported images
by Matt Wagner
Hi all,
I'm sending two rounds of patches, one for aeolus-image-rubygem and one
for Conductor. They address an issue raised in
https://bugzilla.redhat.com/show_bug.cgi?id=761160 -- specifically, we
prompt users to build and push imported images, when this is, by
definition, not possible. (An imported image is just a pointer to an
image that already exists in a cloud.)
The problem is that we really had no means of knowing if an image is
imported or not. With these patches, we will detect whether an Image has
a template, and if does not, we will consider it imported.
(img.imported? == true). In that case, we hide the irrelevant controls.
This depends on a patch sloranz has to prevent Image Factory from
writing an empty template on import; it's an open pull request[1] but
you can pull the branch and test against it.
This patch should get us something useful, and should probably be
reviewed and committed by itself. But before I consider #761160
satisfactorily resolved, I'd like to fix a few more things:
* The image detail page shouldn't show providers for which the imported
image is not built or pushed. Since you cannot built for or push to
them, showing them serves no purpose and rather confusing. (None of
this applies to the non-imported use case, of course.) This seems to
be slightly more involved than I expected so I'm not doing it just
yet. This makes me wonder if we should just show a totally different
page in this case.
* The API image import code is similar-but-different. When I wrote my
web import script the two methods were just too different for it to
make sense to combine, but I'd like to go back and make them both
share the Image.import method. Mostly because:
* To unambiguously find a provider image, we really want to know the
provider _account_. This wasn't being set on image import. After
talking a bit with the Image Factory folks, we decided that it really
didn't make sense to pass this parameter to Factory to have it set it
in Warehouse, when Factory didn't care about this information in the
slightest. Ergo I set the attribute directly if we have it. But
currently, we don't even prompt for it in the web UI or on the command
line. I think we might want to, but I'd like to bounce this idea off
of someone -- does it make sense that ProviderImages should be tied to
a specific provider account as opposed to a provider?
As a tangent, I put together a little documentation about the Image
'family' of models as are stored in iwhd, since some of it was unclear
to me previously. It's based on what I discovered as I went, not
something written by an architect of the original idea, so it's not
necessarily 100% complete.
Whew, sorry for the long email.
-- Matt
[1] https://github.com/aeolusproject/imagefactory/pull/51
[2]
https://www.aeolusproject.org/redmine/projects/aeolus/wiki/Image_Models
12 years, 5 months
[PATCH aeolus-configure] BZ #761447: aeolus-configure-image returns (LoadError).
by Jason Guiditta
https://bugzilla.redhat.com/show_bug.cgi?id=761447
Looking into this bug revealed so many issues, that it makes
the most sense to just nuke this script for now. We can re-add
something with similar functionality (once some interaction
issues with factory are resolved) in the cli project, where it
belongs, at some point.
---
bin/aeolus-configure-image | 69 -----------------------------------------
contrib/aeolus-configure.spec | 2 -
2 files changed, 0 insertions(+), 71 deletions(-)
delete mode 100755 bin/aeolus-configure-image
diff --git a/bin/aeolus-configure-image b/bin/aeolus-configure-image
deleted file mode 100755
index 66a8b54..0000000
--- a/bin/aeolus-configure-image
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/ruby
-# helper script to generate aeolus images
-
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'fileutils'
-
-AEOLUS_IMAGE_VERSION='0.1.0'
-
-image_name = ARGV[0]
-target = ARGV[1]
-template = ARGV[2]
-provider = ARGV[3]
-hwp = ARGV[4]
-
-Dir.chdir "/etc/aeolus-configure"
-
-cmd = "/usr/bin/ruby -rrubygems \
- /usr/lib/ruby/gems/1.8/gems/aeolus-image-#{AEOLUS_IMAGE_VERSION}/bin/aeolus-image build \
- --target #{target} --template #{template}"
-puts "Building image for #{target} using #{template}"
-#puts " Running build command #{cmd}"
-out = `#{cmd}`
-puts "Image build returned w/ exit code #{$?}"
-puts "Image build output: #{out}"
-
-if out =~ /^\s*Image:\s*([0-9a-zA-Z\-]*).*/
- image = $1
- cmd = "/usr/bin/ruby -rrubygems \
- /usr/lib/ruby/gems/1.8/gems/aeolus-image-#{AEOLUS_IMAGE_VERSION}/bin/aeolus-image push \
- --provider #{provider} --id #{image}"
-
- puts "Image #{image} built, pushing to #{provider}"
- #puts "Running push command #{cmd}"
- out = `#{cmd}`
-
- puts "Image push returned w/ exit code #{$?}"
- puts "Image push output: #{out}"
-
- # delay to allow the ec2 image to be uploaded
- sleep 900 if target == "ec2" || target == "rackspace"
-
- deployables_dir = '/var/www/html/deployables'
- FileUtils.mkdir deployables_dir unless File.exist? deployables_dir
- File.open("/var/www/html/deployables/#{image_name}.xml", "w") { |f|
- f.write "<deployable name='#{image_name}'>\n" +
- " <assemblies name = '#{image_name}'>\n" +
- " <assembly name='#{image_name}' hwp='#{hwp}' >\n" +
- " <image id='#{image}'></image>\n" +
- " </assembly>\n" +
- " </assemblies>\n" +
- "</deployable>\n"
- }
-
- puts "Deployment definition written"
- puts "Image building complete"
-end
diff --git a/contrib/aeolus-configure.spec b/contrib/aeolus-configure.spec
index 93fd0e1..b063410 100644
--- a/contrib/aeolus-configure.spec
+++ b/contrib/aeolus-configure.spec
@@ -49,7 +49,6 @@ Aeolus Configure Puppet Recipe
%{__cp} -R %{pbuild}/bin/aeolus-node %{buildroot}/%{aeolushome}/modules/aeolus/
%{__cp} -R %{pbuild}/bin/aeolus-check-services %{buildroot}/%{_bindir}/
%{__cp} -R %{pbuild}/bin/aeolus-restart-services %{buildroot}/%{_sbindir}/
-%{__cp} -R %{pbuild}/bin/aeolus-configure-image %{buildroot}/%{_sbindir}/
%{__cp} -R %{pbuild}/bin/aeolus-configure %{buildroot}/%{_sbindir}/
%{__cp} -R %{pbuild}/bin/aeolus-cleanup %{buildroot}/%{_sbindir}/
@@ -61,7 +60,6 @@ Aeolus Configure Puppet Recipe
%attr(0755, root, root) %{_bindir}/aeolus-check-services
%attr(0755, root, root) %{_sbindir}/aeolus-restart-services
%{aeolushome}
-%{_sbindir}/aeolus-configure-image
%changelog
* Thu Dec 1 2011 Steve Linabery <slinaber(a)redhat.com> - 2.4.0-1
--
1.7.7.3
12 years, 5 months
[PATCH conductor] BUG-2751 - Delete instance on provider side when deleted in conductor
by Tomas Hrcka
---
src/app/models/instance.rb | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index 738da87..279e1a7 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -129,7 +129,7 @@ class Instance < ActiveRecord::Base
validate :pool_and_account_enabled_validation, :on => :create
before_destroy :destroyable?
-
+ before_destroy :destroy_on_provider
# A user should only be able to update certain attributes, but the API may permit other attributes to be
# changed if called from another Aeolus component, so attr_protected isn't quite what we want:
USER_MUTABLE_ATTRS = ['name']
@@ -482,6 +482,18 @@ class Instance < ActiveRecord::Base
{:title => I18n.t("instances.preset_filters.pending"), :id => "pending", :query => where("instances.state" => "pending")}
]
+ def destroy_on_provider
+ begin
+ @task = self.queue_action(self.owner, 'destroy')
+ unless @task
+ raise ActionError.new("destroy cannot be performed on this instance.")
+ end
+ Taskomatic.destroy_instance(@task)
+ rescue Exception => e
+ retry if self.tasks.last.action != 'destroy'
+ end
+ end
+
private
def self.apply_search_filter(search)
--
1.7.6.4
12 years, 5 months
[PATCH conductor] rootpw param in template XML changed is now required
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=761139
---
src/app/util/template-rng.xml | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/app/util/template-rng.xml b/src/app/util/template-rng.xml
index 07eb627..ada49e4 100644
--- a/src/app/util/template-rng.xml
+++ b/src/app/util/template-rng.xml
@@ -36,11 +36,9 @@
<ref name='iso'/>
</choice>
</element>
- <optional>
- <element name='rootpw'>
- <text/>
- </element>
- </optional>
+ <element name='rootpw'>
+ <text/>
+ </element>
<optional>
<element name='key'>
<text/>
--
1.7.6
12 years, 5 months
[PATCH conductor] Added warning if rootpw is missing in template XML
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=761139
---
src/app/controllers/images_controller.rb | 23 +++++++++++++++++++----
src/app/models/template_xml.rb | 6 +++++-
src/config/locales/en.yml | 1 +
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/src/app/controllers/images_controller.rb b/src/app/controllers/images_controller.rb
index a178596..123b8a2 100644
--- a/src/app/controllers/images_controller.rb
+++ b/src/app/controllers/images_controller.rb
@@ -113,12 +113,16 @@ class ImagesController < ApplicationController
begin
doc = TemplateXML.new(xml_source)
- rescue Nokogiri::XML::SyntaxError
- errors = [t('template_xml.errors.xml_parse_error')]
- else
doc.name = @name
@xml = doc.to_xml
errors = doc.validate
+ # check explicitly if rootpw is set or not,
+ # imagefactory requires this param for some
+ # target/platform combinations
+ # https://bugzilla.redhat.com/show_bug.cgi?id=761139
+ flash.now[:warning] = I18n.t('images.flash.warning.no_rootpw') if doc.rootpw.blank?
+ rescue Nokogiri::XML::SyntaxError
+ errors = [t('template_xml.errors.xml_parse_error')]
end
if errors.any?
@@ -134,7 +138,18 @@ class ImagesController < ApplicationController
@name = params[:name]
@xml = params[:image_xml]
- errors = TemplateXML.validate(@xml)
+ begin
+ doc = TemplateXML.new(@xml)
+ errors = doc.validate
+ # check explicitly if rootpw is set or not,
+ # imagefactory requires this param for some
+ # target/platform combinations
+ # https://bugzilla.redhat.com/show_bug.cgi?id=761139
+ flash.now[:warning] = I18n.t('images.flash.warning.no_rootpw') if doc.rootpw.blank?
+ rescue Nokogiri::XML::SyntaxError
+ errors = [t('template_xml.errors.xml_parse_error')]
+ end
+
if errors.any?
flash.now[:error] = errors
render :edit_xml and return
diff --git a/src/app/models/template_xml.rb b/src/app/models/template_xml.rb
index 149c9c5..8a2aa4c 100644
--- a/src/app/models/template_xml.rb
+++ b/src/app/models/template_xml.rb
@@ -57,7 +57,11 @@ class TemplateXML
end
def name
- doc.xpath('/template/name').text
+ @xml.xpath('/template/name').text
+ end
+
+ def rootpw
+ @xml.xpath('/template/os/rootpw').text
end
def to_xml
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 4dab401..602e766 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -727,6 +727,7 @@ en:
warning:
delete_failed: Unable to Delete Image
not_found: Image not found
+ no_rootpw: "Template has no rootpw parameter, build will fail for some targets."
error:
invalid_url: Could not load the provided URL
new:
--
1.7.6
12 years, 5 months
[PATCH conductor] Use names correctly on template upload
by Tomas Sedovic
From: Tomas Sedovic <tomas(a)sedovic.cz>
https://bugzilla.redhat.com/show_bug.cgi?id=761218
When a template name wasn't specified in the UI but was in the uploaded
template, we still weren't showing it on the Overview screen.
---
src/app/controllers/images_controller.rb | 24 +++++++-----------------
src/app/models/template_xml.rb | 5 +++--
2 files changed, 10 insertions(+), 19 deletions(-)
diff --git a/src/app/controllers/images_controller.rb b/src/app/controllers/images_controller.rb
index a178596..66acd6d 100644
--- a/src/app/controllers/images_controller.rb
+++ b/src/app/controllers/images_controller.rb
@@ -102,7 +102,7 @@ class ImagesController < ApplicationController
url = params[:image_url]
begin
xml_source = RestClient.get(url, :accept => :xml)
- rescue RestClient::Exception, SocketError, URI::InvalidURIError
+ rescue RestClient::Exception, SocketError, URI::InvalidURIError, Errno::ECONNREFUSED
flash.now[:error] = t('images.flash.error.invalid_url')
render :new and return
end
@@ -116,7 +116,8 @@ class ImagesController < ApplicationController
rescue Nokogiri::XML::SyntaxError
errors = [t('template_xml.errors.xml_parse_error')]
else
- doc.name = @name
+ doc.name = @name unless @name.blank?
+ @name = doc.name
@xml = doc.to_xml
errors = doc.validate
end
@@ -134,10 +135,13 @@ class ImagesController < ApplicationController
@name = params[:name]
@xml = params[:image_xml]
- errors = TemplateXML.validate(@xml)
+ doc = TemplateXML.new(@xml)
+ errors = doc.validate
if errors.any?
flash.now[:error] = errors
render :edit_xml and return
+ else
+ @name = doc.name
end
end
@@ -205,20 +209,6 @@ class ImagesController < ApplicationController
end
protected
- def add_template_name(doc, name)
- return unless doc
-
- if doc.root.nil? || doc.root.name != 'template'
- doc.root = doc.create_element('template')
- end
-
- if doc.xpath('/template/name').empty?
- doc.xpath('/template').first << doc.create_element('name')
- end
-
- doc.xpath('/template/name').first.content = name unless name.blank?
- end
-
def load_target_images(build)
@target_images_by_target = {}
return unless build
diff --git a/src/app/models/template_xml.rb b/src/app/models/template_xml.rb
index 149c9c5..323b4e0 100644
--- a/src/app/models/template_xml.rb
+++ b/src/app/models/template_xml.rb
@@ -53,11 +53,12 @@ class TemplateXML
@xml.xpath('/template').first << @xml.create_element('name')
end
- @xml.xpath('/template/name').first.content = name unless name.blank?
+ name ||= ""
+ @xml.xpath('/template/name').first.content = name
end
def name
- doc.xpath('/template/name').text
+ @xml.xpath('/template/name').text
end
def to_xml
--
1.7.6.4
12 years, 5 months
Background Jobs in conductor
by Tomas Hrcka
Hi all,
the time has come, and we need to somehow implement background jobs. I
am curently working on task which involve long run operations on
provider side(ie. stop and delete). So I can make the UI not responding
for 2-4 mins, but that is not what we want.
Question is what will we use for performing background jobs. On
ruby-toolbox.com [1] is overview of ruby projects for background jobs.
Or we can implement our own solution.
[1] - https://www.ruby-toolbox.com/categories/Background_Jobs
12 years, 5 months
[PATCH 2/2] WarehouseModel objects now implement a set_attr instance method.
by Matt Wagner
This was previously available only on bucket objects.
A bucket_object method is provided to access @obj.
---
.../model/warehouse/warehouse_model.rb | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/lib/aeolus_image/model/warehouse/warehouse_model.rb b/lib/aeolus_image/model/warehouse/warehouse_model.rb
index ab2498e..dae77f8 100644
--- a/lib/aeolus_image/model/warehouse/warehouse_model.rb
+++ b/lib/aeolus_image/model/warehouse/warehouse_model.rb
@@ -52,6 +52,19 @@ module Aeolus
uuid
end
+ # Returns the bucket object represending this object
+ def bucket_object
+ @obj
+ end
+
+ # Set (and immediately update) an attribute on the object
+ # TODO: It might be nicer to offer a .save! that iterates over each attribute
+ # and calls this, to better match ActiveResource
+ def set_attr(key, value)
+ bucket_object.set_attr(key, value)
+ end
+
+
class << self
attr_accessor :warehouse, :bucket, :bucket_name
--
1.7.6.4
12 years, 5 months