You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2011/02/10 10:48:40 UTC

svn commit: r1069309 - in /incubator/deltacloud/trunk/server: lib/deltacloud/base_driver/features.rb lib/deltacloud/drivers/gogrid/gogrid_driver.rb views/instances/new.html.haml

Author: mfojtik
Date: Thu Feb 10 09:48:39 2011
New Revision: 1069309

URL: http://svn.apache.org/viewvc?rev=1069309&view=rev
Log:
Allow creating 'sandbox' instances in GoGrid

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
    incubator/deltacloud/trunk/server/views/instances/new.html.haml

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb?rev=1069309&r1=1069308&r2=1069309&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/features.rb Thu Feb 10 09:48:39 2011
@@ -204,5 +204,12 @@ module Deltacloud
       end
     end
 
+    declare_feature :instances, :sandboxing do
+      description "Allow lanuching sandbox images"
+      operation :create do
+        param :sandbox, :string,  :optional
+      end
+    end
+
   end
 end

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb?rev=1069309&r1=1069308&r2=1069309&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb Thu Feb 10 09:48:39 2011
@@ -36,6 +36,7 @@ module Deltacloud
 class GogridDriver < Deltacloud::BaseDriver
 
   feature :instances, :authentication_password
+  feature :instances, :sandboxing
 
   def hardware_profiles(credentials, opts={})
     client = new_client(credentials)
@@ -87,7 +88,7 @@ class GogridDriver < Deltacloud::BaseDri
     end
   end
 
-  def create_instance(credentials, image_id, opts=nil)
+  def create_instance(credentials, image_id, opts={})
     server_ram = nil
     if opts[:hwp_memory]
       mem = opts[:hwp_memory].to_i
@@ -96,14 +97,15 @@ class GogridDriver < Deltacloud::BaseDri
       server_ram = "512MB"
     end
     client = new_client(credentials)
-    name = (opts[:name] && opts[:name]!='') ? opts[:name] : get_random_instance_name
+    params = {
+      'name' => opts[:name] || get_random_instance_name,
+      'image' => image_id,
+      'server.ram' => server_ram,
+      'ip' => get_free_ip_from_realm(credentials, opts[:realm_id] || '1')
+    }
+    params.merge!('isSandbox' => 'true') if opts[:sandbox] 
     safely do
-      instance = client.request('grid/server/add', {
-        'name' => name,
-        'image' => image_id,
-        'server.ram' => server_ram,
-        'ip' => get_free_ip_from_realm(credentials, opts[:realm_id] || '1')
-      })['list'].first
+      instance = client.request('grid/server/add', params)['list'].first
       if instance
         login_data = get_login_data(client, instance[:id])
         if login_data['username'] and login_data['password']
@@ -285,8 +287,6 @@ class GogridDriver < Deltacloud::BaseDri
     'Unregistering instances from load balancer is not supported in GoGrid')
   end
 
-
-
   def key(credentials, opts=nil)
     keys(credentials, opts).first
   end
@@ -425,8 +425,8 @@ class GogridDriver < Deltacloud::BaseDri
         opts[:hwp_memory] = (mem.to_i * 1024).to_s
       end
     end
-    prof = InstanceProfile.new("server", opts)
 
+    prof = InstanceProfile.new("server", opts)
     hwp_name = instance['image']['name']
     state = convert_server_state(instance['state']['name'], instance['id'])
 

Modified: incubator/deltacloud/trunk/server/views/instances/new.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/instances/new.html.haml?rev=1069309&r1=1069308&r2=1069309&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/instances/new.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/instances/new.html.haml Thu Feb 10 09:48:39 2011
@@ -14,6 +14,11 @@
       %label
         Number of instances:
       %input{ :type => :text, :value => "1", :name => :instance_count }
+  -if driver_has_feature?(:sandboxing)
+    %p
+      %label
+        Sandbox?:
+      %input{ :type => :checkbox, :value => "1", :name => :sandbox }
   -if driver_has_feature?(:register_to_load_balancer)
     %p
       %label