From: David Lutterkort <[email protected]>

      * Define hardware profiles equivalent to the flavors
      * Expect parameter hwp_id to be passed in for create_instance
      * Store InstanceProfile with instance

This is a little hokey, since OpenNebula doesn't tell us anything what the
different size profiles mean
---
 .../drivers/opennebula/opennebula_driver.rb        |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb 
b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
index e49c662..85efeec 100644
--- a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
+++ b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
@@ -58,6 +58,11 @@ class OpennebulaDriver < Deltacloud::BaseDriver
        } ),
   ] ) unless defined?( FLAVORS )
 
+  define_hardware_profile 'small'
+
+  define_hardware_profile 'medium'
+
+  define_hardware_profile 'large'
 
   def flavors(credentials, opts=nil)
        return FLAVORS if ( opts.nil? )
@@ -150,7 +155,7 @@ class OpennebulaDriver < Deltacloud::BaseDriver
   def create_instance(credentials, image_id, opts=nil)
        occi_client = new_client(credentials)
 
-       flavor_id = opts[:flavor_id].nil? ? 'small' : opts[:flavor_id]
+       hwp_id = opts[:hwp_id] || 'small'
 
        instancexml = ERB.new(OCCI_VM).result(binding)
        instancefile = "|echo '#{instancexml}'"
@@ -206,7 +211,7 @@ class OpennebulaDriver < Deltacloud::BaseDriver
 
        state = (computehash['STATE'].text == 'ACTIVE') ? 'RUNNING' : 
computehash['STATE'].text
 
-       flavor = computehash['INSTANCE_TYPE'].nil? ? 'small' : 
computehash['INSTANCE_TYPE'].text
+       hwp_name = computehash['INSTANCE_TYPE'] || 'small'
 
        networks = []
        (computehash['NETWORK'].each do |n|
@@ -219,6 +224,7 @@ class OpennebulaDriver < Deltacloud::BaseDriver
                :name=>computehash['NAME'].text,
                :image_id=>imageid,
                :flavor_id=>flavor,
+        :instance_profile=>InstanceProfile.new(hwp_name),
                :realm_id=>'Any realm',
                :state=>state,
                :public_addreses=>networks,
@@ -243,7 +249,7 @@ class OpennebulaDriver < Deltacloud::BaseDriver
   (OCCI_VM = %q{
        <COMPUTE>
                <NAME><%=opts[:name]%></NAME>
-               <INSTANCE_TYPE><%= flavor_id %></INSTANCE_TYPE>
+               <INSTANCE_TYPE><%= hwp_id %></INSTANCE_TYPE>
                <STORAGE>
                        <DISK image="<%= image_id %>" dev="sda1" />
                </STORAGE>
-- 
1.6.6.1

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to