mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #3201: onevnet addar accepts a template file
This commit is contained in:
parent
9a6dee3eea
commit
2f54a3b9c1
@ -112,43 +112,49 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Adds an address range to the Virtual Network
|
||||
EOT
|
||||
|
||||
command :addar, addar_desc, :vnetid,
|
||||
command :addar, addar_desc, :vnetid, [:file, nil],
|
||||
:options => STD_OPTIONS + OneVNetHelper::ADDAR_OPTIONS do
|
||||
helper.perform_action(args[0],options,"lease added") do |vn|
|
||||
ar = "AR = [ "
|
||||
|
||||
if options[:ip]
|
||||
if options[:ip6_global] || options[:ip6_ula]
|
||||
ar << "TYPE=\"IP4_6\""
|
||||
else
|
||||
ar << "TYPE=\"IP4\""
|
||||
end
|
||||
if args[1]
|
||||
ar = File.read(args[1])
|
||||
else
|
||||
if options[:ip6_global] || options[:ip6_ula]
|
||||
ar << "TYPE=\"IP6\""
|
||||
ar = "AR = [ "
|
||||
|
||||
if options[:ip]
|
||||
if options[:ip6_global] || options[:ip6_ula]
|
||||
ar << "TYPE=\"IP4_6\""
|
||||
else
|
||||
ar << "TYPE=\"IP4\""
|
||||
end
|
||||
else
|
||||
ar << "TYPE=\"ETHER\""
|
||||
if options[:ip6_global] || options[:ip6_ula]
|
||||
ar << "TYPE=\"IP6\""
|
||||
else
|
||||
ar << "TYPE=\"ETHER\""
|
||||
end
|
||||
end
|
||||
|
||||
if options[:size]
|
||||
ar << ", SIZE = " << options[:size]
|
||||
else
|
||||
STDERR.puts "Address range needs to specify size (-s size)"
|
||||
exit -1
|
||||
end
|
||||
|
||||
ar << ", IP = " << options[:ip] if options[:ip]
|
||||
ar << ", MAC = " << options[:mac] if options[:mac]
|
||||
ar << ", GLOBAL_PREFIX = " <<
|
||||
options[:ip6_global] if options[:ip6_global]
|
||||
ar << ", ULA_PREFIX = " <<
|
||||
options[:ip6_ula] if options[:ip6_ula]
|
||||
ar << ", GATEWAY = " << options[:gateway] if options[:gateway]
|
||||
ar << ", MASK = " << options[:netmask] if options[:netmask]
|
||||
ar << ", VLAN = YES" if options[:vlan]
|
||||
ar << ", VLAN_ID = " << options[:vlanid] if options[:vlanid]
|
||||
|
||||
ar << "]"
|
||||
end
|
||||
|
||||
if options[:size]
|
||||
ar << ", SIZE = " << options[:size]
|
||||
else
|
||||
STDERR.puts "Address range needs to specify size (-s size)"
|
||||
exit -1
|
||||
end
|
||||
|
||||
ar << ", IP = " << options[:ip] if options[:ip]
|
||||
ar << ", MAC = " << options[:mac] if options[:mac]
|
||||
ar << ", GLOBAL_PREFIX = " << options[:ip6_global] if options[:ip6_global]
|
||||
ar << ", ULA_PREFIX = " << options[:ip6_ula] if options[:ip6_ula]
|
||||
ar << ", GATEWAY = " << options[:gateway] if options[:gateway]
|
||||
ar << ", MASK = " << options[:netmask] if options[:netmask]
|
||||
ar << ", VLAN = YES" if options[:vlan]
|
||||
ar << ", VLAN_ID = " << options[:vlanid] if options[:vlanid]
|
||||
|
||||
ar << "]"
|
||||
|
||||
vn.add_ar(ar)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user