mirror of
https://github.com/retspen/webvirtcloud
synced 2025-01-12 08:25:18 +00:00
guess_mac checks for existing dhcp_file
This commit is contained in:
parent
16510dee59
commit
510e0e6ee5
1 changed files with 10 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import socket
|
import socket
|
||||||
|
@ -676,14 +677,15 @@ def inst_graph(request, compute_id, vname):
|
||||||
def guess_mac_address(request, vname):
|
def guess_mac_address(request, vname):
|
||||||
dhcp_file = '/srv/webvirtcloud/dhcpd.conf'
|
dhcp_file = '/srv/webvirtcloud/dhcpd.conf'
|
||||||
data = { 'vname': vname, 'mac': '52:54:00:' }
|
data = { 'vname': vname, 'mac': '52:54:00:' }
|
||||||
with open(dhcp_file, 'r') as f:
|
if os.path.isfile(dhcp_file):
|
||||||
name_found = False
|
with open(dhcp_file, 'r') as f:
|
||||||
for line in f:
|
name_found = False
|
||||||
if "host %s." % vname in line:
|
for line in f:
|
||||||
name_found = True
|
if "host %s." % vname in line:
|
||||||
if name_found and "hardware ethernet" in line:
|
name_found = True
|
||||||
data['mac'] = line.split(' ')[-1].strip().strip(';')
|
if name_found and "hardware ethernet" in line:
|
||||||
break
|
data['mac'] = line.split(' ')[-1].strip().strip(';')
|
||||||
|
break
|
||||||
return HttpResponse(json.dumps(data));
|
return HttpResponse(json.dumps(data));
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Loading…
Reference in a new issue