1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +00:00

instance/check_instance service endpoint added. checks for existing instance (returns json)

This commit is contained in:
Jan Krcmar 2016-02-11 14:37:26 +01:00
parent a1d5edebe2
commit 2958a21ad1
2 changed files with 10 additions and 0 deletions

View file

@ -10,4 +10,6 @@ urlpatterns = [
views.inst_status, name='inst_status'),
url(r'^guess_mac_address/(?P<vname>[\w\-\.]+)/$',
views.guess_mac_address, name='guess_mac_address'),
url(r'^check_instance/(?P<vname>[\w\-\.]+)/$',
views.check_instance, name='check_instance'),
]

View file

@ -680,3 +680,11 @@ def guess_mac_address(request, vname):
data['mac'] = line.split(' ')[-1].strip().strip(';')
break
return HttpResponse(json.dumps(data));
@login_required
def check_instance(request, vname):
check_instance = Instance.objects.filter(name=vname)
data = { 'vname': vname, 'exists': False }
if check_instance:
data['exists'] = True
return HttpResponse(json.dumps(data));