diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 81ab5670cf..68902b2916 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -48,7 +48,7 @@ DB = [ backend = "sqlite" ] # passwd = "oneadmin", # db_name = "opennebula" ] -VNC_BASE_PORT = 5000 +VNC_BASE_PORT = 5900 DEBUG_LEVEL=3 diff --git a/src/cloud/common/CloudServer.rb b/src/cloud/common/CloudServer.rb index 157da9366c..a957923f27 100755 --- a/src/cloud/common/CloudServer.rb +++ b/src/cloud/common/CloudServer.rb @@ -44,6 +44,10 @@ class CloudServer @config = Configuration.new(config_file) + if @config[:vm_type] == nil + raise "No VM_TYPE defined." + end + @instance_types = Hash.new if @config[:vm_type].kind_of?(Array) @@ -56,8 +60,9 @@ class CloudServer # --- Start an OpenNebula Session --- - @one_client = Client.new() + @one_client = Client.new(nil,@config[:one_xmlrpc]) @user_pool = UserPool.new(@one_client) + @img_repo = OpenNebula::ImageRepository.new end @@ -123,7 +128,7 @@ class CloudServer rc = @img_repo.create(image, template) file[:tempfile].unlink - + if OpenNebula.is_error?(rc) return rc end @@ -133,8 +138,8 @@ class CloudServer # Finds out if a port is available on ip # ip:: _String_ IP address where the port to check is - # port:: _String_ port to find out whether is open - # [return] _Boolean_ Newly created image object + # port:: _String_ port to find out whether is open + # [return] _Boolean_ Newly created image object def self.is_port_open?(ip, port) begin Timeout::timeout(2) do diff --git a/src/vmm/XenDriver.cc b/src/vmm/XenDriver.cc index 4866bd583e..53894ffd8d 100644 --- a/src/vmm/XenDriver.cc +++ b/src/vmm/XenDriver.cc @@ -320,7 +320,7 @@ int XenDriver::deployment_description( mac = nic->vector_value("MAC"); bridge = nic->vector_value("BRIDGE"); - + if( !mac.empty() ) { file << "mac=" << mac; @@ -367,7 +367,17 @@ int XenDriver::deployment_description( if ( !port.empty() ) { - file << ",vncdisplay=" << port; + istringstream iss(port); + int display; + + iss >> display; + + if ( iss.fail() || display < 5900 ) + { + goto error_vncdisplay; + } + + file << ",vncdisplay=" << display - 5900; } if ( !passwd.empty() ) @@ -441,4 +451,11 @@ error_disk: vm->log("VMM", Log::ERROR, "Wrong target value in DISK."); file.close(); return -1; + +error_vncdisplay: + vm->log("VMM", Log::ERROR, + "Could not generate a valid xen vncdisplay number, " + "vnc port number must be equal or above 5900."); + file.close(); + return -1; }