From 08cc19900c0572fcf310cb94247280283bd4e6a7 Mon Sep 17 00:00:00 2001 From: "Ing. Jan KRCMAR" Date: Wed, 8 Jun 2016 13:37:26 +0200 Subject: [PATCH] guess_clone_name fix. should check hostname, not fqdn. guess_clone_name calls guess_mac_address in instance view --- instances/templates/instance.html | 1 + instances/views.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/instances/templates/instance.html b/instances/templates/instance.html index b18836a..0ca9c87 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -1052,6 +1052,7 @@ guessed_name = data['name'].split(".")[0]; $('#clone_name').val(guessed_name); update_clone_disk_name(guessed_name); + guess_mac_address('#clone_name', 0); }); } diff --git a/instances/views.py b/instances/views.py index 76d29ec..028891c 100644 --- a/instances/views.py +++ b/instances/views.py @@ -790,7 +790,8 @@ def guess_clone_name(request): for line in f: line = line.strip() if "host %s" % prefix in line: - hostname = line.split(' ')[1] + fqdn = line.split(' ')[1] + hostname = fqdn.split('.')[0] if hostname.startswith(prefix) and hostname not in instance_names: return HttpResponse(json.dumps({'name': hostname})) return HttpResponse(json.dumps({}));