deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject git commit: Fixes JIRA DTACLOUD_231 - Load balancers in the HTML UI (nits brought in modular dcloud)
Date Tue, 12 Jun 2012 11:10:16 GMT
Updated Branches:
  refs/heads/master 7736ee8ea -> a6876a967


Fixes JIRA DTACLOUD_231 - Load balancers in the HTML UI
(nits brought in modular dcloud)

https://issues.apache.org/jira/browse/DTACLOUD-231


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

Branch: refs/heads/master
Commit: a6876a9675847af85ba0290c081479903fbb8367
Parents: 7736ee8
Author: marios <marios@redhat.com>
Authored: Tue Jun 12 13:09:38 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Tue Jun 12 14:09:45 2012 +0300

----------------------------------------------------------------------
 .../lib/deltacloud/collections/load_balancers.rb   |   31 +++++++++++---
 server/views/load_balancers/show.html.haml         |   18 ++++++---
 2 files changed, 36 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a6876a96/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 f6fbc62..7d6392b 100644
--- a/server/lib/deltacloud/collections/load_balancers.rb
+++ b/server/lib/deltacloud/collections/load_balancers.rb
@@ -17,11 +17,28 @@ module Deltacloud::Collections
   class LoadBalancers < Base
     check_capability :for => lambda { |m| driver.has_capability? m }
 
+    new_route_for :load_balancers do
+      @realms = driver.realms(credentials)
+    end
+
     collection :load_balancers do
       description "Load balancers are used distribute workload across multiple instances"
 
       standard_index_operation
-      standard_show_operation
+
+      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}}
+          @unregistered_instances = driver.instances(credentials).collect{|i| {:id =>
i.id, :name => i.name}} - @registered_instances
+          respond_to do |format|
+            format.xml { haml :'load_balancers/show' }
+            format.json { xml_to_json('load_balancers/show') }
+            format.html { haml :'load_balancers/show' }
+          end
+        end
+      end
 
       operation :create do
         param :name,  :string,  :required
@@ -32,11 +49,11 @@ module Deltacloud::Collections
         control do
           @load_balancer = driver.create_load_balancer(credentials, params)
           status 201  # Created
-          response['Location'] = load_balancer_url(@instance.id)
+          response['Location'] = load_balancer_url(@load_balancer.id)
           respond_to do |format|
             format.xml  { haml :"load_balancers/show" }
             format.json { convert_to_json(:load_balancer, @load_balancer) }
-            format.html { haml :"load_balancers/show" }
+            format.html { redirect load_balancer_url(@load_balancer.id)}
           end
         end
       end
@@ -45,11 +62,11 @@ module Deltacloud::Collections
         param :instance_id, :string,  :required
         control do
           driver.lb_register_instance(credentials, params)
-          @load_balancer = driver.load_balancer(credential, params[:id])
+          @load_balancer = driver.load_balancer(credentials, params[:id])
           respond_to do |format|
             format.xml { haml :'load_balancers/show' }
             format.json { xml_to_json('load_balancers/show') }
-            format.html { haml :'load_balancers/show' }
+            format.html { redirect load_balancer_url(@load_balancer.id)}
           end
         end
       end
@@ -58,11 +75,11 @@ module Deltacloud::Collections
         param :instance_id, :string,  :required
         control do
           driver.lb_unregister_instance(credentials, params)
-          @load_balancer = driver.load_balancer(credential, params[:id])
+          @load_balancer = driver.load_balancer(credentials, params[:id])
           respond_to do |format|
             format.xml { haml :'load_balancers/show' }
             format.json { xml_to_json('load_balancers/show')}
-            format.html { haml :'load_balancers/show' }
+            format.html { redirect load_balancer_url(@load_balancer.id) }
           end
         end
       end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a6876a96/server/views/load_balancers/show.html.haml
----------------------------------------------------------------------
diff --git a/server/views/load_balancers/show.html.haml b/server/views/load_balancers/show.html.haml
index 711b5d2..cab8961 100644
--- a/server/views/load_balancers/show.html.haml
+++ b/server/views/load_balancers/show.html.haml
@@ -15,14 +15,21 @@
       %li
         %a{ :href => realm_url(realm.id), :'data-ajax' => 'false'}
           %h3=realm.name
-    %li{ :'data-role' => 'list-divider'} Instances
-    - @load_balancer.instances.each do |instance|
+    %li{ :'data-role' => 'list-divider'} Registered Instances
+    - @registered_instances.each do |instance|
       %li
-        %a{ :href => instance_url(instance.id), :'data-ajax' => 'false'}
-          %h3=instance.name
+        %a{ :href => instance_url(instance[:id]), :'data-ajax' => 'false'}
+          %h3=instance[:name]
+          =link_to_action "UnRegister", api_url_for("load_balancers/#{@load_balancer.id}/unregister?instance_id=#{instance[:id]}"),
:post
+    %li{ :'data-role' => 'list-divider'} UnRegistered Instances
+    - @unregistered_instances.each do |instance|
+      %li
+        %a{:href => instance_url(instance[:id]), :'data-ajax' => 'false'}
+          %h3=instance[:name]
+          =link_to_action "Register", api_url_for("load_balancers/#{@load_balancer.id}/register?instance_id=#{instance[:id]}"),
:post
     %li{ :'data-role' => 'list-divider'} Actions
     %li
-      =link_to_action "Destroy", destroy_load_balancer_url(@load_balancer.id), :delete
+      =link_to_action "Destroy", api_url_for("load_balancers/#{@load_balancer.id}"), :delete
 
   =header "Listeners", :back => 'false'
   %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' =>
'd'}
@@ -33,4 +40,3 @@
       %li{ :'data-role' => 'list-divider'} Instance port
       %li
         %p{ :'data-role' => 'fieldcontain'}=listener.instance_port
-


Mime
View raw message