Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Hector Sanjuan committed 2012-01-06 13:43:32 +01:00
commit c140b442fe
8 files changed
+236 -24

No files matched your search

+10 -3
View File
@@ -230,6 +230,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
$VAR_LOCATION/remotes/vnm/ebtables \
$VAR_LOCATION/remotes/vnm/fw \
$VAR_LOCATION/remotes/vnm/ovswitch \
$VAR_LOCATION/remotes/vnm/vmware \
$VAR_LOCATION/remotes/vmm/xen \
$VAR_LOCATION/remotes/vmm/vmware \
$VAR_LOCATION/remotes/hooks \
@@ -391,6 +392,7 @@ INSTALL_FILES=(
NETWORK_EBTABLES_FILES:$VAR_LOCATION/remotes/vnm/ebtables
NETWORK_FW_FILES:$VAR_LOCATION/remotes/vnm/fw
NETWORK_OVSWITCH_FILES:$VAR_LOCATION/remotes/vnm/ovswitch
NETWORK_VMWARE_FILES:$VAR_LOCATION/remotes/vnm/vmware
EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples
INSTALL_NOVNC_SHARE_FILE:$SHARE_LOCATION
INSTALL_GEMS_SHARE_FILE:$SHARE_LOCATION
@@ -745,6 +747,11 @@ NETWORK_OVSWITCH_FILES="src/vnm_mad/remotes/ovswitch/clean \
src/vnm_mad/remotes/ovswitch/pre \
src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb"
NETWORK_VMWARE_FILES="src/vnm_mad/remotes/vmware/clean \
src/vnm_mad/remotes/vmware/post \
src/vnm_mad/remotes/vmware/pre \
src/vnm_mad/remotes/vmware/VMware.rb"
#-------------------------------------------------------------------------------
# Transfer Manager commands, to be installed under $LIB_LOCATION/tm_commands
@@ -1196,7 +1203,7 @@ SUNSTONE_PUBLIC_IMAGES_FILES="src/sunstone/public/images/ajax-loader.gif \
src/sunstone/public/images/green_bullet.png \
src/sunstone/public/images/vnc_off.png \
src/sunstone/public/images/vnc_on.png"
SUNSTONE_PUBLIC_LOCALE_EN_US="\
src/sunstone/public/locale/en_US/en_US.js \
"
@@ -1268,7 +1275,7 @@ OZONES_PUBLIC_JS_FILES="src/ozones/Server/public/js/ozones.js \
src/sunstone/public/js/sunstone.js \
src/sunstone/public/js/sunstone-util.js \
src/sunstone/public/js/locale.js"
OZONES_PUBLIC_CSS_FILES="src/ozones/Server/public/css/application.css \
src/ozones/Server/public/css/layout.css \
src/ozones/Server/public/css/login.css"
@@ -1322,7 +1329,7 @@ SELF_SERVICE_PUBLIC_CSS_FILES="src/cloud/occi/lib/ui/public/css/application.css
src/cloud/occi/lib/ui/public/css/layout.css \
src/cloud/occi/lib/ui/public/css/login.css"
SELF_SERVICE_PUBLIC_CUSTOMIZE_FILES="src/cloud/occi/lib/ui/public/customize/custom.js"
SELF_SERVICE_PUBLIC_CUSTOMIZE_FILES="src/cloud/occi/lib/ui/public/customize/custom.js"
SELF_SERVICE_PUBLIC_VENDOR_DATATABLES=$SUNSTONE_PUBLIC_VENDOR_DATATABLES
+15 -18
View File
@@ -52,6 +52,7 @@ int LibVirtDriver::deployment_description_vmware(
const VectorAttribute * nic;
string network_id = "";
string mac = "";
string bridge = "";
string script = "";
@@ -163,7 +164,7 @@ int LibVirtDriver::deployment_description_vmware(
// ------------------------------------------------------------------------
file << "\t<devices>" << endl;
get_default("DISK","DRIVER",default_driver);
num = vm->get_template_attribute("DISK",attrs);
@@ -221,7 +222,7 @@ int LibVirtDriver::deployment_description_vmware(
{
file << "\t\t<disk type='file' device='cdrom'>" << endl;
file << "\t\t\t<source file=[" << datastore << "] " << vm->get_oid()
<< "/images/disk." << i << ".iso'/>" << endl;
<< "/images/disk." << i << ".iso'/>" << endl;
}
else
{
@@ -249,8 +250,8 @@ int LibVirtDriver::deployment_description_vmware(
{
if (!default_driver.empty())
{
file << "\t\t\t<driver name='" <<
default_driver << "'/>" << endl;
file << "\t\t\t<driver name='" <<
default_driver << "'/>" << endl;
}
}
@@ -306,21 +307,17 @@ int LibVirtDriver::deployment_description_vmware(
continue;
}
bridge = nic->vector_value("BRIDGE");
mac = nic->vector_value("MAC");
target = nic->vector_value("TARGET");
script = nic->vector_value("SCRIPT");
model = nic->vector_value("MODEL");
network_id = nic->vector_value("NETWORK_ID");
mac = nic->vector_value("MAC");
target = nic->vector_value("TARGET");
script = nic->vector_value("SCRIPT");
model = nic->vector_value("MODEL");
if ( bridge.empty() )
{
file << "\t\t<interface type='ethernet'>" << endl;
}
else
{
file << "\t\t<interface type='bridge'>" << endl;
file << "\t\t\t<source bridge='" << bridge << "'/>" << endl;
}
bridge = "one-pg-";
bridge.append(network_id);
file << "\t\t<interface type='bridge'>" << endl;
file << "\t\t\t<source bridge='" << bridge << "'/>" << endl;
if( !mac.empty() )
{
+3 -2
View File
@@ -24,6 +24,7 @@ require 'OpenNebulaNic'
require 'base64'
require 'scripts_common'
require 'CommandManager'
include OpenNebula
CONF = {
@@ -84,7 +85,7 @@ class VM
def [](element)
if @vm_root
val = @vm_root.elements[element]
if val.text
if !val.nil? and val.text
return val.text
end
end
@@ -106,7 +107,7 @@ class OpenNebulaNetwork
else
@hypervisor = hypervisor
end
@vm = VM.new(REXML::Document.new(vm_tpl).root, xpath_filter, deploy_id, @hypervisor)
end
+17 -1
View File
@@ -22,6 +22,8 @@ class Nics < Array
@nicClass = NicKVM
when "xen"
@nicClass = NicXen
when "vmware"
@nicClass = NicVMware
end
end
@@ -30,7 +32,6 @@ class Nics < Array
end
end
# A NIC using KVM. This class implements functions to get the physical interface
# that the NIC is using
class NicKVM < Hash
@@ -114,3 +115,18 @@ class NicXen < Hash
self
end
end
# A NIC using VMware. This class implements functions to get the physical interface
# that the NIC is using
class NicVMware < Hash
def initialize
super(nil)
end
def get_info(vm)
end
def get_tap(vm)
self
end
end
+123
View File
@@ -0,0 +1,123 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# -------------------------------------------------------------------------#
# Set up the environment for the driver #
# -------------------------------------------------------------------------#
ONE_LOCATION = ENV["ONE_LOCATION"]
if !ONE_LOCATION
ETC_LOCATION = "/etc/one/"
else
ETC_LOCATION = ONE_LOCATION + "/etc/"
end
CONF_FILE = ETC_LOCATION + "/vmwarerc"
require 'yaml'
require 'OpenNebulaNetwork'
class OpenNebulaVMware < OpenNebulaNetwork
XPATH_FILTER = "TEMPLATE/NIC"
VCLI_PREFIX = "/usr/bin/vicfg"
def initialize(vm, deploy_id = nil, hypervisor = nil)
super(vm,XPATH_FILTER,deploy_id,hypervisor)
@config = YAML::load(File.read(CONF_FILE))
set_conn_options
end
def set_conn_options
username = @config[:username]
password = @config[:password]
server = @vm['HISTORY_RECORDS/HISTORY/HOSTNAME']
@conn_options = "--username=#{username} " <<
"--password=#{password} " <<
"--server=#{server}"
end
def activate
vm_id = @vm['ID']
hostname = @vm['HISTORY_RECORDS/HISTORY/HOSTNAME']
process do |nic|
switch = nic[:bridge]
network_id = nic[:network_id]
pg = "one-pg-#{network_id}"
if nic[:vlan] == "YES"
if nic[:vlan_id]
vlan = nic[:vlan_id]
else
vlan = CONF[:start_vlan] + nic[:network_id].to_i
end
else
vlan = nil
end
add_pg(pg, switch, vlan) if !check_pg(pg, switch)
end
return 0
end
def vcli(command, params)
cmd = "#{VCLI_PREFIX}-#{command.to_s} #{@conn_options} #{params}"
end
def vswitch(params)
vcli(:vswitch, params)
end
def check_pg(pg, switch)
cmd = vcli(:vswitch, "--check-pg #{pg} #{switch}")
rc, output = do_action(cmd)
output.strip!
if output.match(/^\d+$/)
return output != "0"
else
OpenNebula.log_error("Unexpected output for #{cmd}:\n#{output}")
return false
end
end
def add_pg(pg, switch, vlan=nil)
add_pg_cmd = vcli(:vswitch, "--add-pg #{pg} #{switch}")
do_action(add_pg_cmd)
if vlan
set_vlan_cmd = vcli(:vswitch, "--vlan #{vlan} --pg #{pg} #{switch}")
do_action(set_vlan_cmd)
end
end
#Performs an action using vCLI
def do_action(cmd)
rc = LocalCommand.run(cmd)
if rc.code == 0
OpenNebula.log("Executed \"#{cmd}\".")
return [true, rc.stdout]
else
err = "Error executing: #{cmd} err: #{rc.stderr} out: #{rc.stdout}"
OpenNebula.log_error(err)
return [false, rc.code]
end
end
end
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
exit 0
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
exit 0
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# $stdout = $stderr
$: << File.dirname(__FILE__)
$: << File.join(File.dirname(__FILE__), "..")
require 'VMware'
deploy_id = nil
hypervisor = "vmware"
vm_64 = ARGV[0]
vmware = OpenNebulaVMware.from_base64(vm_64, deploy_id, hypervisor)
exit vmware.activate