You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2012/06/18 05:44:37 UTC

[PATCH core 1/2] CIMI: Minor tweaks to the CIMI web application client

From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 clients/cimi/init.rb                            |    2 +-
 clients/cimi/lib/client.rb                      |    7 ++++-
 clients/cimi/lib/entities/machine.rb            |    7 +++++
 clients/cimi/views/cloud_entry_point/index.haml |    9 +++----
 clients/cimi/views/layout.haml                  |   20 +++++++++++----
 clients/cimi/views/machine_images/index.haml    |    4 +--
 clients/cimi/views/machines/index.haml          |    5 +--
 clients/cimi/views/machines/show.haml           |   30 +++++++++++++----------
 8 files changed, 52 insertions(+), 32 deletions(-)

diff --git a/clients/cimi/init.rb b/clients/cimi/init.rb
index 94f2b84..fdeca07 100644
--- a/clients/cimi/init.rb
+++ b/clients/cimi/init.rb
@@ -29,4 +29,4 @@ require 'entities'
 
 $:.unshift File.join('..', '..','server', 'lib')
 require 'deltacloud/core_ext'
-require 'cimi/model'
+require 'cimi/models'
diff --git a/clients/cimi/lib/client.rb b/clients/cimi/lib/client.rb
index 0fd85e4..b7c106e 100644
--- a/clients/cimi/lib/client.rb
+++ b/clients/cimi/lib/client.rb
@@ -43,10 +43,13 @@ module CIMI
 
       def provider_header(credentials)
         return Hash.new unless credentials.driver
-        {
+        retval = {
           :'X-Deltacloud-Driver' => credentials.driver,
-          :'X-Deltacloud-Provider' => credentials.provider
         }
+        retval.merge!({
+          :'X-Deltacloud-Provider' => credentials.provider
+        }) if credentials.provider
+        retval
       end
 
       def auth_header(credentials)
diff --git a/clients/cimi/lib/entities/machine.rb b/clients/cimi/lib/entities/machine.rb
index 67e5802..945f603 100644
--- a/clients/cimi/lib/entities/machine.rb
+++ b/clients/cimi/lib/entities/machine.rb
@@ -39,6 +39,13 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
     haml :'machines/index'
   end
 
+  get "/cimi/machines/:id/:action" do
+    method = params[:action] == 'delete' ? 'DELETE' : 'POST'
+    status, headers, body = call env.merge("PATH_INFO" => "/cimi/machines/#{params[:id]}/#{params[:action]}",
+                                           'REQUEST_METHOD' => method)
+    [status, headers, body]
+  end
+
   delete '/cimi/machines/:id/delete' do
     result = destroy_entity('machines', params[:id], credentials)
     if result.code == 200
diff --git a/clients/cimi/views/cloud_entry_point/index.haml b/clients/cimi/views/cloud_entry_point/index.haml
index 9621bc8..13b257a 100644
--- a/clients/cimi/views/cloud_entry_point/index.haml
+++ b/clients/cimi/views/cloud_entry_point/index.haml
@@ -13,16 +13,15 @@
 %blockquote
   %p
     The Cloud Entry Point represents the entry point into the cloud defined by
-    the CIMI Model. The Cloud Entry Point implements a catalog of entities such
-    as Systems, System Templates, Machines, Machine Templates, etc. that can be
-    queried and browsed by the Consumer
+    the CIMI Model. The Cloud Entry Point implements a catalog of resources,
+    such as Systems, System Templates, Machines, Machine Templates, etc., that
+    can be queried and browsed by the Consumer.
 
-%ul
+%ul{ :class => 'nav nav-pills nav-stacked'}
   - @entities.each do |entity|
     %li
       - if @entry_point.respond_to? entity
         %a{ :href => "/cimi/#{entity}"}=struct_to_name @entry_point.send(entity.intern)
-        =not_implemented(entity)
 
 - details('Collection details') do
   - row 'ID', @entry_point.id
diff --git a/clients/cimi/views/layout.haml b/clients/cimi/views/layout.haml
index 44007cb..653540a 100644
--- a/clients/cimi/views/layout.haml
+++ b/clients/cimi/views/layout.haml
@@ -29,8 +29,14 @@
                     %li
                       %a{ :href => '/driver?driver=mock'} Mock
                     %li
+                      %a{ :href => '#sbc', :onclick => "toggleConfig('sbc')"} IBM SBC
+                    %li
                       %a{ :href => '#ec2', :onclick => "toggleConfig('ec2')"} Amazon EC2
                     %li
+                      %a{ :href => '#ec2', :onclick => "toggleConfig('gogrid')"} GoGrid
+                    %li
+                      %a{ :href => '#eucalyptus', :onclick => "toggleConfig('eucalyptus')"} Eucalyptus
+                    %li
                       %a{ :href => '#providerModal', :onclick => "toggleConfig('rhevm')"} RHEV-M
                     %li
                       %a{ :href => '#providerModal', :onclick => "toggleConfig('openstack')"} OpenStack
@@ -57,7 +63,7 @@
                     %span{ :class => 'help-inline'} 
                   %label.control-label API Provider
                   .controls
-                    %input{ :type => :text, :class => :span3, :placeholder => 'http://', :name => :provider, :value => credentials.provider}
+                    %input{ :type => :text, :class => :span3, :name => :provider, :value => credentials.provider}
                     %br/
                     %span{ :class => 'help-inline'} Enter driver specific provider URL
           .modal-footer
@@ -66,14 +72,18 @@
         .content
           .page-header
             %h1=@title || 'no-title-fix-me'
-            = yield_content :breadcrumb
+            = yield_content(:breadcrumb)
           .row
             .span8#main
               - [ :info, :error, :success ].map do |message|
-                = flash_block_for message
+                - flash_block_for message
               =yield
-            .span2#toolbar=yield_content :actions
+            .span2#toolbar
+              = yield_content :actions
         %footer
           %p
-            &copy; 2009-2011 The Apache Software Foundation and individual contributors.
+            %br
+            &copy; 2009-2012 The Apache Software Foundation and individual contributors.
+            %br
+            &copy; 2012 Distributed Management Task Force, Inc. (DMTF).
 
diff --git a/clients/cimi/views/machine_images/index.haml b/clients/cimi/views/machine_images/index.haml
index af4da79..d32fbd6 100644
--- a/clients/cimi/views/machine_images/index.haml
+++ b/clients/cimi/views/machine_images/index.haml
@@ -15,9 +15,7 @@
 
 %blockquote
   %p
-    A Machine Image Collection entity represents the collection of Machine Image
-    entities within a Provider. This entity can be used to locate and create
-    Machine Images.
+    This resource represents the information necessary for hardware virtualized resources to create a Machine Instance.
 
 %h3 MachineImageCollection
 %ul
diff --git a/clients/cimi/views/machines/index.haml b/clients/cimi/views/machines/index.haml
index ba9212c..3835f3b 100644
--- a/clients/cimi/views/machines/index.haml
+++ b/clients/cimi/views/machines/index.haml
@@ -13,6 +13,7 @@
     %a{ :href => "#{@machines.id}?format=xml", :class => 'label warning' } XML
     %a{ :href => "#{@machines.id}?format=json", :class => 'label warning' } JSON
   %p
+    %br &nbsp;
     %a{ :href => '#machineModal', :class => 'btn btn-primary', :'data-toggle' => :modal} New Machine
 
   %div{ :id => :machineModal, :class => 'modal hide fade' }
@@ -45,15 +46,13 @@
       %a{ :href => '#', :class => 'btn btn-primary', :'data-loading-text' => 'Creating MachineAdmin...', :onclick => "postModalForm(this, 'machineModal')"} Continue
       %a{ :href => '#', :class => 'btn', :'data-dismiss' => 'modal'} Cancel
 
-
-
 %blockquote
   %p
     A Machine Collection entity represents the collection of Machine
     entities within a Provider. This entity can be used to locate and create
     Machines.
 
-%ul
+%ul{ :class => 'nav nav-tabs nav-stacked'}
   - @machines.machines.each do |machine|
     %li
       %a{ :href => "/cimi/machines/#{machine.href.split('/').last}"}=machine.href.split('/').last
diff --git a/clients/cimi/views/machines/show.haml b/clients/cimi/views/machines/show.haml
index a847710..64472c0 100644
--- a/clients/cimi/views/machines/show.haml
+++ b/clients/cimi/views/machines/show.haml
@@ -15,24 +15,28 @@
   %p
     %a{ :href => "#{@machine.id}?format=xml", :class => 'label warning' } XML
     %a{ :href => "#{@machine.id}?format=json", :class => 'label warning' } JSON
-  %p
-    - if @machine.state == 'STARTED'
-      %form{ :action => "/cimi/machines/#{@machine.name}/stop", :method => :post, :style => 'display:inline'}
-        %button{ :class => 'btn'} Stop
-    - if @machine.state == 'STOPPED'
-      %form{ :action => "/cimi/machines/#{@machine.name}/start", :method => :post, :style => 'display:inline'}
-        %button{ :class => 'btn success'} Start
-    %form{ :action => "/cimi/machines/#{@machine.name}/restart", :method => :post, :style => 'display:inline'}
-      %button{ :class => 'btn info'} Restart
-    %form{ :action => "/cimi/machines/#{@machine.name}/delete", :method => :post, :style => 'display:inline'}
-      %input{ :type => :hidden, :name => '_method', :value => 'delete'}
-      %button{ :class => 'btn danger'} Destroy
+  %ul{ :class => 'nav nav-pills'}
+    %li.dropdown
+      %a.dropdown-toggle{ :'data-toggle' => 'dropdown'}
+        Machine Actions
+        %b.caret
+      %ul.dropdown-menu
+        - if @machine.state == 'STARTED'
+          %li
+            %a{ :href => "/cimi/machines/#{@machine.name}/stop" } Stop
+        - if @machine.state == 'STOPPED'
+          %li
+            %a{ :href => "/cimi/machines/#{@machine.name}/start" } Start
+        - if @machine.state == 'STARTED'
+          %li
+            %a{ :href => "/cimi/machines/#{@machine.name}/restart" } Restart
+          %li
+            %a{ :href => "/cimi/machines/#{@machine.name}/delete" } Delete
 
 %blockquote
   %p
     This entity represents an instantiated compute resource
 
-
 -details 'Machine details' do
   -row 'ID', @machine.id
   -row 'Description',@machine.description
-- 
1.7.7.5 (Apple Git-26)