deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [5/5] git commit: CIMI: Fixed exception when MachineAdmin not supported in client
Date Wed, 22 Feb 2012 12:33:39 GMT
CIMI: Fixed exception when MachineAdmin not supported in client

Display empty list for MachineAdmin in new operation inside CIMI
client if MachineAdmin is not supported by backend (like RHEV-M).


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

Branch: refs/heads/master
Commit: a1341cfdca5e2a1b9b6a16e60d3833de99acb4fb
Parents: fc32d55
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Wed Feb 22 13:20:26 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Wed Feb 22 13:20:26 2012 +0100

----------------------------------------------------------------------
 clients/cimi/lib/entities/machine.rb |    9 +++++++--
 clients/cimi/views/machines/new.haml |    9 ++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a1341cfd/clients/cimi/lib/entities/machine.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/machine.rb b/clients/cimi/lib/entities/machine.rb
index d70d0e9..d795996 100644
--- a/clients/cimi/lib/entities/machine.rb
+++ b/clients/cimi/lib/entities/machine.rb
@@ -20,8 +20,13 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
     @machine_images = CIMI::Model::MachineImageCollection.from_xml(machine_image_xml)
     machine_conf_xml = get_entity_collection('machine_configurations', credentials)
     @machine_configurations = CIMI::Model::MachineConfigurationCollection.from_xml(machine_conf_xml)
-    machine_admins_xml = get_entity_collection('machine_admins', credentials)
-    @machine_admins = CIMI::Model::MachineAdminCollection.from_xml(machine_admins_xml)
+    begin
+      machine_admins_xml = get_entity_collection('machine_admins', credentials)
+      @machine_admins = CIMI::Model::MachineAdminCollection.from_xml(machine_admins_xml)
+      # In case backend does not support MachineAdmin collection
+    rescue RestClient::InternalServerError
+      @machine_admins = []
+    end
     haml :'machines/new'
   end
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a1341cfd/clients/cimi/views/machines/new.haml
----------------------------------------------------------------------
diff --git a/clients/cimi/views/machines/new.haml b/clients/cimi/views/machines/new.haml
index 984ef9b..8de1fe1 100644
--- a/clients/cimi/views/machines/new.haml
+++ b/clients/cimi/views/machines/new.haml
@@ -43,9 +43,12 @@
         Machine Admin
       %div.input
         %select{ :name => 'machine[machine_admin]' }
-          %option{ :value => '', :selected => :selected }
-          - @machine_admins.machine_admins.each do |admin|
-            %option{ :value => admin.href }=href_to_id(admin.href)
+          - unless @machine_admins.empty?
+            %option{ :value => '', :selected => :selected }
+            - @machine_admins.machine_admins.each do |admin|
+              %option{ :value => admin.href }=href_to_id(admin.href)
+          - else
+            %option{ :disabled => 'disabled'}="Not supported"
     %div.actions
       %input{ :type => :submit, :class => 'btn primary', :value => "Create machine"
}
       %button{ :type => :reset, :class => 'btn' } Reset


Mime
View raw message