deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dko...@apache.org
Subject [1/2] git commit: CIMI: Added #collection_class_for helper to CIMI client
Date Fri, 21 Jun 2013 11:25:58 GMT
Updated Branches:
  refs/heads/master f79783528 -> 8eda668a9


CIMI: Added #collection_class_for helper to CIMI client

Since now the collection classes are not available in the
namespace, this helper will generate them in the client.


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

Branch: refs/heads/master
Commit: 8eda668a957f8b7e898568fa507866d928c0d9e1
Parents: 01541b0
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Jun 13 13:37:27 2013 +0200
Committer: Dies Koper <diesk@fast.au.fujitsu.com>
Committed: Fri Jun 21 21:16:06 2013 +1000

----------------------------------------------------------------------
 clients/cimi/lib/cimi_frontend_helper.rb | 6 ++++++
 clients/cimi/lib/entities/machine.rb     | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8eda668a/clients/cimi/lib/cimi_frontend_helper.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/cimi_frontend_helper.rb b/clients/cimi/lib/cimi_frontend_helper.rb
index 99dbc7c..314ec91 100644
--- a/clients/cimi/lib/cimi_frontend_helper.rb
+++ b/clients/cimi/lib/cimi_frontend_helper.rb
@@ -39,6 +39,12 @@ module CIMI
         obj.class.name.split('::').last
       end
 
+      # Generate the CIMI collection class for given model
+      #
+      def collection_class_for(model_name)
+        CIMI::Model::Collection.generate(CIMI::Model.const_get(model_name.to_s.camelize))
+      end
+
       def flash_block_for(message_type)
         return unless flash[message_type]
         capture_haml do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8eda668a/clients/cimi/lib/entities/machine.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/machine.rb b/clients/cimi/lib/entities/machine.rb
index 6135e62..fef25c8 100644
--- a/clients/cimi/lib/entities/machine.rb
+++ b/clients/cimi/lib/entities/machine.rb
@@ -38,18 +38,18 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
   get '/cimi/machines' do
     # We need to include this stuff for new Machine Form
     machine_image_xml = get_entity_collection('machine_images', credentials)
-    @machine_images = CIMI::Model::MachineImageCollection.from_xml(machine_image_xml)
+    @machine_images = collection_class_for(:machine_image).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_configurations = collection_class_for(:machine_configuration).from_xml(machine_conf_xml)
     begin
       machine_admins_xml = get_entity_collection('machine_admins', credentials)
-      @machine_admins = CIMI::Model::MachineAdminCollection.from_xml(machine_admins_xml)
+      @machine_admins = collection_class_for(:machine_admin).from_xml(machine_admins_xml)
       # In case backend does not support MachineAdmin collection
     rescue RestClient::ResourceNotFound
       @machine_admins = []
     end
     machine_xml = get_entity_collection('machines', credentials)
-    @machines = CIMI::Model::MachineCollection.from_xml(machine_xml)
+    @machines = collection_class_for(:machine).from_xml(machine_xml)
     haml :'machines/index'
   end
 


Mime
View raw message