mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
Merge branch 'feature-863' of git.opennebula.org:one into feature-863
Conflicts: src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb
This commit is contained in:
commit
f167578f6e
50
install.sh
50
install.sh
@ -122,9 +122,9 @@ if [ -z "$ROOT" ] ; then
|
||||
elif [ "$OZONES" = "yes" ]; then
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $OZONES_LOCATION \
|
||||
$ETC_LOCATION"
|
||||
|
||||
|
||||
DELETE_DIRS="$MAKE_DIRS"
|
||||
|
||||
|
||||
CHOWN_DIRS=""
|
||||
else
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
|
||||
@ -162,8 +162,8 @@ else
|
||||
elif [ "$OZONES" = "yes" ]; then
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $OZONES_LOCATION \
|
||||
$ETC_LOCATION"
|
||||
|
||||
DELETE_DIRS="$MAKE_DIRS"
|
||||
|
||||
DELETE_DIRS="$MAKE_DIRS"
|
||||
else
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
|
||||
$INCLUDE_LOCATION $SHARE_LOCATION $IMAGES_LOCATION \
|
||||
@ -259,7 +259,7 @@ SUNSTONE_DIRS="$SUNSTONE_LOCATION/models \
|
||||
$SUNSTONE_LOCATION/public/images \
|
||||
$SUNSTONE_LOCATION/templates \
|
||||
$SUNSTONE_LOCATION/views"
|
||||
|
||||
|
||||
OZONES_DIRS="$OZONES_LOCATION/lib \
|
||||
$OZONES_LOCATION/lib/OZones \
|
||||
$OZONES_LOCATION/models \
|
||||
@ -338,8 +338,8 @@ INSTALL_FILES=(
|
||||
AUTH_SERVER_X509_FILES:$VAR_LOCATION/remotes/auth/server_x509
|
||||
AUTH_SERVER_CIPHER_FILES:$VAR_LOCATION/remotes/auth/server_cipher
|
||||
AUTH_DUMMY_FILES:$VAR_LOCATION/remotes/auth/dummy
|
||||
AUTH_PLAIN_FILES:$VAR_LOCATION/remotes/auth/plain
|
||||
AUTH_QUOTA_FILES:$VAR_LOCATION/remotes/auth/quota
|
||||
AUTH_PLAIN_FILES:$VAR_LOCATION/remotes/auth/plain
|
||||
AUTH_QUOTA_FILES:$VAR_LOCATION/remotes/auth/quota
|
||||
VMM_EXEC_KVM_SCRIPTS:$VAR_LOCATION/remotes/vmm/kvm
|
||||
VMM_EXEC_XEN_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen
|
||||
SHARED_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/shared
|
||||
@ -628,7 +628,8 @@ AUTH_QUOTA_FILES="src/authm_mad/remotes/quota/authorize"
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
NETWORK_FILES="src/vnm_mad/remotes/OpenNebulaNetwork.rb \
|
||||
src/vnm_mad/remotes/OpenNebulaNic.rb"
|
||||
src/vnm_mad/remotes/Firewall.rb \
|
||||
src/vnm_mad/remotes/OpenNebulaNic.rb"
|
||||
|
||||
NETWORK_8021Q_FILES="src/vnm_mad/remotes/802.1Q/clean \
|
||||
src/vnm_mad/remotes/802.1Q/post \
|
||||
@ -644,8 +645,9 @@ NETWORK_EBTABLES_FILES="src/vnm_mad/remotes/ebtables/clean \
|
||||
src/vnm_mad/remotes/ebtables/pre \
|
||||
src/vnm_mad/remotes/ebtables/Ebtables.rb"
|
||||
|
||||
NETWORK_FW_FILES="src/vnm_mad/remotes/fw/firewall \
|
||||
src/vnm_mad/remotes/fw/Firewall.rb"
|
||||
NETWORK_FW_FILES="src/vnm_mad/remotes/fw/post \
|
||||
src/vnm_mad/remotes/fw/pre \
|
||||
src/vnm_mad/remotes/fw/clean"
|
||||
|
||||
NETWORK_OVSWITCH_FILES="src/vnm_mad/remotes/ovswitch/clean \
|
||||
src/vnm_mad/remotes/ovswitch/post \
|
||||
@ -1066,7 +1068,7 @@ SUNSTONE_PUBLIC_IMAGES_FILES="src/sunstone/public/images/ajax-loader.gif \
|
||||
src/sunstone/public/images/Refresh-icon.png \
|
||||
src/sunstone/public/images/vnc_off.png \
|
||||
src/sunstone/public/images/vnc_on.png"
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Ozones files
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -1081,10 +1083,10 @@ OZONES_ETC_FILES="src/ozones/Server/etc/ozones-server.conf"
|
||||
OZONES_MODELS_FILES="src/ozones/Server/models/OzonesServer.rb \
|
||||
src/ozones/Server/models/Auth.rb \
|
||||
src/sunstone/models/OpenNebulaJSON/JSONUtils.rb"
|
||||
|
||||
|
||||
OZONES_TEMPLATE_FILES="src/ozones/Server/templates/index.html \
|
||||
src/ozones/Server/templates/login.html"
|
||||
|
||||
|
||||
OZONES_LIB_FILES="src/ozones/Server/lib/OZones.rb"
|
||||
|
||||
OZONES_LIB_ZONE_FILES="src/ozones/Server/lib/OZones/Zones.rb \
|
||||
@ -1098,7 +1100,7 @@ OZONES_LIB_ZONE_FILES="src/ozones/Server/lib/OZones/Zones.rb \
|
||||
src/ozones/Server/lib/OZones/AggregatedPool.rb \
|
||||
src/ozones/Server/lib/OZones/AggregatedImages.rb \
|
||||
src/ozones/Server/lib/OZones/AggregatedTemplates.rb"
|
||||
|
||||
|
||||
OZONES_LIB_API_FILES="src/ozones/Client/lib/zona.rb"
|
||||
|
||||
OZONES_LIB_API_ZONA_FILES="src/ozones/Client/lib/zona/ZoneElement.rb \
|
||||
@ -1110,7 +1112,7 @@ OZONES_LIB_API_ZONA_FILES="src/ozones/Client/lib/zona/ZoneElement.rb \
|
||||
src/ozones/Client/lib/zona/ZonePool.rb"
|
||||
|
||||
OZONES_PUBLIC_VENDOR_JQUERY=$SUNSTONE_PUBLIC_VENDOR_JQUERY
|
||||
|
||||
|
||||
OZONES_PUBLIC_VENDOR_DATATABLES=$SUNSTONE_PUBLIC_VENDOR_DATATABLES
|
||||
|
||||
OZONES_PUBLIC_VENDOR_JGROWL=$SUNSTONE_PUBLIC_VENDOR_JGROWL
|
||||
@ -1118,18 +1120,18 @@ OZONES_PUBLIC_VENDOR_JGROWL=$SUNSTONE_PUBLIC_VENDOR_JGROWL
|
||||
OZONES_PUBLIC_VENDOR_JQUERYUI=$SUNSTONE_PUBLIC_VENDOR_JQUERYUI
|
||||
|
||||
OZONES_PUBLIC_VENDOR_JQUERYLAYOUT=$SUNSTONE_PUBLIC_VENDOR_JQUERYLAYOUT
|
||||
|
||||
|
||||
OZONES_PUBLIC_JS_FILES="src/ozones/Server/public/js/ozones.js \
|
||||
src/ozones/Server/public/js/login.js \
|
||||
src/ozones/Server/public/js/ozones-util.js \
|
||||
src/sunstone/public/js/layout.js \
|
||||
src/sunstone/public/js/sunstone.js \
|
||||
src/sunstone/public/js/sunstone-util.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"
|
||||
|
||||
|
||||
OZONES_PUBLIC_IMAGES_FILES="src/ozones/Server/public/images/panel.png \
|
||||
src/ozones/Server/public/images/login.png \
|
||||
src/ozones/Server/public/images/login_over.png \
|
||||
@ -1143,16 +1145,16 @@ OZONES_PUBLIC_JS_PLUGINS_FILES="src/ozones/Server/public/js/plugins/zones-tab.js
|
||||
src/ozones/Server/public/js/plugins/vdcs-tab.js \
|
||||
src/ozones/Server/public/js/plugins/aggregated-tab.js \
|
||||
src/ozones/Server/public/js/plugins/dashboard-tab.js"
|
||||
|
||||
OZONES_LIB_CLIENT_CLI_FILES="src/ozones/Client/lib/cli/ozones_helper.rb"
|
||||
|
||||
|
||||
OZONES_LIB_CLIENT_CLI_FILES="src/ozones/Client/lib/cli/ozones_helper.rb"
|
||||
|
||||
OZONES_LIB_CLIENT_CLI_HELPER_FILES="\
|
||||
src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb \
|
||||
src/ozones/Client/lib/cli/ozones_helper/zones_helper.rb"
|
||||
src/ozones/Client/lib/cli/ozones_helper/zones_helper.rb"
|
||||
|
||||
OZONES_BIN_CLIENT_FILES="src/ozones/Client/bin/onevdc \
|
||||
src/ozones/Client/bin/onezone"
|
||||
|
||||
|
||||
OZONES_RUBY_LIB_FILES="src/oca/ruby/OpenNebula.rb"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -1229,7 +1231,7 @@ if [ "$CLIENT" = "yes" ]; then
|
||||
elif [ "$SUNSTONE" = "yes" ]; then
|
||||
INSTALL_SET="${INSTALL_SUNSTONE_RUBY_FILES[@]} ${INSTALL_SUNSTONE_FILES[@]}"
|
||||
elif [ "$OZONES" = "yes" ]; then
|
||||
INSTALL_SET="${INSTALL_OZONES_RUBY_FILES[@]} ${INSTALL_OZONES_FILES[@]}"
|
||||
INSTALL_SET="${INSTALL_OZONES_RUBY_FILES[@]} ${INSTALL_OZONES_FILES[@]}"
|
||||
else
|
||||
INSTALL_SET="${INSTALL_FILES[@]} ${INSTALL_OZONES_FILES[@]} \
|
||||
${INSTALL_SUNSTONE_FILES[@]}"
|
||||
|
@ -99,9 +99,10 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE TEMPLATE",false)
|
||||
puts vm.template_str
|
||||
|
||||
if vm['/VM/HISTORY_RECORDS/HISTORY']
|
||||
if vm.has_elements?("/VM/HISTORY_RECORDS/")
|
||||
puts
|
||||
|
||||
|
||||
|
||||
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE HISTORY",false)
|
||||
format_history(vm)
|
||||
end
|
||||
|
@ -60,10 +60,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Creates a new Host
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :hostname, :im_mad, :vmm_mad, :vnm_mad,
|
||||
:tm_mad do
|
||||
command :create, create_desc, :hostname, :im_mad, :vmm_mad,
|
||||
:tm_mad, :vnm_mad do
|
||||
helper.create_resource(options) do |host|
|
||||
host.allocate(args[0], args[1], args[2], args[3], args[4])
|
||||
host.allocate(args[0], args[1], args[2], args[4], args[3])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,7 +64,7 @@ class OpenNebulaHM < OpenNebulaNetwork
|
||||
|
||||
def device_exists?(dev, vlan=nil)
|
||||
dev = "#{dev}.#{vlan}" if vlan
|
||||
system("#{COMMANDS[:ip]} link show #{dev}")
|
||||
OpenNebula.exec_and_log("#{COMMANDS[:ip]} link show #{dev}")
|
||||
end
|
||||
|
||||
def create_dev_vlan(dev, vlan)
|
||||
|
@ -104,7 +104,7 @@ class OpenNebulaFirewall < OpenNebulaNetwork
|
||||
|
||||
def run_rules(rules)
|
||||
rules.flatten.each do |rule|
|
||||
system(rule)
|
||||
OpenNebula.exec_and_log(rule)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -52,7 +52,7 @@ class VM
|
||||
|
||||
nics = Nics.new(@hypervisor)
|
||||
|
||||
@vm_root.elements.each("TEMPLATE/NIC[VLAN=yes]") do |nic_element|
|
||||
@vm_root.elements.each("TEMPLATE/NIC[VLAN=YES]") do |nic_element|
|
||||
nic = nics.new_nic
|
||||
|
||||
nic_element.elements.each('*') do |nic_attribute|
|
||||
@ -98,7 +98,7 @@ class OpenNebulaNetwork
|
||||
|
||||
def initialize(vm_tpl, hypervisor=nil)
|
||||
if !hypervisor
|
||||
@hypervisor = detect_hypervisor
|
||||
@hypervisor = detect_hypervisor
|
||||
else
|
||||
@hypervisor = hypervisor
|
||||
end
|
||||
|
@ -31,8 +31,8 @@ class Nics < Array
|
||||
end
|
||||
|
||||
|
||||
# A NIC using KVM. This class implements functions to get the physical interface
|
||||
# that the NIC is using
|
||||
# A NIC using KVM. This class implements functions to get the physical interface
|
||||
# that the NIC is using
|
||||
class NicKVM < Hash
|
||||
def initialize
|
||||
super(nil)
|
||||
@ -70,8 +70,8 @@ class NicKVM < Hash
|
||||
end
|
||||
|
||||
|
||||
# A NIC using Xen. This class implements functions to get the physical interface
|
||||
# that the NIC is using
|
||||
# A NIC using Xen. This class implements functions to get the physical interface
|
||||
# that the NIC is using
|
||||
class NicXen < Hash
|
||||
def initialize
|
||||
super(nil)
|
||||
|
@ -6,17 +6,19 @@ $: << File.dirname(__FILE__) + '/../802.1Q'
|
||||
$: << File.dirname(__FILE__) + '/../ovswitch'
|
||||
$: << File.dirname(__FILE__) + '/../../../mad/ruby'
|
||||
$: << './'
|
||||
$: << File.dirname(__FILE__)
|
||||
$: << File.join(File.dirname(__FILE__), '..')
|
||||
$: << File.join(File.dirname(__FILE__),'../../../mad/ruby/')
|
||||
|
||||
require 'rubygems'
|
||||
require 'rspec'
|
||||
require 'SystemMock'
|
||||
require 'pp'
|
||||
|
||||
require 'OpenNebulaNetwork'
|
||||
require 'Ebtables'
|
||||
require 'ebtables/Ebtables'
|
||||
require 'Firewall'
|
||||
require 'HostManaged'
|
||||
require 'OpenvSwitch'
|
||||
require '802.1Q/HostManaged'
|
||||
require 'ovswitch/OpenvSwitch'
|
||||
|
||||
OUTPUT = Hash.new
|
||||
Dir[File.dirname(__FILE__) + "/output/**"].each do |f|
|
||||
@ -24,6 +26,9 @@ Dir[File.dirname(__FILE__) + "/output/**"].each do |f|
|
||||
OUTPUT[key] = File.read(f)
|
||||
end
|
||||
|
||||
require 'scripts_common'
|
||||
require 'SystemMock'
|
||||
include OpenNebula
|
||||
include SystemMock
|
||||
|
||||
RSpec.configure do |config|
|
||||
@ -60,21 +65,6 @@ describe 'networking' do
|
||||
onevlan.vm.nics.should == nics_expected
|
||||
end
|
||||
|
||||
it "filter nics in kvm" do
|
||||
$capture_commands = {
|
||||
/virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml]
|
||||
}
|
||||
onevlan = OpenNebulaNetwork.new(OUTPUT[:onevm_show],"kvm")
|
||||
onevlan.filter(:bridge => "br1")
|
||||
nics_expected = [{:bridge=>"br1",
|
||||
:ip=>"10.1.1.1",
|
||||
:mac=>"02:00:0a:01:01:01",
|
||||
:network=>"r1",
|
||||
:network_id=>"1",
|
||||
:tap=>"vnet1"}]
|
||||
|
||||
onevlan.vm.filtered_nics.should == nics_expected
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ebtables' do
|
||||
@ -92,7 +82,10 @@ describe 'ebtables' do
|
||||
"sudo /sbin/ebtables -A FORWARD -s ! 02:00:0a:01:01:01 -i vnet1 -j DROP",
|
||||
"sudo /sbin/ebtables -A FORWARD -s ! 02:00:0a:01:02:00/ff:ff:ff:ff:ff:00 -o vnet2 -j DROP",
|
||||
"sudo /sbin/ebtables -A FORWARD -s ! 02:00:0a:01:02:01 -i vnet2 -j DROP"]
|
||||
$collector[:system].should == ebtables_cmds
|
||||
|
||||
ebtables_cmds.map{|c| c + " 2>&1 1>/dev/null"}.each do |cmd|
|
||||
$collector[:backtick].include?(cmd).should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -110,7 +103,9 @@ describe 'openvswitch' do
|
||||
"sudo /usr/local/bin/ovs-vsctl set Port vnet2 tag=4"
|
||||
]
|
||||
|
||||
$collector[:system].should == openvswitch_tags
|
||||
openvswitch_tags.map{|c| c + " 2>&1 1>/dev/null"}.each do |cmd|
|
||||
$collector[:backtick].include?(cmd).should == true
|
||||
end
|
||||
end
|
||||
|
||||
it "force VLAN_ID for Open vSwitch vlans in kvm" do
|
||||
@ -121,12 +116,14 @@ describe 'openvswitch' do
|
||||
}
|
||||
onevlan = OpenvSwitchVLAN.new(OUTPUT[:onevm_show_vlan_id_kvm],"kvm")
|
||||
onevlan.activate
|
||||
|
||||
|
||||
onevlan_rules = ["sudo /usr/local/bin/ovs-vsctl set Port vnet0 tag=6",
|
||||
"sudo /usr/local/bin/ovs-vsctl set Port vnet1 tag=50",
|
||||
"sudo /usr/local/bin/ovs-vsctl set Port vnet1 tag=51"]
|
||||
|
||||
$collector[:system].should == onevlan_rules
|
||||
onevlan_rules.map{|c| c + " 2>&1 1>/dev/null"}.each do |cmd|
|
||||
$collector[:backtick].include?(cmd).should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -150,7 +147,9 @@ describe 'firewall' do
|
||||
"sudo /sbin/iptables -A one-36-3 -p icmp -m state --state ESTABLISHED -j ACCEPT",
|
||||
"sudo /sbin/iptables -A one-36-3 -p icmp -j DROP"]
|
||||
|
||||
$collector[:system].should == fw_activate_rules
|
||||
fw_activate_rules.map{|c| c + " 2>&1 1>/dev/null"}.each do |cmd|
|
||||
$collector[:backtick].include?(cmd).should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -159,20 +158,23 @@ describe 'host-managed' do
|
||||
$capture_commands = {
|
||||
/virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml_phydev],
|
||||
/brctl show/ => OUTPUT[:brctl_show],
|
||||
/brctl add/ => nil,
|
||||
/vconfig/ => nil,
|
||||
/ip link/ => nil
|
||||
/brctl add/ => nil,
|
||||
/vconfig/ => nil,
|
||||
/ip link/ => nil
|
||||
}
|
||||
hm = OpenNebulaHM.new(OUTPUT[:onevm_show_phydev_kvm],"kvm")
|
||||
hm.activate
|
||||
|
||||
hm_activate_rules = ["sudo /usr/sbin/brctl addbr onebr6",
|
||||
hm_activate_rules = ["sudo /sbin/brctl addbr onebr6",
|
||||
"sudo /sbin/ip link set onebr6 up",
|
||||
"sudo /sbin/ip link show eth0.8",
|
||||
"sudo /sbin/vconfig add eth0 8",
|
||||
"sudo /sbin/ip link set eth0.8 up",
|
||||
"sudo /usr/sbin/brctl addif onebr6 eth0.8"]
|
||||
$collector[:system].should == hm_activate_rules
|
||||
"sudo /sbin/brctl addif onebr6 eth0.8"]
|
||||
|
||||
hm_activate_rules.map{|c| c + " 2>&1 1>/dev/null"}.each do |cmd|
|
||||
$collector[:backtick].include?(cmd).should == true
|
||||
end
|
||||
end
|
||||
|
||||
it "force VLAN_ID for vlans in kvm" do
|
||||
@ -186,19 +188,21 @@ describe 'host-managed' do
|
||||
hm = OpenNebulaHM.new(OUTPUT[:onevm_show_vlan_id_kvm],"kvm")
|
||||
hm.activate
|
||||
|
||||
hm_vlan_id = ["sudo /usr/sbin/brctl addbr onebr10",
|
||||
hm_vlan_id = ["sudo /sbin/brctl addbr onebr10",
|
||||
"sudo /sbin/ip link set onebr10 up",
|
||||
"sudo /sbin/ip link show eth0.50",
|
||||
"sudo /sbin/vconfig add eth0 50",
|
||||
"sudo /sbin/ip link set eth0.50 up",
|
||||
"sudo /usr/sbin/brctl addif onebr10 eth0.50",
|
||||
"sudo /usr/sbin/brctl addbr specialbr",
|
||||
"sudo /sbin/brctl addif onebr10 eth0.50",
|
||||
"sudo /sbin/brctl addbr specialbr",
|
||||
"sudo /sbin/ip link set specialbr up",
|
||||
"sudo /sbin/ip link show eth0.51",
|
||||
"sudo /sbin/vconfig add eth0 51",
|
||||
"sudo /sbin/ip link set eth0.51 up",
|
||||
"sudo /usr/sbin/brctl addif specialbr eth0.51"]
|
||||
"sudo /sbin/brctl addif specialbr eth0.51"]
|
||||
|
||||
$collector[:system].should == hm_vlan_id
|
||||
hm_vlan_id.map{|c| c + " 2>&1 1>/dev/null"}.each do |cmd|
|
||||
$collector[:backtick].include?(cmd).should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,14 +1,15 @@
|
||||
module SystemMock
|
||||
require 'open3'
|
||||
|
||||
def execute_cmd(cmd)
|
||||
if $capture_commands
|
||||
$capture_commands.each do |regex, output|
|
||||
if cmd.match(regex)
|
||||
Kernel.send(:`,":;exit 0")
|
||||
return output
|
||||
end
|
||||
end
|
||||
end
|
||||
Open3.popen3(cmd){|stdin, stdout, stderr| stdout.read}
|
||||
Kernel.send(:`,cmd)
|
||||
end
|
||||
|
||||
def `(cmd)
|
||||
|
Loading…
x
Reference in New Issue
Block a user