incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962039 - /incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb
Date Thu, 08 Jul 2010 23:18:38 GMT
Author: lutter
Date: Thu Jul  8 23:18:38 2010
New Revision: 962039

URL: http://svn.apache.org/viewvc?rev=962039&view=rev
Log:
Use app/models/**

Modified:
    incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb

Modified: incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb?rev=962039&r1=962038&r2=962039&view=diff
==============================================================================
--- incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb (original)
+++ incubator/deltacloud/trunk/drivers/mock/lib/mock_driver.rb Thu Jul  8 23:18:38 2010
@@ -10,36 +10,36 @@ class MockDriver < DeltaCloud::BaseDrive
   # 
 
   ( FLAVORS = [ 
-    { 
+    Flavor.new({
       :id=>'m1-small',
       :memory=>1.7,
       :storage=>160,
       :architecture=>'i386',
-    },
-    {
+    }),
+    Flavor.new({
       :id=>'m1-large', 
       :memory=>7.5,
       :storage=>850,
       :architecture=>'x86_64',
-    },
-    { 
+    }),
+    Flavor.new({ 
       :id=>'m1-xlarge', 
       :memory=>15,
       :storage=>1690,
       :architecture=>'x86_64',
-    },
-    { 
+    }),
+    Flavor.new({ 
       :id=>'c1-medium', 
       :memory=>1.7,
       :storage=>350,
       :architecture=>'x86_64',
-    },
-    { 
+    }),
+    Flavor.new({ 
       :id=>'c1-xlarge', 
       :memory=>7,
       :storage=>1690,
       :architecture=>'x86_64',
-    },
+    }),
   ] ) unless defined?( FLAVORS )
 
   def flavors(credentials, opts=nil)
@@ -60,16 +60,16 @@ class MockDriver < DeltaCloud::BaseDrive
     Dir[ "#{STORAGE_ROOT}/images/*.yml" ].each do |image_file|
       image = YAML.load( File.read( image_file ) )
       image[:id] = File.basename( image_file, ".yml" )
-      images << image
+      images << Image.new( image ) 
     end
     images = filter_on( images, :id, opts )
     images = filter_on( images, :architecture, opts )
     if ( opts && opts[:owner_id] == 'self' )
-       images = images.select{|e| e[:owner_id] == credentials[:name] }
+      images = images.select{|e| e.owner_id == credentials[:name] }
     else
       images = filter_on( images, :owner_id, opts )
     end
-    images.sort_by{|e| [e[:owner_id],e[:description]]}
+    images.sort_by{|e| [e.owner_id,e.description]}
   end
 
   # 
@@ -84,7 +84,8 @@ class MockDriver < DeltaCloud::BaseDrive
       puts "opts ==> #{opts.inspect}"
       if ( instance[:owner_id] == credentials[:name] )
         instance[:id] = File.basename( instance_file, ".yml" )
-        instances << instance
+        instance[:actions] = [ :reboot ]
+        instances << Instance.new( instance )
       end
     end
     instances = filter_on( instances, :id, opts )
@@ -96,18 +97,19 @@ class MockDriver < DeltaCloud::BaseDrive
     ids = Dir[ "#{STORAGE_ROOT}/instances/*.yml" ].collect{|e| File.basename( e, ".yml" )}
     next_id = ids.sort.last.succ
     instance = {
-      :state=>'running',
+      :state=>'RUNNING',
       :image_id=>image_id,
       :owner_id=>credentials[:name],
-      :public_address=>"#{image_id}.#{next_id}.public.com",
-      :private_address=>"#{image_id}.#{next_id}.private.com",
+      :public_addresses=>["#{image_id}.#{next_id}.public.com"],
+      :private_addresses=>["#{image_id}.#{next_id}.private.com"],
       :flavor_id=>flavor_id,
+      :actions=>[ :reboot ],
     }
     File.open( "#{STORAGE_ROOT}/instances/#{next_id}.yml", 'w' ) {|f|
       YAML.dump( instance, f )
     }
     instance[:id] = next_id
-    instance
+    Instance.new( instance )
   end
 
   def reboot_instance(credentials, id)



Mime
View raw message