Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Finally working!

  • Loading branch information...
commit 16b83d191782c90c119a026dbea357ea716e81fa 1 parent 5733c27
@leehambley leehambley authored
Showing with 21 additions and 9 deletions.
  1. +9 −2 README.md
  2. +12 −7 app/mvmc.rb
View
11 README.md
@@ -8,11 +8,18 @@ That is both good and bad, but we have our reasons!
## Installation
-You'll need Ruby `1.9.3-p194` or greater, it was built against Ruby `2.0.0-p0.
+You'll need the `libvirt-dev` package for your platform, as well as `libvirt``
+and `virsh`:
+
+ # apt-get install -y libvirt-dev libvirt virsh
+ # apt-get install -y
+
+You'll also need Ruby `1.9.3-p194` or greater, it was built against Ruby
+`2.0.0-p0.
$ git clone https://github.com/protonet/mvmc protonet-mvmc
$ cd protonet-mvmc
- $ bundle
+ $ protonet_bundle
## Starting
View
19 app/mvmc.rb
@@ -4,14 +4,17 @@
require 'sinatra/content_for'
require 'sinatra/i18n'
-VIRSH_HOST = "protonet@cebit.local"
-VIRSH_URI = "qemu+ssh://#{VIRSH_HOST}/system?socket=/var/run/libvirt/libvirt-sock"
+VIRSH_HOST = ""
+VIRSH_URI = "qemu://#{VIRSH_HOST}/system?socket=/var/run/libvirt/libvirt-sock"
+VIRSH_POOL_DIR = "/var/lib/libvirt/images"
-VMS_DIR = File.expand_path(File.join(File.dirname(__FILE__), '../vms/'))
-ISOS_DIR = File.expand_path(File.join(File.dirname(__FILE__), '../isos/'))
+VMS_DIR = File.expand_path(File.join(File.dirname(__FILE__), '../vms/'))
+ISOS_DIR = File.expand_path(File.join(File.dirname(__FILE__), '../isos/'))
ISO = Struct.new(:basename, :mtime, :size)
+$libvirt = Libvirt::open(VIRSH_URI)
+
module Virsh
class StoragePool
@@ -68,7 +71,7 @@ def create_pool_xml
xml.pool type: :dir do |pool|
pool.name "virsh-images"
pool.target do |target|
- target.path "/root/virsh-images"
+ target.path VIRSH_POOL_DIR
end
end
warn xml.target!
@@ -126,7 +129,7 @@ def vnc_address_with_port
elements = doc.elements.to_a('/domain/devices/graphics')
ports = elements.collect { |e| e.attribute(:port).value }
port = ports.first
- "vnc://#{VIRSH_HOST}:#{port}"
+ "vnc://#{$libvirt.hostname}:#{port}"
end
class << self
@@ -239,7 +242,9 @@ def create_xml(name, cdisos, volume_paths)
video.address type: :pci, domain: '0x0000', bus: '0x00', slot: '0x02', function: '0x0'
end
- devices.graphics type: :vnc, port: -1
+ devices.graphics type: :vnc, autostart: :no, listen: '0.0.0.0' do |graphics|
+ graphics.listen type: :address, address: '0.0.0.0'
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.