CIMI: allow 202 from system creation & machine deletion
and fix copy & paste error in machine restart in client UI
diff --git a/clients/cimi/lib/entities/machine.rb b/clients/cimi/lib/entities/machine.rb
index 44e3b26..44d0283 100644
--- a/clients/cimi/lib/entities/machine.rb
+++ b/clients/cimi/lib/entities/machine.rb
@@ -58,6 +58,9 @@
     if result.code == 200
       flash[:success] = "Machine '#{params[:id]}' was successfully destroyed."
       redirect '/cimi/machines'
+    elsif result.code == 202
+      flash[:success] = "Deletion of Machine '#{params[:id]}' was successfully initiated."
+      redirect '/cimi/machines'
     else
       flash[:error] = "Unable to destroy machine #{params[:id]}"
     end
@@ -91,7 +94,7 @@
         xml.action "http://schemas.dmtf.org/cimi/1/action/restart"
       }
     end.to_xml
-    entity_action 'machines', 'restart', action_xml, credentials, action_xml
+    entity_action 'machines', 'restart', action_xml, credentials, params[:id]
     flash[:success] = "Machine successfully restarted."
     redirect '/cimi/machines/%s' % params[:id]
   end
diff --git a/clients/cimi/lib/entities/system.rb b/clients/cimi/lib/entities/system.rb
index 665fcfd..a15d222 100644
--- a/clients/cimi/lib/entities/system.rb
+++ b/clients/cimi/lib/entities/system.rb
@@ -175,9 +175,14 @@
     end.to_xml
     begin
       result = create_entity('systems', system_xml, credentials)
-      system = collection_class_for(:system).from_xml(result)
       flash[:success] = "System create was successfully initiated."
-      redirect "/cimi/systems/#{href_to_id(system.id)}"
+      location = result.headers[:location]
+      if location
+        redirect "/cimi/systems/#{href_to_id location}"
+      else
+        system = collection_class_for(:system).from_xml(result)
+        redirect "/cimi/systems/#{href_to_id system.id}"
+      end
     rescue => e
       flash[:error] = "System cannot be created: #{e.message}"
     end