deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1211949 - /deltacloud/trunk/server/lib/cimi/model/machine.rb
Date Thu, 08 Dec 2011 16:21:26 GMT
Author: marios
Date: Thu Dec  8 16:21:26 2011
New Revision: 1211949

URL: http://svn.apache.org/viewvc?rev=1211949&view=rev
Log:
Adds create_entity_metadata to CIMI::Machine model (+typos in xml parsing)

Modified:
    deltacloud/trunk/server/lib/cimi/model/machine.rb

Modified: deltacloud/trunk/server/lib/cimi/model/machine.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/cimi/model/machine.rb?rev=1211949&r1=1211948&r2=1211949&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/cimi/model/machine.rb (original)
+++ deltacloud/trunk/server/lib/cimi/model/machine.rb Thu Dec  8 16:21:26 2011
@@ -70,20 +70,20 @@ class CIMI::Model::Machine < CIMI::Model
 
   def self.create_from_json(body, context)
     json = JSON.parse(body)
-    hardware_profile_id = xml['MachineTemplate']['MachineConfig']["href"].split('/').last
-    image_id = xml['MachineTemplate']['MachineImage']["href"].split('/').last
+    hardware_profile_id = xml['machineTemplate']['machineConfig']["href"].split('/').last
+    image_id = xml['machineTemplate']['machineImage']["href"].split('/').last
     instance = context.create_instance(context.credentials, image_id, { :hwp_id => hardware_profile_id
})
     from_instance(instance, context)
   end
 
   def self.create_from_xml(body, context)
     xml = XmlSimple.xml_in(body)
-    machine_template = xml['MachineTemplate'][0]
-    hardware_profile_id = machine_template['MachineConfig'][0]["href"].split('/').last
-    image_id = machine_template['MachineImage'][0]["href"].split('/').last
+    machine_template = xml['machineTemplate'][0]
+    hardware_profile_id = machine_template['machineConfig'][0]["href"].split('/').last
+    image_id = machine_template['machineImage'][0]["href"].split('/').last
     additional_params = {}
     if machine_template.has_key? 'MachineAdmin'
-      additional_params[:keyname] = machine_template['MachineAdmin'][0]["href"].split('/').last
+      additional_params[:keyname] = machine_template['machineAdmin'][0]["href"].split('/').last
     end
     instance = context.driver.create_instance(context.credentials, image_id, { 
       :hwp_id => hardware_profile_id
@@ -107,6 +107,16 @@ class CIMI::Model::Machine < CIMI::Model
     context.driver.destroy_instance(context.credentials, id)
   end
 
+  def self.create_entity_metadata(context)
+    cimi_entity = self.name.split("::").last
+    metadata = EntityMetadata.metadata_from_deltacloud_features(cimi_entity, :instances,
context)
+    unless metadata.includes_attribute?(:name)
+      metadata.attributes << {:name=>"name", :required=>"false",
+                   :constraints=>"Determined by the cloud provider", :type=>"xs:string"}
+    end
+    metadata
+  end
+
   private
 
   def self.from_instance(instance, context)
@@ -163,11 +173,11 @@ class CIMI::Model::Machine < CIMI::Model
     machine_conf = MachineConfiguration.find(profile.name, context)
     storage_override = profile.overrides.find { |p, v| p == :storage }
     [
-      { :capacity => { 
+      { :capacity => {
           :quantity => storage_override.nil? ? machine_conf.disks.first[:capacity][:quantity]
: storage_override[1],
           :units => machine_conf.disks.first[:capacity][:units]
-        } 
-      } 
+        }
+      }
     ]
   end
 



Mime
View raw message