You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2011/07/07 17:19:08 UTC

[PATCH core 2/2] VSphere: Add initial support for attaching a floppy driver to the VM (user_data feature)

From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 .../deltacloud/drivers/vsphere/vsphere_driver.rb   |   34 ++++++++++++++++++-
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index daf34f1..75221b9 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -21,6 +21,8 @@ module Deltacloud::Drivers::VSphere
 
   class VSphereDriver < Deltacloud::BaseDriver
 
+    feature :instances, :user_data
+
     # Set of predefined hardware profiles
     define_hardware_profile('small') do
       cpu                1
@@ -213,9 +215,37 @@ module Deltacloud::Drivers::VSphere
             :numCPUs => instance_profile.cpu.value,
             :extraConfig => [
               { :key => 'template_id', :value => image_id }
-            ]
-          )
+            ])
         )
+        if opts[:user_data]
+          #
+          # ** TODO **
+          #
+          # Pick up user_data and save it to the temporary file.
+          # User data should be base64 encoded floppy image.
+          # Then upload this file to the datastore.
+          # Code below will attach this floppy to the VM.
+          #
+          # NOTE: You need to do 'modprobe floppy' on Vm in order to
+          #       access /dev/fd0
+          #
+          spec[:config].merge!({
+            :deviceChange => [{
+              :operation => :add,
+              :device => RbVmomi::VIM.VirtualFloppy({
+                :key => 0,
+                :backing => RbVmomi::VIM.VirtualFloppyImageBackingInfo({
+                  :fileName => "[datastore1] floppy.img" # 'datastore1' is the datastore name, floppy.img is the filename in datastore
+                }),
+                :connectable => RbVmomi::VIM.VirtualDeviceConnectInfo({
+                  :connected => true,
+                  :allowGuestControl => true,
+                  :startConnected => true
+                })
+              })
+            }]
+          })
+        end
         #
         # WARNING: This operation may take a very long time (about 1m) to complete
         #
-- 
1.7.4.1