[PATCH conductor] Make 2 deployables specs i18n-compatible
by Tomas Sedovic
From: Tomas Sedovic <tomas(a)sedovic.cz>
---
.../controllers/deployables_controller_spec.rb | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/spec/controllers/deployables_controller_spec.rb b/src/spec/controllers/deployables_controller_spec.rb
index 16d7e82..65583cb 100644
--- a/src/spec/controllers/deployables_controller_spec.rb
+++ b/src/spec/controllers/deployables_controller_spec.rb
@@ -35,13 +35,13 @@ describe DeployablesController do
it "returns flash[:error] when no hardware profile exists" do
get :new, :create_from_image => @image.id
- flash[:error].should eql(["No hardware profile exists! Please create one."])
+ flash[:error].should_not be_empty
end
it "returns flash[:error] when no catalog and hardware profile exists" do
Catalog.stub(:list_for_user).and_return([])
get :new, :create_from_image => @image.id
- flash[:error].should eql(["No catalog exists! Please create one.","No hardware profile exists! Please create one."])
+ flash[:error].should_not be_empty
end
it "returns flash[:error] when no catalog exists" do
--
1.7.6.5
12 years, 3 months
[PATCH aeolus-image-rubygem] RFC - lazy warehouse attributes loading
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
this patch is not supposed to be pushed, it's just an experimental
version. As I mentioned in some mails before, I think that one bottle
neck of warehouse lib is autoloading of all object attributes when getting
a warehouse object. The idea of this patch is to load attributes on demand.
Second optimization is skipping of uuid attribute loading -
uuid is used as a key when saving an object in buckets, IOW
key == uuid, e.g.:
$ curl http://localhost:9090/builds/7c5d70ff-b998-4bb1-8c9a-b8cf3d5dd2a2/uuid
7c5d70ff-b998-4bb1-8c9a-b8cf3d5dd2a2
Generally it's possible to have key != uuid from warehouse point of view,
but both imagefactory and conductor use uuid as key, so this optimization
can be used now.
Here are some numbers (times are from firebug, client side), measured on a
deployable with 25 identical images:
before patch:
deployable show page: 19s (1600 requests)
launch deployment: 51s (2300 requests)
image show page: 4.5s (47 requests) (1 provider image)
image index page: 6.3s (122 requests) (5 images)
lazyload + uuid (deployable show page):
deployable show page: 10s (750 requests)
launch deployment: 43s (1125 requests)
image show page: 3.5s (19 requests) (1 provider image)
image index page: 5.5s (78 requests) (5 images)
(Honestly I expected better improvement).
Do we want to get this in for 1.0 release? (For single image deployments there
won't be big difference).
---
lib/aeolus_image/model/warehouse/icicle.rb | 2 +-
lib/aeolus_image/model/warehouse/image.rb | 12 +++++-----
lib/aeolus_image/model/warehouse/image_build.rb | 6 ++--
lib/aeolus_image/model/warehouse/provider_image.rb | 6 ++--
lib/aeolus_image/model/warehouse/target_image.rb | 10 ++++----
.../model/warehouse/warehouse_model.rb | 24 ++++++++++++++++---
6 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/lib/aeolus_image/model/warehouse/icicle.rb b/lib/aeolus_image/model/warehouse/icicle.rb
index 1a11da8..a1cfa96 100644
--- a/lib/aeolus_image/model/warehouse/icicle.rb
+++ b/lib/aeolus_image/model/warehouse/icicle.rb
@@ -43,7 +43,7 @@ module Aeolus
def get_icicle
unless @icicle_xml
- icicle = Icicle.bucket.objects.find(@uuid) if @uuid
+ icicle = Icicle.bucket.objects.find(uuid) if uuid
begin
@icicle_xml = Nokogiri::XML icicle.first.body
rescue
diff --git a/lib/aeolus_image/model/warehouse/image.rb b/lib/aeolus_image/model/warehouse/image.rb
index 7a06f0e..c48ae20 100644
--- a/lib/aeolus_image/model/warehouse/image.rb
+++ b/lib/aeolus_image/model/warehouse/image.rb
@@ -43,12 +43,12 @@ module Aeolus
end
def latest_pushed_build
- ImageBuild.find(@latest_build) if @latest_build
+ ImageBuild.find(latest_build) if respond_to?(:latest_build)
end
def latest_pushed_or_unpushed_build
- build = @latest_build ? ImageBuild.find(@latest_build) : nil
- push = @latest_unpushed ? ImageBuild.find(@latest_unpushed) : nil
+ build = respond_to?(:latest_build) ? ImageBuild.find(latest_build) : nil
+ push = respond_to?(:latest_unpushed) ? ImageBuild.find(latest_unpushed) : nil
if build and push
return push.timestamp > build.timestamp ? push : build
end
@@ -56,7 +56,7 @@ module Aeolus
end
def image_builds
- ImageBuild.where("($image == \"" + @uuid.to_s + "\")")
+ ImageBuild.where("($image == \"" + uuid.to_s + "\")")
end
# Return all Provider Images associated with this Image
@@ -101,12 +101,12 @@ module Aeolus
end
rescue NoMethodError
end
- Image.delete(@uuid)
+ Image.delete(uuid)
end
# No template is created on imported images
def imported?
- !@template
+ !respond_to?(:template)
end
# template_xml.xpath(PATH).text => template_xpath(PATH)
diff --git a/lib/aeolus_image/model/warehouse/image_build.rb b/lib/aeolus_image/model/warehouse/image_build.rb
index 5b9f7d4..8f5dcf5 100644
--- a/lib/aeolus_image/model/warehouse/image_build.rb
+++ b/lib/aeolus_image/model/warehouse/image_build.rb
@@ -19,11 +19,11 @@ module Aeolus
@bucket_name = 'builds'
def image
- Image.find(@image) if @image
+ Image.find(_image) if respond_to?(:_image)
end
def target_images
- TargetImage.where("($build == \"" + @uuid.to_s + "\")")
+ TargetImage.where("($build == \"" + uuid.to_s + "\")")
end
# Convenience Method to get all provider images for this build
@@ -52,7 +52,7 @@ module Aeolus
end
rescue NoMethodError
end
- ImageBuild.delete(@uuid)
+ ImageBuild.delete(uuid)
end
end
end
diff --git a/lib/aeolus_image/model/warehouse/provider_image.rb b/lib/aeolus_image/model/warehouse/provider_image.rb
index 6a65ab7..83c7a2f 100644
--- a/lib/aeolus_image/model/warehouse/provider_image.rb
+++ b/lib/aeolus_image/model/warehouse/provider_image.rb
@@ -19,16 +19,16 @@ module Aeolus
@bucket_name = 'provider_images'
def target_image
- TargetImage.find(@target_image) if @target_image
+ TargetImage.find(target_image) if respond_to?(:target_image)
end
def provider_name
- @provider
+ provider
end
# Deletes this provider image
def delete!
- ProviderImage.delete(@uuid)
+ ProviderImage.delete(uuid)
end
end
end
diff --git a/lib/aeolus_image/model/warehouse/target_image.rb b/lib/aeolus_image/model/warehouse/target_image.rb
index 5e6b84c..e3e88af 100644
--- a/lib/aeolus_image/model/warehouse/target_image.rb
+++ b/lib/aeolus_image/model/warehouse/target_image.rb
@@ -19,15 +19,15 @@ module Aeolus
@bucket_name = 'target_images'
def build
- ImageBuild.find(@build) if @build
+ ImageBuild.find(_build) if respond_to?(:_build)
end
def provider_images
- ProviderImage.where("($target_image == \"" + @uuid.to_s + "\")")
+ ProviderImage.where("($target_image == \"" + uuid.to_s + "\")")
end
def target_template
- Template.find(@template) if @template
+ Template.find(template) if respond_to?(:template)
end
# Deletes this targetimage and all child objects
@@ -38,11 +38,11 @@ module Aeolus
end
rescue NoMethodError
end
- TargetImage.delete(@uuid)
+ TargetImage.delete(uuid)
end
def find_provider_image_by_provider_and_account(provider, provider_account)
- conditions = ["$target_image == \"#{@uuid}\""]
+ conditions = ["$target_image == \"#{uuid}\""]
conditions << "$provider == \"#{provider}\"" if provider
conditions << "$provider_account_identifier == \"#{provider_account}\"" if provider_account
ProviderImage.where('(' + conditions.join(' && ') + ')')
diff --git a/lib/aeolus_image/model/warehouse/warehouse_model.rb b/lib/aeolus_image/model/warehouse/warehouse_model.rb
index dd494d6..ca53fa4 100644
--- a/lib/aeolus_image/model/warehouse/warehouse_model.rb
+++ b/lib/aeolus_image/model/warehouse/warehouse_model.rb
@@ -20,14 +20,30 @@ module Aeolus
class WarehouseModel
attr_writer :body
+ attr_reader :obj
+ attr_accessor :uuid
def initialize(obj)
@obj = obj
- @attrs = obj.attrs(obj.attr_list)
- @attrs.each do |k,v|
+ @uuid = @obj.key
+ @attr_list = obj.attr_list
+ @attr_list.each do |k|
self.class.send(:attr_writer, k.to_sym) unless respond_to?(:"#{k}=")
- self.class.send(:attr_reader, k.to_sym) unless respond_to?(k.to_sym)
- send(:"#{k}=", v)
+ lazy_attr_reader(k)
+ end
+ end
+
+ def lazy_attr_reader(orig_attr)
+ attr = respond_to?(orig_attr.to_sym) ? "_#{orig_attr}" : orig_attr
+ # TODO: security - restrict attr names
+ attr_sym = "@#{attr}".to_sym
+ (class << self; self; end).class_eval do
+ define_method attr do
+ unless instance_variable_defined?(attr_sym)
+ instance_variable_set(attr_sym, @obj.attr(orig_attr))
+ end
+ instance_variable_get(attr_sym)
+ end
end
end
--
1.7.7.5
12 years, 3 months
[PATCH conductor 0/1] #788114 - Unable to add realm
by Matt Wagner
This patch fixes https://bugzilla.redhat.com/show_bug.cgi?id=788114 which prevented the addition of new realms. What was actually happening, per the stack trace, is that Provider#populate_realms had become a protected method, in what seems like a merge conflict.
The diff in the patch is hugely misleading. What I actually did was move the populate_realms method above the 'protected' line, which git diff thought should be represented by showing the impact on a wholly unrelated method nearby.
-- Matt
12 years, 3 months
[PATCH conductor] Fixed non i18n string in catalogs#new/edit form.
by jzigmund@redhat.com
From: Jozef Zigmund <jzigmund(a)redhat.com>
---
src/app/views/catalogs/_form.html.haml | 2 +-
src/config/locales/en.yml | 2 ++
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/app/views/catalogs/_form.html.haml b/src/app/views/catalogs/_form.html.haml
index a1f91e7..34122d6 100644
--- a/src/app/views/catalogs/_form.html.haml
+++ b/src/app/views/catalogs/_form.html.haml
@@ -6,7 +6,7 @@
= form.text_field :name, :class => 'em long'
%p
= form.label :pool_id, t('pools.pool')
- = form.select(:pool_id, @pools.collect{|p| [p.name, p.id]}, :prompt => "Select pool")
+ = form.select(:pool_id, @pools.collect{|p| [p.name, p.id]}, :prompt => t("catalogs.form.select_pool"))
%fieldset.options
= link_to t('cancel'), catalogs_path, :class => 'button danger'
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 7b809fb..048047b 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -669,6 +669,8 @@ en:
edit:
edit_catalog: Editing Catalog
cancel_editing: Cancel Editing
+ form:
+ select_pool: Select Pool
flash:
notice:
updated:
--
1.7.7.6
12 years, 3 months
[PATCH conductor] BZ#785223 Limit export instances scope
by Tomas Sedovic
From: Tomas Sedovic <tomas(a)sedovic.cz>
https://bugzilla.redhat.com/show_bug.cgi?id=785223
When exporting instances from the Deployments Details page, only the instances
belonging to that deployment should be included in the CSV.
---
src/app/views/instances/_list.html.haml | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/app/views/instances/_list.html.haml b/src/app/views/instances/_list.html.haml
index e120e68..675efc2 100644
--- a/src/app/views/instances/_list.html.haml
+++ b/src/app/views/instances/_list.html.haml
@@ -1,5 +1,5 @@
- content_for :form_header do
- %li= link_to "#{t'instances.list.export_events'}", export_events_instances_path, :class => 'button'
+ %li= link_to "#{t'instances.list.export_events'}", export_events_instances_path(:deployment_id => @deployment), :class => 'button'
%li= restful_submit_tag "#{t'instances.list.stop_selected_instances'}", 'stop', multi_stop_instances_path, 'GET', :class => 'button', :id => 'stop_selected_instances'
%li= restful_submit_tag "#{t'instances.list.reboot_selected_instances'}", 'reboot', multi_reboot_instances_path, 'GET', :class => 'button', :id => 'reboot_selected_instances'
= hidden_field_tag 'backlink', request.url
--
1.7.6.5
12 years, 3 months
[PATCH conductor] BZ#770902 - Deployment creation with blank entries displays The record you tried to access does not exists, it may have been deleted
by Tomas Hrcka
---
src/app/controllers/deployments_controller.rb | 5 +++++
src/app/views/deployments/_launch_new.html.haml | 2 +-
src/config/locales/en.yml | 1 +
3 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/app/controllers/deployments_controller.rb b/src/app/controllers/deployments_controller.rb
index a03ea4d..3fb128e 100644
--- a/src/app/controllers/deployments_controller.rb
+++ b/src/app/controllers/deployments_controller.rb
@@ -56,6 +56,11 @@ class DeploymentsController < ApplicationController
def launch_time_params
+ unless params.has_key?(:deployable_id)
+ flash[:error] = t('deployments.flash.warning.deployable_not_selected')
+ redirect_to launch_new_deployments_path(:pool_id => params[:deployment][:pool_id]) and return
+ end
+
@deployable = Deployable.find(params[:deployable_id])
@deployment = Deployment.new(params[:deployment])
@pool = @deployment.pool
diff --git a/src/app/views/deployments/_launch_new.html.haml b/src/app/views/deployments/_launch_new.html.haml
index d8e62f5..6403f76 100644
--- a/src/app/views/deployments/_launch_new.html.haml
+++ b/src/app/views/deployments/_launch_new.html.haml
@@ -37,7 +37,7 @@
%p
%label{:for => 'frontend_realm_id'}
= t('realms.index.realm')
- = select :deployment, :frontend_realm_id, @realms.map{|r| [r.name, r.id]}, :include_blank => true
+ = select :deployment, :frontend_realm_id, @realms.map{|r| [r.name, r.id]}
%fieldset.options
= submit_tag t('.next'), :class => 'button', :id => "next_button"
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index ad5f784..330ddda 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -247,6 +247,7 @@ en:
warning:
disabled_pool: "Cannot launch a Deployment in this Pool. The pool has been disabled."
failed_to_launch: "Deployment launch failed!"
+ deployable_not_selected: "You need to select deployable"
error:
not_launched: "Some assemblies will not be launched:"
failed_to_launch_assemblies: "Failed to launch following assemblies:"
--
1.7.7.5
12 years, 3 months
[PATCH aeolus-conductor] BZ#753880 Catch exceptions on DC valid credentials request
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
src/app/models/provider_account.rb | 8 ++++++--
src/spec/models/provider_account_spec.rb | 8 ++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/app/models/provider_account.rb b/src/app/models/provider_account.rb
index 89009aa..af107de 100644
--- a/src/app/models/provider_account.rb
+++ b/src/app/models/provider_account.rb
@@ -86,8 +86,12 @@ class ProviderAccount < ActiveRecord::Base
end
def validate_credentials
- unless valid_credentials?
- errors.add(:base, "Login Credentials are Invalid for this Provider")
+ begin
+ unless valid_credentials?
+ errors.add(:base, "Login Credentials are Invalid for this Provider")
+ end
+ rescue
+ errors.add(:base, "An error occured when checking provider credentials please check your setup and try again")
end
end
diff --git a/src/spec/models/provider_account_spec.rb b/src/spec/models/provider_account_spec.rb
index 04b4b1e..49039f4 100644
--- a/src/spec/models/provider_account_spec.rb
+++ b/src/spec/models/provider_account_spec.rb
@@ -64,6 +64,14 @@ describe ProviderAccount do
provider_account.save.should == false
end
+ it "should add errors when testing credentials fails" do
+ provider_account = Factory.build(:mock_provider_account)
+ provider_account.credentials_hash = {'password' => "wrong_password"}
+ provider_account.stub(:valid_credentials).and_raise("DeltacloudError")
+ provider_account.save.should == false
+ provider_account.errors[:base].should == ["An error occured when checking provider credentials please check your setup and try again"]
+ end
+
it "should fail to create a cloud account if fetching of hw profiles fails" do
provider_account = Factory.build(:mock_provider_account)
provider_account.stub(:populate_hardware_profiles).and_raise(ActiveRecord::RecordInvalid)
--
1.7.6.4
12 years, 3 months
[PATCH conductor] Larger administer navigation hover background image to accomodate nav items with long names
by Jirka Tomasek
From: Jiri Tomasek <jtomasek(a)redhat.com>
---
src/public/images/administer_nav_bg_hover.png | Bin 496 -> 522 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/src/public/images/administer_nav_bg_hover.png b/src/public/images/administer_nav_bg_hover.png
index 9ebd5d07e10577dce892c8b298f7afb02c6b6064..5af51134c36959a76eff921d0d1815d2fbe5b02e 100644
GIT binary patch
literal 522
zcmeAS@N?(olHy`uVBq!ia0vp^CxF<NgAGW&U{^C?U|_uH>EaktaqI1M&7R;uhSrD4
zf+{S{2NDD%oSF_O7)Y?NfjMBx?aGBc@3`+?x?X#KS+3Wt1c79TDu)CEgX@!wPbP3Y
zvOlT*E2wm`{de1=g*9vq%m3EZi#06&SyLz1u>A1h!`uuuYp=iVX0XZKe%qVD=55*T
z(?F51)!GbuK1{3=ZCHLbtys1}oM|WH0q*+>=8P4J6QUVxbj7-F1Ig*9tr=|2rfuHM
zVB@Pcxf)0=zx*4hvFj^CgLvFVIi?RLa{cm*A53KU<e5L1NcGNR_+TQzGmq)RmG|H0
zGk&=8`s+OA4~KX^F*S(iO_<JLQ@Z;uGs8TqxqeIy%gc8E<!V?Swt6blgOxXPo-tN*
zJ^o?Jpnpf9lwqD!uN!y6@~XY}*dMG6Tiwf8u_|meH^V%wsi)Y0ZmncKz}>iq^})&*
zz5UD&R)%QFGJXir5xdX)Aw)yOj^V?U^Uv*>J~%1NXRJ8&v?!jT;#At^cpy8)=sw7Q
z@(eahFTb46V6(A)cZyM^?o_W@Yr8-3_1ayFgw#)Tv{*<?oMSiX@qbxWq0ZttQp!S)
z65f<d6ktzQcM+;<e?EsVx!%P|rf05zr-<wPj>rFR=9eGkD>;9*$rl*M44$rjF6*2U
FngBZm)jj|K
literal 496
zcmeAS@N?(olHy`uVBq!ia0vp^IY4a7!3HEfw)D&gQY^(zo*^7SP{WbZ0pxQQctjR6
zFmMZjFyp1Wb$@_@G9|7NCBgY=CFO}lsSJ)O`AMk?Zka`?<@rU~#R|^BriEJ{n*r5{
zfYdn`r6!hS=I1GdWag$aSn3<<8yc#AoTkaZ!06@a;uumf=j|;+FXljz)`!B9+}hh8
z32hSDeS6nj&AXj<x11EZ(-?VhbAV$&;S3eyKmGrkr!b52Jui|^G55V3+hSPrkHv7y
zwY=?ePM;+u&RmEpR&BarAi>;RsCo!Ye|*T3d^o|zDj`Rrr}5wpp+qqKgRgmGq5&J*
z<Eb1#S)dSav!Q{+{X_#Zo?{0R_JCFKf|NK5F*5^=0_x-8IR;h?rXO2_c#pkWfJ%T`
z+73!c^!%UIgk)w}H2;Px7JdAlag*-o|M;_Wm7KoS1+NW_s@=|q+or0RNAnl-t+G<N
zscw1p&yyKXUS=_`Ww^UR-*|SJ&!+XOwuiRunxx0%{f~ET_l8M*KnBm-Dg7JxX7iLL
x#<EWP!?AYt2B9ApKhDl?Kap+4t?hY_v7l*NTWxWr2{6<dJYD@<);T3K0RRKty($0z
--
1.7.7.6
12 years, 3 months