mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Add IPv6 support.
This commit is contained in:
parent
0738ec7ec4
commit
c5a96b7662
5 changed files with 391 additions and 128 deletions
|
|
@ -86,11 +86,24 @@ def network(request, compute_id, pool):
|
|||
state = conn.is_active()
|
||||
device = conn.get_bridge_device()
|
||||
autostart = conn.get_autostart()
|
||||
ipv4_forward = conn.get_ipv4_forward()
|
||||
ipv4_dhcp_range_start = conn.get_ipv4_dhcp_range_start()
|
||||
ipv4_dhcp_range_end = conn.get_ipv4_dhcp_range_end()
|
||||
ipv4_network = conn.get_ipv4_network()
|
||||
fixed_address = conn.get_mac_ipaddr()
|
||||
net_forward = conn.get_network_forward()
|
||||
dhcp_range_start = ipv4_dhcp_range_end = dict()
|
||||
|
||||
ip_networks = conn.get_ip_networks()
|
||||
for family, ip_network in ip_networks.items():
|
||||
if family == "ipv4":
|
||||
ipv4_dhcp_range_start = conn.get_dhcp_range_start(family)
|
||||
ipv4_dhcp_range_end = conn.get_dhcp_range_end(family)
|
||||
ipv4_network = ip_network
|
||||
ipv4_fixed_address = conn.get_dhcp_host_addr(family)
|
||||
elif family == "ipv6":
|
||||
ipv6_dhcp_range_start = conn.get_dhcp_range_start(family)
|
||||
ipv6_dhcp_range_end = conn.get_dhcp_range_end(family)
|
||||
ipv6_network = ip_network
|
||||
ipv6_fixed_address = conn.get_dhcp_host_addr(family)
|
||||
else:
|
||||
raise Exception("Unknown Network Family")
|
||||
|
||||
xml = conn._XMLDesc(0)
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
|
@ -130,26 +143,34 @@ def network(request, compute_id, pool):
|
|||
if 'modify_fixed_address' in request.POST:
|
||||
name = request.POST.get('name', '')
|
||||
address = request.POST.get('address', '')
|
||||
mac = request.POST.get('mac', '')
|
||||
family = request.POST.get('family', 'ipv4')
|
||||
|
||||
if family == 'ipv4':
|
||||
mac_duid = request.POST.get('mac', '')
|
||||
if family == 'ipv6':
|
||||
mac_duid = request.POST.get('id', '')
|
||||
|
||||
try:
|
||||
ret_val = conn.modify_fixed_address(name, address, mac)
|
||||
messages.success(request, "Fixed Address Operation Completed.")
|
||||
ret_val = conn.modify_fixed_address(name, address, mac_duid, family)
|
||||
messages.success(request, "{} Fixed Address Operation Completed.".format(family))
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err.message)
|
||||
except ValueError as val_err:
|
||||
error_messages.append(val_err.message)
|
||||
if 'delete_fixed_address' in request.POST:
|
||||
mac = request.POST.get('mac', '')
|
||||
conn.delete_fixed_address(mac)
|
||||
messages.success(request, "Fixed Address is Deleted.")
|
||||
ip = request.POST.get('address', '')
|
||||
family = request.POST.get('family', 'ipv4')
|
||||
conn.delete_fixed_address(ip, family)
|
||||
messages.success(request, "{} Fixed Address is Deleted.".format(family))
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
if 'modify_dhcp_range' in request.POST:
|
||||
range_start = request.POST.get('range_start', '')
|
||||
range_end = request.POST.get('range_end', '')
|
||||
family = request.POST.get('family', 'ipv4')
|
||||
try:
|
||||
conn.modify_dhcp_range(range_start, range_end)
|
||||
messages.success(request, "DHCP Range is Changed.")
|
||||
conn.modify_dhcp_range(range_start, range_end, family)
|
||||
messages.success(request, "{} DHCP Range is Changed.".format(family))
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err.message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue