Skip to content

Commit

Permalink
Added disk_count property. Resolves issue jedi4ever#86
Browse files Browse the repository at this point in the history
  • Loading branch information
manin committed Mar 1, 2013
1 parent 6ee5839 commit 3e60a37
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/veewee/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Definition
attr_writer :cpu_count, :memory_size

attr_accessor :video_memory_size, :iso_file
attr_accessor :disk_size, :disk_format, :disk_variant
attr_accessor :disk_size, :disk_format, :disk_variant, :disk_count

attr_accessor :os_type_id

Expand Down Expand Up @@ -83,7 +83,7 @@ def initialize(name, path, env)
@postinstall_files = [] ; @postinstall_timeout = 10000 ;

@iso_file = ""
@disk_size = '10240' ; @disk_format = 'VDI' ; @disk_variant = 'Standard'
@disk_size = '10240' ; @disk_format = 'VDI' ; @disk_variant = 'Standard' ; @disk_count = 1
@use_sata = true

# :hostiocache => 'off' ,
Expand Down
36 changes: 19 additions & 17 deletions lib/veewee/provider/virtualbox/box/helper/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def add_ide_controller
shell_exec("#{command}")
end

def add_sata_controller
def add_sata_controller
#unless => "${vboxcmd} showvminfo \"${vname}\" | grep \"SATA Controller\" ";
command ="#{@vboxcmd} storagectl \"#{name}\" --name \"SATA Controller\" --add sata --hostiocache #{definition.hostiocache} --sataportcount 1"
command ="#{@vboxcmd} storagectl \"#{name}\" --name \"SATA Controller\" --add sata --hostiocache #{definition.hostiocache} --sataportcount #{definition.disk_count}"
shell_exec("#{command}")
end

Expand Down Expand Up @@ -79,25 +79,27 @@ def suppress_messages


def create_disk
ui.info "Creating new harddrive of size #{definition.disk_size.to_i}, format #{definition.disk_format}, variant #{definition.disk_variant} "


place=get_vbox_home
command ="#{@vboxcmd} createhd --filename \"#{File.join(place,name,name+"."+definition.disk_format.downcase)}\" --size \"#{definition.disk_size.to_i}\" --format #{definition.disk_format.downcase} --variant #{definition.disk_variant.downcase}"
shell_exec("#{command}")

place=get_vbox_home
1.upto(definition.disk_count) do |f|
ui.info "Creating new harddrive of size #{definition.disk_size.to_i}, format #{definition.disk_format}, variant #{definition.disk_variant} "
command ="#{@vboxcmd} createhd --filename \"#{File.join(place,name,name+"#{f}."+definition.disk_format.downcase)}\" --size \"#{definition.disk_size.to_i}\" --format #{definition.disk_format.downcase} --variant #{definition.disk_variant.downcase}"
shell_exec("#{command}")
end
end

def attach_disk_common(storagectl, device_number)
place=get_vbox_home
location=name+"."+definition.disk_format.downcase

location="#{File.join(place,name,location)}"
ui.info "Attaching disk: #{location}"

#command => "${vboxcmd} storageattach \"${vname}\" --storagectl \"SATA Controller\" --port 0 --device 0 --type hdd --medium \"${vname}.vdi\"",
command ="#{@vboxcmd} storageattach \"#{name}\" --storagectl \"#{storagectl}\" --port 0 --device #{device_number} --type hdd --medium \"#{location}\""
shell_exec("#{command}")

1.upto(definition.disk_count) do |f|
location=name+"#{f}."+definition.disk_format.downcase

location="#{File.join(place,name,location)}"
ui.info "Attaching disk: #{location}"

#command => "${vboxcmd} storageattach \"${vname}\" --storagectl \"SATA Controller\" --port 0 --device 0 --type hdd --medium \"${vname}.vdi\"",
command ="#{@vboxcmd} storageattach \"#{name}\" --storagectl \"#{storagectl}\" --port #{f-1} --device #{device_number} --type hdd --medium \"#{location}\""
shell_exec("#{command}")
end
end

def attach_disk_ide(device_number=0)
Expand Down

0 comments on commit 3e60a37

Please sign in to comment.