You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:43:55 UTC

svn commit: r962293 - /incubator/deltacloud/trunk/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb

Author: lutter
Date: Thu Jul  8 23:43:55 2010
New Revision: 962293

URL: http://svn.apache.org/viewvc?rev=962293&view=rev
Log:
OpenNebula: use hardware profiles

      * 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

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb?rev=962293&r1=962292&r2=962293&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb Thu Jul  8 23:43:55 2010
@@ -58,6 +58,11 @@ class OpennebulaDriver < Deltacloud::Bas
 	} ),
   ] ) 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::Bas
   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::Bas
 
 	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::Bas
 		: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::Bas
   (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>