Commits

Kaspar Schiess committed a9237d6

Introduces #ram and #cpus to control more vm params

  • Participants
  • Parent commits 58a5ae1
  • Tags r0.2.11

Comments (0)

Files changed (6)

 
+= 0.3.0
+  
+  + Allows controlling #ram and #cpus
+
 = 0.2.10 / 25Sep12
 
   ! Another bugfix: Don't cache answer from iscsiadm list target

File lib/mushroom/vm.rb

     # A list of network configuration statements that will be passed through
     # to qemu. 
     attr_reader :nets
+    # The number of cpus to configure, defaults to 2. 
+    attr_accessor :cpus
+    # Ram in megabytes
+    attr_accessor :ram
     
     def initialize(backend)
       @disks = []
       @nics = []
       @nets = []
+      @cpus = 2
+      @ram = 1024
       @backend = backend
     end
-    
+        
     def add_disk(path)
       @disks << path
     end
     #
     def command opts={}
       cmd = ''
-      cmd << " -m 1024 -name #{name}"
+      cmd << " -name #{name}"
+      cmd << " -m #{ram}"
       cmd << " -daemonize"
       cmd << ' -nographic'
-      cmd << " -cpu qemu64 -smp 2"
+      cmd << " -cpu qemu64 -smp #{cpus}"
       cmd << " -no-hpet -enable-kvm"
       cmd << " -vga cirrus"
       cmd << " -k de-ch"

File mushroom.gemspec

 
 Gem::Specification.new do |s|
   s.name = 'mushroom'
-  s.version = '0.2.10'
+  s.version = '0.2.11'
 
   s.authors = ['Kaspar Schiess']
   s.email = 'kaspar.schiess@technologyastronauts.ch'

File spec/fixture/etc/cpuram.rb

+virtual_machine "cpuram" do
+  disk '/dev/null'
+
+  cpus 4
+  ram  2048   # these are mbs 
+end

File spec/fixture/etc/foobar.rb

 
   # Network configuration
   # nic 'eth0', 
-  #   macaddr: '0:24:81:1a:9e:e4', 
+  #   macaddr: '0:24:81:54:97:fe', 
   #   via: 'igbX'
 end

File spec/lib/mushroom/vm_spec.rb

       command.should include('-drive file=/dev/rdsk/c4t600144F0503CC9000000503201B00001d0p1,if=virtio,index=1,media=disk,cache=none')
     end 
   end
+  describe 'cpus and ram' do
+    let(:cpuram) { Mushroom::VM['cpuram', backend] }
+    let(:command) { cpuram.command }
+    
+    it "sets the proper amount of smp cpus and ram" do
+      command.should match(/-m 2048/)
+      command.should match(/-smp 4 /)
+    end 
+  end
 
   describe '#target(host, port)' do
     it "returns an ISCSITarget instance" do