From 02f90f33339011f62e61c496354294cac50dcc78 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 5 Dec 2011 15:29:22 +0100 Subject: [PATCH 01/27] Do not update userpool cache when the token expires --- src/cloud/common/CloudAuth.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cloud/common/CloudAuth.rb b/src/cloud/common/CloudAuth.rb index 3177e95247..7f02d68146 100644 --- a/src/cloud/common/CloudAuth.rb +++ b/src/cloud/common/CloudAuth.rb @@ -105,7 +105,6 @@ class CloudAuth if time_now > @token_expiration_time - EXPIRE_MARGIN @token_expiration_time = time_now + EXPIRE_DELTA - update_userpool_cache end @token_expiration_time From 908d5e137c458139fe2e09769a3f50790d8c5021 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 5 Dec 2011 16:57:25 +0100 Subject: [PATCH 02/27] feature #863: fix minor typo in xpath --- src/cli/one_helper/onevm_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index 1ecdd0ac87..02a0d838e0 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -99,10 +99,10 @@ class OneVMHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE TEMPLATE",false) puts vm.template_str - if vm.has_elements?("/VM/HISTORY_RECORDS/") + if vm.has_elements?("/VM/HISTORY_RECORDS") puts - - + + CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE HISTORY",false) format_history(vm) end From d7853c4a000ec15f1937deae7733fcff29d2a53d Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 5 Dec 2011 16:58:34 +0100 Subject: [PATCH 03/27] feature #863: don't use exec_and_log for commands that may fail --- src/vnm_mad/remotes/802.1Q/HostManaged.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vnm_mad/remotes/802.1Q/HostManaged.rb b/src/vnm_mad/remotes/802.1Q/HostManaged.rb index 47a65a3cce..28e9a602be 100644 --- a/src/vnm_mad/remotes/802.1Q/HostManaged.rb +++ b/src/vnm_mad/remotes/802.1Q/HostManaged.rb @@ -64,7 +64,8 @@ class OpenNebulaHM < OpenNebulaNetwork def device_exists?(dev, vlan=nil) dev = "#{dev}.#{vlan}" if vlan - OpenNebula.exec_and_log("#{COMMANDS[:ip]} link show #{dev}") + `#{COMMANDS[:ip]} link show #{dev}` + $?.exitstatus == 0 end def create_dev_vlan(dev, vlan) From 6aca0412d2ae6265167b0d08057f983901e0b8ed Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 5 Dec 2011 16:59:31 +0100 Subject: [PATCH 04/27] feature #863: add a test for vlan tag and fix other tests --- .../remotes/test/OpenNebulaNetwork_spec.rb | 59 ++++++++++---- src/vnm_mad/remotes/test/SystemMock.rb | 11 ++- .../remotes/test/output/onevm_show_mixed | 81 +++++++++++++++++++ 3 files changed, 134 insertions(+), 17 deletions(-) create mode 100644 src/vnm_mad/remotes/test/output/onevm_show_mixed diff --git a/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb b/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb index c06453ffb0..b97942055e 100644 --- a/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb +++ b/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb @@ -1,10 +1,10 @@ #!/usr/bin/env ruby -$: << File.dirname(__FILE__) + '/..' -$: << File.dirname(__FILE__) + '/../ebtables' -$: << File.dirname(__FILE__) + '/../802.1Q' -$: << File.dirname(__FILE__) + '/../ovswitch' -$: << File.dirname(__FILE__) + '/../../../mad/ruby' +$: << File.dirname(__FILE__) + '/..' +$: << File.dirname(__FILE__) + '/../ebtables' +$: << File.dirname(__FILE__) + '/../802.1Q' +$: << File.dirname(__FILE__) + '/../ovswitch' +$: << File.dirname(__FILE__) + '/../../../mad/ruby' $: << './' $: << File.dirname(__FILE__) $: << File.join(File.dirname(__FILE__), '..') @@ -159,34 +159,35 @@ end describe 'host-managed' do it "tag tun/tap devices with vlans in kvm" do $capture_commands = { - /virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml_phydev], + /virsh.*dumpxml/ => nil, /brctl show/ => OUTPUT[:brctl_show], - /brctl add/ => nil, + /brctl add/ => nil, /vconfig/ => nil, - /ip link/ => nil + /ip link set/ => nil, + /ip link show/ => [nil,255] } hm = OpenNebulaHM.new(OUTPUT[:onevm_show_phydev_kvm],"kvm") hm.activate 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 /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 + hm_activate_rules.each do |cmd| + $collector[:backtick].grep(Regexp.new("^"+cmd)).length.should >= 1 end end it "force VLAN_ID for vlans in kvm" do $capture_commands = { - /virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml_vlan_id], + /virsh.*dumpxml/ => nil, /brctl show/ => OUTPUT[:brctl_show], /brctl add/ => nil, /vconfig/ => nil, - /ip link/ => nil + /ip link set/ => nil, + /ip link show/ => [nil,255] } hm = OpenNebulaHM.new(OUTPUT[:onevm_show_vlan_id_kvm],"kvm") hm.activate @@ -204,8 +205,36 @@ describe 'host-managed' do "sudo /sbin/ip link set eth0.51 up", "sudo /sbin/brctl addif specialbr eth0.51"] - hm_vlan_id.map{|c| c + " 2>&1 1>/dev/null"}.each do |cmd| - $collector[:backtick].include?(cmd).should == true + hm_vlan_id.each do |cmd| + $collector[:backtick].grep(Regexp.new("^"+cmd)).length.should >= 1 + end + end + + it "ignore interfaces that don't have vlan=yes" do + $capture_commands = { + /virsh.*dumpxml/ => nil, + /brctl show/ => OUTPUT[:brctl_show], + /brctl add/ => nil, + /vconfig/ => nil, + /ip link set/ => nil, + /ip link show/ => [nil,255] + } + + + + hm = OpenNebulaHM.new(OUTPUT[:onevm_show_mixed],"kvm") + hm.activate + + hm_vlan_tag = [ "sudo /sbin/brctl show", + "sudo /sbin/brctl addbr onebr1", + "sudo /sbin/ip link set onebr1 up", + "sudo /sbin/ip link show eth0.50", + "sudo /sbin/vconfig add eth0 50", + "sudo /sbin/ip link set eth0.50 up", + "sudo /sbin/brctl addif onebr1 eth0.50" ] + + hm_vlan_tag.each do |cmd| + $collector[:backtick].grep(Regexp.new("^"+cmd)).length.should >= 1 end end end diff --git a/src/vnm_mad/remotes/test/SystemMock.rb b/src/vnm_mad/remotes/test/SystemMock.rb index 6e83e85411..e1447a4ff3 100644 --- a/src/vnm_mad/remotes/test/SystemMock.rb +++ b/src/vnm_mad/remotes/test/SystemMock.rb @@ -2,9 +2,16 @@ module SystemMock def execute_cmd(cmd) if $capture_commands - $capture_commands.each do |regex, output| + $capture_commands.each do |regex, params| + code = nil + if params.instance_of? Array + output, code = params + else + output = params + end + code ||= 0 if cmd.match(regex) - Kernel.send(:`,":;exit 0") + Kernel.send(:`,":;exit #{code}") return output end end diff --git a/src/vnm_mad/remotes/test/output/onevm_show_mixed b/src/vnm_mad/remotes/test/output/onevm_show_mixed new file mode 100644 index 0000000000..a45abbf003 --- /dev/null +++ b/src/vnm_mad/remotes/test/output/onevm_show_mixed @@ -0,0 +1,81 @@ + + 12 + 0 + 0 + oneadmin + oneadmin + ttylinux + 1323096916 + 3 + 3 + 1323096908 + 0 + one-12 + 0 + 0 + 0 + 0 + + + + 0 + localhost + /var/lib/one/ + 1 + 1323096914 + 0 + vmm_kvm + 802.1Q + tm_shared + 1323096914 + 1323096914 + 1323096914 + 0 + 0 + 0 + 0 + + + From 09aa1a7df331fc8df0668652256347926f820c6e Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 5 Dec 2011 17:43:16 +0100 Subject: [PATCH 05/27] features #914, #949: --check and faster install_gems * added --check options that detects the ruby libraries not installed * only install gems not found * execute 'gem' only once when possible --- share/install_gems/install_gems | 156 +++++++++++++++++++++++++------- 1 file changed, 122 insertions(+), 34 deletions(-) diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index d0c44fc7db..46e2b29ee4 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -2,9 +2,6 @@ require 'pp' -PACKAGES=%w{optional sunstone quota cloud ozones_client ozones_server - ozones_server_mysql ozones_server_sqlite} - DEFAULT=%w{optional sunstone quota cloud ozones_server acct} if defined?(RUBY_VERSION) && RUBY_VERSION>="1.8.7" @@ -12,6 +9,10 @@ if defined?(RUBY_VERSION) && RUBY_VERSION>="1.8.7" # xmlparser gem is not compatible with ruby 1.9 OPTIONAL=%w{nokogiri} + + if RUBY_VERSION=='1.8.7' + OPTIONAL << 'xmlparser' + end else SQLITE='sqlite3-ruby --version 1.2.0' OPTIONAL=%w{nokogiri xmlparser} @@ -33,6 +34,8 @@ GROUPS={ :acct_mysql => ['sequel', 'mysql'] } +PACKAGES=GROUPS.keys + DISTRIBUTIONS={ :debian => { :id => ['Ubuntu', 'Debian'], @@ -82,6 +85,15 @@ class String end end +def installed_gems + text=`gem list --no-versions --no-details` + if $?.exitstatus!=0 + nil + else + text.split(/\s+/) + end +end + def try_library(name, error_message) begin require name.to_s @@ -107,12 +119,14 @@ def help puts puts "If no parameters are specified then this list will be used:" puts DEFAULT.join(' ') + puts + puts "Use --check parameter to search for non installed libraries." end def get_gems(packages) packages.map do |package| GROUPS[package.to_sym] - end.flatten.uniq + end.flatten.uniq-installed_gems end def detect_distro @@ -191,6 +205,88 @@ def install_dependencies(gems, distro) end end +def run_command(cmd) + puts cmd + system cmd + #system "true" + + if $?!=0 + puts "Error executing #{cmd}" + exit(-1) + end +end + +def install_gems(packages) + gems_list=get_gems(packages) + + if gems_list.empty? + puts "Gems already installed" + exit(0) + end + + dist=detect_distro + + install_dependencies(gems_list, dist) + + packages_string=gems_list.join(' ') + + prefix="" + + if dist && dist.last[:gem_env] + prefix=dist.last[:gem_env].collect do |name, value| + "#{name}=\"#{value}\"" + end.join(' ')+' ' + end + + command_string = "#{prefix}gem install --no-ri --no-rdoc" + + install_warning(packages) + + simple_gems=gems_list.select {|g| !(g.match(/\s/)) } + if simple_gems and !simple_gems.empty? + cmd=command_string+" " << simple_gems.join(' ') + run_command(cmd) + end + + special_gems=gems_list.select {|g| g.match(/\s/) } + special_gems.each do |gem| + cmd=command_string+" "<0 - packages=ARGV +if params.length>0 + packages=params else packages=DEFAULT end -gems_list=get_gems(packages) -dist=detect_distro - -install_dependencies(gems_list, dist) - -packages_string=gems_list.join(' ') - -prefix="" - -if dist && dist.last[:gem_env] - prefix=dist.last[:gem_env].collect do |name, value| - "#{name}=\"#{value}\"" - end.join(' ')+' ' +case command +when 'help' + help + exit(0) +when 'check' + check_gems(packages) +when 'install' + install_gems(packages) end -command_string = "#{prefix}gem install --no-ri --no-rdoc" -install_warning(packages) -gems_list.each do |gem| - cmd=command_string+" "< Date: Mon, 5 Dec 2011 17:56:34 +0100 Subject: [PATCH 06/27] Bump to version 3.1.80 --- include/Nebula.h | 4 +- share/man/econe-describe-images.1 | 2 +- share/man/econe-describe-instances.1 | 2 +- share/man/econe-register.1 | 2 +- share/man/econe-run-instances.1 | 2 +- share/man/econe-terminate-instances.1 | 2 +- share/man/econe-upload.1 | 2 +- share/man/occi-compute.1 | 2 +- share/man/occi-network.1 | 2 +- share/man/occi-storage.1 | 2 +- share/man/oneacl.1 | 4 +- share/man/onedb.1 | 11 +- share/man/onegroup.1 | 4 +- share/man/onehost.1 | 6 +- share/man/oneimage.1 | 18 ++- share/man/onetemplate.1 | 4 +- share/man/oneuser.1 | 49 ++++++- share/man/onevdc.1 | 179 +------------------------ share/man/onevm.1 | 6 +- share/man/onevnet.1 | 50 ++++++- share/man/onezone.1 | 151 +-------------------- src/cli/one_helper.rb | 2 +- src/cloud/common/CloudClient.rb | 2 +- src/ozones/Server/templates/index.html | 2 +- src/sunstone/views/index.erb | 2 +- 25 files changed, 136 insertions(+), 376 deletions(-) diff --git a/include/Nebula.h b/include/Nebula.h index 1048358887..ef6575cff6 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -228,12 +228,12 @@ public: static string version() { - return "OpenNebula 3.1.0"; + return "OpenNebula 3.1.80"; }; static string db_version() { - return "3.1.0"; + return "3.1.80"; } void start(); diff --git a/share/man/econe-describe-images.1 b/share/man/econe-describe-images.1 index 975ca7f8fd..2b5bb362c8 100644 --- a/share/man/econe-describe-images.1 +++ b/share/man/econe-describe-images.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands" +.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-describe-images .SH SYNOPSIS diff --git a/share/man/econe-describe-instances.1 b/share/man/econe-describe-instances.1 index ec9e972991..514180ea31 100644 --- a/share/man/econe-describe-instances.1 +++ b/share/man/econe-describe-instances.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands" +.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-describe-instances .SH SYNOPSIS diff --git a/share/man/econe-register.1 b/share/man/econe-register.1 index 1db1a75d02..2f542b3901 100644 --- a/share/man/econe-register.1 +++ b/share/man/econe-register.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands" +.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-register .SH SYNOPSIS diff --git a/share/man/econe-run-instances.1 b/share/man/econe-run-instances.1 index 92ab73a6d2..01695748dc 100644 --- a/share/man/econe-run-instances.1 +++ b/share/man/econe-run-instances.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands" +.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-run-instances .SH SYNOPSIS diff --git a/share/man/econe-terminate-instances.1 b/share/man/econe-terminate-instances.1 index f39fb6b867..e74a983734 100644 --- a/share/man/econe-terminate-instances.1 +++ b/share/man/econe-terminate-instances.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands" +.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-terminate-instances .SH SYNOPSIS diff --git a/share/man/econe-upload.1 b/share/man/econe-upload.1 index 10239bc1d3..424f0ab75c 100644 --- a/share/man/econe-upload.1 +++ b/share/man/econe-upload.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands" +.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.1.80" "User Commands" .SH NAME OpenNebula \- OpenNebula econe-upload .SH SYNOPSIS diff --git a/share/man/occi-compute.1 b/share/man/occi-compute.1 index 7e2276bb51..b4d112e9e6 100644 --- a/share/man/occi-compute.1 +++ b/share/man/occi-compute.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands" +.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands" .SH NAME OpenNebula \- OpenNebula occi-compute .SH SYNOPSIS diff --git a/share/man/occi-network.1 b/share/man/occi-network.1 index 21ae49696c..e63a1659ea 100644 --- a/share/man/occi-network.1 +++ b/share/man/occi-network.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands" +.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands" .SH NAME OpenNebula \- OpenNebula occi-network .SH SYNOPSIS diff --git a/share/man/occi-storage.1 b/share/man/occi-storage.1 index e63697e535..5c6b6865f1 100644 --- a/share/man/occi-storage.1 +++ b/share/man/occi-storage.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1. -.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands" +.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands" .SH NAME OpenNebula \- OpenNebula occi-storage .SH SYNOPSIS diff --git a/share/man/oneacl.1 b/share/man/oneacl.1 index 874513861c..56635977c5 100644 --- a/share/man/oneacl.1 +++ b/share/man/oneacl.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEACL" "1" "September 2011" "" "oneacl(1) -- manages OpenNebula ACLs" +.TH "ONEACL" "1" "December 2011" "" "oneacl(1) -- manages OpenNebula ACLs" . .SH "NAME" \fBoneacl\fR @@ -128,7 +128,7 @@ Comma\-separated list of OpenNebula ACL names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) . .P 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 diff --git a/share/man/onedb.1 b/share/man/onedb.1 index 91683af3ab..2c0bc12d35 100644 --- a/share/man/onedb.1 +++ b/share/man/onedb.1 @@ -1,21 +1,12 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEDB" "1" "September 2011" "" "onedb(1) -- OpenNebula database migration tool" +.TH "ONEDB" "1" "December 2011" "" "onedb(1) -- OpenNebula database migration tool" . .SH "NAME" \fBonedb\fR . .P -DB Connection options: -. -.P -By default, onedb reads the connection data from oned\.conf If any of these options is set, oned\.conf is ignored (i\.e\. if you set MySQL\'s port onedb won\'t look for the rest of the options in oned\.conf) -. -.P -Description: -. -.P This command enables the user to manage the OpenNebula database\. It provides information about the DB version, means to upgrade it to the latest version, and backup tools\. . .SH "OPTIONS" diff --git a/share/man/onegroup.1 b/share/man/onegroup.1 index 32bf32f9be..7434605887 100644 --- a/share/man/onegroup.1 +++ b/share/man/onegroup.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEGROUP" "1" "September 2011" "" "onegroup(1) -- manages OpenNebula groups" +.TH "ONEGROUP" "1" "December 2011" "" "onegroup(1) -- manages OpenNebula groups" . .SH "NAME" \fBonegroup\fR @@ -160,7 +160,7 @@ Comma\-separated list of OpenNebula GROUP names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) . .P 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 diff --git a/share/man/onehost.1 b/share/man/onehost.1 index 0082e1339f..bc2f1d15e2 100644 --- a/share/man/onehost.1 +++ b/share/man/onehost.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEHOST" "1" "September 2011" "" "onehost(1) -- manages OpenNebula hosts" +.TH "ONEHOST" "1" "December 2011" "" "onehost(1) -- manages OpenNebula hosts" . .SH "NAME" \fBonehost\fR @@ -27,7 +27,7 @@ .SH "COMMANDS" . .IP "\(bu" 4 -create \fIhostname\fR \fIim_mad\fR \fIvmm_mad\fR \fItm_mad\fR +create \fIhostname\fR \fIim_mad\fR \fIvmm_mad\fR \fItm_mad\fR \fIvnm_mad\fR . .IP "" 4 . @@ -234,7 +234,7 @@ Comma\-separated list of OpenNebula HOST names or ids .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) . .P 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 diff --git a/share/man/oneimage.1 b/share/man/oneimage.1 index b100089273..f984ee317f 100644 --- a/share/man/oneimage.1 +++ b/share/man/oneimage.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEIMAGE" "1" "September 2011" "" "oneimage(1) -- manages OpenNebula images" +.TH "ONEIMAGE" "1" "December 2011" "" "oneimage(1) -- manages OpenNebula images" . .SH "NAME" \fBoneimage\fR @@ -141,6 +141,20 @@ Enables the given Image . .IP "" 0 +. +.IP "\(bu" 4 +chtype \fIrange|imageid_list\fR \fItype\fR +. +.IP "" 4 +. +.nf + +Changes the Image\'s type +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 disable \fIrange|imageid_list\fR @@ -353,7 +367,7 @@ user IMAGE of the user identified by the username .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) . .P 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 diff --git a/share/man/onetemplate.1 b/share/man/onetemplate.1 index 7a3f23139a..4e7688cad6 100644 --- a/share/man/onetemplate.1 +++ b/share/man/onetemplate.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONETEMPLATE" "1" "September 2011" "" "onetemplate(1) -- manages OpenNebula templates" +.TH "ONETEMPLATE" "1" "December 2011" "" "onetemplate(1) -- manages OpenNebula templates" . .SH "NAME" \fBonetemplate\fR @@ -312,7 +312,7 @@ user VMTEMPLATE of the user identified by the username .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) . .P 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 diff --git a/share/man/oneuser.1 b/share/man/oneuser.1 index 8bed68c785..3dc6ea80e4 100644 --- a/share/man/oneuser.1 +++ b/share/man/oneuser.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEUSER" "1" "September 2011" "" "oneuser(1) -- manages OpenNebula users" +.TH "ONEUSER" "1" "December 2011" "" "oneuser(1) -- manages OpenNebula users" . .SH "NAME" \fBoneuser\fR @@ -14,11 +14,12 @@ .nf \-r, \-\-read\-file Read password from file - \-p, \-\-plain Store plain password + \-\-sha1 The password will be hashed using the sha1 algorithm \-\-ssh SSH Auth system \-\-x509 x509 Auth system for x509 certificates \-k, \-\-key path_to_private_key_pem Path to the Private Key of the User \-c, \-\-cert path_to_user_cert_pem Path to the Certificate of the User + \-\-driver driver Driver to autehnticate this user \-\-x509_proxy x509 Auth system based on x509 proxy certificates \-\-proxy path_to_user_proxy_pem Path to the user proxy certificate \-\-time x Token duration in seconds, defaults to 3600 (1 h) @@ -44,11 +45,25 @@ create \fIusername\fR [\fIpassword\fR] Creates a new User Examples: oneuser create my_user my_password - oneuser create my_user /tmp/mypass \-r + oneuser create my_user \-r /tmp/mypass oneuser create my_user \-\-ssh \-\-key /tmp/id_rsa oneuser create my_user \-\-ssh \-r /tmp/public_key oneuser create my_user \-\-x509 \-\-cert /tmp/my_cert\.pem -valid options: read_file, plain, ssh, x509, key, cert +valid options: read_file, sha1, ssh, x509, key, cert, driver +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +update \fIuserid\fR +. +.IP "" 4 +. +.nf + +Launches the system editor to modify and update the template contents . .fi . @@ -112,7 +127,7 @@ passwd \fIuserid\fR [\fIpassword\fR] .nf Changes the given User\'s password -valid options: read_file, plain, ssh, x509, key, cert +valid options: read_file, sha1, ssh, x509, key, cert, driver . .fi . @@ -132,6 +147,28 @@ Changes the User\'s main group . .IP "" 0 +. +.IP "\(bu" 4 +chauth \fIuserid\fR [\fIauth\fR] [\fIpassword\fR] +. +.IP "" 4 +. +.nf + +Changes the User\'s auth driver and its password (optional) +Examples: + oneuser chauth my_user core + oneuser chauth my_user core new_password + oneuser chauth my_user core \-r /tmp/mypass + oneuser chauth my_user \-\-ssh \-\-key /home/oneadmin/\.ssh/id_rsa + oneuser chauth my_user \-\-ssh \-r /tmp/public_key + oneuser chauth my_user \-\-x509 \-\-cert /tmp/my_cert\.pem +valid options: read_file, sha1, ssh, x509, key, cert, driver +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 list @@ -268,7 +305,7 @@ User password .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) . .P 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 diff --git a/share/man/onevdc.1 b/share/man/onevdc.1 index c6aa1c9e5a..c0113faa15 100644 --- a/share/man/onevdc.1 +++ b/share/man/onevdc.1 @@ -1,184 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEVDC" "1" "September 2011" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" +.TH "ONEVDC" "1" "December 2011" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters" . .SH "NAME" \fBonevdc\fR -. -.SH "SYNOPSIS" -\fBonevdc\fR command [\fIargs\fR] [\fIoptions\fR] -. -.SH "OPTIONS" -. -.nf - - \-f, \-\-force Force the usage of Hosts in more than one VDC - \-l, \-\-list x,y,z Selects columns to display with list command - \-d, \-\-delay x Sets the delay in seconds for top command - \-x, \-\-xml Show the resource in xml format - \-n, \-\-numeric Do not translate user and group IDs - \-k, \-\-kilobytes Show units in kilobytes - \-v, \-\-verbose Verbose mode - \-h, \-\-help Show this message - \-V, \-\-version Show version and copyright information -. -.fi -. -.SH "COMMANDS" -. -.IP "\(bu" 4 -create \fIfile\fR -. -.IP "" 4 -. -.nf - -Create a new VDC -valid options: force -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -show \fIvdcid\fR -. -.IP "" 4 -. -.nf - -Show information of a particular VDC -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -list -. -.IP "" 4 -. -.nf - -Lists VDCs in the pool -valid options: list, delay, xml, numeric, kilobytes -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -delete \fIvdcid\fR -. -.IP "" 4 -. -.nf - -Deletes a VDC -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -addhost \fIvdcid\fR \fIrange\fR -. -.IP "" 4 -. -.nf - -Adds the set of hosts to the VDC -valid options: force -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -delhost \fIvdcid\fR \fIrange\fR -. -.IP "" 4 -. -.nf - -Deletes the set of hosts from the VDC -valid options: force -. -.fi -. -.IP "" 0 - -. -.IP "" 0 -. -.SH "ARGUMENT FORMATS" -. -.IP "\(bu" 4 -file -. -.IP "" 4 -. -.nf - -Path to a file -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -range -. -.IP "" 4 -. -.nf - -List of id\'s in the form 1,8\.\.15 -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -text -. -.IP "" 4 -. -.nf - -String -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -vdcid -. -.IP "" 4 -. -.nf - -VDC ID -. -.fi -. -.IP "" 0 - -. -.IP "" 0 -. -.SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) -. -.P -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 diff --git a/share/man/onevm.1 b/share/man/onevm.1 index 7ecebedb64..d39165017c 100644 --- a/share/man/onevm.1 +++ b/share/man/onevm.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEVM" "1" "September 2011" "" "onevm(1) -- manages OpenNebula virtual machines" +.TH "ONEVM" "1" "December 2011" "" "onevm(1) -- manages OpenNebula virtual machines" . .SH "NAME" \fBonevm\fR @@ -17,6 +17,7 @@ \-x, \-\-xml Show the resource in xml format \-n, \-\-numeric Do not translate user and group IDs \-k, \-\-kilobytes Show units in kilobytes + \-t, \-\-type type Type of the new Image \-l, \-\-list x,y,z Selects columns to display with list command \-d, \-\-delay x Sets the delay in seconds for top command \-v, \-\-verbose Verbose mode @@ -106,6 +107,7 @@ shut down gracefuly (i\.e\., using \'onevm shutdown\' and not \'onevm delete\') States: ANY +valid options: type . .fi . @@ -493,7 +495,7 @@ user VM of the user identified by the username .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) . .P 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 diff --git a/share/man/onevnet.1 b/share/man/onevnet.1 index 75844a4749..40801443b4 100644 --- a/share/man/onevnet.1 +++ b/share/man/onevnet.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEVNET" "1" "September 2011" "" "onevnet(1) -- manages OpenNebula networks" +.TH "ONEVNET" "1" "December 2011" "" "onevnet(1) -- manages OpenNebula networks" . .SH "NAME" \fBonevnet\fR @@ -81,6 +81,34 @@ Removes a lease from the Virtual Network . .IP "" 0 +. +.IP "\(bu" 4 +hold \fIvnetid\fR \fIip\fR +. +.IP "" 4 +. +.nf + +Holds a Virtual Network lease, marking it as used +. +.fi +. +.IP "" 0 + +. +.IP "\(bu" 4 +release \fIvnetid\fR \fIip\fR +. +.IP "" 4 +. +.nf + +Releases a Virtual Network lease on hold +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 publish \fIrange|vnetid_list\fR @@ -113,7 +141,7 @@ can\'t be used by any other User . .IP "\(bu" 4 -chgrp \fIrange|vnid_list\fR \fIgroupid\fR +chgrp \fIrange|vnetid_list\fR \fIgroupid\fR . .IP "" 4 . @@ -127,7 +155,7 @@ Changes the Virtual Network group . .IP "\(bu" 4 -chown \fIrange|vnid_list\fR \fIuserid\fR [\fIgroupid\fR] +chown \fIrange|vnetid_list\fR \fIuserid\fR [\fIgroupid\fR] . .IP "" 4 . @@ -169,6 +197,20 @@ valid options: xml . .IP "" 0 +. +.IP "\(bu" 4 +update \fIvnetid\fR +. +.IP "" 4 +. +.nf + +Launches the system editor to modify and update the template contents +. +.fi +. +.IP "" 0 + . .IP "" 0 . @@ -294,7 +336,7 @@ user VNET of the user identified by the username .IP "" 0 . .SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) +OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) . .P 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 diff --git a/share/man/onezone.1 b/share/man/onezone.1 index f6467d59fd..ca66f3191b 100644 --- a/share/man/onezone.1 +++ b/share/man/onezone.1 @@ -1,156 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ONEZONE" "1" "September 2011" "" "onezone(1) -- manages OpenNebula zones" +.TH "ONEZONE" "1" "December 2011" "" "onezone(1) -- manages OpenNebula zones" . .SH "NAME" \fBonezone\fR -. -.SH "SYNOPSIS" -\fBonezone\fR \fIcommand\fR [\fIargs\fR] [\fIoptions\fR] -. -.SH "OPTIONS" -. -.nf - - \-l, \-\-list x,y,z Selects columns to display with list command - \-d, \-\-delay x Sets the delay in seconds for top command - \-x, \-\-xml Show the resource in xml format - \-n, \-\-numeric Do not translate user and group IDs - \-k, \-\-kilobytes Show units in kilobytes - \-v, \-\-verbose Verbose mode - \-h, \-\-help Show this message - \-V, \-\-version Show version and copyright information -. -.fi -. -.SH "COMMANDS" -. -.IP "\(bu" 4 -create \fIfile\fR -. -.IP "" 4 -. -.nf - -Create a new Zone -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -show \fIzoneid\fR [\fIresource\fR] -. -.IP "" 4 -. -.nf - -Show information of a particular Zone -Available resources: host, vm, image, vn, template, user -Examples: - onezone show 4 - onezone show 4 host -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -list -. -.IP "" 4 -. -.nf - -Lists Zones in the pool -valid options: list, delay, xml, numeric, kilobytes -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -delete \fIzoneid\fR -. -.IP "" 4 -. -.nf - -Deletes a Zone -. -.fi -. -.IP "" 0 - -. -.IP "" 0 -. -.SH "ARGUMENT FORMATS" -. -.IP "\(bu" 4 -file -. -.IP "" 4 -. -.nf - -Path to a file -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -range -. -.IP "" 4 -. -.nf - -List of id\'s in the form 1,8\.\.15 -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -text -. -.IP "" 4 -. -.nf - -String -. -.fi -. -.IP "" 0 - -. -.IP "\(bu" 4 -zoneid -. -.IP "" 4 -. -.nf - -Zone ID -. -.fi -. -.IP "" 0 - -. -.IP "" 0 -. -.SH "LICENSE" -OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org) -. -.P -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 diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 18e684674e..7b542e468f 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -21,7 +21,7 @@ include OpenNebula module OpenNebulaHelper ONE_VERSION=<<-EOT -OpenNebula 3.1.0 +OpenNebula 3.1.80 Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/src/cloud/common/CloudClient.rb b/src/cloud/common/CloudClient.rb index 176471419b..562888917d 100644 --- a/src/cloud/common/CloudClient.rb +++ b/src/cloud/common/CloudClient.rb @@ -173,7 +173,7 @@ module CloudCLI def version_text version=< diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index 9140aafa6e..a6f1938409 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -67,7 +67,7 @@ From 547d0985eae7a270f5d81009f22c0e74af09c5fd Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 1 Dec 2011 18:03:16 +0000 Subject: [PATCH 07/27] fix a bug setting quota configuration (cherry picked from commit d1054d465e463a1d99a46585a1bbfac8cfe4ef47) --- src/authm_mad/remotes/quota/quota.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/authm_mad/remotes/quota/quota.rb b/src/authm_mad/remotes/quota/quota.rb index 9037c94510..b9b29393bb 100644 --- a/src/authm_mad/remotes/quota/quota.rb +++ b/src/authm_mad/remotes/quota/quota.rb @@ -113,7 +113,15 @@ class Quota def initialize conf = YAML.load_file(CONF_FILE) @conf=CONF.merge(conf) {|key,h1,h2| - h1.merge(h2) if h1.instance_of?(Hash) && h2.instance_of?(Hash) + if h1.instance_of?(Hash) && h2.instance_of?(Hash) + h1.merge(h2) + else + if h2 + h2 + else + h1 + end + end } @client = OpenNebula::Client.new From 3bb367bc1043a648d5394ef62e89d398a024fe90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 5 Dec 2011 20:04:07 +0100 Subject: [PATCH 08/27] onedb migrator: New migrator from 3.1.0 to 3.1.80 --- install.sh | 1 + src/onedb/3.1.0_to_3.1.80.rb | 127 +++++++++++++++++++++++++++++++++++ src/vm/History.cc | 2 +- 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 src/onedb/3.1.0_to_3.1.80.rb diff --git a/install.sh b/install.sh index 6fb7f2bcfe..c4d1a8e0da 100755 --- a/install.sh +++ b/install.sh @@ -746,6 +746,7 @@ ONEDB_MIGRATOR_FILES="src/onedb/2.0_to_2.9.80.rb \ src/onedb/2.9.85_to_2.9.90.rb \ src/onedb/2.9.90_to_3.0.0.rb \ src/onedb/3.0.0_to_3.1.0.rb \ + src/onedb/3.1.0_to_3.1.80.rb \ src/onedb/onedb.rb \ src/onedb/onedb_backend.rb" diff --git a/src/onedb/3.1.0_to_3.1.80.rb b/src/onedb/3.1.0_to_3.1.80.rb new file mode 100644 index 0000000000..5a27679015 --- /dev/null +++ b/src/onedb/3.1.0_to_3.1.80.rb @@ -0,0 +1,127 @@ +# -------------------------------------------------------------------------- * +# 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. * +# -------------------------------------------------------------------------- * + +require 'digest/sha1' +require "rexml/document" +include REXML +require 'ipaddr' + +module Migrator + def db_version + "3.1.80" + end + + def one_version + "OpenNebula 3.1.80" + end + + def up + puts " > Networking isolation hooks have been moved to Host drivers.\n"<< + " If you were using a networking hook, enter its name, or press enter\n"<< + " to use the default dummy vn_mad driver.\n\n" + print " Driver name (802.1Q, dummy, ebtables, ovswitch): " + vn_mad = gets.chomp + + vn_mad = "dummy" if vn_mad.empty? + + # New VN_MAD element for hosts + + @db.run "ALTER TABLE host_pool RENAME TO old_host_pool;" + @db.run "CREATE TABLE host_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, state INTEGER, last_mon_time INTEGER, UNIQUE(name));" + + @db.fetch("SELECT * FROM old_host_pool") do |row| + doc = Document.new(row[:body]) + + vn_mad_elem = doc.root.add_element("VN_MAD") + vn_mad_elem.text = vn_mad + + @db[:host_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => doc.root.to_s, + :state => row[:state], + :last_mon_time => row[:last_mon_time]) + end + + @db.run "DROP TABLE old_host_pool;" + + # New VLAN and RANGE for vnets + + @db.run "ALTER TABLE network_pool RENAME TO old_network_pool;" + @db.run "CREATE TABLE network_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, public INTEGER, UNIQUE(name,uid));" + + @db.fetch("SELECT * FROM old_network_pool") do |row| + doc = Document.new(row[:body]) + + type = "" + doc.root.each_element("TYPE") { |e| + type = e.text + } + + if type == "0" # RANGED + range_elem = doc.root.add_element("RANGE") + ip_start_elem = range_elem.add_element("IP_START") + ip_end_elem = range_elem.add_element("IP_END") + + net_address = "" + doc.root.each_element("TEMPLATE/NETWORK_ADDRESS") { |e| + net_address = e.text + } + + net_address = IPAddr.new(net_address, Socket::AF_INET) + + + st_size = "" + doc.root.each_element("TEMPLATE/NETWORK_SIZE") { |e| + st_size = e.text + } + + if ( st_size == "C" || st_size == "c" ) + host_bits = 8 + elsif ( st_size == "B" || st_size == "b" ) + host_bits = 16 + elsif ( st_size == "A" || st_size == "a" ) + host_bits = 24 + else + size = st_size.to_i + host_bits = (Math.log(size+2)/Math.log(2)).ceil + end + + net_mask = 0xFFFFFFFF << host_bits + + net_address = net_address.to_i & net_mask + + ip_start_elem.text = IPAddr.new((ip_start = net_address + 1), Socket::AF_INET).to_s + ip_end_elem.text = IPAddr.new((net_address + (1 << host_bits) - 2), Socket::AF_INET).to_s + end + + # TODO: Set vlan = 1 if PHYDEV is set + vlan_elem = doc.root.add_element("VLAN") + vlan_elem.text = "0" + + @db[:network_pool].insert( + :oid => row[:oid], + :name => row[:name], + :body => doc.root.to_s, + :uid => row[:uid], + :gid => row[:gid], + :public => row[:public]) + end + + @db.run "DROP TABLE old_network_pool;" + + return true + end +end diff --git a/src/vm/History.cc b/src/vm/History.cc index f2a52ccb3c..a14edc9646 100644 --- a/src/vm/History.cc +++ b/src/vm/History.cc @@ -301,7 +301,7 @@ int History::rebuild_attributes() rc += xpath(stime , "/HISTORY/STIME", 0); rc += xpath(etime , "/HISTORY/ETIME", 0); rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found"); - rc += xpath(vnm_mad_name , "/HISTORY/VNMMAD", "not_found"); + xpath(vnm_mad_name , "/HISTORY/VNMMAD", "dummy"); rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found"); rc += xpath(prolog_stime , "/HISTORY/PSTIME", 0); rc += xpath(prolog_etime , "/HISTORY/PETIME", 0); From 2cfa7ab0dc1273c4e54d122cd4a24bf38a43ba7d Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 7 Dec 2011 01:18:13 +0100 Subject: [PATCH 09/27] Task #864, Feature #602: Improve leases support in Sunstone and new vnet operations in Sunstone This commit includes: * Support for ip_start, ip_end parameters when creating ranged vnetworks. * Removal of the add lease/remove lease dialogs. * Renewal of the representation of leases pool in the "extended information" windows. The list of leases is represented so that it is clearly visible those leases which are free, on hold (reserved), or used by a VM. Right on the list, leases can be added, updated or deleted. (cherry picked from commit eccae0e73126d5571cd138a782d5ba0e58aa0e22) --- .../OpenNebulaJSON/VirtualNetworkJSON.rb | 12 +- src/sunstone/public/images/green_bullet.png | Bin 0 -> 484 bytes src/sunstone/public/images/red_bullet.png | Bin 0 -> 484 bytes src/sunstone/public/images/yellow_bullet.png | Bin 0 -> 449 bytes src/sunstone/public/js/opennebula.js | 14 + src/sunstone/public/js/plugins/vnets-tab.js | 250 ++++++++++++++++-- 6 files changed, 246 insertions(+), 30 deletions(-) create mode 100644 src/sunstone/public/images/green_bullet.png create mode 100644 src/sunstone/public/images/red_bullet.png create mode 100644 src/sunstone/public/images/yellow_bullet.png diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb index b18230f2ac..fcc71d8e2f 100644 --- a/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb @@ -43,11 +43,13 @@ module OpenNebulaJSON rc = case action_hash['perform'] when "addleases" then self.addleases(action_hash['params']) - when "rmleases" then self.rmleases(action_hash['params']) + when "rmleases" then self.rmleases(action_hash['params']) when "publish" then self.publish when "unpublish" then self.unpublish when "update" then self.update(action_hash['params']) when "chown" then self.chown(action_hash['params']) + when "hold" then self.hold(action_hash['params']) + when "release" then self.release(action_hash['params']) else error_msg = "#{action_hash['perform']} action not " << " available for this resource" @@ -70,5 +72,13 @@ module OpenNebulaJSON def chown(params=Hash.new) super(params['owner_id'].to_i,params['group_id'].to_i) end + + def hold(params=Hash.new) + super(params['ip']) + end + + def release(params=Hash.new) + super(params['ip']) + end end end diff --git a/src/sunstone/public/images/green_bullet.png b/src/sunstone/public/images/green_bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..d64f9dbf9d6c519d56a1128452779baf5b323db0 GIT binary patch literal 484 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1SD^YpWXnZ7>k44ofy`glX(f`a29w(7Bet# z3xhBt!>l_iO9UAn2wYz}S4_HU zN%TR!vul06)J$wG6jRfhX2#0EUTw#%a$nN!<4a55vqckI`P+BDu(+N3-7AVAfiG{) z)%#zV7&IQ0EM8>6z4&p?ZjoOZj0_B$$~T{Ed3V2hNwl(^Sk=@O72EIrmrzyPp7eKT zSpVxkoZiYyd{3Xs=i;VuD`Z|32!d- zooCt}smwEVs(iD-lSyUEi#nroZajb7;QzX|jninAhK>T)nyw02_L{2D-AmFVdQ&MBb@0FFAlQ2+n{ literal 0 HcmV?d00001 diff --git a/src/sunstone/public/images/red_bullet.png b/src/sunstone/public/images/red_bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..b8317a77cff95bffdd8857b21363a6c55233488b GIT binary patch literal 484 zcmVPx#32;bRa{vGf6951U69E94oEQKA00(qQO+^RW3ul(NKH zK#WntA(IJF#L0=qIkJq!g5{DdJ4hHqlJN4vbV`zFs*1&ehX>|!@|^u1P^YId8c9(o z5fucQG-bJDKIicf?>S(tG>z*z9Yy`YKvR}v8F`NP0_xME=l#cO)uw5ardq63)_z_< z01#-Qac*DN&1$9jj}9!nLIWG;?0Vf(#$b$u;RhUITiC%4iXfk44ofy`glX(f`a29w(7Bet# z3xhBt!>lS|xv6<2KrRD=b5UwyNotBh zd1gt5g1e`0K#E=}JJ4_~PZ!4!iOZ=M&-xv5U~qkCocgOf$=Ae9r9~n+M)J`m_79vj zVew7A*N-?j3-Ic-WG!EMdFC#Li%0TnC+*&GNUAq5M{EV>Q<=R?1<6fv7gg(~hp8BL zDXDs&5bC;_FY@gr&r2Ro_DN@(bP|7FS>wLKL|=M=EXSfojWmWn^+4fGOCtMA%ydno z=es_BxiVi{u;ink%qh#GJX7CwuU&O)h4?4KpEn%WUs(P2)V!?`-pevhg?~yvX@4zA zdXIsS9;k@uG*n?&o(yV3)<=6qpa>%k)K52K6u6{1-oD!M\ \
\ - \ - \ + \ +
\ + \ +
\ + \ +
\ + \ + \ \ \ \ @@ -95,9 +101,9 @@ var create_vn_tmpl =
\
\ \ - \ +
\ \ - \ +
\ \ \
\ @@ -248,7 +254,7 @@ var vnet_actions = { call: OpenNebula.Network.addleases, callback: vnShow, error: onError, - notify: true + notify: false, }, "Network.rmleases" : { @@ -256,9 +262,25 @@ var vnet_actions = { call: OpenNebula.Network.rmleases, callback: vnShow, error: onError, - notify: true + notify: false, }, + "Network.hold" : { + type: "single", + call: OpenNebula.Network.hold, + callback: vnShow, + error: onError, + notify: false, + }, + + "Network.release" : { + type: "single", + call: OpenNebula.Network.release, + callback: vnShow, + error: onError, + notify: false, + }, +/* "Network.modifyleases" : { type: "custom", call: function(action,obj){ @@ -278,7 +300,7 @@ var vnet_actions = { type: "custom", call: popUpRemoveLeaseDialog }, - +*/ "Network.chown" : { type: "multiple", call: OpenNebula.Network.chown, @@ -368,7 +390,7 @@ var vnet_buttons = { tip: "Select the new group:", condition: mustBeAdmin, }, - +/* "action_list" : { type: "select", actions: { @@ -382,7 +404,7 @@ var vnet_buttons = { } } }, - +*/ "Network.delete" : { type: "action", text: "Delete" @@ -455,6 +477,9 @@ function updateVNetworkElement(request, vn_json){ id = vn_json.VNET.ID; element = vNetworkElementArray(vn_json); updateSingleElement(element,dataTable_vNetworks,'#vnetwork_'+id); + + //we update this too, even if it's not shown. + $('#leases_form').replaceWith(printLeases(vn_json.VNET)); } //Callback to delete a vnet element from the table @@ -466,6 +491,8 @@ function deleteVNetworkElement(req){ function addVNetworkElement(request,vn_json){ var element = vNetworkElementArray(vn_json); addElement(element,dataTable_vNetworks); + //we update this too, even if it's not shown. + $('#leases_form').replaceWith(printLeases(vn_json.VNET)); } //updates the list of virtual networks @@ -494,6 +521,10 @@ function updateVNetworkInfo(request,vn){ ID\ '+vn_info.ID+'\ \ + \ + Name\ + '+vn_info.NAME+'\ + \ \ Owner\ '+vn_info.UNAME+'\ @@ -508,17 +539,15 @@ function updateVNetworkInfo(request,vn){ \ \ Physical device\ - '+(vn_info.PHYDEV ? vn_info.PHYDEV : "--" )+'\ + '+ (typeof(vn_info.PHYDEV) == "object" ? "--": vn_info.PHYDEV) +'\ \ - \ - \ - \ - \ - '+ - printLeases(vn_info.LEASES)+ - '
Leases information
';; - + \ + VNET ID\ + '+ (typeof(vn_info.VLAN_ID) == "object" ? "--": vn_info.VLAN_ID) +'\ + \ + '; + info_tab_content += printLeases(vn_info); var info_tab = { title: "Virtual Network information", @@ -541,19 +570,101 @@ function updateVNetworkInfo(request,vn){ } -function printLeases(leases){ - if (!leases.LEASE) //empty - { - return ""; +function printLeases(vn_info){ + var html ='
\ + \ + \ + '; + + if (vn_info.TYPE == "0"){ + html += '\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + '; + } else { + html += ''; }; - if (leases.LEASE.constructor == Array) //>1 lease + var leases = vn_info.LEASES.LEASE; + + if (!leases) //empty { - return prettyPrintJSON(leases.LEASE); + html+='\ + '; + return html; } - else {//1 lease - return prettyPrintJSON([leases.LEASE]); + else if (leases.constructor != Array) //>1 lease + { + leases = [leases]; }; + + var lease; + var state=null; + + for (var i=0; i'; + }; + + html += '
Leases information
IP Start'+vn_info.RANGE.IP_START+'
IP End'+vn_info.RANGE.IP_END+'
Network mask'+( vn_info.TEMPLATE.NETWORK_MASK ? vn_info.TEMPLATE.NETWORK_MASK : "--" )+'
\ + \ + \ +
\ + \ + \ +
\ + No leases to show\ + \ +
'; + html+=''; + + html += '\ + '+lease.MAC+'   '; + + switch (state){ + case 0: + html += 'hold | delete'; + break; + case 1: + html += 'Used by VM '+lease.VID; + break; + case 2: + html += 'release'; + break; + }; + html += '
'; + + return html; } //Prepares the vnet creation dialog @@ -622,6 +733,17 @@ function setupCreateVNetDialog() { return false; }); + $('#custom_pool', dialog).change(function(){ + if ($(this).is(':checked')){ + $('#ip_start', $create_vn_dialog).removeAttr('disabled'); + $('#ip_end', $create_vn_dialog).removeAttr('disabled'); + } + else { + $('#ip_start', $create_vn_dialog).attr('disabled','disabled'); + $('#ip_end', $create_vn_dialog).attr('disabled','disabled'); + }; + }); + $('#add_custom_var_vnet_button', dialog).click( function(){ @@ -681,7 +803,11 @@ function setupCreateVNetDialog() { else { //type ranged var network_addr = $('#net_address',this).val(); - var network_size = $('#net_size',this).val(); + var network_mask = $('#net_mask',this).val(); + var custom = $('#custom_pool',this).is(':checked'); + var ip_start = $('#ip_start',this).val(); + var ip_end = $('#ip_end',this).val(); + if (!network_addr.length){ notifyError("Please provide a network address"); return false; @@ -692,10 +818,17 @@ function setupCreateVNetDialog() { "vnet" : { "type" : "RANGED", "bridge" : bridge, - "network_size" : network_size, + "network_mask" : network_mask, "network_address" : network_addr, "name" : name } }; + + if (custom){ + if (ip_start.length) + network_json["vnet"]["ip_start"] = ip_start; + if (ip_end.length) + network_json["vnet"]["ip_start"] = ip_end; + }; }; //Time to add custom attributes @@ -826,6 +959,62 @@ function popUpVNetTemplateUpdateDialog(){ } +function setupLeasesOps(){ + $('button#panel_add_lease_button').live("click",function(){ + var lease = $(this).prev().val(); + //var mac = $(this).previous().val(); + var id = $(this).parents('form').attr('vnid'); + if (lease.length){ + var obj = {ip: lease}; + Sunstone.runAction('Network.addleases',id,obj); + } + return false; + }); + + $('button#panel_hold_lease_button').live("click",function(){ + var lease = $(this).prev().val(); + //var mac = $(this).previous().val(); + var id = $(this).parents('form').attr('vnid'); + if (lease.length){ + var obj = {ip: lease}; + Sunstone.runAction('Network.hold',id,obj); + } + return false; + }); + + $('form#leases_form a.delete_lease').live("click",function(){ + var lease = $(this).parents('tr').attr('ip'); + var id = $(this).parents('form').attr('vnid'); + var obj = { ip: lease}; + Sunstone.runAction('Network.rmleases',id,obj); + //Set spinner + $(this).parents('tr').html(''+spinner+''); + return false; + }); + + $('a.hold_lease').live("click",function(){ + var lease = $(this).parents('tr').attr('ip'); + var id = $(this).parents('form').attr('vnid'); + var obj = { ip: lease}; + Sunstone.runAction('Network.hold',id,obj); + //Set spinner + $(this).parents('tr').html(''+spinner+''); + return false; + }); + + $('a.release_lease').live("click",function(){ + var lease = $(this).parents('tr').attr('ip'); + var id = $(this).parents('form').attr('vnid'); + var obj = { ip: lease}; + Sunstone.runAction('Network.release',id,obj); + //Set spinner + $(this).parents('tr').html(''+spinner+''); + return false; + }); +} + + +/* function setupAddRemoveLeaseDialog() { dialogs_context.append('
'); $lease_vn_dialog = $('#lease_vn_dialog',dialogs_context) @@ -893,6 +1082,8 @@ function popUpRemoveLeaseDialog() { $lease_vn_dialog.dialog("open"); } +*/ + function setVNetAutorefresh() { setInterval(function(){ var checked = $('input.check_item:checked',dataTable_vNetworks); @@ -946,7 +1137,8 @@ $(document).ready(function(){ setupCreateVNetDialog(); setupVNetTemplateUpdateDialog(); - setupAddRemoveLeaseDialog(); + //setupAddRemoveLeaseDialog(); + setupLeasesOps(); setupVNetActionCheckboxes(); setVNetAutorefresh(); From 833b1295e5817d1f0cdab1d7a2ecb316bfbb1947 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 7 Dec 2011 10:08:27 +0100 Subject: [PATCH 10/27] feature #602: Include bullets to install file --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index c4d1a8e0da..1e75815fd8 100755 --- a/install.sh +++ b/install.sh @@ -1112,6 +1112,9 @@ SUNSTONE_PUBLIC_IMAGES_FILES="src/sunstone/public/images/ajax-loader.gif \ src/sunstone/public/images/panel_short.png \ src/sunstone/public/images/pbar.gif \ src/sunstone/public/images/Refresh-icon.png \ + src/sunstone/public/images/red_bullet.png \ + src/sunstone/public/images/yellow_bullet.png \ + src/sunstone/public/images/green_bullet.png \ src/sunstone/public/images/vnc_off.png \ src/sunstone/public/images/vnc_on.png" From 879f66ce5bdeb6939e724c71e061a2f265f18656 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 5 Dec 2011 19:21:13 +0100 Subject: [PATCH 11/27] make ldap drivers compatible with 3.2 (return driver name) --- src/authm_mad/remotes/ldap/authenticate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/authm_mad/remotes/ldap/authenticate b/src/authm_mad/remotes/ldap/authenticate index 90501553f1..8d0fa527d9 100755 --- a/src/authm_mad/remotes/ldap/authenticate +++ b/src/authm_mad/remotes/ldap/authenticate @@ -54,7 +54,7 @@ if options[:group] end if ldap.authenticate(user_name, secret) - puts "#{user} #{user_name}" + puts "ldap #{user} #{user_name}" exit(0) else STDERR.puts "Bad user/password" From 843c6722dd044172cdcf8f89aece0d0fb62f1eac Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Wed, 7 Dec 2011 12:05:46 +0100 Subject: [PATCH 12/27] correct uuidtools gem name in install_gems --- share/install_gems/install_gems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index 46e2b29ee4..e2c37f9ccf 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -22,7 +22,7 @@ GROUPS={ :optional => OPTIONAL, :quota => [SQLITE, 'sequel'], :sunstone => ['json', 'rack', 'sinatra', 'thin', 'sequel', SQLITE], - :cloud => %w{amazon-ec2 rack sinatra thin uuid curb}, + :cloud => %w{amazon-ec2 rack sinatra thin uuidtools curb}, :ozones_client => %w{json}, :ozones_server => %w{json data_mapper dm-sqlite-adapter dm-mysql-adapter}+[ SQLITE, 'mysql' From d69d7674208e952929cda3a629b1c5c34d0fdf05 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Wed, 7 Dec 2011 14:49:07 +0100 Subject: [PATCH 13/27] feature #863: specific xpath filters for each network driver --- src/vnm_mad/remotes/802.1Q/HostManaged.rb | 3 ++- src/vnm_mad/remotes/Firewall.rb | 4 +++- src/vnm_mad/remotes/OpenNebulaNetwork.rb | 15 ++++++++------- src/vnm_mad/remotes/ebtables/Ebtables.rb | 3 ++- src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb | 3 ++- .../remotes/test/OpenNebulaNetwork_spec.rb | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/vnm_mad/remotes/802.1Q/HostManaged.rb b/src/vnm_mad/remotes/802.1Q/HostManaged.rb index 28e9a602be..90cbff26e1 100644 --- a/src/vnm_mad/remotes/802.1Q/HostManaged.rb +++ b/src/vnm_mad/remotes/802.1Q/HostManaged.rb @@ -17,8 +17,9 @@ require 'OpenNebulaNetwork' class OpenNebulaHM < OpenNebulaNetwork + XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" def initialize(vm, hypervisor = nil) - super(vm,hypervisor) + super(vm,XPATH_FILTER,hypervisor) @bridges = get_interfaces end diff --git a/src/vnm_mad/remotes/Firewall.rb b/src/vnm_mad/remotes/Firewall.rb index 2cc4f98eca..c139bfeabe 100644 --- a/src/vnm_mad/remotes/Firewall.rb +++ b/src/vnm_mad/remotes/Firewall.rb @@ -15,8 +15,10 @@ #--------------------------------------------------------------------------- # class OpenNebulaFirewall < OpenNebulaNetwork + XPATH_FILTER = "TEMPLATE/NIC[ICMP|WHITE_PORTS_TCP|WHITE_PORTS_UDP|" << + "BLACK_PORTS_TCP|BLACK_PORTS_UDP]" def initialize(vm, hypervisor = nil) - super(vm,hypervisor) + super(vm,XPATH_FILTER,hypervisor) end def activate vm_id = @vm['ID'] diff --git a/src/vnm_mad/remotes/OpenNebulaNetwork.rb b/src/vnm_mad/remotes/OpenNebulaNetwork.rb index a944adeb8d..284eb7a680 100644 --- a/src/vnm_mad/remotes/OpenNebulaNetwork.rb +++ b/src/vnm_mad/remotes/OpenNebulaNetwork.rb @@ -45,14 +45,15 @@ COMMANDS = { class VM attr_accessor :nics, :vm_info - def initialize(vm_root, hypervisor) - @vm_root = vm_root - @hypervisor = hypervisor - @vm_info = Hash.new + def initialize(vm_root, xpath_filter, hypervisor) + @vm_root = vm_root + @xpath_filter = xpath_filter + @hypervisor = hypervisor + @vm_info = Hash.new nics = Nics.new(@hypervisor) - @vm_root.elements.each("TEMPLATE/NIC[VLAN='YES']") do |nic_element| + @vm_root.elements.each(@xpath_filter) do |nic_element| nic = nics.new_nic nic_element.elements.each('*') do |nic_attribute| @@ -96,14 +97,14 @@ class OpenNebulaNetwork self.new(vm_xml, hypervisor) end - def initialize(vm_tpl, hypervisor=nil) + def initialize(vm_tpl, xpath_filter, hypervisor=nil) if !hypervisor @hypervisor = detect_hypervisor else @hypervisor = hypervisor end - @vm = VM.new(REXML::Document.new(vm_tpl).root, @hypervisor) + @vm = VM.new(REXML::Document.new(vm_tpl).root, xpath_filter, @hypervisor) end def process(&block) diff --git a/src/vnm_mad/remotes/ebtables/Ebtables.rb b/src/vnm_mad/remotes/ebtables/Ebtables.rb index c22ad69340..fc3dead298 100644 --- a/src/vnm_mad/remotes/ebtables/Ebtables.rb +++ b/src/vnm_mad/remotes/ebtables/Ebtables.rb @@ -17,8 +17,9 @@ require 'OpenNebulaNetwork' class EbtablesVLAN < OpenNebulaNetwork + XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" def initialize(vm, hypervisor = nil) - super(vm,hypervisor) + super(vm,XPATH_FILTER,hypervisor) end def ebtables(rule) diff --git a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb index 9716d99f8a..2cdaeafd80 100644 --- a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb +++ b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb @@ -17,8 +17,9 @@ require 'OpenNebulaNetwork' class OpenvSwitchVLAN < OpenNebulaNetwork + XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" def initialize(vm, hypervisor = nil) - super(vm,hypervisor) + super(vm,XPATH_FILTER,hypervisor) end def activate diff --git a/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb b/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb index b97942055e..cfbfe8cf89 100644 --- a/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb +++ b/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb @@ -43,7 +43,7 @@ describe 'networking' do $capture_commands = { /virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml] } - onevlan = OpenNebulaNetwork.new(OUTPUT[:onevm_show],"kvm") + onevlan = OpenNebulaNetwork.new(OUTPUT[:onevm_show],"TEMPLATE/NIC","kvm") nics_expected = [{:bridge=>"br0", :ip=>"172.16.0.100", :mac=>"02:00:ac:10:00:64", From 4c1832ff4e6a04aa61f0013fbdba815082e237f8 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 7 Dec 2011 18:29:30 +0100 Subject: [PATCH 14/27] Update VNET render in OCCI --- src/cloud/occi/etc/occi-server.conf | 3 -- src/cloud/occi/lib/OCCIServer.rb | 2 +- src/cloud/occi/lib/VirtualNetworkOCCI.rb | 54 +++++++++++++----------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/cloud/occi/etc/occi-server.conf b/src/cloud/occi/etc/occi-server.conf index 859329f2df..e803e49788 100644 --- a/src/cloud/occi/etc/occi-server.conf +++ b/src/cloud/occi/etc/occi-server.conf @@ -24,9 +24,6 @@ # SSL proxy that serves the API (set if is being used) #:ssl_server: fqdm.of.the.server -# Configuration for OpenNebula's Virtual Networks -#:bridge: NAME_OF_DEFAULT_BRIDGE - # Authentication driver for incomming requests # occi, for OpenNebula's user-password scheme # x509, for x509 certificates based authentication diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb index 613ecd5333..69ced7f360 100755 --- a/src/cloud/occi/lib/OCCIServer.rb +++ b/src/cloud/occi/lib/OCCIServer.rb @@ -317,7 +317,7 @@ class OCCIServer < CloudServer VirtualNetwork.build_xml, @client, request.body, - @config[:bridge]) + @config[:template_location]) # --- Generate the template and Allocate the new Instance --- template = network.to_one_template diff --git a/src/cloud/occi/lib/VirtualNetworkOCCI.rb b/src/cloud/occi/lib/VirtualNetworkOCCI.rb index eeb7194c92..f996b967d2 100755 --- a/src/cloud/occi/lib/VirtualNetworkOCCI.rb +++ b/src/cloud/occi/lib/VirtualNetworkOCCI.rb @@ -15,6 +15,7 @@ #--------------------------------------------------------------------------- # require 'OpenNebula' +require 'ipaddr' include OpenNebula @@ -26,35 +27,23 @@ class VirtualNetworkOCCI < VirtualNetwork <% if self['TEMPLATE/DESCRIPTION'] != nil %> <%= self['TEMPLATE/DESCRIPTION'] %> <% end %> -
<%= self['TEMPLATE/NETWORK_ADDRESS'] %>
- <% if self['TEMPLATE/NETWORK_SIZE'] %> - <%= self['TEMPLATE/NETWORK_SIZE'] %> + <% if network_address != nil %> +
<%= network_address %>
<% end %> + <% if network_size != nil %> + <%= network_size %> + <% end %> + <%= self['TOTAL_LEASES'] %> <%= self['PUBLIC'] == "0" ? "NO" : "YES"%> } - ONE_NETWORK = %q{ - NAME = "<%= @vnet_info['NAME'] %>" - TYPE = RANGED - <% if @vnet_info['DESCRIPTION'] != nil %> - DESCRIPTION = "<%= @vnet_info['DESCRIPTION'] %>" - <% end %> - <% if @vnet_info['PUBLIC'] != nil %> - PUBLIC = "<%= @vnet_info['PUBLIC'] %>" - <% end %> - <% if @bridge %> - BRIDGE = <%= @bridge %> - <% end %> - NETWORK_ADDRESS = <%= @vnet_info['ADDRESS'] %> - NETWORK_SIZE = <%= @vnet_info['SIZE']%> - }.gsub(/^ /, '') - # Class constructor - def initialize(xml, client, xml_info=nil, bridge=nil) + # + def initialize(xml, client, xml_info=nil, base=nil) super(xml, client) - @bridge = bridge @vnet_info = nil + @common_template = base + '/network.erb' if base if xml_info != nil xmldoc = XMLElement.build_xml(xml_info, 'NETWORK') @@ -64,6 +53,18 @@ class VirtualNetworkOCCI < VirtualNetwork # Creates the OCCI representation of a Virtual Network def to_occi(base_url) + network_address = nil + network_size = nil + + if self['RANGE/IP_START'] + network_address = self['RANGE/IP_START'] + + ip_start = IPAddr.new(network_address, Socket::AF_INET) + ip_end = IPAddr.new(self['RANGE/IP_END'], Socket::AF_INET) + + network_size = ip_end.to_i - ip_start.to_i + end + begin occi = ERB.new(OCCI_NETWORK) occi_text = occi.result(binding) @@ -78,11 +79,16 @@ class VirtualNetworkOCCI < VirtualNetwork def to_one_template() if @vnet_info == nil error_msg = "Missing NETWORK section in the XML body" - error = OpenNebula::Error.new(error_msg) + return OpenNebula::Error.new(error_msg), 400 + end + + begin + template = ERB.new(File.read(@common_template)).result(binding) + rescue Exception => e + error = OpenNebula::Error.new(e.message) return error end - one = ERB.new(ONE_NETWORK) - return one.result(binding) + return template end end From cee7ae3c5d73afed1ee6efaef856372b29d82127 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 7 Dec 2011 18:30:09 +0100 Subject: [PATCH 15/27] Use a constant for pool filtering in OCCI --- src/cloud/occi/lib/OCCIServer.rb | 15 ++++++--------- src/cloud/occi/lib/VirtualMachineOCCI.rb | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb index 69ced7f360..86e68c5fd9 100755 --- a/src/cloud/occi/lib/OCCIServer.rb +++ b/src/cloud/occi/lib/OCCIServer.rb @@ -40,6 +40,9 @@ require 'pp' COLLECTIONS = ["compute", "instance_type", "network", "storage"] +# FLAG that will filter the elements retrieved from the Pools +POOL_FILTER = Pool::INFO_GROUP + class OCCIServer < CloudServer # Server initializer # config_file:: _String_ path of the config file @@ -109,11 +112,9 @@ class OCCIServer < CloudServer # [return] _String_,_Integer_ Pool Representation or error, status code def get_computes(request) # --- Get User's VMs --- - user_flag = -1 - vmpool = VirtualMachinePoolOCCI.new( @client, - user_flag) + POOL_FILTER) # --- Prepare XML Response --- rc = vmpool.info @@ -136,11 +137,9 @@ class OCCIServer < CloudServer # => status code def get_networks(request) # --- Get User's VNETs --- - user_flag = -1 - network_pool = VirtualNetworkPoolOCCI.new( @client, - user_flag) + POOL_FILTER) # --- Prepare XML Response --- rc = network_pool.info @@ -162,11 +161,9 @@ class OCCIServer < CloudServer # status code def get_storages(request) # --- Get User's Images --- - user_flag = -1 - image_pool = ImagePoolOCCI.new( @client, - user_flag) + POOL_FILTER) # --- Prepare XML Response --- rc = image_pool.info diff --git a/src/cloud/occi/lib/VirtualMachineOCCI.rb b/src/cloud/occi/lib/VirtualMachineOCCI.rb index 73274ba9b0..f05f194920 100755 --- a/src/cloud/occi/lib/VirtualMachineOCCI.rb +++ b/src/cloud/occi/lib/VirtualMachineOCCI.rb @@ -100,11 +100,11 @@ class VirtualMachineOCCI < VirtualMachine def to_one_template() if @vm_info == nil error_msg = "Missing COMPUTE section in the XML body" - return OpenNebula::Error.new(error_msg), 400 + return OpenNebula::Error.new(error_msg) end if @template == nil - return OpenNebula::Error.new("Bad instance type"), 500 + return OpenNebula::Error.new("Bad instance type") end begin From d9d82dca99015a73d8b1a5950913cd6ca1aa6715 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Wed, 7 Dec 2011 18:36:54 +0100 Subject: [PATCH 16/27] feature #863: the post scripts require the deploy_id --- src/vmm_mad/exec/one_vmm_exec.rb | 34 ++++++++++++--------- src/vnm_mad/one_vnm.rb | 7 +++-- src/vnm_mad/remotes/802.1Q/HostManaged.rb | 5 +-- src/vnm_mad/remotes/802.1Q/post | 5 ++- src/vnm_mad/remotes/Firewall.rb | 6 ++-- src/vnm_mad/remotes/OpenNebulaNetwork.rb | 17 ++++++----- src/vnm_mad/remotes/OpenNebulaNic.rb | 6 +++- src/vnm_mad/remotes/ebtables/Ebtables.rb | 5 +-- src/vnm_mad/remotes/ebtables/post | 7 +++-- src/vnm_mad/remotes/fw/post | 5 ++- src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb | 5 +-- src/vnm_mad/remotes/ovswitch/post | 6 ++-- 12 files changed, 69 insertions(+), 39 deletions(-) diff --git a/src/vmm_mad/exec/one_vmm_exec.rb b/src/vmm_mad/exec/one_vmm_exec.rb index b16867ee56..ffd1bd6069 100755 --- a/src/vmm_mad/exec/one_vmm_exec.rb +++ b/src/vmm_mad/exec/one_vmm_exec.rb @@ -72,14 +72,16 @@ class VmmAction @vnm_src = VirtualNetworkDriver.new(@data[:net_drv], :local_actions => @vmm.options[:local_actions], :message => @xml_data, - :ssh_stream => @ssh_src) + :ssh_stream => @ssh_src, + :extra_data => @data) if @data[:dest_host] and !@data[:dest_host].empty? @ssh_dst = @vmm.get_ssh_stream(@data[:dest_host], @id) @vnm_dst = VirtualNetworkDriver.new(@data[:dest_driver], :local_actions => @vmm.options[:local_actions], :message => @xml_data, - :ssh_stream => @ssh_dst) + :ssh_stream => @ssh_dst, + :extra_data => @data) end end @@ -115,7 +117,7 @@ class VmmAction # Executes a set of steps. If one step fails any recover action is performed # and the step execution breaks. # @param [Array] array of steps to be executed - # @return [String, Hash] "SUCCESS/FAILURE" for the step set, and + # @return [String, Hash] "SUCCESS/FAILURE" for the step set, and # information associated to each step (by :_info). In case of # failure information is also in [:failed_info] def execute_steps(steps) @@ -124,7 +126,7 @@ class VmmAction steps.each do |step| # Execute Step case step[:driver] - when :vmm + when :vmm if step[:destination] host = @data[:dest_host] ssh = @ssh_dst @@ -134,7 +136,7 @@ class VmmAction end result, info = @vmm.do_action(get_parameters(step[:parameters]), - @id, + @id, host, step[:action], :ssh_stream => ssh, @@ -153,20 +155,21 @@ class VmmAction info = "No driver in #{step[:action]}" end - # Save the step info + # Save the step info @data["#{step[:action]}_info".to_sym] = info + @data[step[:save_info_as]] = info if step[:save_info_as] # Roll back steps, store failed info and break steps - if DriverExecHelper.failed?(result) + if DriverExecHelper.failed?(result) execute_steps(@data[:fail_actions]) if @data[:fail_actions] @data[:failed_info] = info - @vmm.log(@id, + @vmm.log(@id, "Failed to execute #{DRIVER_NAMES[step[:driver]]} " \ "operation: #{step[:action]}.") break else - @vmm.log(@id, + @vmm.log(@id, "Sussecfully execute #{DRIVER_NAMES[step[:driver]]} " \ "operation: #{step[:action]}.") end @@ -217,7 +220,7 @@ class ExecDriver < VirtualMachineDriver @options={ :threaded => true }.merge!(options) - + super("vmm/#{hypervisor}", @options) @hypervisor = hypervisor @@ -273,11 +276,12 @@ class ExecDriver < VirtualMachineDriver }, # Boot the Virtual Machine { - :driver => :vmm, - :action => :deploy, - :parameters => [dfile, :host], - :stdin => domain - }, + :driver => :vmm, + :action => :deploy, + :parameters => [dfile, :host], + :stdin => domain, + :save_info_as => :deploy_id + }, # Execute post-boot networking setup { :driver => :vnm, diff --git a/src/vnm_mad/one_vnm.rb b/src/vnm_mad/one_vnm.rb index aba0339611..23dba5a34e 100644 --- a/src/vnm_mad/one_vnm.rb +++ b/src/vnm_mad/one_vnm.rb @@ -31,6 +31,7 @@ class VirtualNetworkDriver @options = options @ssh_stream = options[:ssh_stream] @message = options[:message] + @extra_data = options[:extra_data] @vm_encoded = Base64.encode64(@message.elements['VM'].to_s).delete("\n") @@ -49,7 +50,9 @@ class VirtualNetworkDriver :stdin => nil, }.merge(ops) - cmd = action_command_line(aname, @vm_encoded) + deploy_id=@extra_data[:deploy_id] || '-' + + cmd = action_command_line(aname, "#{@vm_encoded} #{deploy_id}") if action_is_local?(aname) execution = LocalCommand.run(cmd, log_method(id)) @@ -67,4 +70,4 @@ class VirtualNetworkDriver result, info = get_info_from_execution(execution) end -end \ No newline at end of file +end diff --git a/src/vnm_mad/remotes/802.1Q/HostManaged.rb b/src/vnm_mad/remotes/802.1Q/HostManaged.rb index 90cbff26e1..67547840fc 100644 --- a/src/vnm_mad/remotes/802.1Q/HostManaged.rb +++ b/src/vnm_mad/remotes/802.1Q/HostManaged.rb @@ -18,8 +18,9 @@ require 'OpenNebulaNetwork' class OpenNebulaHM < OpenNebulaNetwork XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" - def initialize(vm, hypervisor = nil) - super(vm,XPATH_FILTER,hypervisor) + + def initialize(vm, deploy_id = nil, hypervisor = nil) + super(vm,XPATH_FILTER,deploy_id,hypervisor) @bridges = get_interfaces end diff --git a/src/vnm_mad/remotes/802.1Q/post b/src/vnm_mad/remotes/802.1Q/post index 6458772e86..7b0afd182e 100755 --- a/src/vnm_mad/remotes/802.1Q/post +++ b/src/vnm_mad/remotes/802.1Q/post @@ -22,6 +22,9 @@ $: << File.join(File.dirname(__FILE__), "..") require 'OpenNebulaNetwork' require 'Firewall' -fw = OpenNebulaFirewall.from_base64(ARGV[0]) +template64 = ARGV[0] +deploy_id = ARGV[1] + +fw = OpenNebulaFirewall.from_base64(template64, deploy_id) fw.activate diff --git a/src/vnm_mad/remotes/Firewall.rb b/src/vnm_mad/remotes/Firewall.rb index c139bfeabe..76f00bf09e 100644 --- a/src/vnm_mad/remotes/Firewall.rb +++ b/src/vnm_mad/remotes/Firewall.rb @@ -17,9 +17,11 @@ class OpenNebulaFirewall < OpenNebulaNetwork XPATH_FILTER = "TEMPLATE/NIC[ICMP|WHITE_PORTS_TCP|WHITE_PORTS_UDP|" << "BLACK_PORTS_TCP|BLACK_PORTS_UDP]" - def initialize(vm, hypervisor = nil) - super(vm,XPATH_FILTER,hypervisor) + + def initialize(vm, deploy_id = nil, hypervisor = nil) + super(vm,XPATH_FILTER,deploy_id,hypervisor) end + def activate vm_id = @vm['ID'] process do |nic| diff --git a/src/vnm_mad/remotes/OpenNebulaNetwork.rb b/src/vnm_mad/remotes/OpenNebulaNetwork.rb index 284eb7a680..c4ed9f8a23 100644 --- a/src/vnm_mad/remotes/OpenNebulaNetwork.rb +++ b/src/vnm_mad/remotes/OpenNebulaNetwork.rb @@ -43,14 +43,17 @@ COMMANDS = { } class VM - attr_accessor :nics, :vm_info + attr_accessor :nics, :vm_info, :deploy_id - def initialize(vm_root, xpath_filter, hypervisor) + def initialize(vm_root, xpath_filter, deploy_id, hypervisor) @vm_root = vm_root @xpath_filter = xpath_filter + @deploy_id = deploy_id @hypervisor = hypervisor @vm_info = Hash.new + @deploy_id = nil if deploy_id == "-" + nics = Nics.new(@hypervisor) @vm_root.elements.each(@xpath_filter) do |nic_element| @@ -92,19 +95,19 @@ end class OpenNebulaNetwork attr_reader :hypervisor, :vm - def self.from_base64(vm_64, hypervisor=nil) + def self.from_base64(vm_64, deploy_id = nil, hypervisor = nil) vm_xml = Base64::decode64(vm_64) - self.new(vm_xml, hypervisor) + self.new(vm_xml, deploy_id, hypervisor) end - def initialize(vm_tpl, xpath_filter, hypervisor=nil) + def initialize(vm_tpl, xpath_filter, deploy_id = nil, hypervisor = nil) if !hypervisor @hypervisor = detect_hypervisor else @hypervisor = hypervisor end - - @vm = VM.new(REXML::Document.new(vm_tpl).root, xpath_filter, @hypervisor) + + @vm = VM.new(REXML::Document.new(vm_tpl).root, xpath_filter, deploy_id, @hypervisor) end def process(&block) diff --git a/src/vnm_mad/remotes/OpenNebulaNic.rb b/src/vnm_mad/remotes/OpenNebulaNic.rb index 84214bd154..176d41246e 100644 --- a/src/vnm_mad/remotes/OpenNebulaNic.rb +++ b/src/vnm_mad/remotes/OpenNebulaNic.rb @@ -39,7 +39,11 @@ class NicKVM < Hash end def get_info(vm) - deploy_id = vm['DEPLOY_ID'] + if vm.deploy_id + deploy_id = vm.deploy_id + else + deploy_id = vm['DEPLOY_ID'] + end if deploy_id and vm.vm_info[:dumpxml].nil? vm.vm_info[:dumpxml] = `#{COMMANDS[:virsh]} dumpxml #{deploy_id} \ diff --git a/src/vnm_mad/remotes/ebtables/Ebtables.rb b/src/vnm_mad/remotes/ebtables/Ebtables.rb index fc3dead298..b76d0cad19 100644 --- a/src/vnm_mad/remotes/ebtables/Ebtables.rb +++ b/src/vnm_mad/remotes/ebtables/Ebtables.rb @@ -18,8 +18,9 @@ require 'OpenNebulaNetwork' class EbtablesVLAN < OpenNebulaNetwork XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" - def initialize(vm, hypervisor = nil) - super(vm,XPATH_FILTER,hypervisor) + + def initialize(vm, deploy_id = nil, hypervisor = nil) + super(vm,XPATH_FILTER,deploy_id,hypervisor) end def ebtables(rule) diff --git a/src/vnm_mad/remotes/ebtables/post b/src/vnm_mad/remotes/ebtables/post index a862a9aaa9..9e31babff5 100755 --- a/src/vnm_mad/remotes/ebtables/post +++ b/src/vnm_mad/remotes/ebtables/post @@ -22,10 +22,13 @@ $: << File.join(File.dirname(__FILE__), "..") require 'Ebtables' require 'Firewall' -onevlan = EbtablesVLAN.from_base64(ARGV[0]) +template64 = ARGV[0] +deploy_id = ARGV[1] + +onevlan = EbtablesVLAN.from_base64(template64, deploy_id) onevlan.activate -fw = OpenNebulaFirewall.from_base64(ARGV[0]) +fw = OpenNebulaFirewall.from_base64(template64, deploy_id) fw.activate diff --git a/src/vnm_mad/remotes/fw/post b/src/vnm_mad/remotes/fw/post index 6458772e86..7b0afd182e 100755 --- a/src/vnm_mad/remotes/fw/post +++ b/src/vnm_mad/remotes/fw/post @@ -22,6 +22,9 @@ $: << File.join(File.dirname(__FILE__), "..") require 'OpenNebulaNetwork' require 'Firewall' -fw = OpenNebulaFirewall.from_base64(ARGV[0]) +template64 = ARGV[0] +deploy_id = ARGV[1] + +fw = OpenNebulaFirewall.from_base64(template64, deploy_id) fw.activate diff --git a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb index 2cdaeafd80..8471f66a30 100644 --- a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb +++ b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb @@ -18,8 +18,9 @@ require 'OpenNebulaNetwork' class OpenvSwitchVLAN < OpenNebulaNetwork XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" - def initialize(vm, hypervisor = nil) - super(vm,XPATH_FILTER,hypervisor) + + def initialize(vm, deploy_id = nil, hypervisor = nil) + super(vm,XPATH_FILTER,deploy_id,hypervisor) end def activate diff --git a/src/vnm_mad/remotes/ovswitch/post b/src/vnm_mad/remotes/ovswitch/post index 520d74a455..ceb0a0fc41 100755 --- a/src/vnm_mad/remotes/ovswitch/post +++ b/src/vnm_mad/remotes/ovswitch/post @@ -22,11 +22,13 @@ $: << File.join(File.dirname(__FILE__), "..") require 'OpenvSwitch' require 'Firewall' +template64 = ARGV[0] +deploy_id = ARGV[1] -onevlan = OpenvSwitchVLAN.from_base64(ARGV[0]) +onevlan = OpenvSwitchVLAN.from_base64(template64, deploy_id) onevlan.activate -fw = OpenNebulaFirewall.from_base64(ARGV[0]) +fw = OpenNebulaFirewall.from_base64(template64, deploy_id) fw.activate From 1d11cbc5866ffe1542b59a5f47daa716f21280ee Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 7 Dec 2011 14:26:45 +0100 Subject: [PATCH 17/27] Task #864, Feature #602: Small fixes to vnets in Sunstone. Removal of commented code. (cherry picked from commit 1ad5326f2927297ac04a9a9d36d1f95cc5c1ac34) --- src/sunstone/public/js/plugins/vnets-tab.js | 148 +++----------------- 1 file changed, 23 insertions(+), 125 deletions(-) diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index 21c6150945..cb0df258d2 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -87,11 +87,11 @@ var create_vn_tmpl =
\ \
\ - \ + \
\ - \ + \
\ - \ + \ \
\ \ @@ -280,27 +280,7 @@ var vnet_actions = { error: onError, notify: false, }, -/* - "Network.modifyleases" : { - type: "custom", - call: function(action,obj){ - nodes = getSelectedNodes(dataTable_vNetworks); - $.each(nodes,function(){ - Sunstone.runAction(action,this,obj); - }); - } - }, - "Network.addleases_dialog" : { - type: "custom", - call: popUpAddLeaseDialog - }, - - "Network.rmleases_dialog" : { - type: "custom", - call: popUpRemoveLeaseDialog - }, -*/ "Network.chown" : { type: "multiple", call: OpenNebula.Network.chown, @@ -390,21 +370,7 @@ var vnet_buttons = { tip: "Select the new group:", condition: mustBeAdmin, }, -/* - "action_list" : { - type: "select", - actions: { - "Network.addleases_dialog" : { - type: "action", - text: "Add lease" - }, - "Network.rmleases_dialog" : { - type: "action", - text: "Remove lease" - } - } - }, -*/ + "Network.delete" : { type: "action", text: "Delete" @@ -416,10 +382,10 @@ var vnet_info_panel = { title: "Virtual network information", content: "" }, - "vnet_template_tab" : { - title: "Virtual network template", + "vnet_leases_tab" : { + title: "Lease management", content: "" - } + }, } var vnets_tab = { @@ -547,31 +513,34 @@ function updateVNetworkInfo(request,vn){ \ '; - info_tab_content += printLeases(vn_info); + info_tab_content += '\ + \ + '+ + prettyPrintJSON(vn_info.TEMPLATE)+ + '
Virtual Network template (attributes)
' + + + var leases_tab_content = printLeases(vn_info); var info_tab = { title: "Virtual Network information", content: info_tab_content - } + }; - var template_tab = { - title: "Virtual Network template", - content: - '\ - '+ - prettyPrintJSON(vn_info.TEMPLATE)+ - '
Virtual Network template
' - } + var leases_tab = { + title: "Lease management", + content: leases_tab_content + }; Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_info_tab",info_tab); - Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_template_tab",template_tab); + Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_leases_tab",leases_tab); Sunstone.popUpInfoPanel("vnet_info_panel"); } function printLeases(vn_info){ - var html ='
\ + var html ='
\ \ \ '; @@ -1013,77 +982,6 @@ function setupLeasesOps(){ }); } - -/* -function setupAddRemoveLeaseDialog() { - dialogs_context.append('
'); - $lease_vn_dialog = $('#lease_vn_dialog',dialogs_context) - - var dialog = $lease_vn_dialog; - - dialog.html( - '\ -
\ -
Please specify:
\ - \ -
\ - \ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ - ' - ); - - //Prepare the jquery-ui dialog. Set style options here. - dialog.dialog({ - autoOpen: false, - modal: true, - width: 410, - height: 220 - }); - - $('button',dialog).button(); - - $('#lease_vn_form',dialog).submit(function(){ - var ip = $('#add_lease_ip',this).val(); - var mac = $('#add_lease_mac',this).val(); - - var obj = {ip: ip, mac: mac}; - - if (!mac.length) { delete obj.mac; }; - - Sunstone.runAction("Network.modifyleases", - $('#lease_vn_proceed',this).val(), - obj); - $lease_vn_dialog.dialog('close'); - return false; - }); -} - -function popUpAddLeaseDialog() { - $lease_vn_dialog.dialog("option","title","Add lease"); - $('#add_lease_mac',$lease_vn_dialog).show(); - $('#add_lease_mac_label',$lease_vn_dialog).show(); - $('#lease_vn_proceed',$lease_vn_dialog).val("Network.addleases"); - $lease_vn_dialog.dialog("open"); -} - -function popUpRemoveLeaseDialog() { - $lease_vn_dialog.dialog("option","title","Remove lease"); - $('#add_lease_mac',$lease_vn_dialog).hide(); - $('#add_lease_mac_label',$lease_vn_dialog).hide(); - $('#lease_vn_proceed',$lease_vn_dialog).val("Network.rmleases"); - $lease_vn_dialog.dialog("open"); -} - -*/ - function setVNetAutorefresh() { setInterval(function(){ var checked = $('input.check_item:checked',dataTable_vNetworks); @@ -1097,7 +995,7 @@ function setVNetAutorefresh() { function is_public_vnet(id) { var data = getElementData(id,"#vnetwork",dataTable_vNetworks)[7]; - return $(data).attr("checked"); + return $(data).is(":checked"); }; function setupVNetActionCheckboxes(){ From 63e9ad23f0a2b25d377668754bdd90d17d30448f Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 7 Dec 2011 18:55:17 +0100 Subject: [PATCH 18/27] Use HTTP_CODES in OCCI --- src/cloud/occi/lib/OCCIServer.rb | 99 +++++++++++--------------------- 1 file changed, 34 insertions(+), 65 deletions(-) diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb index 86e68c5fd9..0b5d26e5d2 100755 --- a/src/cloud/occi/lib/OCCIServer.rb +++ b/src/cloud/occi/lib/OCCIServer.rb @@ -118,13 +118,8 @@ class OCCIServer < CloudServer # --- Prepare XML Response --- rc = vmpool.info - if OpenNebula.is_error?(rc) - if rc.message.match("Error getting") - return rc, 404 - else - return rc, 500 - end + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end return to_occi_xml(vmpool, 200) @@ -143,13 +138,8 @@ class OCCIServer < CloudServer # --- Prepare XML Response --- rc = network_pool.info - if OpenNebula.is_error?(rc) - if rc.message.match("Error getting") - return rc, 404 - else - return rc, 500 - end + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end return to_occi_xml(network_pool, 200) @@ -167,13 +157,8 @@ class OCCIServer < CloudServer # --- Prepare XML Response --- rc = image_pool.info - if OpenNebula.is_error?(rc) - if rc.message.match("Error getting") - return rc, 404 - else - return rc, 500 - end + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end return to_occi_xml(image_pool, 200) @@ -189,7 +174,6 @@ class OCCIServer < CloudServer # --- Prepare XML Response --- rc = user_pool.info - if OpenNebula.is_error?(rc) return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end @@ -224,7 +208,9 @@ class OCCIServer < CloudServer return template, 500 if OpenNebula.is_error?(template) rc = vm.allocate(template) - return rc, 500 if OpenNebula.is_error?(rc) + if OpenNebula.is_error?(rc) + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] + end # --- Prepare XML Response --- vm.info @@ -243,13 +229,8 @@ class OCCIServer < CloudServer # --- Prepare XML Response --- rc = vm.info - if OpenNebula.is_error?(rc) - if rc.message.match("Error getting") - return rc, 404 - else - return rc, 500 - end + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end return to_occi_xml(vm, 200) @@ -266,12 +247,11 @@ class OCCIServer < CloudServer VirtualMachine.build_xml(params[:id]), @client) - rc = vm.info - return rc, 404 if OpenNebula::is_error?(rc) - # --- Finalize the VM --- result = vm.finalize - return result, 500 if OpenNebula::is_error?(result) + if OpenNebula.is_error?(result) + return result, CloudServer::HTTP_ERROR_CODE[result.errno] + end return "", 204 end @@ -321,7 +301,9 @@ class OCCIServer < CloudServer return template, 500 if OpenNebula.is_error?(template) rc = network.allocate(template) - return rc, 500 if OpenNebula.is_error?(rc) + if OpenNebula.is_error?(rc) + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] + end # --- Prepare XML Response --- network.info @@ -339,13 +321,8 @@ class OCCIServer < CloudServer # --- Prepare XML Response --- rc = network.info - if OpenNebula.is_error?(rc) - if rc.message.match("Error getting") - return rc, 404 - else - return rc, 500 - end + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end return to_occi_xml(network, 200) @@ -360,12 +337,11 @@ class OCCIServer < CloudServer VirtualNetwork.build_xml(params[:id]), @client) - rc = network.info - return rc, 404 if OpenNebula::is_error?(rc) - # --- Delete the VNET --- rc = network.delete - return rc, 500 if OpenNebula::is_error?(rc) + if OpenNebula.is_error?(rc) + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] + end return "", 204 end @@ -382,15 +358,15 @@ class OCCIServer < CloudServer VirtualNetwork.build_xml(params[:id]), @client) - rc = vnet.info - return rc, 400 if OpenNebula.is_error?(rc) - + rc = nil if vnet_info['PUBLIC'] == 'YES' rc = vnet.publish - return rc, 400 if OpenNebula.is_error?(rc) elsif vnet_info['PUBLIC'] == 'NO' rc = vnet.unpublish - return rc, 400 if OpenNebula.is_error?(rc) + end + + if OpenNebula.is_error?(rc) + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end # --- Prepare XML Response --- @@ -429,7 +405,9 @@ class OCCIServer < CloudServer return template, 500 if OpenNebula.is_error?(template) rc = image.allocate(template) - return rc, 500 if OpenNebula.is_error?(rc) + if OpenNebula.is_error?(rc) + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] + end # --- Prepare XML Response --- image.info @@ -447,13 +425,8 @@ class OCCIServer < CloudServer @client) rc = image.info - if OpenNebula.is_error?(rc) - if rc.message.match("Error getting") - return rc, 404 - else - return rc, 500 - end + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end # --- Prepare XML Response --- @@ -470,12 +443,11 @@ class OCCIServer < CloudServer Image.build_xml(params[:id]), @client) - rc = image.info - return rc, 404 if OpenNebula::is_error?(rc) - # --- Delete the Image --- rc = image.delete - return rc, 500 if OpenNebula::is_error?(rc) + if OpenNebula.is_error?(rc) + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] + end return "", 204 end @@ -492,24 +464,22 @@ class OCCIServer < CloudServer Image.build_xml(params[:id]), @client) - rc = image.info - return rc, 400 if OpenNebula.is_error?(rc) - + rc = nil if image_info['PERSISTENT'] && image_info['PUBLIC'] error_msg = "It is not allowed more than one change per request" return OpenNebula::Error.new(error_msg), 400 elsif image_info['PERSISTENT'] == 'YES' rc = image.persistent - return rc, 400 if OpenNebula.is_error?(rc) elsif image_info['PERSISTENT'] == 'NO' rc = image.nonpersistent - return rc, 400 if OpenNebula.is_error?(rc) elsif image_info['PUBLIC'] == 'YES' rc = image.publish - return rc, 400 if OpenNebula.is_error?(rc) elsif image_info['PUBLIC'] == 'NO' rc = image.unpublish - return rc, 400 if OpenNebula.is_error?(rc) + end + + if OpenNebula.is_error?(rc) + return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end # --- Prepare XML Response --- @@ -529,7 +499,6 @@ class OCCIServer < CloudServer # --- Prepare XML Response --- rc = user.info - if OpenNebula.is_error?(rc) return rc, CloudServer::HTTP_ERROR_CODE[rc.errno] end From 1a8b2ef6a487e7542a03a03eb29987d46b27b921 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Wed, 7 Dec 2011 19:01:41 +0100 Subject: [PATCH 19/27] feature #863: fix tests --- src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb b/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb index cfbfe8cf89..f451b53c3e 100644 --- a/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb +++ b/src/vnm_mad/remotes/test/OpenNebulaNetwork_spec.rb @@ -43,7 +43,7 @@ describe 'networking' do $capture_commands = { /virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml] } - onevlan = OpenNebulaNetwork.new(OUTPUT[:onevm_show],"TEMPLATE/NIC","kvm") + onevlan = OpenNebulaNetwork.new(OUTPUT[:onevm_show],"TEMPLATE/NIC",nil,"kvm") nics_expected = [{:bridge=>"br0", :ip=>"172.16.0.100", :mac=>"02:00:ac:10:00:64", @@ -76,7 +76,7 @@ describe 'ebtables' do /virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml], /ebtables/ => nil } - onevlan = EbtablesVLAN.new(OUTPUT[:onevm_show],"kvm") + onevlan = EbtablesVLAN.new(OUTPUT[:onevm_show],nil,"kvm") onevlan.activate ebtables_cmds = [ "sudo /sbin/ebtables -A FORWARD -s ! 02:00:ac:10:00:00/ff:ff:ff:ff:ff:00 -o vnet0 -j DROP", @@ -98,7 +98,7 @@ describe 'openvswitch' do /virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml], /ovs-vsctl/ => nil } - onevlan = OpenvSwitchVLAN.new(OUTPUT[:onevm_show],"kvm") + onevlan = OpenvSwitchVLAN.new(OUTPUT[:onevm_show],nil,"kvm") onevlan.activate openvswitch_tags = [ "sudo /usr/local/bin/ovs-vsctl set Port vnet0 tag=2", @@ -117,7 +117,7 @@ describe 'openvswitch' do /brctl show/ => OUTPUT[:brctl_show], /ovs-vsctl/ => nil } - onevlan = OpenvSwitchVLAN.new(OUTPUT[:onevm_show_vlan_id_kvm],"kvm") + onevlan = OpenvSwitchVLAN.new(OUTPUT[:onevm_show_vlan_id_kvm],nil,"kvm") onevlan.activate onevlan_rules = ["sudo /usr/local/bin/ovs-vsctl set Port vnet0 tag=6", @@ -166,7 +166,7 @@ describe 'host-managed' do /ip link set/ => nil, /ip link show/ => [nil,255] } - hm = OpenNebulaHM.new(OUTPUT[:onevm_show_phydev_kvm],"kvm") + hm = OpenNebulaHM.new(OUTPUT[:onevm_show_phydev_kvm],nil,"kvm") hm.activate hm_activate_rules = ["sudo /sbin/brctl addbr onebr6", @@ -189,7 +189,7 @@ describe 'host-managed' do /ip link set/ => nil, /ip link show/ => [nil,255] } - hm = OpenNebulaHM.new(OUTPUT[:onevm_show_vlan_id_kvm],"kvm") + hm = OpenNebulaHM.new(OUTPUT[:onevm_show_vlan_id_kvm],nil,"kvm") hm.activate hm_vlan_id = ["sudo /sbin/brctl addbr onebr10", @@ -222,7 +222,7 @@ describe 'host-managed' do - hm = OpenNebulaHM.new(OUTPUT[:onevm_show_mixed],"kvm") + hm = OpenNebulaHM.new(OUTPUT[:onevm_show_mixed],nil,"kvm") hm.activate hm_vlan_tag = [ "sudo /sbin/brctl show", From 966db944785aa6e899d352d947e04f5cdcc1d839 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 7 Dec 2011 19:03:41 +0100 Subject: [PATCH 20/27] Do not show FSTYPE in OCCI if type OS --- src/cloud/occi/lib/ImageOCCI.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cloud/occi/lib/ImageOCCI.rb b/src/cloud/occi/lib/ImageOCCI.rb index cd573554c3..50a12133f5 100755 --- a/src/cloud/occi/lib/ImageOCCI.rb +++ b/src/cloud/occi/lib/ImageOCCI.rb @@ -30,7 +30,7 @@ class ImageOCCI < Image <%= self['TEMPLATE/DESCRIPTION'] %> <% end %> <%= self['SIZE'] %> - <% if self['FSTYPE'] != nil %> + <% if self['FSTYPE'] != nil and !self['FSTYPE'].empty? %> <%= self['FSTYPE'] %> <% end %> <%= self['PUBLIC'] == "0" ? "NO" : "YES"%> From 6d0b58da21363b1c091a74ccc1a268f37a48342b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 7 Dec 2011 19:18:38 +0100 Subject: [PATCH 21/27] onedb migrator to 3.1.80: Improvements, better handling of new VLAN attribute for VNETs --- src/onedb/3.1.0_to_3.1.80.rb | 110 +++++++++++++++++++++++++++++++---- 1 file changed, 99 insertions(+), 11 deletions(-) diff --git a/src/onedb/3.1.0_to_3.1.80.rb b/src/onedb/3.1.0_to_3.1.80.rb index 5a27679015..5644157197 100644 --- a/src/onedb/3.1.0_to_3.1.80.rb +++ b/src/onedb/3.1.0_to_3.1.80.rb @@ -28,13 +28,42 @@ module Migrator end def up - puts " > Networking isolation hooks have been moved to Host drivers.\n"<< - " If you were using a networking hook, enter its name, or press enter\n"<< - " to use the default dummy vn_mad driver.\n\n" - print " Driver name (802.1Q, dummy, ebtables, ovswitch): " - vn_mad = gets.chomp + puts " > Networking isolation hooks have been moved to Host drivers.\n"<< + " If you were using a networking hook, enter its name, or press enter\n"<< + " to use the default dummy vn_mad driver.\n\n" - vn_mad = "dummy" if vn_mad.empty? + vn_mad = "" + + while !( ["802.1Q", "dummy", "ebtables", "ovswitch"].include?(vn_mad) ) do + print " Driver name (802.1Q, dummy, ebtables, ovswitch): " + vn_mad = gets.chomp + vn_mad = "dummy" if vn_mad.empty? + end + + # 0 = all, 1 = none, 2 = interactive + vlan_option = 1 + + if ( vn_mad == "ebtables" || vn_mad == "ovswitch" ) + puts + puts " > A new attribute, VLAN = YES/NO will be added to each VNET.\n"<< + " For driver '#{vn_mad}', please choose if you want to isolate all networks (all),\n"<< + " none (none), or be asked individually for each VNET (interactive)\n" + + vlan = "" + while !( ["all", "none", "interactive"].include?(vlan) ) do + print " Isolate VNETs (all, none, interactive): " + vlan = gets.chomp + end + + case vlan + when "all" + vlan_option = 0 + when "none" + vlan_option = 1 + when "interactive" + vlan_option = 2 + end + end # New VN_MAD element for hosts @@ -80,7 +109,19 @@ module Migrator net_address = e.text } - net_address = IPAddr.new(net_address, Socket::AF_INET) + net_valid = false + while !net_valid do + begin + net_address = IPAddr.new(net_address, Socket::AF_INET) + net_valid = true + rescue ArgumentError + puts + puts " > Error processing VNET ##{row[:oid]} '#{row[:name]}'\n"<< + " This network address is invalid: '#{net_address}'\n" + print " Please enter a valid network address: " + net_address = gets.chomp + end + end st_size = "" @@ -98,18 +139,44 @@ module Migrator size = st_size.to_i host_bits = (Math.log(size+2)/Math.log(2)).ceil end - + net_mask = 0xFFFFFFFF << host_bits net_address = net_address.to_i & net_mask - ip_start_elem.text = IPAddr.new((ip_start = net_address + 1), Socket::AF_INET).to_s + ip_start_elem.text = IPAddr.new((net_address + 1), Socket::AF_INET).to_s ip_end_elem.text = IPAddr.new((net_address + (1 << host_bits) - 2), Socket::AF_INET).to_s end - # TODO: Set vlan = 1 if PHYDEV is set + phydev_present = false + doc.root.each_element("PHYDEV") { |e| + phydev_present = true + } + vlan_elem = doc.root.add_element("VLAN") - vlan_elem.text = "0" + + if phydev_present + vlan_elem.text = "1" + else + case vlan_option + when 0 + vlan_elem.text = "1" + when 1 + vlan_elem.text = "0" + when 2 + vlan = "" + while !( ["y", "n"].include?(vlan) ) do + print " > Isolate VNET ##{row[:oid]} '#{row[:name]}'? (y/n) : " + vlan = gets.chomp + end + + if ( vlan == "y" ) + vlan_elem.text = "1" + else + vlan_elem.text = "0" + end + end + end @db[:network_pool].insert( :oid => row[:oid], @@ -122,6 +189,27 @@ module Migrator @db.run "DROP TABLE old_network_pool;" + # Add empty HISTORY_RECORDS element to VMs without any records + @db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;" + @db.run "CREATE TABLE vm_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, last_poll INTEGER, state INTEGER, lcm_state INTEGER);" + @db.run "INSERT INTO vm_pool SELECT * FROM old_vm_pool;" + + @db.fetch("SELECT * FROM old_vm_pool") do |row| + doc = Document.new(row[:body]) + + found = false + doc.root.each_element("HISTORY_RECORDS") { |e| + found = true + } + + if !found + doc.root.add_element("HISTORY_RECORDS") + end + end + + @db.run "DROP TABLE old_vm_pool;" + + return true end end From 10e52c413c7c94533669c48fc93d1b9a9eef8696 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 8 Dec 2011 00:08:18 +0100 Subject: [PATCH 22/27] Add network.erb for OCCI --- src/cloud/occi/etc/templates/network.erb | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/cloud/occi/etc/templates/network.erb diff --git a/src/cloud/occi/etc/templates/network.erb b/src/cloud/occi/etc/templates/network.erb new file mode 100644 index 0000000000..6dfb23079a --- /dev/null +++ b/src/cloud/occi/etc/templates/network.erb @@ -0,0 +1,25 @@ +# +# This template is processed by the OCCI Server to include specific data for +# the VNET, you should not need to modify the ruby code. +# You can add common attributes for your VNET templates (e.g. VLAN, PHYDEV) +# + +NAME = "<%= @vnet_info['NAME'] %>" +TYPE = RANGED + +NETWORK_ADDRESS = <%= @vnet_info['ADDRESS'] %> +<% if @vnet_info['SIZE'] != nil %> +NETWORK_SIZE = <%= @vnet_info['SIZE']%> +<% end %> + +<% if @vnet_info['DESCRIPTION'] != nil %> +DESCRIPTION = "<%= @vnet_info['DESCRIPTION'] %>" +<% end %> + +<% if @vnet_info['PUBLIC'] != nil %> +PUBLIC = "<%= @vnet_info['PUBLIC'] %>" +<% end %> + +#BRIDGE = NAME_OF_DEFAULT_BRIDGE +#PHYDEV = NAME_OF_PHYSICAL_DEVICE +#VLAN = YES|NO From dca599c5dc54bcbb51e1852543f496f063eef8e8 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 8 Dec 2011 00:29:05 +0100 Subject: [PATCH 23/27] feature #863: Make use of action_info to pass extra parameters to net drivers --- src/vmm_mad/exec/one_vmm_exec.rb | 14 +++++--------- src/vnm_mad/one_vnm.rb | 10 ++++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/vmm_mad/exec/one_vmm_exec.rb b/src/vmm_mad/exec/one_vmm_exec.rb index ffd1bd6069..960d877065 100755 --- a/src/vmm_mad/exec/one_vmm_exec.rb +++ b/src/vmm_mad/exec/one_vmm_exec.rb @@ -72,16 +72,14 @@ class VmmAction @vnm_src = VirtualNetworkDriver.new(@data[:net_drv], :local_actions => @vmm.options[:local_actions], :message => @xml_data, - :ssh_stream => @ssh_src, - :extra_data => @data) + :ssh_stream => @ssh_src) if @data[:dest_host] and !@data[:dest_host].empty? @ssh_dst = @vmm.get_ssh_stream(@data[:dest_host], @id) @vnm_dst = VirtualNetworkDriver.new(@data[:dest_driver], :local_actions => @vmm.options[:local_actions], :message => @xml_data, - :ssh_stream => @ssh_dst, - :extra_data => @data) + :ssh_stream => @ssh_dst) end end @@ -149,7 +147,8 @@ class VmmAction vnm = @vnm_src end - result, info = vnm.do_action(@id, step[:action]) + result, info = vnm.do_action(@id, step[:action], + :parameters => get_parameters(step[:parameters])) else result = DriverExecHelper.const_get(:RESULT)[:failure] info = "No driver in #{step[:action]}" @@ -157,7 +156,6 @@ class VmmAction # Save the step info @data["#{step[:action]}_info".to_sym] = info - @data[step[:save_info_as]] = info if step[:save_info_as] # Roll back steps, store failed info and break steps if DriverExecHelper.failed?(result) @@ -280,12 +278,12 @@ class ExecDriver < VirtualMachineDriver :action => :deploy, :parameters => [dfile, :host], :stdin => domain, - :save_info_as => :deploy_id }, # Execute post-boot networking setup { :driver => :vnm, :action => :post, + :parameters => [:deploy_info] :fail_actions => [ { :driver => :vmm, @@ -496,5 +494,3 @@ exec_driver = ExecDriver.new(hypervisor, :local_actions => local_actions) exec_driver.start_driver - - diff --git a/src/vnm_mad/one_vnm.rb b/src/vnm_mad/one_vnm.rb index 23dba5a34e..30c886e97a 100644 --- a/src/vnm_mad/one_vnm.rb +++ b/src/vnm_mad/one_vnm.rb @@ -31,7 +31,6 @@ class VirtualNetworkDriver @options = options @ssh_stream = options[:ssh_stream] @message = options[:message] - @extra_data = options[:extra_data] @vm_encoded = Base64.encode64(@message.elements['VM'].to_s).delete("\n") @@ -45,14 +44,17 @@ class VirtualNetworkDriver # @param [String, Symbol] aname name of the action # @param [Hash] ops extra options for the command # @option ops [String] :stdin text to be writen to stdin + # @option ops [String] :parameters additional parameters for vnm action def do_action(id, aname, ops = {}) options={ - :stdin => nil, + :stdin => nil, + :parameters => nil }.merge(ops) - deploy_id=@extra_data[:deploy_id] || '-' + cmd_params = "#{@vm_encoded}" + cmd_params << " #{options[:parameters]}" if options[:parameters] - cmd = action_command_line(aname, "#{@vm_encoded} #{deploy_id}") + cmd = action_command_line(aname, cmd_params) if action_is_local?(aname) execution = LocalCommand.run(cmd, log_method(id)) From 9bbbd291f6fb945d40c1f4f90f8e21659ade5aae Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 8 Dec 2011 03:39:52 +0100 Subject: [PATCH 24/27] Add network.erb to install.sh --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 1e75815fd8..3d4e4e933d 100755 --- a/install.sh +++ b/install.sh @@ -959,6 +959,7 @@ OCCI_ETC_TEMPLATE_FILES="src/cloud/occi/etc/templates/common.erb \ src/cloud/occi/etc/templates/custom.erb \ src/cloud/occi/etc/templates/small.erb \ src/cloud/occi/etc/templates/medium.erb \ + src/cloud/occi/etc/templates/network.erb \ src/cloud/occi/etc/templates/large.erb" #----------------------------------------------------------------------------- From 1da7f8be130b041d5c771c24173301ae43298c26 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 8 Dec 2011 22:49:05 +0100 Subject: [PATCH 25/27] add net-ldap to install_gems, needed by ldap auth --- share/install_gems/install_gems | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index e2c37f9ccf..3b85b5069c 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -2,7 +2,7 @@ require 'pp' -DEFAULT=%w{optional sunstone quota cloud ozones_server acct} +DEFAULT=%w{optional sunstone quota cloud ozones_server acct auth_ldap} if defined?(RUBY_VERSION) && RUBY_VERSION>="1.8.7" SQLITE='sqlite3' @@ -31,7 +31,8 @@ GROUPS={ :ozones_server_mysql => %w{json data_mapper dm-mysql-adapter mysql}, :acct => ['sequel', SQLITE, 'mysql'], :acct_sqlite => ['sequel', SQLITE], - :acct_mysql => ['sequel', 'mysql'] + :acct_mysql => ['sequel', 'mysql'], + :auth_ldap => 'net-ldap' } PACKAGES=GROUPS.keys From 67a594474e574519faa5946acd6893417bee7984 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 9 Dec 2011 16:51:56 +0100 Subject: [PATCH 26/27] feature #863: fixes bug --- src/vmm_mad/exec/one_vmm_exec.rb | 2 +- src/vnm_mad/remotes/test/output/onevm_show_xen | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/exec/one_vmm_exec.rb b/src/vmm_mad/exec/one_vmm_exec.rb index 960d877065..324542ac89 100755 --- a/src/vmm_mad/exec/one_vmm_exec.rb +++ b/src/vmm_mad/exec/one_vmm_exec.rb @@ -283,7 +283,7 @@ class ExecDriver < VirtualMachineDriver { :driver => :vnm, :action => :post, - :parameters => [:deploy_info] + :parameters => [:deploy_info], :fail_actions => [ { :driver => :vmm, diff --git a/src/vnm_mad/remotes/test/output/onevm_show_xen b/src/vnm_mad/remotes/test/output/onevm_show_xen index 9f0685ad44..4952762493 100644 --- a/src/vnm_mad/remotes/test/output/onevm_show_xen +++ b/src/vnm_mad/remotes/test/output/onevm_show_xen @@ -34,7 +34,7 @@ - + From bcd9281b638c7f1a5c813d9b64d66c1a6ca7432b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 10 Dec 2011 21:08:03 +0100 Subject: [PATCH 27/27] bug: solve reference by name in CONTEXT attribute for name and virtual network --- src/vm/vm_var_syntax.cc | 42 +++++++++++++++++++---------------------- src/vm/vm_var_syntax.h | 2 +- src/vm/vm_var_syntax.y | 20 ++++++++------------ 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/vm/vm_var_syntax.cc b/src/vm/vm_var_syntax.cc index 6a75d06320..a8b665169b 100644 --- a/src/vm/vm_var_syntax.cc +++ b/src/vm/vm_var_syntax.cc @@ -146,7 +146,6 @@ void get_image_attribute(VirtualMachine * vm, ImagePool * ipool = nd.get_ipool(); Image * img; int iid = -1; - string iid_str; int num; vector attrs; @@ -154,7 +153,7 @@ void get_image_attribute(VirtualMachine * vm, attr_value.clear(); - if (img_name.empty() || img_name != "IMAGE_ID") + if ( img_name.empty() || (img_name!="IMAGE" && img_name!="IMAGE_ID") ) { return; } @@ -174,11 +173,10 @@ void get_image_attribute(VirtualMachine * vm, continue; } - iid_str = disk->vector_value("IMAGE_ID"); - - if ( iid_str == img_value ) + if ( disk->vector_value(img_name.c_str()) == img_value ) { - istringstream iss(img_value); + string iid_str = disk->vector_value("IMAGE_ID"); + istringstream iss(iid_str); iss >> iid; @@ -232,7 +230,6 @@ void get_network_attribute(VirtualMachine * vm, VirtualNetworkPool * vnpool = nd.get_vnpool(); VirtualNetwork * vn; int vnet_id = -1; - string vnet_id_str; int num; vector attrs; @@ -240,7 +237,7 @@ void get_network_attribute(VirtualMachine * vm, attr_value.clear(); - if (net_name.empty() || net_name != "NETWORK_ID") + if ( net_name.empty() || (net_name!="NETWORK" && net_name!="NETWORK_ID") ) { return; } @@ -260,11 +257,10 @@ void get_network_attribute(VirtualMachine * vm, continue; } - vnet_id_str = net->vector_value("NETWORK_ID"); - - if ( vnet_id_str == net_value ) + if ( net->vector_value(net_name.c_str()) == net_value ) { - istringstream iss(net_value); + string vnet_id_str = net->vector_value("NETWORK_ID"); + istringstream iss(vnet_id_str); iss >> vnet_id; @@ -460,7 +456,7 @@ void insert_vector(VirtualMachine * vm, /* Line 268 of yacc.c */ -#line 464 "vm_var_syntax.cc" +#line 460 "vm_var_syntax.cc" /* Enabling traces. */ #ifndef YYDEBUG @@ -506,7 +502,7 @@ typedef union YYSTYPE { /* Line 293 of yacc.c */ -#line 408 "vm_var_syntax.y" +#line 404 "vm_var_syntax.y" char * val_str; int val_int; @@ -515,7 +511,7 @@ typedef union YYSTYPE /* Line 293 of yacc.c */ -#line 519 "vm_var_syntax.cc" +#line 515 "vm_var_syntax.cc" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -540,7 +536,7 @@ typedef struct YYLTYPE /* Line 343 of yacc.c */ -#line 544 "vm_var_syntax.cc" +#line 540 "vm_var_syntax.cc" #ifdef short # undef short @@ -830,7 +826,7 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 432, 432, 433, 436, 440, 453, 468 + 0, 428, 428, 429, 432, 436, 449, 464 }; #endif @@ -1831,7 +1827,7 @@ yyreduce: case 4: /* Line 1806 of yacc.c */ -#line 437 "vm_var_syntax.y" +#line 433 "vm_var_syntax.y" { (*parsed) << (yyvsp[(1) - (1)].val_str); } @@ -1840,7 +1836,7 @@ yyreduce: case 5: /* Line 1806 of yacc.c */ -#line 441 "vm_var_syntax.y" +#line 437 "vm_var_syntax.y" { string name((yyvsp[(1) - (2)].val_str)); @@ -1858,7 +1854,7 @@ yyreduce: case 6: /* Line 1806 of yacc.c */ -#line 454 "vm_var_syntax.y" +#line 450 "vm_var_syntax.y" { string name((yyvsp[(1) - (5)].val_str)); string vname((yyvsp[(3) - (5)].val_str)); @@ -1878,7 +1874,7 @@ yyreduce: case 7: /* Line 1806 of yacc.c */ -#line 469 "vm_var_syntax.y" +#line 465 "vm_var_syntax.y" { string name((yyvsp[(1) - (9)].val_str)); string vname((yyvsp[(3) - (9)].val_str)); @@ -1901,7 +1897,7 @@ yyreduce: /* Line 1806 of yacc.c */ -#line 1905 "vm_var_syntax.cc" +#line 1901 "vm_var_syntax.cc" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2139,7 +2135,7 @@ yyreturn: /* Line 2067 of yacc.c */ -#line 487 "vm_var_syntax.y" +#line 483 "vm_var_syntax.y" extern "C" void vm_var__error( diff --git a/src/vm/vm_var_syntax.h b/src/vm/vm_var_syntax.h index d40f8d1d51..337bb45d68 100644 --- a/src/vm/vm_var_syntax.h +++ b/src/vm/vm_var_syntax.h @@ -56,7 +56,7 @@ typedef union YYSTYPE { /* Line 2068 of yacc.c */ -#line 408 "vm_var_syntax.y" +#line 404 "vm_var_syntax.y" char * val_str; int val_int; diff --git a/src/vm/vm_var_syntax.y b/src/vm/vm_var_syntax.y index bd75e41a02..027dade20e 100644 --- a/src/vm/vm_var_syntax.y +++ b/src/vm/vm_var_syntax.y @@ -85,7 +85,6 @@ void get_image_attribute(VirtualMachine * vm, ImagePool * ipool = nd.get_ipool(); Image * img; int iid = -1; - string iid_str; int num; vector attrs; @@ -93,7 +92,7 @@ void get_image_attribute(VirtualMachine * vm, attr_value.clear(); - if (img_name.empty() || img_name != "IMAGE_ID") + if ( img_name.empty() || (img_name!="IMAGE" && img_name!="IMAGE_ID") ) { return; } @@ -113,11 +112,10 @@ void get_image_attribute(VirtualMachine * vm, continue; } - iid_str = disk->vector_value("IMAGE_ID"); - - if ( iid_str == img_value ) + if ( disk->vector_value(img_name.c_str()) == img_value ) { - istringstream iss(img_value); + string iid_str = disk->vector_value("IMAGE_ID"); + istringstream iss(iid_str); iss >> iid; @@ -171,7 +169,6 @@ void get_network_attribute(VirtualMachine * vm, VirtualNetworkPool * vnpool = nd.get_vnpool(); VirtualNetwork * vn; int vnet_id = -1; - string vnet_id_str; int num; vector attrs; @@ -179,7 +176,7 @@ void get_network_attribute(VirtualMachine * vm, attr_value.clear(); - if (net_name.empty() || net_name != "NETWORK_ID") + if ( net_name.empty() || (net_name!="NETWORK" && net_name!="NETWORK_ID") ) { return; } @@ -199,11 +196,10 @@ void get_network_attribute(VirtualMachine * vm, continue; } - vnet_id_str = net->vector_value("NETWORK_ID"); - - if ( vnet_id_str == net_value ) + if ( net->vector_value(net_name.c_str()) == net_value ) { - istringstream iss(net_value); + string vnet_id_str = net->vector_value("NETWORK_ID"); + istringstream iss(vnet_id_str); iss >> vnet_id;
Leases information