deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [1/4] git commit: Core: Fixed passing wrong instance variables to load balancer
Date Tue, 16 Apr 2013 21:01:05 GMT
Updated Branches:
  refs/heads/master c8ace9a4f -> 1ee230122


Core: Fixed passing wrong instance variables to load balancer


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/d358f63b
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/d358f63b
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/d358f63b

Branch: refs/heads/master
Commit: d358f63b0b98603618d1ccf4c9a60d1251f60ea5
Parents: c8ace9a
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Tue Apr 16 11:20:33 2013 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Apr 16 11:20:33 2013 +0200

----------------------------------------------------------------------
 .../lib/deltacloud/collections/load_balancers.rb   |   21 ++++++++------
 server/views/load_balancers/new.html.haml          |    7 -----
 2 files changed, 12 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d358f63b/server/lib/deltacloud/collections/load_balancers.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/load_balancers.rb b/server/lib/deltacloud/collections/load_balancers.rb
index 9c0a918..c08cfad 100644
--- a/server/lib/deltacloud/collections/load_balancers.rb
+++ b/server/lib/deltacloud/collections/load_balancers.rb
@@ -30,19 +30,22 @@ module Deltacloud::Collections
       operation :show, :with_capability => :load_balancer do
         param :id, :string, :required
         control do
-          @load_balancer = driver.load_balancer(credentials, params)
-          @registered_instances = @load_balancer.instances.collect{|i| {:id => i.id, :name=>
i.name}}
-          # if provider supports realm_filter and load balancer has only one realm (which
is mostly the case), use optimization:
-          if @load_balancer.realms.size == 1 and driver.class.has_feature?(:instances, :realm_filter)
-            all_instances = driver.instances(credentials, :realm_id => @load_balancer.realms.first.id).collect{|i|
{:id => i.id, :name => i.name}}
-          elsif
+          vars = {}
+          vars[:load_balancer] = driver.load_balancer(credentials, params)
+          vars[:registered_instances] = vars[:load_balancer].instances.map{ |i| {:id =>
i.id, :name=> i.name} }
+          # If provider supports realm_filter and load balancer has only one realm (which
is mostly the case), use optimization:
+          if vars[:load_balancer].realms.size == 1 and driver.class.has_feature?(:instances,
:realm_filter)
+            all_instances = driver.instances(credentials, :realm_id => vars[:load_balancer].realms.first.id).collect{
|i|
+              { :id => i.id, :name => i.name }
+            }
+          else
             all_instances = driver.instances(credentials).collect{|i| {:id => i.id, :name
=> i.name} }
           end
-          @unregistered_instances = all_instances - @registered_instances
+          vars[:unregistered_instances] = all_instances - vars[:registered_instances]
           respond_to do |format|
-            format.xml { haml :'load_balancers/show', :locals => { :load_balancer =>
@load_balancer } }
+            format.xml { haml :'load_balancers/show', :locals => vars }
             format.json { JSON::dump(:load_balancer => @load_balancer.to_hash(self)) }
-            format.html { haml :'load_balancers/show' } # FIXME: Fix the HTML view + instance
variables
+            format.html { haml :'load_balancers/show', :locals => vars }
           end
         end
       end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d358f63b/server/views/load_balancers/new.html.haml
----------------------------------------------------------------------
diff --git a/server/views/load_balancers/new.html.haml b/server/views/load_balancers/new.html.haml
index e3b4016..8cba89f 100644
--- a/server/views/load_balancers/new.html.haml
+++ b/server/views/load_balancers/new.html.haml
@@ -6,13 +6,6 @@
       %label
         Name:
       %input{ :name => 'name', :size => 30 }/
-    -if instances
-      %p
-        %label
-          Running instance:
-        %select{ :name => 'instance_id'}
-          - instances.select{|i| i.state=="RUNNING"}.each do |instance|
-            %option{ :value => instance.id } #{instance.id}
     %p
       %label
         Realm:


Mime
View raw message