1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Feature #3306: Add IPv4, IPv6 support for vCenter networks

This commit is contained in:
Tino Vazquez 2014-12-10 19:19:19 +01:00 committed by Ruben S. Montero
parent 98df77f19b
commit 57606c6084
2 changed files with 70 additions and 14 deletions

View File

@ -268,6 +268,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
next if STDIN.gets.strip.downcase != 'y'
# Size
STDOUT.print " How many VMs are you planning"\
" to fit into this network [255]? "
@ -275,11 +277,68 @@ cmd=CommandParser::CmdParser.new(ARGV) do
size = "255" if size.to_i.to_s != size
# Type
STDOUT.print " What type of Virtual Network"\
" do you want to create (IPv[4],IPv[6]"\
",[E]thernet) ?"
type = STDIN.gets.strip
ar_str = "\nAR=[TYPE=\""
case type.downcase
when "4"
ar_str += "IP4\""
STDOUT.print " Please input the first IP "\
"in the range: "
ip = STDIN.gets.strip
ar_str += ",IP=" + ip
STDOUT.print " Please input the first MAC "\
"in the range [Enter for default]: "
mac = STDIN.gets.strip
ar_str += ",MAC=" + mac if !mac.empty?
when "6"
ar_str += "IP6\""
STDOUT.print " Please input the first MAC "\
"in the range [Enter for default]: "
mac = STDIN.gets.strip
ar_str += ",MAC=" + mac if !mac.empty?
STDOUT.print " Please input the GLOBAL PREFIX "\
"[Enter for default]: "
gp = STDIN.gets.strip
ar_str += ",GLOBAL_PREFIX=" + gp if !gp.empty?
STDOUT.print " Please input the ULA PREFIX "\
"[Enter for default]: "
up = STDIN.gets.strip
ar_str += ",ULA_PREFIX=" + up if !up.empty?
when "E"
ar_str += "ETHER\""
STDOUT.print " Please input the first MAC "\
"in the range [Enter for default]: "
mac = STDIN.gets.strip
ar_str += ",MAC=" + mac if !mac.empty?
else
STDOUT.puts " Type [#{type}] not supported,"\
" defaulting to Ethernet."
ar_str += "ETHER\""
STDOUT.print " Please input the first MAC "\
"in the range [Enter for default]: "
mac = STDIN.gets.strip
ar_str += ",MAC=" + mac if !mac.empty?
end
ar_str += ",SIZE = \"#{size}\"]"
one_vn = ::OpenNebula::VirtualNetwork.new(
::OpenNebula::Template.build_xml, vc.one)
vnet_template = n[:one] +
" SIZE = \"#{size.to_i}\"\n]"
vnet_template = n[:one] + ar_str
puts vnet_template
rc = one_vn.allocate(vnet_template)

View File

@ -254,9 +254,7 @@ class VIClient
networks.each { |n|
vnet_template = "NAME=\"#{n[:name]}\"\n" +
"BRIDGE=\"#{n[:name]}\"\n" +
"VCENTER_TYPE=\"Port Group\"" +
"AR=[\n" +
" TYPE = \"ETHER\"\n,"
"VCENTER_TYPE=\"Port Group\""
one_nets << {:name => n.name,
:bridge => n.name,
@ -270,9 +268,7 @@ class VIClient
networks.each { |n|
vnet_template = "NAME=\"#{n[:name]}\"\n" +
"BRIDGE=\"#{n[:name]}\"\n" +
"VCENTER_TYPE=\"Distributed Port Group\"" +
"AR=[\n" +
" TYPE = \"ETHER\"\n,"
"VCENTER_TYPE=\"Distributed Port Group\""
vlan = n.config.defaultPortConfig.vlan.vlanId
vlan_str = ""
@ -288,18 +284,19 @@ class VIClient
end
end
if !vlan_str.empty?
vnet_template = "VLAN=\"YES\"\nVLAN_ID=#{vlan_str}\n" +
vnet_template
end
one_net = {:name => n.name,
:bridge => n.name,
:type => "Distributed Port Group",
:one => vnet_template}
if !vlan_str.empty?
one_net[:vlan] = vlan_str
vnet_template = "VLAN=\"YES\"\nVLAN_ID=#{one_net[:vlan]}" +
vnet_template
end
one_net[:vlan] = vlan_str if !vlan_str.empty?
one_nets << one_net
one_nets << one_net
}
vcenter_networks[dc.name] = one_nets