mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
instance/clone added Guess mac address button. search for mac address of Clone Name via ajax request. Currently scans only local dhcpd configuration file.
This commit is contained in:
parent
33916c6a82
commit
39f3c9e12b
3 changed files with 26 additions and 0 deletions
|
|
@ -666,3 +666,17 @@ def inst_graph(request, compute_id, vname):
|
|||
|
||||
response.write(data)
|
||||
return response
|
||||
|
||||
@login_required
|
||||
def guess_mac_address(request, vname):
|
||||
dhcp_file = '/srv/webvirtcloud/dhcpd.hype.ipv4.conf'
|
||||
data = { 'vname': vname, 'mac': '52:54:00:' }
|
||||
with open(dhcp_file, 'r') as f:
|
||||
name_found = False
|
||||
for line in f:
|
||||
if "host %s." % vname in line:
|
||||
name_found = True
|
||||
if name_found and "hardware ethernet" in line:
|
||||
data['mac'] = line.split(' ')[-1].strip().strip(';')
|
||||
break
|
||||
return HttpResponse(json.dumps(data));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue