From: Michal Fojtik <[email protected]>

Signed-off-by: Michal fojtik <[email protected]>
---
 clients/cimi/lib/entities/machine.rb            |   17 +++++++++++------
 clients/cimi/views/machines/new.haml            |    9 ++++++---
 server/lib/cimi/model/machine.rb                |    1 +
 server/lib/deltacloud/backend_capability.rb     |    3 ++-
 server/lib/deltacloud/base_driver/exceptions.rb |    7 +++++++
 5 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/clients/cimi/lib/entities/machine.rb 
b/clients/cimi/lib/entities/machine.rb
index d70d0e9..c17925b 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
 
@@ -86,10 +91,10 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
       xml.Machine(:xmlns => CIMI::Frontend::CMWG_NAMESPACE) {
         xml.name params[:machine][:name]
         xml.description params[:machine][:description]
-        xml.MachineTemplate {
-          xml.MachineConfig( :href => params[:machine][:machine_configuration] 
)
-          xml.MachineImage( :href => params[:machine][:machine_image] )
-          xml.MachineAdmin( :href => params[:machine][:machine_admin] ) unless 
params[:machine][:machine_admin].empty?
+        xml.machineTemplate {
+          xml.machineConfig( :href => params[:machine][:machine_configuration] 
)
+          xml.machineImage( :href => params[:machine][:machine_image] )
+          xml.machineAdmin( :href => params[:machine][:machine_admin] ) unless 
params[:machine][:machine_admin].nil?
         }
       }
     end.to_xml
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
diff --git a/server/lib/cimi/model/machine.rb b/server/lib/cimi/model/machine.rb
index 949a072..88c9f73 100644
--- a/server/lib/cimi/model/machine.rb
+++ b/server/lib/cimi/model/machine.rb
@@ -82,6 +82,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
     hardware_profile_id = 
machine_template['machineConfig'][0]["href"].split('/').last
     image_id = machine_template['machineImage'][0]["href"].split('/').last
     additional_params = {}
+    additional_params[:name] =xml['name'][0] if xml['name']
     if machine_template.has_key? 'machineAdmin'
       additional_params[:keyname] = 
machine_template['machineAdmin'][0]["href"].split('/').last
     end
diff --git a/server/lib/deltacloud/backend_capability.rb 
b/server/lib/deltacloud/backend_capability.rb
index 57e8cd3..05e193c 100644
--- a/server/lib/deltacloud/backend_capability.rb
+++ b/server/lib/deltacloud/backend_capability.rb
@@ -37,7 +37,8 @@ module Deltacloud::BackendCapability
 
   def check_capability(backend)
     if !has_capability?(backend)
-      raise Failure.new(capability, "#{capability} capability not supported by 
backend #{backend.class.name}")
+      e = Failure.new(capability, "#{capability} capability not supported by 
backend #{backend.class.name}")
+      raise Deltacloud::ExceptionHandler::NotSupported.new(e, nil)
     end
   end
 
diff --git a/server/lib/deltacloud/base_driver/exceptions.rb 
b/server/lib/deltacloud/base_driver/exceptions.rb
index e44c89b..3969e7e 100644
--- a/server/lib/deltacloud/base_driver/exceptions.rb
+++ b/server/lib/deltacloud/base_driver/exceptions.rb
@@ -79,6 +79,13 @@ module Deltacloud
       end
     end
 
+    class NotSupported < DeltacloudException
+      def initialize(e, message)
+        message ||= e.message
+        super(501, e.class.name, message, e.backtrace)
+      end
+    end
+
     class ExceptionDef
       attr_accessor :status
       attr_accessor :message
-- 
1.7.9.1

Reply via email to